Files
BeWoPlaner/Service/ServiceUtils/Paths/ServerFilePaths.cs

99 lines
3.8 KiB
C#

using BS.SharedLauncher.Enums;
using BS.SharedLauncher.Exceptions;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeWo.Service.ServiceUtils.Paths
{
public static class ServerFilePaths
{
// UpdateFiles
// L files
// L versions
// L 1.0.0.0
// L _default
// L exampleData#2
// L tenant#1
// L exampleData#3
// L 1.0.0.1
// L _default
// L exampleData#4
// L tenant#1
// L exampleData#5
// L special_tenant_files
// L tenant#1
// L exampleData#1
// L log
// L config
// L update_plan.config
private static string _RootPath;
public static string RootPath => _RootPath ?? (_RootPath = ConfigurationManager.AppSettings.Get("RootPath"));
private static string _ConfigPath;
public static string ConfigPath => _ConfigPath ?? (_ConfigPath = Path.Combine(RootPath, "config"));
private static string _UpdateConfigPath;
public static string UpdateConfigPath => _UpdateConfigPath ?? (_UpdateConfigPath = Path.Combine(ConfigPath, "update_plan.config"));
private static string _LogPath;
public static string LogPath => _LogPath ?? (_LogPath = Path.Combine(RootPath, "log"));
private static string _FilesPath;
public static string FilesPath => _FilesPath ?? (_FilesPath = Path.Combine(RootPath, "files"));
private static string _SpecialTenantFilesPath;
public static string SpecialTenantFilesPath => _SpecialTenantFilesPath ?? (_SpecialTenantFilesPath = Path.Combine(FilesPath, "special_tenant_files"));
private static string _VersionsFilePath;
public static string VersionsFilePath => _VersionsFilePath ?? (_VersionsFilePath = Path.Combine(FilesPath, "versions"));
static ServerFilePaths()
{
}
private static string GetVersionFolderPath(string version) => Path.Combine(VersionsFilePath, version);
private static string GetSpecialTenantFolderPath(string tenant) => Path.Combine(SpecialTenantFilesPath, tenant);
private static string GetVersionTenantFolderPath(string version, string tenant) => Path.Combine(GetVersionFolderPath(version), tenant);
private static string GetVersionDefaultFolderPath(string version) => GetVersionTenantFolderPath(version, "default");
public static string GetSourceFolderPath(UpdateFileSource source, string version, string tenant)
{
switch (source)
{
case UpdateFileSource.Invalid:
throw new UpdateException("Invalid UpdateFileSource");
case UpdateFileSource.VersionDefault:
return GetVersionDefaultFolderPath(version);
case UpdateFileSource.VersionTenant:
return GetVersionTenantFolderPath(version, tenant);
case UpdateFileSource.VersionUser:
break;
case UpdateFileSource.OverrideTenant:
return GetSpecialTenantFolderPath(tenant);
case UpdateFileSource.OverrideUser:
break;
default:
break;
}
// User bekommt eigene Daten Feature
throw new UpdateException("UpdateFileSourceType Unknown: " + source.ToString());
}
public static string GetLogFolderPath(string tenant) => Path.Combine(LogPath, tenant);
}
}