Ejemplo n.º 1
0
        /// <summary>
        /// 查询Tag名称是否存在
        /// </summary>
        /// <param name="tag">Tag名称</param>
        /// <returns>true存在,false不存在</returns>
        public bool CheckTagIsExit(string tag)
        {
            ObjektCollection <Objekt> oc = new ObjektCollection <Objekt>(Klass.ForId("FeTag@Klass"), new WhereClause("\"tag\" = '" + tag + "'"));

            if (oc == null)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置指定对象的seo关键字。
        /// </summary>
        /// <param name="keys"></param>
        /// <param name="relationshipName"></param>
        /// <param name="sourceId"></param>
        public static void SetObjektSeo(List <string> keys, string relationshipName, string sourceId)
        {
            List <FeSeoKey> entityKeys = new List <FeSeoKey>();

            foreach (string key in keys)
            {
                FeSeoKey entity = new ObjektCollection <FeSeoKey>(Klass.ForId("FeSeoKey@Klass"), new WhereClause("\"key\" = '" + key + "'")).TryGetSingleResult();
                if (entity == null)
                {
                    entity     = new FeSeoKey();
                    entity.Key = key;
                    entity.Save();
                }
                IEnumerable <FeSeoKey> query = from t in entityKeys
                                               where t.Key == entity.Key
                                               select t;
                if (query.Count() == 0)
                {
                    entityKeys.Add(entity);
                }
            }
            Objekt objekt = ObjektFactory.Find(sourceId);
            List <RelationshipObjekt> relationshipList = objekt.ROCC.GetROC(relationshipName).ToList();
            List <RelationshipObjekt> deleteList       = new List <RelationshipObjekt>();

            foreach (RelationshipObjekt item3 in relationshipList)
            {
                IEnumerable <FeSeoKey> existQuery2 = from t in entityKeys
                                                     where t.Id == item3.Related.Id
                                                     select t;
                if (existQuery2.Count() == 0)
                {
                    deleteList.Add(item3);
                }
            }
            foreach (RelationshipObjekt item4 in deleteList)
            {
                item4.Delete();
                item4.Save();
            }
            foreach (FeSeoKey item5 in entityKeys)
            {
                IEnumerable <RelationshipObjekt> existQuery = from t in relationshipList
                                                              where t.Related.Id == item5.Id
                                                              select t;
                if (existQuery.Count() == 0)
                {
                    RelationshipObjekt relationship = ObjektFactory.New <RelationshipObjekt>(Klass.ForName(relationshipName));
                    relationship.Source  = objekt;
                    relationship.Related = item5;
                    relationship.Save();
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     获取图片包中原图文件
        /// </summary>
        /// <returns></returns>
        public File SourceImageFile()
        {
            if (!IsImagePack)
            {
                throw new Exception("当前文件并不是图片包");
            }
            string fileName            = File.Name.Substring(0, File.Name.Length - 10);
            string sql                 = "\"parent\" = '" + File.Id + "' and \"name\" = '" + fileName + "'";
            ObjektCollection <File> oc = new ObjektCollection <File>(Klass.ForId("File@Klass"), new WhereClause(sql));

            return(oc.GetSingleResult());
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     创建新增对象排序。
        /// </summary>
        /// <returns></returns>
        public static decimal NewSortOrder()
        {
            ObjektCollection <FeArticle> oc = new ObjektCollection <FeArticle>(Klass.ForId("FeArticle@Klass"), new WhereClause("\"sortOrder\" is not null"));

            oc.OrderByClause.Add(new OrderByCell("sortOrder", Order.Desc));
            FeArticle entity = oc.FirstOrDefault();
            int       sort2  = 1;

            if (entity != null && entity.IsExists() && entity.SortOrder.HasValue)
            {
                sort2 = (int)entity.SortOrder.Value;
                sort2++;
            }
            return(sort2);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     创建新增对象排序。
        /// </summary>
        /// <returns></returns>
        public static decimal NewSortOrder()
        {
            ObjektCollection <FeCharacter> oc = new ObjektCollection <FeCharacter>(Klass.ForId("FeCharacter@Klass"), new WhereClause("\"sortOrder\" is not null"));

            oc.OrderByClause.Add(new OrderByCell("sortOrder", Order.Desc));
            FeCharacter character = oc.FirstOrDefault();
            int         sort2     = 1;

            if (character != null && character.IsExists() && character.SortOrder.HasValue)
            {
                sort2 = (int)character.SortOrder.Value;
                sort2++;
            }
            return(sort2);
        }
Ejemplo n.º 6
0
        public void ChildrenDeleteCheck()
        {
            List <FeComment> feComment = new ObjektCollection <FeComment>(Klass.ForId("FeComment@Klass"), new WhereClause("\"parent\" = '" + base.Id + "'")).ToList();

            if (feComment.Count > 0)
            {
                foreach (FeComment item in feComment)
                {
                    List <FeArticleComment> feArticleCommentList = new ObjektCollection <FeArticleComment>(Klass.ForId("FeArticleComment@Klass"), new WhereClause("\"related\" = '" + item.Id + "'")).ToList();
                    foreach (FeArticleComment item2 in feArticleCommentList)
                    {
                        item2.Delete();
                        item2.Save();
                    }
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 设置指定对象的seo关键字。
        /// </summary>
        /// <param name="tags"></param>
        /// <param name="relationshipName"></param>
        /// <param name="sourceId"></param>
        public static void SetObjektTag(List <string> tags, string relationshipName, string sourceId)
        {
            List <FeTag> entityTags = new List <FeTag>();

            foreach (string tag in tags)
            {
                FeTag entity = new ObjektCollection <FeTag>(Klass.ForId("FeTag@Klass"), new WhereClause("\"tag\" = '" + tag + "'")).TryGetSingleResult();
                if (entity == null)
                {
                    entity      = new FeTag();
                    entity.Tag  = tag;
                    entity.From = ObjektFactory.Find <Value>("75d290896b3d40ad802c9d6b04d61a9b@Value");
                    entity.Save();
                }
                IEnumerable <FeTag> query = from t in entityTags
                                            where t.Tag == entity.Tag
                                            select t;
                if (query.Count() == 0)
                {
                    entityTags.Add(entity);
                }
            }
            Objekt objekt = ObjektFactory.Find(sourceId);
            List <RelationshipObjekt> relationshipList = objekt.ROCC.GetROC(relationshipName).ToList();

            foreach (RelationshipObjekt item2 in relationshipList)
            {
                item2.Delete();
                item2.Save();
            }
            foreach (FeTag item3 in entityTags)
            {
                RelationshipObjekt relationship = ObjektFactory.New <RelationshipObjekt>(Klass.ForName(relationshipName));
                relationship.Source  = objekt;
                relationship.Related = item3;
                relationship.Save();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     添加删除业务逻辑。
        /// </summary>
        public override void BeforeDelete()
        {
            ObjektCollection <FeArticle> oc = new ObjektCollection <FeArticle>(Klass.ForId("FeArticle@Klass"), new WhereClause("\"category\" = '" + base.Id + "'"));

            if (oc.Count > 0)
            {
                throw new Exception("请先删除分类下的所有文章");
            }
            ObjektCollection <FeChannel> channelOc = new ObjektCollection <FeChannel>(Klass.ForId("FeChannel@Klass"), new WhereClause("\"category\" = '" + base.Id + "'"));

            if (channelOc.Count > 0)
            {
                throw new Exception("请先删除分类绑定的频道");
            }
            List <FeArticleCategory> children = GetChildren().ToList();

            foreach (FeArticleCategory item in children)
            {
                item.Delete();
                item.Save();
            }
            base.BeforeDelete();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 子评论恢复处理
        /// </summary>
        public void ChildrenRevertCheck()
        {
            ObjektCollection <FeComment> feComment = new ObjektCollection <FeComment>(Klass.ForId("FeComment@Klass"), new WhereClause("\"parent\" = '" + base.Id + "'"));

            if (feComment.Count > 0)
            {
                foreach (FeComment item in feComment)
                {
                    item.Revert();
                }
            }
        }
Ejemplo n.º 10
0
 private ObjektCollection <FeArticleCategory> GetChildren()
 {
     return(new ObjektCollection <FeArticleCategory>(Klass.ForId("FeArticleCategory@Klass"), new WhereClause("\"parent\" = '" + base.Id + "'")));
 }
Ejemplo n.º 11
0
        /// <summary>
        ///     清空文章分类所有数据。
        /// </summary>
        public static void DeleteAll()
        {
            ObjektCollection <FeArticleCategory> list = Klass.ForId("FeArticleCategory@Klass").GetInstances <FeArticleCategory>();

            list.DeleteAll();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 查询tag关键字。
        /// 根据value模糊查询。
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static List <FeTag> FindTags(string value)
        {
            ObjektCollection <FeTag> oc = new ObjektCollection <FeTag>(Klass.ForId("FeTag@Klass"), new WhereClause("\"tag\" like '%" + value + "%'"));

            return(oc.ToList());
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 查询seo关键字。
        /// 根据value模糊查询。
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static List <FeSeoKey> FindSeoKes(string value)
        {
            ObjektCollection <FeSeoKey> oc = new ObjektCollection <FeSeoKey>(Klass.ForId("FeSeoKey@Klass"), new WhereClause("\"key\" like '%" + value + "%'"));

            return(oc.ToList());
        }