示例#1
0
        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));
        }
示例#2
0
        public string noadopt(int id)
        {
            MessageModel <string> result = new MessageModel <string>();
            string        data           = string.Empty;
            List <string> DelList        = new List <string>();//删除事务
            DataSet       ds             = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().Querys("select * from tb_role_log where id='" + id + "'");

            if (ds != null)
            {
                string content = ds.Tables[0].Rows[0]["CONTENT"].ToString();
                if (content.StartsWith("新增"))
                {
                    string logsql = string.Empty;
                    if (content.StartsWith("新增用户"))
                    {
                        logsql  = "delete from TB_USER where USERID='" + ds.Tables[0].Rows[0]["oid"].ToString() + "';";
                        logsql += "delete from tb_role_log_process where  lid in(select id from tb_role_log where type='TB_USER' and oid='" + ds.Tables[0].Rows[0]["oid"].ToString() + "');";
                        logsql += "delete from tb_role_log where type='TB_USER' and oid='" + ds.Tables[0].Rows[0]["oid"].ToString() + "';";
                    }
                    else if (content.StartsWith("新增角色"))
                    {
                        logsql  = "delete from TB_ROLE where roleid='" + ds.Tables[0].Rows[0]["oid"].ToString() + "';";
                        logsql += "delete from tb_role_log_process where  lid in(select id from tb_role_log where type='TB_ROLE' and oid='" + ds.Tables[0].Rows[0]["oid"].ToString() + "');";
                        logsql += "delete from tb_role_log where type='TB_ROLE' and oid='" + ds.Tables[0].Rows[0]["oid"].ToString() + "';";
                    }
                    logsql = !string.IsNullOrEmpty(logsql) ? logsql.Substring(0, logsql.Length - 1) : string.Empty;
                    string[] arr_del = logsql.Split(';');

                    for (int i = 0; i < arr_del.Length; i++)
                    {
                        //CommandInfo info = new CommandInfo();
                        //info.CommandText = arr_del[i];
                        DelList.Add(arr_del[i]);
                    }
                }
            }

            // string update = "update TB_ROLE_LOG set status='-1' where id='" + id + "'";
            int update = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().Update("update TB_ROLE_LOG set status='-1' where id='" + id + "'");

            if (update > 0)
            {
                TB_ROLE_LOG_PROCESS rlog_p = new TB_ROLE_LOG_PROCESS();
                rlog_p.LID    = id;
                rlog_p.OMAN   = usermodel.REALNAME;
                rlog_p.OTIME  = DateTime.Now;
                rlog_p.REMARK = "审批不通过";
                role_logbll.AddTB_ROLE_LOG_PROCESS(rlog_p);
                int ss = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().UpdateTran(DelList);
                data = "审批成功";
            }
            else
            {
                data = "审批失败";
            }
            result.data    = data;
            result.code    = System.Net.HttpStatusCode.OK;
            result.success = false;
            result.msg     = "获取成功";
            return(Newtonsoft.Json.JsonConvert.SerializeObject(result));
        }
示例#3
0
        public string adopt(int id)
        {
            MessageModel <string> result = new MessageModel <string>();
            string data = string.Empty;

            List <string> AddList  = new List <string>(); //添加事务
            List <string> DelList  = new List <string>(); //删除事务
            List <string> EditList = new List <string>(); //修改事务
            DataSet       ds       = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().Querys("select * from TB_ROLE_LOG where id='" + id + "'");

            if (ds != null)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    string   sqls    = ds.Tables[0].Rows[0]["SAVESQL"].ToString();
                    string[] arr_sql = sqls.Split(';');
                    for (int i = 0; i < arr_sql.Length; i++)
                    {
                        //CommandInfo info = new CommandInfo();
                        //info.CommandText = arr_sql[i];
                        if (arr_sql[i].StartsWith("insert"))
                        {
                            AddList.Add(arr_sql[i]);
                        }
                        else if (arr_sql[i].StartsWith("delete"))
                        {
                            DelList.Add(arr_sql[i]);
                        }
                        else if (arr_sql[i].StartsWith("update"))
                        {
                            EditList.Add(arr_sql[i]);
                        }
                    }
                }
            }
            //CommandInfo update = new CommandInfo();
            //update.CommandText = "update TB_ROLE_LOG set status='1' where id='" + id + "'";
            int update = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().Update("update TB_ROLE_LOG set status='1' where id = " + id + "");

            int e = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().UpdateTran(EditList);
            int d = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().UpdateTran(DelList);
            int a = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().UpdateTran(AddList);

            if (d > 0 || a > 0 || e > 0)
            {
                TB_ROLE_LOG_PROCESS rlog_p = new  TB_ROLE_LOG_PROCESS();
                rlog_p.LID    = id;
                rlog_p.OMAN   = usermodel.REALNAME;
                rlog_p.OTIME  = DateTime.Now;
                rlog_p.REMARK = "审批通过";
                role_logbll.AddTB_ROLE_LOG_PROCESS(rlog_p);
                data = "审批成功";
            }
            else
            {
                data = "审批失败";
            }
            result.data    = data;
            result.code    = System.Net.HttpStatusCode.OK;
            result.success = false;
            result.msg     = "获取成功";
            return(Newtonsoft.Json.JsonConvert.SerializeObject(result));
        }
示例#4
0
        public string noadoptmore(string ids)
        {
            MessageModel <string> result = new MessageModel <string>();
            string data = string.Empty;

            try
            {
                //ids = ids.Substring(0, ids.Length - 1);
                string[] arr = ids.Split(',');
                string   add = "";
                for (int i = 0; i < arr.Length; i++)
                {
                    add += "'" + arr[i] + "',";
                }
                add = add.Substring(0, add.Length - 1);
                List <string> DelList = new List <string>();//删除事务
                DataSet       ds      = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().Querys("select * from tb_role_log where id in(" + add + ")");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        string content = ds.Tables[0].Rows[i]["CONTENT"].ToString();
                        if (content.StartsWith("新增"))
                        {
                            string logsql = string.Empty;
                            if (content.StartsWith("新增用户"))
                            {
                                logsql  = "delete from TB_USER where USERID='" + ds.Tables[0].Rows[i]["oid"].ToString() + "';";
                                logsql += "delete from tb_role_log_process where  lid in(select id from tb_role_log where type='TB_USER' and oid='" + ds.Tables[0].Rows[i]["oid"].ToString() + "');";
                                logsql += "delete from tb_role_log where type='TB_USER' and oid='" + ds.Tables[0].Rows[i]["oid"].ToString() + "';";
                            }
                            else if (content.StartsWith("新增角色"))
                            {
                                logsql  = "delete from TB_ROLE where roleid='" + ds.Tables[0].Rows[i]["oid"].ToString() + "';";
                                logsql += "delete from tb_role_log_process where  lid in(select id from tb_role_log where type='TB_ROLE' and oid='" + ds.Tables[0].Rows[i]["oid"].ToString() + "');";
                                logsql += "delete from tb_role_log where type='TB_ROLE' and oid='" + ds.Tables[0].Rows[i]["oid"].ToString() + "';";
                            }
                            logsql = !string.IsNullOrEmpty(logsql) ? logsql.Substring(0, logsql.Length - 1) : string.Empty;
                            string[] arr_del = logsql.Split(';');

                            for (int m = 0; m < arr_del.Length; m++)
                            {
                                DelList.Add(arr_del[m].ToString());
                            }
                        }
                    }
                }
                int update = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().Update("update TB_ROLE_LOG set status='-1' where id in(" + add + ")");
                if (update > 0)
                {
                    for (int i = 0; i < arr.Length; i++)
                    {
                        TB_ROLE_LOG_PROCESS rlog_p = new  TB_ROLE_LOG_PROCESS();
                        rlog_p.LID    = Convert.ToDecimal(arr[i]);
                        rlog_p.OMAN   = usermodel.REALNAME;
                        rlog_p.OTIME  = DateTime.Now;
                        rlog_p.REMARK = "审批不通过";
                        role_logbll.AddTB_ROLE_LOG_PROCESS(rlog_p);
                        //YunTuCore.Bussiness.TB_ROLE_LOGBLL().Update(add);
                        int ss = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().UpdateTran(DelList);
                    }
                    data = "审批成功!";
                }
                else
                {
                    data = "审批失败!";
                }
            }
            catch (Exception ex)
            {
                data = "审批失败!";
            }
            result.data    = data;
            result.code    = System.Net.HttpStatusCode.OK;
            result.success = false;
            result.msg     = "获取成功";
            return(Newtonsoft.Json.JsonConvert.SerializeObject(result));
            // return JsonConvert<TableResultFormat<string>>.ObjectToJson(result);
        }
示例#5
0
        public string adoptmore(string ids)
        {
            MessageModel <string> result = new MessageModel <string>();
            string data = string.Empty;

            try
            {
                string[] arr = ids.Split(',');
                string   add = "";
                for (int i = 0; i < arr.Length; i++)
                {
                    add += "'" + arr[i] + "',";
                }
                add = add.Substring(0, add.Length - 1);
                for (int i = 0; i < arr.Length; i++)
                {
                    List <string> AddList  = new List <string>(); //添加事务
                    List <string> DelList  = new List <string>(); //删除事务
                    List <string> EditList = new List <string>(); //修改事务
                    DataSet       ds       = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().Querys("select * from TB_ROLE_LOG where id = " + arr[i] + "");
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string   sqls    = ds.Tables[0].Rows[0]["SAVESQL"].ToString();
                        string[] arr_sql = sqls.Split(';');
                        for (int m = 0; m < arr_sql.Length; m++)
                        {
                            //CommandInfo info = new CommandInfo();
                            //info.CommandText = arr_sql[m];
                            if (arr_sql[m].StartsWith("insert"))
                            {
                                AddList.Add(arr_sql[m]);
                            }
                            else if (arr_sql[m].StartsWith("delete"))
                            {
                                DelList.Add(arr_sql[m]);
                            }
                            else if (arr_sql[m].StartsWith("update"))
                            {
                                EditList.Add(arr_sql[m]);
                            }
                        }

                        //CommandInfo update = new CommandInfo();
                        int update = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().Update("update TB_ROLE_LOG set status='1' where id = " + arr[i] + "");
                        //update.CommandText = "update TB_ROLE_LOG set status='1' where id = " + arr[i] + "";
                        //EditList.Add(update);

                        int e = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().UpdateTran(EditList);
                        int d = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().UpdateTran(DelList);
                        int a = new YunTuCore.Bussiness.TB_ROLE_LOGBLL().UpdateTran(AddList);

                        if (d > 0 && a > 0 && e > 0)
                        {
                            TB_ROLE_LOG_PROCESS rlog_p = new TB_ROLE_LOG_PROCESS();
                            rlog_p.LID    = Convert.ToDecimal(arr[i]);
                            rlog_p.OMAN   = usermodel.REALNAME;
                            rlog_p.OTIME  = DateTime.Now;
                            rlog_p.REMARK = "审批通过";
                            role_logbll.AddTB_ROLE_LOG_PROCESS(rlog_p);
                        }
                    }
                }
                data = "审批成功";
            }
            catch (Exception ex)
            {
                data = "审批失败";
            }
            result.data    = data;
            result.code    = System.Net.HttpStatusCode.OK;
            result.success = false;
            result.msg     = "获取成功";
            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);
        }