Ejemplo n.º 1
0
 /// <summary>
 /// 更新节点信息
 /// </summary>
 /// <param name="dNode">节点信息</param>
 /// <returns>0:fail 1:success</returns>
 public int UpdateNodeModel(DefineNodes dNode)
 {
     if (dNode == null)
     {
         throw new ArgumentNullException("dNode");
     }
     using (var dbcontextscope = _dbContextScopeFactory.Create())
     {
         var db = dbcontextscope.DbContexts.Get <OADbContext>();
         return(Repository.Update <DefineNodes>(db, dNode));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 失效节点
 /// </summary>
 /// <param name="dNode">节点信息</param>
 /// <returns>返回处理结果1成功,0失败</returns>
 public int AbateNodelModel(DefineNodes dNode)
 {
     if (dNode == null)
     {
         throw new ArgumentNullException("DNode");
     }
     using (var dbcontextscope = _dbContextScopeFactory.Create())
     {
         var           db      = dbcontextscope.DbContexts.Get <OADbContext>();
         List <string> collist = new List <string>();
         collist.Add("IS_ABLE");
         dNode.IS_ABLE = isAble.No.ToString();
         return(Repository.Update <DefineNodes>(db, dNode, collist));
     }
 }
Ejemplo n.º 3
0
        public int AddDefineModelNode(DefineBindingModel dbmodel, string userid)
        {
            if (dbmodel == null || string.IsNullOrEmpty(userid))
            {
                throw new ArgumentNullException("jsondata or modelname");
            }
            try
            {
                var          jdata  = JArray.Parse(dbmodel.Model_Json);
                DefineNodes  dnode  = new DefineNodes();
                DefineModels dmodel = new DefineModels();
                using (var dbcontextscope = _dbContextScopeFactory.Create())
                {
                    var db        = dbcontextscope.DbContexts.Get <OADbContext>();
                    var lastmodel = db.Set <DefineModels>().Where(p => p.MODEL_NAME.Equals(dbmodel.Model_Name)).OrderByDescending(m => m.VERSION_NO).FirstOrDefault();
                    if (lastmodel == null)
                    {
                        dmodel.MODEL_ID         = Guid.NewGuid().ToString();
                        dmodel.MODEL_NAME       = dbmodel.Model_Name;
                        dmodel.VERSION_NO       = 1;
                        dmodel.IS_ABLE          = Enums.isAble.Yes.ToString();
                        dmodel.META_INFO        = dbmodel.Model_Json;
                        dmodel.MODIFIER         = userid;
                        dmodel.CREATOR          = userid;
                        dmodel.CREATE_TIME      = DateTime.Now;
                        dmodel.LAST_UPDATE_TIME = DateTime.Now;
                    }
                    else
                    {
                        dmodel.MODEL_ID         = Guid.NewGuid().ToString();
                        dmodel.MODEL_NAME       = dbmodel.Model_Name;
                        dmodel.VERSION_NO      += 1;
                        dmodel.IS_ABLE          = Enums.isAble.Yes.ToString();
                        dmodel.META_INFO        = dbmodel.Model_Json;
                        dmodel.MODIFIER         = userid;
                        dmodel.CREATOR          = userid;
                        dmodel.CREATE_TIME      = DateTime.Now;
                        dmodel.LAST_UPDATE_TIME = DateTime.Now;
                    }
                    var model = db.Set <DefineModels>();
                    model.Add(dmodel);

                    foreach (var item in jdata)
                    {
                        dnode.BACK_NODE_ID     = Guid.NewGuid().ToString();
                        dnode.CREATER          = userid;
                        dnode.CREATE_TIME      = DateTime.Now;
                        dnode.IS_ABLE          = Enums.isAble.Yes.ToString();
                        dnode.MODEL_ID         = dmodel.MODEL_ID;
                        dnode.MODIFIER         = userid;
                        dnode.LAST_UPDATE_TIME = DateTime.Now;
                        dnode.NODE_CONDITON    = string.Empty;
                        dnode.NODE_ID          = Guid.NewGuid().ToString();
                    }
                    return(db.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }