public string SaveRoleAudit(int roleid, string rolename, string flowname, string flowidls) { MessageModel <bool> result = new MessageModel <bool>(); try { TB_ROLE_LOG rlog = new TB_ROLE_LOG(); TB_ROLE_LOG_PROCESS rlog_p = new TB_ROLE_LOG_PROCESS(); //插入待处理表 rlog.OID = roleid; rlog.TYPE = "TB_RoleAudit"; rlog.STATUS = "0"; rlog.BEFORE_CONTENT = string.Empty; rlog.CONTENT = $"分配审核权限|角色名称:{rolename},分配审核流程为:{flowname}"; rlog.SQLREMARK = $"roleid:{roleid};auditid:{flowidls}.auditname:{flowname}"; string logsql = string.Empty; logsql += $"delete FROM TB_RoleAudit where R_RoleID={roleid} ;"; var fls = flowidls.Split(','); for (int i = 0; i < fls.Length; i++) { logsql += $"insert into TB_RoleAudit (R_RoleID, R_AuditID,CreateBy,IsAudit) VALUES({roleid},{fls[i]},{usermodel.USERID},1);"; } logsql = !string.IsNullOrEmpty(logsql) ? logsql.Substring(0, logsql.Length - 1) : string.Empty; rlog.SAVESQL = logsql; int logid = _logbll.Add(rlog); if (logid != -1) { rlog_p.LID = logid; rlog_p.OMAN = usermodel.REALNAME; rlog_p.OTIME = DateTime.Now; rlog_p.REMARK = "待审批"; _logprobll.Add(rlog_p); result.code = System.Net.HttpStatusCode.OK; result.msg = "分配成功!等待审批后生效!"; } else { result.code = System.Net.HttpStatusCode.BadRequest; result.msg = "分配失败!"; } } catch (Exception ex) { result.data = false; result.code = System.Net.HttpStatusCode.InternalServerError; result.msg = ex.Message; result.success = false; } return(Newtonsoft.Json.JsonConvert.SerializeObject(result)); }
public string AddAUserSave(int id, string loginname, string username, string tel, string unitid, string unit, string duty, string email, string password, string sex, string rid, string rname, string memo, string reason) { MessageModel <string> result = new MessageModel <string>(); TB_USER user = null; string r = string.Empty; if (id == -1) { if (userbll.Exists(loginname)) { result.data = null; result.code = System.Net.HttpStatusCode.BadRequest; result.success = false; result.msg = "已经存在相同名称的用户"; r = Newtonsoft.Json.JsonConvert.SerializeObject(result); return(r); } user = new TB_USER(); } else { user = userbll.GetModel(id); } user.LOGINNAME = loginname; user.REALNAME = username; user.SEX = sex == null ? "" : sex; user.TEL = tel == null ? "" : tel; user.UNITID = int.Parse(unitid); user.UNIT = unit == null ? "" : unit; user.DUTY = duty == null ? "" : duty; user.EMAIL = email == null ? "" : email; user.MEMO = memo == null ? "" : memo; user.PWD = DESEncrypt.Encrypt(password); if (id == -1) { user.ISSYSADMIN = "0"; user.ADDTIME = DateTime.Now; user.CREATEUID = int.Parse(usermodel.USERID.ToString()); int tmp = userbll.USERAdd(user); if (tmp > 0) { TB_USER_ROLE bll = new TB_USER_ROLE(); user_role.Delete(tmp); TB_ROLE_LOG rlog = new TB_ROLE_LOG(); TB_ROLE_LOG_PROCESS rlog_p = new TB_ROLE_LOG_PROCESS(); rlog.OID = tmp; rlog.TYPE = "TB_USER"; rlog.STATUS = "0"; rlog.BEFORE_CONTENT = string.Empty; rlog.REMARK = reason; string logcontent = string.Empty; string sqlremark = string.Empty; logcontent = "新增用户|登录账号:" + user.LOGINNAME + ";真实姓名:" + user.REALNAME + ";性别:" + user.SEX + ";联系电话:" + user.TEL + ";所属单位:" + user.UNIT + ";邮箱:" + user.EMAIL + ";密码:" + password + ";拥有角色:" + rname + ""; sqlremark = "LOGINNAME:" + user.LOGINNAME + ";REALNAME:" + user.REALNAME + ";SEX:" + user.SEX + ";TEL:" + user.TEL + ";UNIT:" + user.UNIT + ";EMAIL:" + user.EMAIL + ";pwd:" + password + ";rids:" + rid + ""; rlog.CONTENT = logcontent; rlog.SQLREMARK = sqlremark;; string logsql = string.Empty; if (rid != "") { string[] rids = rid.Split(','); for (int i = 0; i < rids.Length; i++) { if (rids[i] != "" && Convert.ToInt32(rids[i]) > 0) { logsql += "insert into TB_USER_ROLE(USERID,ROLEID) values('" + tmp + "','" + rids[i] + "');"; } } } logsql = !string.IsNullOrEmpty(logsql) ? logsql.Substring(0, logsql.Length - 1) : string.Empty; rlog.SAVESQL = logsql; int logid = userbll.AddROLE_LOG(rlog); string msg = string.Empty; if (logid != -1) { rlog_p.LID = logid; rlog_p.OMAN = usermodel.REALNAME; rlog_p.OTIME = DateTime.Now; rlog_p.REMARK = "待审批"; userbll.AddROLE_LOG_PROCESS(rlog_p); msg = "新增成功!等待审批后生效!"; } else { msg = "新增失败!"; } result.data = null; result.code = System.Net.HttpStatusCode.OK; result.success = false; result.msg = msg; r = Newtonsoft.Json.JsonConvert.SerializeObject(result); } } else { TB_USER users = userbll.GetModel(id); List <string> list = UserEquals(users, user, rid, rname); string logcontent = list[0]; string sqlremark = list[1]; string msg = string.Empty; if (!string.IsNullOrEmpty(logcontent)) { TB_ROLE_LOG rlog = new TB_ROLE_LOG(); TB_ROLE_LOG_PROCESS rlog_p = new TB_ROLE_LOG_PROCESS(); rlog.OID = id; rlog.TYPE = "TB_USER"; rlog.STATUS = "0"; rlog.BEFORE_CONTENT = string.Empty; rlog.REMARK = reason; logcontent = "编辑用户|" + logcontent; rlog.CONTENT = logcontent; rlog.SQLREMARK = sqlremark; string logsql = "update TB_USER set LOGINNAME='" + user.LOGINNAME + "',PWD='" + user.PWD + "',REALNAME='" + user.REALNAME + "',SEX='" + user.SEX + "',TEL='" + user.TEL + "',UNIT='" + user.UNIT + "',DUTY='" + user.DUTY + "',EMAIL='" + user.EMAIL + "',UNITID='" + user.UNITID + "',memo='" + user.MEMO + "' where USERID=" + id + ";"; logsql += "delete from TB_USER_ROLE where userid=" + id + ";"; if (rid != "" && rid != null) { string[] rids = rid.Split(','); for (int i = 0; i < rids.Length; i++) { if (rids[i] != "" && Convert.ToInt32(rids[i]) > 0) { logsql += "insert into TB_USER_ROLE(USERID,ROLEID) values('" + id + "','" + rids[i] + "');"; } } } logsql = !string.IsNullOrEmpty(logsql) ? logsql.Substring(0, logsql.Length - 1) : string.Empty; rlog.SAVESQL = logsql; int logid = userbll.AddROLE_LOG(rlog); if (logid != -1) { rlog_p.LID = logid; rlog_p.OMAN = usermodel.REALNAME; rlog_p.OTIME = DateTime.Now; rlog_p.REMARK = "待审批"; userbll.AddROLE_LOG_PROCESS(rlog_p); msg = "编辑成功!等待审批后生效!"; } else { msg = "编辑失败!"; } } else { msg = "编辑成功!"; } result.data = null; result.code = System.Net.HttpStatusCode.OK; result.success = false; result.msg = msg; r = Newtonsoft.Json.JsonConvert.SerializeObject(result); } return(r); }