public bool SaveBacklogDetails(StrObjectDict sod) { var backlogIds = sod.GetObject("BacklogIds") as object[]; if (backlogIds == null) { return(false); } var batchStates = backlogIds.Select(id => { var dic = id as Dictionary <string, object>; if (dic == null) { return(null); } return(new DBState() { Name = "INSERT_BacklogDetails", Param = new { ID = Utils.getGUID(), FormID = sod.GetString("FormID"), ObjectID = sod.GetString("ObjectID"), BacklogID = dic["eventId"], TargetID = dic["id"], Hander = sod.GetString("Hander") }.toStrObjDict(), Type = ESqlType.INSERT }); }).ToList(); return(batchStates.Count != 0 && DB.Execute(batchStates) > 0); }
/// <summary> /// 修改计划方案明细 /// </summary> /// <returns></returns> public bool UpdateSchemeDetails(StrObjectDict sod, string user) { //先删除该计划方案下的明细,然后重新添加 var batchStates = new List <DBState>(); //删除计划方案下的明细 var schemeID = sod.GetString("SchemeID"); batchStates.Add(new DBState { Name = "DELETE_PatientSchemeDetails", Param = new { SchemeID = schemeID }.toStrObjDict(), Type = ESqlType.DELETE }); //添加明细 if (sod.GetObject("Targets") != null) { foreach (var item in sod.GetObject("Targets") as Dictionary <string, object> ) { foreach (var details in item.Value as object[]) { var target = details as Dictionary <string, object>; batchStates.Add(new DBState { Name = "INSERT_PatientSchemeDetails", Param = new { SchemeID = schemeID, Name = "", Code = target["Code"].ToString(), Content = target["TargetContent"].ToString(), TargetID = target["TargetID"].ToString(), IsCustom = 1, ModifyTime = DateTime.Now, ModifyUser = user }.toStrObjDict(), Type = ESqlType.INSERT }); } } } return(DB.ExecuteWithTransaction(batchStates) > 0); }
public override ActionResult List() { StrObjectDict reqData = base.GetHttpData(); StrObjectDict reqParam = reqData.GetObject("Params").toStrObjDict(false); IList <StrObjectDict> result = base.crudManager.ListSod <CommonCodeDetail>(reqParam); Tree tree = new Tree(); tree.datasList = result; tree.TransformTree("SuperID"); return(this.MyJson(1, tree.data)); }
public override ActionResult Delete() { StrObjectDict reqParam = GetParams(); string roleID = reqParam.GetString("RoleID"); IList <RoleMember> list = new List <RoleMember>(); List <Object> userIDs = ((Object[])reqParam.GetObject("UserIDs")).ToList(); foreach (var item in userIDs) { RoleMember rm = new RoleMember() { RoleID = roleID, UserID = item.ToString() }; list.Add(rm); } var result = RoleManager.Instance.DeleteBatchs(list); return(this.MyJson(1, result)); }
public ActionResult SetPower() { StrObjectDict dict = GetParams(); string roleID = dict.GetString("RoleGroupID"); string powerID = dict.GetString("PowerID"); dict["RoleID"] = dict["RoleGroupID"]; #region 参数有效性检查 if (string.IsNullOrEmpty(roleID)) { return(this.MyJson(0, "参数错误:RoleGroupID")); } if (string.IsNullOrEmpty(powerID)) { return(this.MyJson(0, "参数错误:PowerID")); } #endregion IList <Object> menuIDs = new List <Object>(); try { menuIDs = ((Object[])dict.GetObject("PowerID")).ToList(); } catch { return(this.MyJson(0, "至少保留一个菜单项")); } IList <RolePower> list = new List <RolePower>(); RolePower rp = new RolePower(); foreach (var item in menuIDs) { var powers = item.toStrObjDict(); string powerId = null; string menuId = null; foreach (var items in powers) { if (items.Key == "btnId") { powerId = items.Value.ToString(); } if (items.Key == "menuId") { menuId = items.Value.ToString(); } } rp = new RolePower() { RoleID = roleID, PowerID = powerId, MenuID = menuId }; list.Add(rp); } //查询到已被分配权限,执行Delete + Insert //Delete var delete = RoleManager.Instance.DeletePowers(dict); //Insert var result = RoleManager.Instance.InsertPowers(list); if (result > 0) { return(this.MyJson(1, "保存成功.")); } else { return(this.MyJson(0, "保存失败.")); } }
public int InsertOrUpdate(StrObjectDict dict, StrObjectDict dicts) { string id = Utils.getGUID(); string ClearID = ""; if (!dict.ContainsKey("ID")) { dict["ID"] = id; ClearID = id; IList <DBState> dblist = new List <DBState>(); dblist.Add(new DBState { Name = "INSERT_Function", Param = dict.toStrObjDict(), Type = ESqlType.INSERT }); List <Object> options = ((Object[])dicts.GetObject("SyncRoot")).ToList(); if (options.Count > 0) { IList <DBState> dblists = new List <DBState>(); foreach (var item in options) { StrObjectDict temp = item.toStrObjDict(); temp["ID"] = Utils.getGUID(); temp["FunID"] = id; DBState db = new DBState() { Name = "INSERT_FunctionOption", Param = temp, Type = ESqlType.INSERT }; dblists.Add(db); } int i = DB.Execute(dblist); int a = DB.Execute(dblists); if (i > 0 && a > 0) { return(1); } else { return(0); } } else { return(DB.Execute(dblist)); } } else { //保存待清空菜单操作的当前菜单ID ClearID = dict["ID"].ToString(); IList <DBState> dblist = new List <DBState>(); dblist.Add(new DBState { Name = "UPDATE_Function", Param = dict.toStrObjDict(), Type = ESqlType.UPDATE }); List <Object> options = ((Object[])dicts.GetObject("SyncRoot")).ToList(); //判断是否清除当前功能下的所有关联按钮 if (options.Count > 0) { //先执行Delete,后Insert。完成Update操作 //Delete IList <DBState> dbdel = new List <DBState>(); foreach (var item in options) { StrObjectDict temp = item.toStrObjDict(); DBState db = new DBState() { Name = "DELETE_FunctionOptionFunID", Param = temp, Type = ESqlType.DELETE }; dbdel.Add(db); } DB.Execute(dbdel); //Insert IList <DBState> dblists = new List <DBState>(); foreach (var item in options) { StrObjectDict temp = item.toStrObjDict(); temp["ID"] = Utils.getGUID(); DBState db = new DBState() { Name = "INSERT_FunctionOption", Param = temp, Type = ESqlType.INSERT }; dblists.Add(db); } int i = DB.Execute(dblist); int a = DB.Execute(dblists); if (i > 0 && a > 0) { return(1); } else { return(0); } } else { //执行清除 DBState state = null; state = new DBState { Name = "DELETE_FunctionOptionFunID", Param = new { FunID = ClearID }.toStrObjDict(), Type = ESqlType.DELETE }; DB.Execute(state); return(DB.Execute(dblist)); } } }
public int InsertData(StrObjectDict list, StrObjectDict dict) { var name = "type"; List <Object> result = ((Object[])list.GetObject("SyncRoot")).ToList(); IList <DBState> dblist = new List <DBState>(); foreach (var item in result) { StrObjectDict temp = item.toStrObjDict(); //string superID = temp.GetString("id"); if (temp.ContainsKey("options")) { List <Object> temp1 = ((Object[])temp.GetObject("options")).ToList(); temp.Remove("options"); var id = temp.GetString("id"); var ywhy = temp.GetString("YWHY"); var type = temp.GetString("type"); var text = temp.GetString("text"); var no = temp.GetString("NO"); var style = 1; switch (type) { case "input": style = 1; break; case "radio": style = 2; break; case "checkbox": style = 2; break; case "grade": style = 1; break; case "label": style = 1; break; } //foreach (var value in temp) //{ dblist.Add(new DBState { Name = "INSERT_FormStructure", Param = new { ID = id, FormID = dict["FormID"], VersionCode = dict["VersionCode"], ElementName = text, ElementAttribute = type, Implication = ywhy, FormOfExpression = style, NO = no }.toStrObjDict(), Type = ESqlType.INSERT }); //} foreach (var lls in temp1) { StrObjectDict sod = lls.toStrObjDict(); var ids = sod.GetString("id"); var ywhys = sod.GetString("YWHY"); var types = sod.GetString("type"); var texts = sod.GetString("text"); var nos = sod.GetString("NO"); var styles = 1; switch (types) { case "input": style = 1; break; case "radio": style = 2; break; case "checkbox": style = 2; break; case "grade": style = 1; break; case "label": style = 1; break; } dblist.Add(new DBState { Name = "INSERT_FormStructure", Param = new { ID = ids, FormID = dict["FormID"], VersionCode = dict["VersionCode"], ElementName = texts, ElementAttribute = types, Implication = ywhys, FormOfExpression = styles, SuperID = id, NO = nos }.toStrObjDict(), Type = ESqlType.INSERT }); } } else { var id = temp.GetString("id"); var ywhy = temp.GetString("YWHY"); var type = temp.GetString("type"); var text = temp.GetString("text"); var no = temp.GetString("NO"); var style = 1; switch (type) { case "input": style = 1; break; case "radio": style = 2; break; case "checkbox": style = 2; break; case "grade": style = 1; break; case "label": style = 1; break; } dblist.Add(new DBState { Name = "INSERT_FormStructure", Param = new { ID = id, FormID = dict["FormID"], VersionCode = dict["VersionCode"], ElementName = text, ElementAttribute = type, Implication = ywhy, FormOfExpression = style, NO = no }.toStrObjDict(), Type = ESqlType.INSERT }); } } return(DB.Execute(dblist)); }
public string Save(StrObjectDict sod, string userName) { var id = Guid.NewGuid().ToString(); var mark = sod.GetObject("Mark") as Dictionary <string, object>; var details = sod.GetObject("Details") as object[]; var time = DateTime.Now; mark.Add("MarkUser", userName); mark.Add("MarkTime", time); mark.Add("ModifyTime", time); List <DBState> batchStates = new List <DBState>(); //包含ID键,则需要删除详细,然后在增加详细以及修改评分 if (mark.ContainsKey("ID")) { //删除详细 batchStates.Add(new DBState() { Name = "DELETE_PatientMarkDetails", Param = new { MarkID = mark.GetString("ID") }.toStrObjDict(), Type = ESqlType.DELETE }); //修改评分表 batchStates.Add( new DBState() { Name = "UPDATE_PatientCareMark", Param = mark, Type = ESqlType.UPDATE }); //增加评分详细 foreach (var item in details) { batchStates.Add(new DBState() { Name = "INSERT_PatientMarkDetails", Param = item as Dictionary <string, object>, Type = ESqlType.INSERT }); } DB.ExecuteWithTransaction(batchStates); return("update"); } else//添加评分以及详细 { mark["ID"] = id; //增加评分 batchStates.Add(new DBState() { Name = "INSERT_PatientCareMark", Param = mark, Type = ESqlType.INSERT }); //增加评分详细 foreach (var item in details) { var dic = item as Dictionary <string, object>; dic["MarkID"] = id; batchStates.Add(new DBState() { Name = "INSERT_PatientMarkDetails", Param = dic, Type = ESqlType.INSERT }); } DB.ExecuteWithTransaction(batchStates); return(id); } }
/// <summary> /// 新增计划(保存病人护理计划、方案、方案明细) /// </summary> /// <param name="sod"></param> /// <returns></returns> public bool SaveNewPlan(StrObjectDict sod, string createUser) { var batchStates = new List <DBState>(); var planID = Guid.NewGuid().ToString(); batchStates.Add(new DBState//病人计划保存 { Name = "INSERT_PatientNursingPlan", Param = new { ID = planID, DeptID = sod.GetString("LesionID"), ObjectID = sod.GetString("PatientID"), ModifyUser = createUser, ModifyTime = DateTime.Now, PlanStandardID = "", IsInvalid = 0 }.toStrObjDict(), Type = ESqlType.INSERT }); foreach (var item in sod.GetObject("Questions") as object[]) { var question = item as Dictionary <string, object>; var questionID = question["ID"].ToString(); var schemeID = Guid.NewGuid().ToString(); //计划方案保存 batchStates.Add(new DBState { Name = "INSERT_PatientScheme", Type = ESqlType.INSERT, Param = new { ID = schemeID, PatientPlanID = planID, QuestionID = questionID, FormType = int.Parse(question["Type"].ToString()), IsInvalid = 0 }.toStrObjDict() }); #region ========= 计划方案明细保存 ================= var planStandardID = question.GetString("PlanStandardID"); if (string.IsNullOrEmpty(planStandardID))//标准计划ID为空查询<问题_方法关联> { var result = DB.ListSod("LIST_QuestionRelation", new { ID = questionID }); foreach (var details in result) { batchStates.Add(new DBState { Name = "INSERT_PatientSchemeDetails", Param = new { SchemeID = schemeID, Name = "", Code = details["CODE"].ToString(), Content = details["FNAME"].ToString(), TargetID = details["FID"].ToString(), IsCustom = 1, ModifyTime = DateTime.Now, ModifyUser = createUser }.toStrObjDict(), Type = ESqlType.INSERT }); } } else//查询标准计划明细 { var result = DB.ListSod("LIST_PlantDetails", new { PlanID = planStandardID, QuestionID = questionID }); foreach (var details in result) { batchStates.Add(new DBState { Name = "INSERT_PatientSchemeDetails", Param = new { SchemeID = schemeID, Name = "", Code = details["CODE"].ToString(), Content = details["TARGETNAME"].ToString(), TargetID = details["PLANTARGETID"].ToString(), IsCustom = 1, ModifyTime = DateTime.Now, ModifyUser = createUser }.toStrObjDict(), Type = ESqlType.INSERT }); } } #endregion } return(DB.ExecuteWithTransaction(batchStates) > 0); }
/// <summary> /// 1.检查站点设备 /// 2.注册站点设备,保存内容:所属机构,站点设备相关信息,应用模块代码 /// </summary> /// <returns></returns> public ActionResult Index() { StrObjectDict dict = GetParams(); object pointID = dict.GetObject("PointID"); object orgID = dict.GetObject("OrgID"); object pointInfo = dict.GetObject("PointInfo"); object moduleCode = dict.GetObject("ModuleCode"); #region 检查参数是否正确 if (pointID == null || string.IsNullOrEmpty(pointID.ToString())) { return(this.MyJson(0, "参数错误:PointID")); } if (orgID == null || string.IsNullOrEmpty(orgID.ToString())) { return(this.MyJson(1, "参数错误:OrgID")); } if (pointInfo == null || string.IsNullOrEmpty(pointInfo.ToString())) { return(this.MyJson(0, "参数错误:PointInfo")); } if (moduleCode == null || string.IsNullOrEmpty(moduleCode.ToString())) { return(this.MyJson(0, "参数错误:ModuleID")); } #endregion //检查设备是否已经注册 SiteDevice device = SiteManager.Instance.GetSiteDeviceByDeviceID(pointID.ToString()); if (device == null || string.IsNullOrEmpty(device.ID)) { int deviceCount = 99;//通过授权文件查询出授权使用的设备数量 int regDeviceCount = SiteManager.Instance.GetSiteDeviceCount(); if (deviceCount <= regDeviceCount) { return(this.MyJson(0, "已超过允许注册设备的最大数量,请联系管理员!")); } //未注册同时也没有超过设备允许注册的最大数量,则自动注册该设备 int result = SiteDeviceManager.Instance.Add(new SiteDevice { DeviceID = pointID.ToString(), DeviceInfo = pointInfo.ToString(), Enable = 1, IsMobile = 1, RegTime = DateTime.Now, Remark = "", DeptID = orgID.ToString() }, moduleCode.ToString()); if (result < 1) { return(this.MyJson(0, "设备注册失败,请联系管理员!")); } } return(this.MyJson(1)); }
public int InsertOrUpdate(StrObjectDict menu, StrObjectDict menuoption) { string id = Utils.getGUID(); string ClearID = ""; if (!menu.ContainsKey("ID")) { menu["ID"] = id; ClearID = id; IList <DBState> dblist = new List <DBState>(); dblist.Add(new DBState { Name = "INSERT_Menu", Param = menu.toStrObjDict(), Type = ESqlType.INSERT }); List <Object> options = ((Object[])menuoption.GetObject("SyncRoot")).ToList(); if (options.Count > 0) { IList <DBState> dblists = new List <DBState>(); foreach (var item in options) { StrObjectDict temp = item.toStrObjDict(); temp["ID"] = Utils.getGUID(); temp["MenuID"] = id; DBState db = new DBState() { Name = "INSERT_MenuOption", Param = temp, Type = ESqlType.INSERT }; dblists.Add(db); } int i = DB.Execute(dblist); int a = DB.Execute(dblists); if (i > 0 && a > 0) { return(1); } else { return(0); } } else { return(DB.Execute(dblist)); } } else { //保存待清空菜单操作的当前菜单ID ClearID = menu["ID"].ToString(); IList <DBState> dblist = new List <DBState>(); dblist.Add(new DBState { Name = "UPDATE_Menu", Param = menu.toStrObjDict(), Type = ESqlType.UPDATE }); List <Object> options = ((Object[])menuoption.GetObject("SyncRoot")).ToList(); //判断是否清除当前菜单下的所有关联按钮 if (options.Count > 0) { //先执行Delete,后Insert。完成Update操作 //Delete组装 IList <DBState> dbdel = new List <DBState>(); foreach (var item in options) { StrObjectDict temp = item.toStrObjDict(); DBState db = new DBState() { Name = "DELETE_MenuOptionMenuID", Param = temp, Type = ESqlType.DELETE }; dbdel.Add(db); } //Step1:清除按钮相关已分配权限 DBState del = null; del = new DBState { Name = "DEL_RolePower", Param = new { MenuID = ClearID }.toStrObjDict(), Type = ESqlType.DELETE }; DB.Execute(del); //Step2:Delete DB.Execute(dbdel); IList <DBState> dblists = new List <DBState>(); foreach (var item in options) { StrObjectDict temp = item.toStrObjDict(); temp["ID"] = Utils.getGUID(); DBState db = new DBState() { Name = "INSERT_MenuOption", Param = temp, Type = ESqlType.INSERT }; dblists.Add(db); } int i = DB.Execute(dblist); int a = DB.Execute(dblists); if (i > 0 && a > 0) { return(1); } else { return(0); } } else { //执行清除 DBState state = null; state = new DBState { Name = "DELETE_MenuOptionMenuID", Param = new { MenuID = ClearID }.toStrObjDict(), Type = ESqlType.DELETE }; DB.Execute(state); return(DB.Execute(dblist)); } } }