public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { try { var dict = new DFDictionary(); if (!string.IsNullOrWhiteSpace(entity["UserId"])) { using (var db = Pub.DB) { var sql = "SELECT * FROM WF_M_USER where UserId=@UserId"; var item = db.Query <VM_WF_M_USER>(sql, new { UserId = entity["UserId"] }).FirstOrDefault(); if (null != item) { dict.Merge(DFDictionary.Create <VM_WF_M_USER>(item)); } } } return(dict); } catch (Exception ex) { message = ex.Message; return(null); } }
public override int Update(FormM form, DFDictionary entity, ref string message) { if (entity["EditMode"] != "Edit") { return(Insert(form, entity, ref message)); } var user = Util.GetCurrentUser(); using (var db = Pub.DB) { var sql = "select * from WF_M_CONNECTOR where 1=1"; sql += " and ConnectorId=@ConnectorId"; var parameters = new { ConnectorId = entity["ConnectorId"] }; var oldEntity = db.Query <WF_M_CONNECTOR>(sql, parameters).FirstOrDefault(); if (oldEntity == null) { throw new WFException("找不到要更新的记录".GetRes()); } // 先将数据库查出来的老的实体转成字典,然后把客户端传过来的字典合并进去,这样就实现了数据的更新 var newEntity = DFDictionary.Create <WF_M_CONNECTOR>(oldEntity).Merge(entity).To <WF_M_CONNECTOR>(); newEntity.LastModifyTime = DateTime.Now; newEntity.LastModifyUser = user.UserName; db.Update <WF_M_CONNECTOR>(newEntity); message = "保存成功".GetRes(); return(DFPub.EXECUTE_SUCCESS); } }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { try { var dict = new DFDictionary(); /*基本查询语句*/ var sql = @"select a.* from WF_M_RES a where 1=1"; /*查询条件*/ sql += " and a.ResId=@ResId"; if (!string.IsNullOrWhiteSpace(entity["ResId"])) { using (var db = Pub.DB) { var parameters = new { ResId = entity["ResId"] }; var item = db.Query <VM_WF_M_RES>(sql, parameters).FirstOrDefault(); if (item != null) { dict = DFDictionary.Create <VM_WF_M_RES>(item); } } } return(dict); } catch (Exception ex) { message = ex.Message; return(null); } }
public override int Update(FormM form, DFDictionary entity, ref string message) { try { var dict = new DFDictionary(); /*基本查询语句*/ var sql = "select * from WF_M_ROLE where 1=1"; /*查询条件*/ using (var db = Pub.DB) { var parameters = entity.To <WF_M_ROLE>(); var oldEntity = db.Query <WF_M_ROLE>(sql, parameters).FirstOrDefault(); if (oldEntity == null) { message = "记录已经不存在".GetRes(); return(DFPub.EXECUTE_ERROR); } var newDict = DFDictionary.Create <WF_M_ROLE>(oldEntity); // 把更新的值更新进去 newDict.Merge(entity); // 将 Dictionary 转成 Entity var newEntity = newDict.To <WF_M_ROLE>(); db.Update <WF_M_ROLE>(newEntity); return(DFPub.EXECUTE_SUCCESS); } } catch (Exception ex) { message = ex.Message; return(DFPub.EXECUTE_ERROR); } }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { try { var dict = new DFDictionary(); if (!string.IsNullOrWhiteSpace(entity["RoleId"])) { using (var db = Pub.DB) { var sql = "select * from WF_M_ROLE where RoleId=@RoleId"; var item = db.Query <WF_M_ROLE>(sql, new { RoleId = entity["RoleId"] }).FirstOrDefault(); if (null != item) { dict.Merge(DFDictionary.Create <WF_M_ROLE>(item)); } } } return(dict); } catch (Exception ex) { message = ex.Message; return(null); } }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { var dict = new DFDictionary(); var item = WF_M_ROLE_MODELLoader.Get(entity["ModelId"], entity["RoleId"]); if (item != null) { dict = DFDictionary.Create <WF_M_ROLE_MODEL>(item); } return(dict); }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { var dict = new DFDictionary(); if (!string.IsNullOrWhiteSpace(entity["InstanceStepExecutorId"])) { using (var db = Pub.DB) { var sql = @"select a.*,c.DFFormName from WF_T_INSTANCESTEPEXECUTOR a left outer join WF_T_INSTANCE b on a.InstanceId=b.InstanceId left outer join WF_M_MODEL c on b.ModelId=c.ModelId where 1=1"; sql += " and a.InstanceStepExecutorId=@InstanceStepExecutorId"; var parameters = new { InstanceStepExecutorId = entity["InstanceStepExecutorId"] }; var item = db.Query <VM_WF_T_INSTANCESTEPEXECUTOR>(sql, parameters).FirstOrDefault(); if (item != null) { dict = DFDictionary.Create <VM_WF_T_INSTANCESTEPEXECUTOR>(item); } } } else if (!string.IsNullOrWhiteSpace(entity["InstanceId"])) { using (var db = Pub.DB) { var sql = @"select a.*,b.DFFormName from WF_T_INSTANCE a left outer join WF_M_MODEL b on a.ModelId=b.ModelId where 1=1"; sql += " and a.InstanceId=@InstanceId"; var parameters = new { InstanceId = entity["InstanceId"] }; var item = db.Query <VM_WF_T_INSTANCE>(sql, parameters).FirstOrDefault(); if (item != null) { dict = DFDictionary.Create <VM_WF_T_INSTANCE>(item); } } } else { throw new Exception("无效的参数,必须提供 InstanceStepExecutorId 或者 InstanceId".GetRes()); } return(dict); }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { if (string.IsNullOrWhiteSpace(entity["ModelId"])) { throw new Exception("缺少参数 ModelId".GetRes()); } var engine = NinjectHelper.Get <IEngine>(); if (engine == null) { throw new Exception("找不到 IEngine".GetRes()); } var user = Util.GetCurrentUser(); var instanceId = Pub.GetNextIdFromDB("T", DateTime.Now.ToString("yyyyMMdd"), string.Empty, 4); var Requestor = user.UserId; var RequestorName = user.UserName; var RequestorProxy = string.Empty; var RequestorProxyName = string.Empty; // 开始工作流 engine.StartDBWF(entity["ModelId"], instanceId, Requestor, RequestorProxy, RequestorName, RequestorProxyName, DateTime.Now, true, user.UserId, user.UserName); var dict = new DFDictionary(); if (!string.IsNullOrWhiteSpace(entity["ModelId"])) { using (var db = Pub.DB) { var sql = "select * from WF_T_INSTANCE where 1=1"; sql += " and InstanceId=@InstanceId"; var parameters = new { InstanceId = instanceId }; var item = db.Query <WF_T_INSTANCE>(sql, parameters).FirstOrDefault(); if (item != null) { dict = DFDictionary.Create <WF_T_INSTANCE>(item); } } } return(dict); }
public override int Update(FormM form, DFDictionary entity, ref string message) { if (entity["EditMode"] != "Edit") { return(Insert(form, entity, ref message)); } try { if (string.IsNullOrWhiteSpace(entity["MenuId"])) { throw new Exception("请传入 MenuId 参数".GetRes()); } if (string.IsNullOrWhiteSpace(entity["ModuleId"])) { throw new Exception("请选择对应的模块".GetRes()); } if (string.IsNullOrWhiteSpace(entity["PMenuId"])) { throw new Exception("请选择父菜单".GetRes()); } var oldEntity = WF_M_MENULoader.Query(entity["MenuId"]).FirstOrDefault(); if (oldEntity == null) { throw new Exception("找不到要更新的记录".GetRes()); } // 先将数据库查出来的老的实体转成字典,然后把客户端传过来的字典合并进去,这样就实现了数据的更新 var newEntity = DFDictionary.Create <WF_M_MENU>(oldEntity).Merge(entity).To <WF_M_MENU>(); var user = Util.GetCurrentUser(); var parent = WF_M_MENULoader.Query(entity["PMenuId"]).FirstOrDefault(); var siblings = WF_M_MENULoader.Query(null, parent.MenuLabel).ToList(); newEntity.MenuLabel = LabelHelper.GetNextLabelUsingSubLabelList(parent.MenuLabel, siblings.Select(a => a.MenuLabel).ToList()); newEntity.LastModifyTime = DateTime.Now; newEntity.LastModifyUser = user.UserName; newEntity.Expanded = ParseHelper.ParseInt(entity["Expanded"]); WF_M_MENULoader.Update(newEntity); message = "保存成功".GetRes(); return(DFPub.EXECUTE_SUCCESS); } catch (Exception ex) { message = ex.Message; return(DFPub.EXECUTE_ERROR); } }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { try { if (!string.IsNullOrWhiteSpace(entity["ModuleId"])) { var item = WF_M_MODULELoader.Query(entity["ModuleId"]).FirstOrDefault(); if (item != null) { return(DFDictionary.Create <WF_M_MODULE>(item)); } } } catch (Exception ex) { message = ex.Message; } return(null); }
public override int Update(FormM form, DFDictionary entity, ref string message) { if (entity["EditMode"] != "Edit") { return(Insert(form, entity, ref message)); } var currentUser = Util.GetCurrentUser(); var dict = new DFDictionary(); /*基本查询语句*/ var sql = "select * from WF_M_USER where 1=1"; /*查询条件*/ sql += " and UserId=@UserId"; if (entity["Category"] == "SENDER") { if (string.IsNullOrWhiteSpace(entity["CompanyName"])) { throw new WFException("请输入托运单位"); } } using (var db = Pub.DB) { var parameters = new { UserId = entity["UserId"] }; var oldEntity = db.Query <WF_M_USER>(sql, parameters).FirstOrDefault(); if (oldEntity == null) { throw new WFException("记录已经不存在".GetRes()); } var newEntity = DFDictionary.Create <WF_M_USER>(oldEntity).Merge(entity).To <WF_M_USER>(); newEntity.Status = ParseHelper.ParseInt(entity["Status"]); newEntity.LastModifyUser = currentUser.UserName; newEntity.LastModifyTime = DateTime.Now; db.Update(newEntity); message = "保存成功".GetRes(); return(DFPub.EXECUTE_SUCCESS); } }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { try { var dict = new DFDictionary(); if (!string.IsNullOrWhiteSpace(entity["RoleId"])) { using (var db = Pub.DB) { var sql = "select * from WF_M_ROLE where RoleId=@RoleId"; var item = db.Query <WF_M_ROLE>(sql, new { RoleId = entity["RoleId"] }).FirstOrDefault(); if (null != item) { dict.Merge(DFDictionary.Create <WF_M_ROLE>(item)); } // 载入权限 sql = "select * from WF_M_AUTH_MODULE where RoleId=@RoleId"; var list1 = db.Query <WF_M_AUTH_MODULE>(sql, new { RoleId = entity["RoleId"] }).ToList(); dict.Add("DF_TREE_VIEWSTATE1", Base64StringHelper.ConvertToBase64String(JsonSerializeHelper.SerializeObject( list1.Select(a => new WFTreeNode { id = a.ModuleId, _checked = true, expanded = true })))); sql = "select * from WF_M_AUTH_DATA where RoleId=@RoleId"; var list2 = db.Query <WF_M_AUTH_DATA>(sql, new { RoleId = entity["RoleId"] }).ToList(); dict.Add("DF_TREE_VIEWSTATE2", Base64StringHelper.ConvertToBase64String(JsonSerializeHelper.SerializeObject( list2.Select(a => new WFTreeNode { id = a.DeptId, _checked = true, expanded = true })))); } } return(dict); } catch (Exception ex) { message = ex.Message; return(null); } }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { var dict = new DFDictionary(); /*基本查询语句*/ var sql = @"select a.* from WF_M_USER a where 1=1"; /*查询条件*/ sql += " and a.UserId=@UserId"; if (!string.IsNullOrWhiteSpace(entity["UserId"])) { using (var db = Pub.DB) { var parameters = new { UserId = entity["UserId"] }; var item = db.Query <VM_WF_M_USER>(sql, parameters).FirstOrDefault(); if (item != null) { dict = DFDictionary.Create <VM_WF_M_USER>(item); } } } return(dict); }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { var dict = new DFDictionary(); if (!string.IsNullOrWhiteSpace(entity["StepId"])) { using (var db = Pub.DB) { var sql = "select * from WF_M_STEP where 1=1"; sql += " and StepId=@StepId"; var parameters = new { StepId = entity["StepId"] }; var item = db.Query <WF_M_STEP>(sql, parameters).FirstOrDefault(); if (item != null) { dict = DFDictionary.Create <WF_M_STEP>(item); } } } return(dict); }
public override int Update(FormM form, DFDictionary entity, ref string message) { if (entity["EditMode"] != "Edit") { return(Insert(form, entity, ref message)); } var oldEntity = WF_M_ROLE_MODELLoader.Get(entity["ModelId"], entity["RoleId"]); if (oldEntity == null) { //return Insert(form, entity, ref message); throw new WFException("要更新的记录不存在"); } var newEntity = DFDictionary.Create <WF_M_ROLE_MODEL>(oldEntity).Merge(entity).To <WF_M_ROLE_MODEL>(); var user = string.Empty; user = Util.GetCurrentUser().UserName; newEntity.LastModifyTime = DateTime.Now; newEntity.LastModifyUser = user; WF_M_ROLE_MODELLoader.Update(newEntity); message = "保存成功"; return(DFPub.EXECUTE_SUCCESS); }
public override DFDictionary Get(FormM form, DFDictionary entity, ref string message) { ArgumentCheck.CheckMustInput(entity, "ModelId"); var engine = NinjectHelper.Get <IEngine>(); if (engine == null) { throw new Exception("找不到 IEngine".GetRes()); } var user = Util.GetCurrentUser(); var instanceId = string.Empty; // 信达生物 SAP 只能传递 10 位流水号 var model = WFDA.Instance.GetModelById(entity["ModelId"]); if (model.DFFormName == "Form_XDSW_T_PR") { instanceId = Pub.GetNextIdFromDB("P", DateTime.Now.ToString("yyMMdd"), string.Empty, 3); } else if (model.DFFormName == "Form_AD_T_PO") { instanceId = Pub.GetNextIdFromDB("P", DateTime.Now.ToString("yyyyMMdd"), string.Empty, 4); } else if (model.DFFormName == "Form_AD_T_BANK_PAYMENT") { instanceId = Pub.GetNextIdFromDB("F", DateTime.Now.ToString("yyyyMMdd"), string.Empty, 4); } else if (model.DFFormName == "Form_AD_T_FA") { instanceId = Pub.GetNextIdFromDB("G", DateTime.Now.ToString("yyyyMMdd"), string.Empty, 4); } else { instanceId = Pub.GetNextIdFromDB("A", DateTime.Now.ToString("yyyyMMdd"), string.Empty, 4); } var Requestor = user.UserId; var RequestorName = user.UserName; var RequestorProxy = string.Empty; var RequestorProxyName = string.Empty; // 如果是代理申请,客户端会传上来申请人编号 if (!string.IsNullOrWhiteSpace(entity["Requestor"])) { Requestor = entity["Requestor"]; var requestor = WF_M_USERLoader.Get(Requestor); if (requestor == null) { throw new Exception(string.Format("根据用户编号 {0} 找不到用户", Requestor)); } RequestorName = requestor.UserName; RequestorProxy = user.UserId; RequestorProxyName = user.UserName; } // 开始工作流 engine.StartDBWF(entity["ModelId"], instanceId, Requestor, RequestorProxy, RequestorName, RequestorProxyName, DateTime.Now, true, user.UserId, user.UserName); if (!string.IsNullOrWhiteSpace(entity["SourceInstanceId"])) { // 复制单据 CloneInstance(entity, instanceId); } var dict = new DFDictionary(); if (!string.IsNullOrWhiteSpace(entity["ModelId"])) { using (var db = Pub.DB) { var sql = "select * from WF_T_INSTANCE where 1=1"; sql += " and InstanceId=@InstanceId"; var parameters = new { InstanceId = instanceId }; var item = db.Query <WF_T_INSTANCE>(sql, parameters).FirstOrDefault(); if (item != null) { dict = DFDictionary.Create <WF_T_INSTANCE>(item); } } } return(dict); }