public override object Install(Package package) { base.Install(package); var themePackage = package as ThemePackage; if (themePackage != null) { var newTheme = themePackage.Theme; newTheme.IsActived = false; if (_themeService.Count(m => m.ID == newTheme.ID) == 0) { _themeService.Add(newTheme); } else { var oldTheme = _themeService.Get(newTheme.ID); if (oldTheme.IsActived) { newTheme.IsActived = true; } _themeService.Update(newTheme); } } return(package); }
public override object Install(Package package) { base.Install(package); var themePackage = package as ThemePackage; if (themePackage != null) { var newTheme = themePackage.Theme; newTheme.IsActived = false; if (_themeService.Count(m => m.ID == newTheme.ID) == 0) { _themeService.Add(newTheme); } else { var oldTheme = _themeService.Get(newTheme.ID); oldTheme.Description = newTheme.Description; oldTheme.Thumbnail = newTheme.Thumbnail; oldTheme.Title = newTheme.Title; oldTheme.Url = newTheme.Url; oldTheme.UrlDebugger = newTheme.UrlDebugger; _themeService.Update(oldTheme); } } return(package); }
public override object Install(Package package) { var filePackage = package as FilePackage; if (filePackage != null && filePackage.Files != null) { filePackage.Files.ForEach(file => { file.FilePath = file.FilePath.Replace("~/Themes", ThemePath); }); } base.Install(package); var themePackage = package as ThemePackage; if (themePackage != null) { var newTheme = themePackage.Theme; newTheme.IsActived = false; if (_themeService.Count(m => m.ID == newTheme.ID) == 0) { _themeService.Add(newTheme); } else { var oldTheme = _themeService.Get(newTheme.ID); oldTheme.Description = newTheme.Description; oldTheme.Thumbnail = newTheme.Thumbnail; oldTheme.Title = newTheme.Title; oldTheme.Url = newTheme.Url; oldTheme.UrlDebugger = newTheme.UrlDebugger; _themeService.Update(oldTheme); } } return(package); }
private ThemeEntity CreateTheme(string themeName, List <PositionEntry> cssFiles) { const string themeCss = "theme.css"; const string themeCssMin = "theme.min.css"; const string thumbnail = "thumbnail.jpg"; #region Write theme.css,theme.min.css using (FileStream themeFilestram = new FileStream(Path.Combine(ThemeBasePath, themeName, themeCssMin), FileMode.Create)) { using (StreamWriter writer = new StreamWriter(themeFilestram)) { if (cssFiles.All(css => !BootstrapFilter.IsMatch(css.Entry))) { writer.WriteLine("@import url(\"/lib/bootstrap/dist/css/bootstrap.min.css\");"); } writer.WriteLine("@import url(\"/css/theme-base.css\");"); foreach (var item in cssFiles.OrderBy(m => m.Position)) { writer.WriteLine("@import url(\"{0}\");", item.Entry); } } } using (FileStream themeFilestram = new FileStream(Path.Combine(ThemeBasePath, themeName, themeCss), FileMode.Create)) { using (StreamWriter writer = new StreamWriter(themeFilestram)) { if (cssFiles.All(css => !BootstrapFilter.IsMatch(css.Entry))) { writer.WriteLine("@import url(\"/lib/bootstrap/dist/css/bootstrap.min.css\");"); } writer.WriteLine("@import url(\"/css/theme-base.css\");"); foreach (var item in cssFiles.OrderBy(m => m.Position)) { writer.WriteLine("@import url(\"{0}\");", item.Entry); } } } #endregion if (!File.Exists(Path.Combine(ThemeBasePath, themeName, thumbnail)) && File.Exists(Path.Combine(ThemeBasePath, "Default", thumbnail))) { File.Copy(Path.Combine(ThemeBasePath, "Default", thumbnail), Path.Combine(ThemeBasePath, themeName, thumbnail)); } ThemeEntity themeEntity = new ThemeEntity { ID = themeName, Title = themeName, Description = "By TemplateImporter", IsActived = false, Status = (int)Easy.Constant.RecordStatus.Active, Thumbnail = $"~/{ThemeFolder}/{themeName}/{thumbnail}", Url = $"~/{ThemeFolder}/{themeName}/{themeCssMin}", UrlDebugger = $"~/{ThemeFolder}/{themeName}/{themeCss}" }; var theme = _themeService.Get(themeEntity.ID); if (theme == null) { _themeService.Add(themeEntity); } _themeService.ChangeTheme(themeEntity.ID); return(themeEntity); }