protected override void initTheme() { if (ContentTheme.IdHasError( base.themeId )) { logger.Error( "theme id error, id=" + base.themeId ); return; } this.xapp = ContentTheme.GetByThemeId( base.themeId ); if (this.xapp == null) throw new Exception( "没有有效的主题数据, themeId=" + base.themeId ); }
protected override void initTheme() { if (base.themeId <= 0) return; ContentTheme x = cdb.findById<ContentTheme>( base.themeId ); if (x == null) return; String jsonStr = file.Read( x.GetFileAbsPath() ); xapp = Json.Deserialize<XApp>( jsonStr ); if (xapp == null) throw new Exception( "没有有效的主题数据, name=" + x.Name + ", path=" + x.GetFileAbsPath() ); }
private void replaceIdToClass( XApp xapp, String id, String cls ) { xapp.Style = xapp.Style.Replace( id, cls ); xapp.SkinStyle = xapp.SkinStyle.Replace( id, cls ); }
private void processCssId( XApp xapp, List<ContentSection> sectionList ) { foreach (ContentSection s in sectionList) { XSection xSection = getXSection( xapp.SectionList, s ); replaceIdToClass( xapp, "#section" + s.Id, xSection.CssPath + " " ); replaceIdToClass( xapp, "#sectionTitle" + s.Id, xSection.CssPath + " .sectionTitle " ); replaceIdToClass( xapp, "#sectionContent" + s.Id, xSection.CssPath + " .sectionContent " ); replaceIdToClass( xapp, "#sectionContentText" + s.Id, xSection.CssPath + " .sectionContentText " ); } }
/// <summary> /// 将安装包保存到磁盘 /// </summary> /// <param name="xapp"></param> private void exportToDisk( XApp xapp, ContentTheme theme ) { String jsonString = Json.ToString( xapp ); theme.Insert( jsonString ); }
private XApp exportApp( ContentApp app ) { XApp x = new XApp(); x.Style = app.Style; x.Layout = app.Layout; x.SkinStyle = app.SkinStyle; return x; }
/// <summary> /// 将安装包保存到磁盘 /// </summary> /// <param name="xapp"></param> private void exportToDisk( XApp xapp, ContentTheme theme ) { String jsonString = Json.ToString( xapp ); String fileName = Guid.NewGuid().ToString() + ".config"; String savedPath = ContentTheme.GetFileAbsDir(); if (Directory.Exists( savedPath ) == false) { Directory.CreateDirectory( savedPath ); } file.Write( Path.Combine( savedPath, fileName ), jsonString ); theme.FileName = fileName; theme.insert(); }