public Uri[] ListFiles(string domain, string path, string pattern, bool recursive) { var filePaths = ListFilesRelative(domain, path, pattern, recursive); return Array.ConvertAll( filePaths, x => GetUri(domain, CrossPlatform.PathCombine(PathUtils.Normalize(path), x))); }
public async Task StartAsync(CancellationToken cancellationToken) { try { var cfg = ConfigurationExtension.GetSetting <SsoAuthSettings>("ssoauth"); startInfo = new ProcessStartInfo { CreateNoWindow = false, UseShellExecute = false, FileName = "node", WindowStyle = ProcessWindowStyle.Hidden, Arguments = string.Format("\"{0}\"", Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, cfg.Path, "app.js"))), WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory }; startInfo.EnvironmentVariables.Add("core.machinekey", Configuration["core:machinekey"]); startInfo.EnvironmentVariables.Add("port", cfg.Port); LogDir = Logger.LogDirectory; startInfo.EnvironmentVariables.Add("logPath", LogDir); await StartNode(cancellationToken); } catch (Exception e) { Logger.Error("Start", e); } }
public MappedPath(PathUtils pathUtils, string tenant, bool appendTenant, string ppath, IDictionary <string, string> storageConfig) : this(pathUtils) { tenant = tenant.Trim('/'); ppath = PathUtils.ResolvePhysicalPath(ppath, storageConfig); PhysicalPath = ppath.IndexOf('{') == -1 && appendTenant?CrossPlatform.PathCombine(ppath, tenant) : string.Format(ppath, tenant); }
public Task StartAsync(CancellationToken cancellationToken) { try { var pythonName = "python"; var configPath = Path.GetFullPath(CrossPlatform.PathCombine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "radicale.config")); if (WorkContext.IsMono) { pythonName = "python3"; } StartInfo = new ProcessStartInfo { CreateNoWindow = false, UseShellExecute = false, FileName = pythonName, WindowStyle = ProcessWindowStyle.Hidden, Arguments = $"-m radicale --config \"{configPath}\"", WorkingDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) }; StartRedicale(); } catch (Exception e) { Logger.Error(e); } return(Task.CompletedTask); }
public Task StartAsync(CancellationToken cancellationToken) { try { var settings = Configuration.GetSetting <ThumbnailsSettings>("thumb"); StartInfo = new ProcessStartInfo { CreateNoWindow = false, UseShellExecute = false, FileName = "node", WindowStyle = ProcessWindowStyle.Hidden, Arguments = string.Format("\"{0}\"", Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, settings.Path, "index.js"))), WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory }; var savePath = settings.SavePath; if (!savePath.EndsWith("/")) { savePath += "/"; } StartInfo.EnvironmentVariables.Add("port", settings.Port); StartInfo.EnvironmentVariables.Add("logPath", CrossPlatform.PathCombine(Logger.LogDirectory, "web.thumbnails.log")); StartInfo.EnvironmentVariables.Add("savePath", Path.GetFullPath(savePath)); StartNode(cancellationToken); } catch (Exception e) { Logger.Error("Start", e); } return(Task.CompletedTask); }
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseSystemd() .UseWindowsService() .UseServiceProviderFactory(new AutofacServiceProviderFactory()) .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup <BaseWorkerStartup>()) .ConfigureAppConfiguration((hostContext, config) => { var buided = config.Build(); var path = buided["pathToConf"]; if (!Path.IsPathRooted(path)) { path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path)); } config.SetBasePath(path); var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production"); config .AddInMemoryCollection(new Dictionary <string, string> { { "pathToConf", path } } ) .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env}.json", true) .AddJsonFile($"appsettings.services.json", true) .AddJsonFile("storage.json") .AddJsonFile("notify.json") .AddJsonFile($"notify.{env}.json", true) .AddJsonFile("kafka.json") .AddJsonFile($"kafka.{env}.json", true) .AddJsonFile("elastic.json", true) .AddEnvironmentVariables() .AddCommandLine(args); }) .ConfigureServices((hostContext, services) =>
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseSystemd() .UseWindowsService() .UseServiceProviderFactory(new AutofacServiceProviderFactory()) .ConfigureWebHostDefaults(webBuilder => { var builder = webBuilder.UseStartup <Startup>(); builder.ConfigureKestrel((hostingContext, serverOptions) => { serverOptions.Limits.MaxRequestBodySize = 100 * 1024 * 1024; serverOptions.Limits.MaxRequestBufferSize = 100 * 1024 * 1024; serverOptions.Limits.MinRequestBodyDataRate = null; serverOptions.Limits.MinResponseDataRate = null; var kestrelConfig = hostingContext.Configuration.GetSection("Kestrel"); if (!kestrelConfig.Exists()) { return; } var unixSocket = kestrelConfig.GetValue <string>("ListenUnixSocket"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { if (!String.IsNullOrWhiteSpace(unixSocket)) { unixSocket = String.Format(unixSocket, hostingContext.HostingEnvironment.ApplicationName.Replace("ASC.", "").Replace(".", "")); serverOptions.ListenUnixSocket(unixSocket); } } }); }) .ConfigureAppConfiguration((hostingContext, config) => { var buided = config.Build(); var path = buided["pathToConf"]; if (!Path.IsPathRooted(path)) { path = Path.GetFullPath(CrossPlatform.PathCombine(hostingContext.HostingEnvironment.ContentRootPath, path)); } config.SetBasePath(path); config .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true) .AddJsonFile("storage.json") .AddJsonFile("kafka.json") .AddJsonFile($"kafka.{hostingContext.HostingEnvironment.EnvironmentName}.json", true) .AddEnvironmentVariables() .AddCommandLine(args) .AddInMemoryCollection(new Dictionary <string, string> { { "pathToConf", path } }); }) .ConfigureNLogLogging();
public static string ToRootedPath(string path, string basePath) { if (!Path.IsPathRooted(path)) { path = CrossPlatform.PathCombine(basePath, path); } return(Path.GetFullPath(path)); }
public MappedPath AppendDomain(string domain) { domain = domain.Replace('.', '_'); //Domain prep. Remove dots return(new MappedPath(PathUtils) { PhysicalPath = CrossPlatform.PathCombine(PhysicalPath, PathUtils.Normalize(domain, true)), }); }
public static string ToRootedConfigPath(string path) { if (!Path.HasExtension(path)) { path = CrossPlatform.PathCombine(path, "Web.config"); } return(ToRootedPath(path)); }
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseSystemd() .UseWindowsService() .UseServiceProviderFactory(new AutofacServiceProviderFactory()) .ConfigureAppConfiguration((hostContext, config) => { var buided = config.Build(); var path = buided["pathToConf"]; if (!Path.IsPathRooted(path)) { path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path)); } config.SetBasePath(path); var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production"); config .AddInMemoryCollection(new Dictionary <string, string> { { "pathToConf", path } } ) .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env}.json", true) .AddJsonFile($"appsettings.services.json", true) .AddJsonFile("storage.json") .AddJsonFile("notify.json") .AddJsonFile($"notify.{env}.json", true) .AddJsonFile("kafka.json") .AddJsonFile($"kafka.{env}.json", true) .AddEnvironmentVariables() .AddCommandLine(args); }) .ConfigureServices((hostContext, services) => { services.AddMemoryCache(); var diHelper = new DIHelper(services); diHelper.TryAdd(typeof(ICacheNotify <>), typeof(KafkaCache <>)); diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath); services.AddHostedService <ServiceLauncher>(); diHelper.TryAdd <ServiceLauncher>(); diHelper.TryAdd <FactoryIndexerCase>(); diHelper.TryAdd <FactoryIndexerContact>(); diHelper.TryAdd <FactoryIndexerContactInfo>(); diHelper.TryAdd <FactoryIndexerDeal>(); diHelper.TryAdd <FactoryIndexerEvents>(); diHelper.TryAdd <FactoryIndexerFieldValue>(); diHelper.TryAdd <FactoryIndexerInvoice>(); diHelper.TryAdd <FactoryIndexerTask>(); }) .ConfigureContainer <ContainerBuilder>((context, builder) => { builder.Register(context.Configuration, true, false, "search.json"); }) .ConfigureNLogLogging();
private void Clean() { var filePath = string.Empty; var dirPath = string.Empty; try { if (FileName == null) { return; } filePath = ((NLog.Layouts.SimpleLayout)FileName).Text; if (string.IsNullOrEmpty(filePath)) { return; } dirPath = Path.GetDirectoryName(filePath); if (string.IsNullOrEmpty(dirPath)) { return; } if (!Path.IsPathRooted(dirPath)) { dirPath = CrossPlatform.PathCombine(AppDomain.CurrentDomain.BaseDirectory, dirPath); } var directory = new DirectoryInfo(dirPath); if (!directory.Exists) { return; } var files = directory.GetFiles(); var cleanPeriod = GetCleanPeriod(); foreach (var file in files.Where(file => (DateTime.UtcNow.Date - file.CreationTimeUtc.Date).Days > cleanPeriod)) { file.Delete(); } } catch (Exception err) { base.Write(new LogEventInfo { Exception = err, Level = LogLevel.Error, Message = string.Format("file: {0}, dir: {1}, mess: {2}", filePath, dirPath, err.Message), LoggerName = "SelfCleaningTarget" }); } }
private string GetBackupFilePath(string tenantAlias) { if (!Directory.Exists(BackupDirectory ?? DefaultDirectoryName)) { Directory.CreateDirectory(BackupDirectory ?? DefaultDirectoryName); } return(CrossPlatform.PathCombine(BackupDirectory ?? DefaultDirectoryName, tenantAlias + DateTime.UtcNow.ToString("(yyyy-MM-dd HH-mm-ss)") + ".backup")); }
private string GetTarget(string domain, string path) { var pathMap = GetPath(domain); //Build Dir var target = CrossPlatform.PathCombine(pathMap.PhysicalPath, PathUtils.Normalize(path)); ValidatePath(target); return(target); }
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .UseSystemd() .UseWindowsService() .UseServiceProviderFactory(new AutofacServiceProviderFactory()) .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup <BaseWorkerStartup>()) .ConfigureAppConfiguration((hostContext, config) => { var buided = config.Build(); var path = buided["pathToConf"]; if (!Path.IsPathRooted(path)) { path = Path.GetFullPath(CrossPlatform.PathCombine(hostContext.HostingEnvironment.ContentRootPath, path)); } config.SetBasePath(path); var env = hostContext.Configuration.GetValue("ENVIRONMENT", "Production"); config .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{env}.json", true) .AddJsonFile($"appsettings.services.json", true) .AddJsonFile("storage.json") .AddJsonFile("notify.json") .AddJsonFile($"notify.{env}.json", true) .AddJsonFile("kafka.json") .AddJsonFile($"kafka.{env}.json", true) .AddEnvironmentVariables() .AddCommandLine(args) .AddInMemoryCollection(new Dictionary <string, string> { { "pathToConf", path } } ); }) .ConfigureServices((hostContext, services) => { services.AddMemoryCache(); var diHelper = new DIHelper(services); diHelper.TryAdd(typeof(ICacheNotify <>), typeof(KafkaCache <>)); diHelper.RegisterProducts(hostContext.Configuration, hostContext.HostingEnvironment.ContentRootPath); services.Configure <NotifyServiceCfg>(hostContext.Configuration.GetSection("notify")); diHelper.TryAdd <NotifyServiceLauncher>(); diHelper.TryAdd <JabberSender>(); diHelper.TryAdd <SmtpSender>(); diHelper.TryAdd <AWSSender>(); // fix private services.AddHostedService <NotifyServiceLauncher>(); }) .ConfigureContainer <ContainerBuilder>((context, builder) => { builder.Register(context.Configuration); }) .ConfigureNLogLogging();
public static string GetTempFileName(string tempDir) { string tempPath; do { tempPath = CrossPlatform.PathCombine(tempDir, Path.GetRandomFileName()); } while (File.Exists(tempPath)); return(tempPath); }
private void DoRestoreStorage(IDataReadOperator dataReader) { Logger.Debug("begin restore storage"); var fileGroups = GetFilesToProcess(dataReader).GroupBy(file => file.Module).ToList(); var groupsProcessed = 0; foreach (var group in fileGroups) { foreach (var file in group) { var storage = StorageFactory.GetStorage(ConfigPath, Dump ? file.Tenant.ToString() : ColumnMapper.GetTenantMapping().ToString(), group.Key); var quotaController = storage.QuotaController; storage.SetQuotaController(null); try { var adjustedPath = file.Path; var module = ModuleProvider.GetByStorageModule(file.Module, file.Domain); if (module == null || module.TryAdjustFilePath(Dump, ColumnMapper, ref adjustedPath)) { var key = file.GetZipKey(); if (Dump) { key = CrossPlatform.PathCombine(KeyHelper.GetStorage(), key); } using var stream = dataReader.GetEntry(key); try { storage.Save(file.Domain, adjustedPath, module != null ? module.PrepareData(key, stream, ColumnMapper) : stream); } catch (Exception error) { Logger.WarnFormat("can't restore file ({0}:{1}): {2}", file.Module, file.Path, error); } } } finally { if (quotaController != null) { storage.SetQuotaController(quotaController); } } } SetCurrentStepProgress((int)(++groupsProcessed * 100 / (double)fileGroups.Count)); } if (fileGroups.Count == 0) { SetStepCompleted(); } Logger.Debug("end restore storage"); }
public Assembly Resolving(AssemblyLoadContext context, AssemblyName assemblyName) { var path = CrossPlatform.PathCombine(Path.GetDirectoryName(ResolvePath), $"{assemblyName.Name}.dll"); if (!File.Exists(path)) { return(null); } return(context.LoadFromAssemblyPath(path)); }
public string Upload(string storageBasePath, string localPath, Guid userId) { if (!Directory.Exists(storageBasePath)) { throw new FileNotFoundException("Directory not found."); } var storagePath = CrossPlatform.PathCombine(storageBasePath, Path.GetFileName(localPath)); if (localPath != storagePath) { File.Copy(localPath, storagePath, true); } return(storagePath); }
private string GetUniqFileName(string filePath, string ext) { var dir = string.IsNullOrEmpty(TempDir) ? Path.GetDirectoryName(filePath) : TempDir; var name = Path.GetFileNameWithoutExtension(filePath); var result = CrossPlatform.PathCombine(dir, string.Format("{0}_{1}{2}", Storage, name, ext)); var index = 1; while (File.Exists(result)) { result = CrossPlatform.PathCombine(dir, string.Format("{0}_{1}({2}){3}", Storage, name, index++, ext)); } return(result); }
public string ResolvePhysicalPath(string physPath, IDictionary <string, string> storageConfig) { physPath = Normalize(physPath, false).TrimStart('~'); if (physPath.Contains(Constants.STORAGE_ROOT_PARAM)) { physPath = physPath.Replace(Constants.STORAGE_ROOT_PARAM, StorageRoot ?? storageConfig[Constants.STORAGE_ROOT_PARAM]); } if (!Path.IsPathRooted(physPath)) { physPath = Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, physPath.Trim(Path.DirectorySeparatorChar))); } return(physPath); }
private ProcessStartInfo GetProcessStartInfo() { var path = configuration["urlshortener:path"] ?? "../../ASC.UrlShortener/index.js"; var port = configuration["urlshortener:port"] ?? "9999"; var startInfo = new ProcessStartInfo { CreateNoWindow = false, UseShellExecute = false, FileName = "node", WindowStyle = ProcessWindowStyle.Hidden, Arguments = string.Format("\"{0}\"", Path.GetFullPath(CrossPlatform.PathCombine(hostEnvironment.ContentRootPath, path))), WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory }; startInfo.EnvironmentVariables.Add("core.machinekey", configuration["core:machinekey"]); startInfo.EnvironmentVariables.Add("port", port); var conString = configurationExtension.GetConnectionStrings()["default"].ConnectionString; var dict = new Dictionary <string, string> { { "Server", "host" }, { "Database", "database" }, { "User ID", "user" }, { "Password", "password" } }; foreach (var conf in conString.Split(';')) { var splited = conf.Split('='); if (splited.Length < 2) { continue; } if (dict.ContainsKey(splited[0])) { startInfo.EnvironmentVariables.Add("sql:" + dict[splited[0]], splited[1]); } } startInfo.EnvironmentVariables.Add("logPath", CrossPlatform.PathCombine(log.LogDirectory, "web.urlshortener.log")); return(startInfo); }
public DbHelper(IOptionsMonitor <ILog> options, ConnectionStringSettings connectionString, BackupsContext backupsContext) { log = options.CurrentValue; this.backupsContext = backupsContext; var file = connectionString.ElementInformation.Source; if ("web.connections.config".Equals(Path.GetFileName(file), StringComparison.InvariantCultureIgnoreCase)) { file = CrossPlatform.PathCombine(Path.GetDirectoryName(file), "Web.config"); } var xconfig = XDocument.Load(file); var provider = xconfig.XPathSelectElement("/configuration/system.data/DbProviderFactories/add[@invariant='" + connectionString.ProviderName + "']"); factory = (DbProviderFactory)Activator.CreateInstance(Type.GetType(provider.Attribute("type").Value, true)); builder = factory.CreateCommandBuilder(); connect = factory.CreateConnection(); connect.ConnectionString = connectionString.ConnectionString; connect.Open(); mysql = connectionString.ProviderName.ToLower().Contains("mysql"); if (mysql) { CreateCommand("set @@session.sql_mode = concat(@@session.sql_mode, ',NO_AUTO_VALUE_ON_ZERO')").ExecuteNonQuery(); } columns = connect.GetSchema("Columns"); whereExceptions["calendar_calendar_item"] = " where calendar_id in (select id from calendar_calendars where tenant = {0}) "; whereExceptions["calendar_calendar_user"] = "******"; whereExceptions["calendar_event_item"] = " inner join calendar_events on calendar_event_item.event_id = calendar_events.id where calendar_events.tenant = {0} "; whereExceptions["calendar_event_user"] = "******"; whereExceptions["crm_entity_contact"] = " inner join crm_contact on crm_entity_contact.contact_id = crm_contact.id where crm_contact.tenant_id = {0} "; whereExceptions["crm_entity_tag"] = " inner join crm_tag on crm_entity_tag.tag_id = crm_tag.id where crm_tag.tenant_id = {0} "; whereExceptions["files_folder_tree"] = " inner join files_folder on folder_id = id where tenant_id = {0} "; whereExceptions["forum_answer_variant"] = " where answer_id in (select id from forum_answer where tenantid = {0})"; whereExceptions["forum_topic_tag"] = " where topic_id in (select id from forum_topic where tenantid = {0})"; whereExceptions["forum_variant"] = " where question_id in (select id from forum_question where tenantid = {0})"; whereExceptions["projects_project_participant"] = " inner join projects_projects on projects_project_participant.project_id = projects_projects.id where projects_projects.tenant_id = {0} "; whereExceptions["projects_following_project_participant"] = " inner join projects_projects on projects_following_project_participant.project_id = projects_projects.id where projects_projects.tenant_id = {0} "; whereExceptions["projects_project_tag"] = " inner join projects_projects on projects_project_tag.project_id = projects_projects.id where projects_projects.tenant_id = {0} "; whereExceptions["tenants_tenants"] = " where id = {0}"; whereExceptions["core_acl"] = " where tenant = {0} or tenant = -1"; whereExceptions["core_subscription"] = " where tenant = {0} or tenant = -1"; whereExceptions["core_subscriptionmethod"] = " where tenant = {0} or tenant = -1"; }
public WebSkin(IWebHostEnvironment webHostEnvironment) { try { var dir = CrossPlatform.PathCombine(webHostEnvironment.ContentRootPath, "~/skins/default/"); if (!Directory.Exists(dir)) { return; } foreach (var f in Directory.GetFiles(dir, "common_style.*.css")) { BaseCultureCss.Add(Path.GetFileName(f).Split('.')[1]); } } catch { } }
public bool Exists(string relativePath) { var path = GetPath(relativePath); if (!Existing.ContainsKey(path)) { if (Uri.IsWellFormedUriString(path, UriKind.Relative) && HttpContextAccessor?.HttpContext != null) { //Local Existing[path] = File.Exists(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, path)); } if (Uri.IsWellFormedUriString(path, UriKind.Absolute)) { //Make request Existing[path] = CheckWebPath(path); } } return(Existing[path]); }
public void SaveColorTheme(string theme) { var settings = new ColorThemesSettings { ColorThemeName = theme, FirstRequest = false }; var path = "/skins/" + ColorThemesSettings.ThemeFolderTemplate; var resolvedPath = path.ToLower().Replace(ColorThemesSettings.ThemeFolderTemplate, theme); try { var filePath = CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, resolvedPath); if (Directory.Exists(filePath)) { SettingsManager.Save(settings); } } catch (Exception) { } }
static string CombinePath(string physPath, HttpContext requestContext) { var pathInfo = GetRouteValue("pathInfo").Replace('/', Path.DirectorySeparatorChar); var path = CrossPlatform.PathCombine(physPath, pathInfo); var tenant = GetRouteValue("0"); if (string.IsNullOrEmpty(tenant)) { tenant = CrossPlatform.PathCombine(GetRouteValue("t1"), GetRouteValue("t2"), GetRouteValue("t3")); } path = path.Replace("{0}", tenant); return(path); string GetRouteValue(string name) { return((requestContext.GetRouteValue(name) ?? "").ToString()); } }
public Task StartAsync(CancellationToken cancellationToken) { try { var settings = ConfigurationExtension.GetSetting <SocketSettings>("socket"); StartInfo = new ProcessStartInfo { CreateNoWindow = false, UseShellExecute = false, FileName = "node", WindowStyle = ProcessWindowStyle.Hidden, Arguments = string.Format("\"{0}\"", Path.GetFullPath(CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, settings.Path, "app.js"))), WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory }; StartInfo.EnvironmentVariables.Add("core.machinekey", Configuration["core:machinekey"]); StartInfo.EnvironmentVariables.Add("port", settings.Port); if (!string.IsNullOrEmpty(settings.RedisHost) && !string.IsNullOrEmpty(settings.RedisPort)) { StartInfo.EnvironmentVariables.Add("redis:host", settings.RedisHost); StartInfo.EnvironmentVariables.Add("redis:port", settings.RedisPort); } if (CoreBaseSettings.Standalone) { StartInfo.EnvironmentVariables.Add("portal.internal.url", "http://localhost"); } LogDir = Logger.LogDirectory; StartInfo.EnvironmentVariables.Add("logPath", CrossPlatform.PathCombine(LogDir, "web.socketio.log")); StartNode(); } catch (Exception e) { Logger.Error(e); } return(Task.CompletedTask); }
protected override void DoJob() { using var scope = ServiceProvider.CreateScope(); var tenantManager = scope.ServiceProvider.GetService <TenantManager>(); var staticUploader = scope.ServiceProvider.GetService <StaticUploader>(); var tenant = tenantManager.GetTenant(TenantId); tenantManager.SetCurrentTenant(tenant); tenant.SetStatus(TenantStatus.Migrating); tenantManager.SaveTenant(tenant); PublishChanges(); foreach (var file in directoryFiles) { var filePath = file.Substring(mappedPath.TrimEnd('/').Length); staticUploader.UploadFile(CrossPlatform.PathCombine(relativePath, filePath), file, (res) => StepDone()); } tenant.SetStatus(Core.Tenants.TenantStatus.Active); tenantManager.SaveTenant(tenant); }
public string GetThemeFolderName(IUrlHelper urlHelper, string path) { var folderName = GetColorThemesSettings(); var resolvedPath = path.ToLower().Replace(ColorThemesSettings.ThemeFolderTemplate, folderName); //TODO check if (!urlHelper.IsLocalUrl(resolvedPath)) { resolvedPath = urlHelper.Action(resolvedPath); } try { var filePath = CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, resolvedPath); if (!File.Exists(filePath)) { throw new FileNotFoundException("", path); } } catch (Exception) { resolvedPath = path.ToLower().Replace(ColorThemesSettings.ThemeFolderTemplate, "default"); if (!urlHelper.IsLocalUrl(resolvedPath)) { resolvedPath = urlHelper.Action(resolvedPath); } var filePath = CrossPlatform.PathCombine(HostEnvironment.ContentRootPath, resolvedPath); if (!File.Exists(filePath)) { throw new FileNotFoundException("", path); } } return(resolvedPath); }