Example #1
0
        private static List <ContentTheme> findAll()
        {
            List <String> nameList = new List <String>();

            List <ContentTheme> list = new List <ContentTheme>();

            String themeDir = GetFileAbsDir();

            if (Directory.Exists(themeDir) == false)
            {
                logger.Error("theme dir not exist=" + themeDir);
                return(list);
            }

            String[] files = Directory.GetFiles(themeDir);
            foreach (String x in files)
            {
                if (x.EndsWith(".data.config"))
                {
                    continue;
                }
                if (x.EndsWith(".config") == false)
                {
                    continue;
                }

                String name = Path.GetFileName(x);
                if (nameList.Contains(name))
                {
                    continue;
                }

                String jsonString = file.Read(x);
                try {
                    ContentTheme theme = Json.Deserialize <ContentTheme>(jsonString);

                    if (theme == null)
                    {
                        logger.Error("Deserialize ContentTheme=null");
                    }
                    else if (strUtil.IsNullOrEmpty(theme.Name))
                    {
                        logger.Error("Deserialize ContentTheme=theme name is empty");
                    }
                    else
                    {
                        theme.Id = strUtil.TrimEnd(name, ".config");

                        list.Add(theme);
                    }
                }
                catch (Exception ex) {
                    logger.Error("Deserialize ContentTheme=" + ex);
                }

                nameList.Add(name);
            }

            return(list);
        }
Example #2
0
        private static void deletePrivate(String guid, String ext)
        {
            String fileName  = guid + ext + ".config";
            String savedPath = ContentTheme.GetFileAbsDir();
            String filePath  = Path.Combine(savedPath, fileName);

            if (file.Exists(filePath))
            {
                file.Delete(filePath);
            }
        }
Example #3
0
        private void saveDataPrivate(String jsonString, String ext)
        {
            String fileName  = this.Id + ext + ".config";
            String savedPath = ContentTheme.GetFileAbsDir();

            if (Directory.Exists(savedPath) == false)
            {
                Directory.CreateDirectory(savedPath);
            }

            file.Write(Path.Combine(savedPath, fileName), jsonString);
        }
Example #4
0
        public static XApp GetByThemeId(String themeId)
        {
            ContentTheme x = findById(themeId);

            if (x == null)
            {
                return(null);
            }

            String jsonStr = file.Read(x.GetFileAbsPath());

            return(Json.Deserialize <XApp>(jsonStr));
        }
        public virtual void Export() {

            ContentTheme theme = new ContentTheme();
            theme.Name = ctx.Post( "Name" );
            theme.Description = strUtil.CutString( ctx.Post( "Description" ), 200 );

            if (strUtil.IsNullOrEmpty( theme.Name )) {
                echoError( "请填写主题名称" );
                return;
            }


            List<ContentSection> sectionList = sectionService.GetByApp( ctx.app.Id );

            // 1、获取app信息
            ContentApp app = ctx.app.obj as ContentApp;
            XApp xapp = exportApp( app );
            xapp.SectionList = new List<XSection>();

            // 2、循环导出section
            string[] rowList = app.RowList;

            // 循环行
            for (int iRow = 1; iRow < (rowList.Length + 1); iRow++) {

                int columnCount = cvt.ToInt( rowList[iRow - 1] );
                if (columnCount <= 0) continue;

                // 循环列
                for (int iColumn = 1; iColumn < (columnCount + 1); iColumn++) {

                    List<ContentSection> sections = sectionService.GetByRowColumn( sectionList, iRow, iColumn );

                    // 循环section
                    for (int iSection = 1; iSection < sections.Count + 1; iSection++) {

                        XSection xSection = getSection( sections[iSection - 1], iRow, iColumn, iSection );
                        xapp.SectionList.Add( xSection );
                    }
                }
            }

            // 处理 #sectionId 的css问题,==> 转化成 #portarContainer .row-iRow .col-iColumn .section-iSection
            processCssId( xapp, sectionList );


            // 3、保存为 json 格式
            exportToDisk( xapp, theme );

            echoToParentPart( lang( "opok" ) );
        }
Example #6
0
        public int CompareTo(object obj)
        {
            ContentTheme t = obj as ContentTheme;

            if (this.OrderId > t.OrderId)
            {
                return(-1);
            }
            if (this.OrderId < t.OrderId)
            {
                return(1);
            }
            return(0);
        }
Example #7
0
 /// <summary>
 /// 将安装包保存到磁盘
 /// </summary>
 /// <param name="xapp"></param>
 private void exportToDisk( XApp xapp, ContentTheme theme )
 {
     String jsonString = Json.ToString( xapp );
     theme.Insert( jsonString );
 }
Example #8
0
        /// <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();
        }