Example #1
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();
                }
            }
        }
Example #2
0
        /// <summary>
        ///     设置指定对象的属性。
        /// </summary>
        /// <param name="characters"></param>
        /// <param name="relationshipName"></param>
        /// <param name="sourceId"></param>
        public static void SetObjektCharacter(List <string> characters, string relationshipName, string sourceId)
        {
            Objekt objekt = ObjektFactory.Find(sourceId);
            List <RelationshipObjekt> relationshipList = objekt.ROCC.GetROC(relationshipName).ToList();

            foreach (RelationshipObjekt item in relationshipList)
            {
                item.Delete();
                item.Save();
            }
            foreach (string character in characters)
            {
                RelationshipObjekt relationship = ObjektFactory.New <RelationshipObjekt>(Klass.ForName(relationshipName));
                relationship.Source  = objekt;
                relationship.Related = ObjektFactory.Find(character);
                relationship.Save();
            }
        }
Example #3
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();
            }
        }