public int DefineModelAndNodes(DefineBindingModel dmodel, string userid) { DefineModels model = DefineModelRepository.GetLastDefineModelByName(dmodel.Model_Name); if (model == null) { model = new DefineModels { MODEL_ID = Guid.NewGuid().ToString(), MODEL_NAME = dmodel.Model_Name, VERSION_NO = 1, IS_ABLE = "1", META_INFO = dmodel.Model_Json, CREATOR = userid, CREATE_TIME = DateTime.Now, MODIFIER = userid, LAST_UPDATE_TIME = DateTime.Now }; } else { model.MODIFIER = userid; model.LAST_UPDATE_TIME = DateTime.Now; model.VERSION_NO += 1; model.META_INFO = dmodel.Model_Json; model.IS_ABLE = "1"; } return(DefineModelRepository.AddDefineModel(model)); }
public int AddDefineModel(DefineModels dmodel) { if (dmodel == null) { throw new ArgumentNullException("dmodel"); } using (var dbContextScope = _dbContextScopeFactory.Create()) { var db = dbContextScope.DbContexts.Get <OADbContext>(); return(Repository.Add <DefineModels>(db, dmodel)); } }
public int AbateDefineModel(DefineModels model) { if (model == null) { throw new ArgumentNullException("model"); } using (var dbContextScope = _dbContextScopeFactory.Create()) { var dbContext = dbContextScope.DbContexts.Get <OADbContext>(); List <string> collist = new List <string>(); collist.Add("IS_ABLE"); return(Repository.Update <DefineModels>(dbContext, model, collist)); } }
public int AbateDefineModelByID(string m_id) { if (string.IsNullOrEmpty(m_id)) { throw new ArgumentNullException("m_id"); } using (var dbcontextscop = _dbContextScopeFactory.Create()) { var db = dbcontextscop.DbContexts.Get <OADbContext>(); DefineModels dmodel = Repository.Get <DefineModels>(db, p => p.MODEL_ID == m_id); if (dmodel != null) { dmodel.IS_ABLE = "0"; List <string> collist = new List <string>(); collist.Add("IS_ABLE"); return(Repository.Update <DefineModels>(db, dmodel, collist)); } else { return(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; } }