Exemplo n.º 1
0
        public int GetCategoryLftByTag(int siteId, string tag)
        {
            this.ChkPreload();
            string key = this.catTagKey(siteId, tag);

            return(Kvdb.GetInt(key));
        }
Exemplo n.º 2
0
        public int GetCategoryLftById(int siteId, int id)
        {
            //添加ID映射
            string key = this.catIdKey(siteId, id);

            return(Kvdb.GetInt(key));
        }
Exemplo n.º 3
0
        public int GetCategoryLftById(int siteId, int id)
        {
            //添加ID映射
            var key = catIdKey(siteId, id);

            return(Kvdb.GetInt(key));
        }
Exemplo n.º 4
0
        public int GetCategoryLftById(int siteId, int id)
        {
            //添加ID映射
            string key = String.Format("{0}+cache_id_lft_{1}", siteId.ToString(), id.ToString());

            return(Kvdb.GetInt(key));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 加载分类词典
        /// </summary>
        private void GetCategoryDictionary()
        {
            RepositoryDataCache._categories = new Dictionary <int, IList <ICategory> >();

            IList <ICategory> categories = new List <ICategory>();
            ICategory         category;

            categoryDal.GetAllCategories(rd =>
            {
                while (rd.Read())
                {
                    category = this.CreateCategory(
                        int.Parse(rd["id"].ToString()),
                        _siteRep.GetSiteById(int.Parse(rd["siteId"].ToString()))
                        );

                    rd.CopyToEntity(category);

                    categories.Add(category);
                }
            });

            //排序
            // IOrderedEnumerable<ICategory> categories2 = categories.OrderBy(a => a.ID);

            foreach (ICategory _category in categories)
            {
                if (!RepositoryDataCache._categories.ContainsKey(_category.Site.Id))
                {
                    RepositoryDataCache._categories.Add(_category.Site.Id, new List <ICategory>());
                }
                RepositoryDataCache._categories[_category.Site.Id].Add(_category);

                //添加Tag映射
                Kvdb.Put(String.Format("{0}:cache:t:lft:{1}",
                                       _category.Site.Id.ToString(),
                                       _category.Tag),
                         _category.Lft.ToString());

                if (_category.Site.Id == 1 && _category.Tag.IndexOf("duct") != -1)
                {
                    var x = "1:cache:t:lft:duct-machine" == String.Format("{0}:cache:t:lft:{1}",
                                                                          _category.Site.Id.ToString(),
                                                                          _category.Tag);
                }

                //添加ID映射
                Kvdb.Put(String.Format("{0}:cache:id:lft:{1}",
                                       _category.Site.Id.ToString(),
                                       _category.Id.ToString()),
                         _category.Lft.ToString());
            }

            //categories2 = null;
            categories = null;
        }
Exemplo n.º 6
0
        public int GetCategoryLftByTag(int siteId, string tag)
        {
            if (RepositoryDataCache._categories == null)
            {
                GetCategoryDictionary();
            }
            string key = String.Format("{0}:cache:t:lft:{1}", siteId.ToString(), tag);

            return(Kvdb.GetInt(key));
        }
Exemplo n.º 7
0
        public int GetCategoryLftById(int siteId, int id)
        {
            if (RepositoryDataCache._categories == null)
            {
                GetCategoryDictionary();
            }

            //添加ID映射
            string key = String.Format("{0}:cache:id:lft:{1}", siteId.ToString(), id.ToString());

            return(Kvdb.GetInt(key));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 加载分类词典
        /// </summary>
        private void InitCategoryDictionary()
        {
            RepositoryDataCache._categories = new Dictionary <int, IList <ICategory> >();

            IList <ICategory> categories = new List <ICategory>();
            ICategory         ic;

            categoryDal.GetAllCategories(rd =>
            {
                while (rd.Read())
                {
                    var category         = new CmsCategoryEntity();
                    category.ID          = Convert.ToInt32(rd["id"]);
                    category.Title       = (rd["page_title"] ?? "").ToString();
                    category.Description = (rd["page_description"] ?? "").ToString();
                    category.Icon        = Convert.ToString(rd["icon"]);
                    category.Keywords    = Convert.ToString(rd["page_keywords"]);
                    category.Location    = Convert.ToString(rd["location"]);
                    category.Name        = Convert.ToString(rd["name"]);
                    category.Tag         = Convert.ToString(rd["tag"]);
                    category.ParentId    = Convert.ToInt32(rd["parent_id"]);
                    category.SiteId      = Convert.ToInt32(rd["site_id"]);
                    category.Flag        = Convert.ToInt32(rd["flag"]);
                    category.Path        = Convert.ToString(rd["path"]);
                    category.SortNumber  = Convert.ToInt32(rd["sort_number"]);

                    ic = CreateCategory(category);
                    if (ic.Site() != null)
                    {
                        categories.Add(ic);
                    }
                }
            });

            foreach (var _category in categories)
            {
                if (!RepositoryDataCache._categories.ContainsKey(_category.Site().GetAggregateRootId()))
                {
                    RepositoryDataCache._categories.Add(_category.Site().GetAggregateRootId(), new List <ICategory>());
                }
                RepositoryDataCache._categories[_category.Site().GetAggregateRootId()].Add(_category);

                //添加Id->Path映射
                var key = catIdKey(_category.Site().GetAggregateRootId(), _category.GetDomainId());
                Kvdb.Put(key, _category.Get().Path);
            }

            categories = null;
        }
Exemplo n.º 9
0
        private static void InitKvDb()
        {
            //注册KvDB
            string kvDir = Cms.PyhicPath + CmsVariables.TEMP_PATH + "data/gcp";

            if (Directory.Exists(kvDir))
            {
                try
                {
                    Directory.Delete(kvDir, true);
                }
                catch
                {
                }
            }
            Kvdb.SetPath(kvDir);
            Kvdb.Clean();
        }
Exemplo n.º 10
0
        /// <summary>
        /// 加载分类词典
        /// </summary>
        private void InitCategoryDictionary()
        {
            RepositoryDataCache._categories = new Dictionary <int, IList <ICategory> >();

            IList <ICategory> categories = new List <ICategory>();
            ICategory         ic;

            categoryDal.GetAllCategories(rd =>
            {
                while (rd.Read())
                {
                    CmsCategoryEntity category = new CmsCategoryEntity();
                    category.ID          = Convert.ToInt32(rd["id"]);
                    category.Title       = (rd["page_title"] ?? "").ToString();
                    category.Description = (rd["page_description"] ?? "").ToString();
                    category.Icon        = Convert.ToString(rd["icon"]);
                    category.Keywords    = Convert.ToString(rd["page_keywords"]);
                    category.Location    = Convert.ToString(rd["location"]);
                    category.Name        = Convert.ToString(rd["name"]);
                    category.Tag         = Convert.ToString(rd["tag"]);
                    category.ParentId    = Convert.ToInt32(rd["parent_id"]);
                    category.SiteId      = Convert.ToInt32(rd["site_id"]);
                    category.Flag        = Convert.ToInt32(rd["flag"]);
                    category.Path        = Convert.ToString(rd["path"]);
                    category.SortNumber  = Convert.ToInt32(rd["sort_number"]);

                    ic = this.CreateCategory(category);
                    if (ic.Site() != null)
                    {
                        categories.Add(ic);
                    }
                }
            });

            //排序
            // IOrderedEnumerable<ICategory> categories2 = categories.OrderBy(a => a.ID);

            foreach (ICategory _category in categories)
            {
                if (!RepositoryDataCache._categories.ContainsKey(_category.Site().GetAggregaterootId()))
                {
                    RepositoryDataCache._categories.Add(_category.Site().GetAggregaterootId(), new List <ICategory>());
                }
                RepositoryDataCache._categories[_category.Site().GetAggregaterootId()].Add(_category);

                //添加Tag映射
                String key = this.catPathKey(_category.Site().GetAggregaterootId(), _category.Get().Path);
                Kvdb.PutInt(key, _category.Lft);

                /*
                 * if (_category.Site.Id == 1 && _category.Tag.IndexOf("duct") != -1)
                 * {
                 *  var x = "1:cache:t:lft:duct-machine" == String.Format("{0}:cache:t:lft:{1}",
                 *  _category.Site.Id.ToString(),
                 *  _category.Tag);
                 * }
                 */

                //添加Id映射
                key = this.catIdKey(_category.Site().GetAggregaterootId(), _category.GetDomainId());
                Kvdb.PutInt(key, _category.Lft);
            }
            //categories2 = null;
            categories = null;
        }
Exemplo n.º 11
0
        /// <summary>
        /// 设置应用程序,如在过程中发生异常则重启并提醒!
        /// </summary>
        public static void Init()
        {
            if (!Installed)
            {
                return;
            }

            //初始化目录
            ChkCreate(CmsVariables.TEMP_PATH);
            //todo:

            //初始化设置
            string   cmsConfigFile = String.Format("{0}config/cms.config", Cms.PyhicPath);
            FileInfo cfgFile       = new FileInfo(cmsConfigFile);

            if (cfgFile.Exists)
            {
                Configuration.Load(cmsConfigFile);
            }
            else
            {
                throw new Exception("CMS配置文件不存在");
            }

            //设置数据库
            CmsDataBase.Initialize(
                String.Format("{0}://{1}", Settings.DB_TYPE.ToString(),
                              Settings.DB_CONN.ToString()),
                Settings.DB_PREFIX);


            //清空临时文件
            //resetTempFiles();


            //注册KvDB
            string kvDir = Cms.PyhicPath + CmsVariables.TEMP_PATH + "data/.gca";

            if (Directory.Exists(kvDir))
            {
                Directory.Delete(kvDir, true);
            }
            Kvdb.SetPath(kvDir);
            Kvdb.Clean();

            //获取静态服务器
            //UpdateServerInfo();

            //
            //TODO:
            //
            //检查网站激活状态
            //SoftwareActivator.VerifyActivation();

            //如果不存在模板文件夹,则创建目录
            if (!Directory.Exists(Cms.PyhicPath + "templates/"))
            {
                Directory.CreateDirectory(Cms.PyhicPath + "templates/").Create();

                //暂时网络安装默认模板(后可使用资源代替)
                Updater.InstallTemplate("default", "tpl_default.zip");
            }

            //注册模板
            Template.Register("/templates/", true);

            //PluginConfig.PLUGIN_FILE_PARTTERN = "*.dll,*.so";
            PluginConfig.PLUGIN_DIRECTORY         = CmsVariables.PLUGIN_PATH;
            PluginConfig.PLUGIN_TMP_DIRECTORY     = CmsVariables.TEMP_PATH + "plugin/";
            PluginConfig.PLUGIN_LOG_OPENED        = true;
            PluginConfig.PLUGIN_LOG_EXCEPT_FORMAT = "** {time} **:{message}\r\nSource:{source}\r\nAddress:{addr}\r\nStack:{stack}\r\n\r\n";

            string pluginPhysicPath = Cms.PyhicPath + PluginConfig.PLUGIN_TMP_DIRECTORY;

            if (!Directory.Exists(pluginPhysicPath))
            {
                Directory.CreateDirectory(pluginPhysicPath).Create();
            }

            //连接插件
            CmsPluginContext.Connect();


            if (OnInit != null)
            {
                Cms.OnInit();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// 加载分类词典
        /// </summary>
        private void GetCategoryDictionary()
        {
            RepositoryDataCache._categories = new Dictionary <int, IList <ICategory> >();

            IList <ICategory> categories = new List <ICategory>();
            ICategory         category;

            categoryDal.GetAllCategories(rd =>
            {
                while (rd.Read())
                {
                    category = this.CreateCategory(
                        int.Parse(rd["id"].ToString()),
                        _siteRep.GetSiteById(int.Parse(rd["site_id"].ToString()))
                        );
                    category.PageTitle   = (rd["page_title"] ?? "").ToString();
                    category.Description = (rd["page_description"] ?? "").ToString();
                    category.Icon        = Convert.ToString(rd["icon"]);
                    category.Keywords    = Convert.ToString(rd["page_keywords"]);
                    category.Lft         = Convert.ToInt32(rd["lft"]);
                    category.Rgt         = Convert.ToInt32(rd["rgt"]);
                    category.Location    = Convert.ToString(rd["location"]);
                    category.Name        = Convert.ToString(rd["name"]);
                    category.Tag         = Convert.ToString(rd["tag"]);
                    category.SortNumber  = Convert.ToInt32(rd["sort_number"]);

                    categories.Add(category);
                }
            });

            //排序
            // IOrderedEnumerable<ICategory> categories2 = categories.OrderBy(a => a.ID);

            foreach (ICategory _category in categories)
            {
                if (!RepositoryDataCache._categories.ContainsKey(_category.Site.Id))
                {
                    RepositoryDataCache._categories.Add(_category.Site.Id, new List <ICategory>());
                }
                RepositoryDataCache._categories[_category.Site.Id].Add(_category);

                //添加Tag映射
                String key = this.catTagKey(_category.Site.Id, _category.Tag);
                Kvdb.PutInt(key, _category.Lft);

                /*
                 * if (_category.Site.Id == 1 && _category.Tag.IndexOf("duct") != -1)
                 * {
                 *  var x = "1:cache:t:lft:duct-machine" == String.Format("{0}:cache:t:lft:{1}",
                 *  _category.Site.Id.ToString(),
                 *  _category.Tag);
                 * }
                 */

                //添加Id映射
                key = this.catIdKey(_category.Site.Id, _category.Id);
                Kvdb.PutInt(key, _category.Lft);
            }
            //categories2 = null;
            categories = null;
        }
Exemplo n.º 13
0
        public int GetCategoryLftByTag(int siteId, string tag)
        {
            string key = String.Format("{0}+cache_t_lft_{1}", siteId.ToString(), tag);

            return(Kvdb.GetInt(key));
        }