Exemple #1
0
        public int SaveAs(string id            = null, string title = null, string content = null, string categoryID = null, string status = null, string plainText = null
                          , string publishTime = "1990-01-01", string thumbnailSrc = null, string bizMode = null)
        {
            var session = SESSION.Current;

            var inst  = new DocItem();
            var isNew = false;

            if (StringChecker.IsNotEmptyObjectId(id))
            {
                inst._id = ObjectId.Parse(id);
            }
            else
            {
                inst._id = ObjectId.GenerateNewId();
                //inst.ID = Guid.NewGuid();
                inst.CreateTime  = DateTime.Now.AddDays(new Random().Next(-100, 100));
                inst.CreatorName = session.UserName;
                inst.CreatorID   = session.UserID;
                isNew            = true;
            }
            inst.Title         = title;
            inst.Keyword       = "暂空";
            inst.Summary       = "暂空";
            inst.Content       = content;
            inst.ContentLength = content.Length;
            //inst.CategoryID = categoryID;
            //inst.CategoryName = CategoryManager.GetInstance().Get(categoryID).Name;
            //inst.ContentType = "文档库模板";
            inst.PublishTime     = DateTime.Parse(publishTime);
            inst.Status          = status;
            inst.PlainText       = plainText;
            inst.PlainTextLength = plainText.Length;
            inst.UpdateTime      = DateTime.Now;
            if (StringChecker.IsHttpUrl(thumbnailSrc))
            {
                inst.ImageUrl = thumbnailSrc;
            }
            else
            {
                var pic = (DataSourceBaidu.GetInstance().GetPic(inst.Title)[0] as Dictionary <string, object>)["thumbURL"].ToString();
                inst.ImageUrl = pic;
            }

            inst.Save();

            ///添加记录
            //if (isNew)
            //{
            //    ModifyLogItem.LogAsNew(inst.id, CONST.DB.DBName_DocService, CONST.DB.CollectionName_DocItem);
            //}
            //else
            //{
            //    ModifyLogItem.LogAsModify(inst.id, CONST.DB.DBName_DocService, CONST.DB.CollectionName_DocItem);
            //}

            return(0);
        }
Exemple #2
0
        public static void Save(string jsonInput)
        {
            var dict = Convertor.FromJsonToDict2(jsonInput);
            var inst = new DocItem();

            if (dict.ContainsKey("ID") && null != dict["ID"])
            {
                inst.ID = dict["ID"].ToString();
            }
            inst = EntityManager.GetInstance().Get <DocItem>(inst);
            foreach (var kv in dict)
            {
                inst.GetType().GetProperty(kv.Key).SetValue(inst, kv.Value);
            }
            inst.Save();
        }
Exemple #3
0
 /// <summary>
 /// 保存一个目录
 /// </summary>
 /// <param name="name"></param>
 /// <param name="parentId"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public int SaveEntity(string jsonInput)
 {
     DocItem.Save(jsonInput);
     return(0);
 }