Exemple #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_Menu menu = new BLL.Sys_Menu();

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(request.Cookies["UserID"].Value);
            DataSet         dsemp   = emp.GetList("id=" + int.Parse(request.Cookies["UserID"].Value));
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "GetSysApp")
            {
                DataSet ds = null;

                int appid = int.Parse(request["appid"]);

                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        ds = menu.GetList(0, "App_id=" + appid, "Menu_order");
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string menus = getauth.GetAuthority(request.Cookies["UserID"].Value, "Menus");
                        ds = menu.GetList(0, "App_id=" + appid + " and Menu_id in " + menus, "Menu_order");
                    }
                }

                string dt = "[" + GetTasksString(0, ds.Tables[0]) + "]";

                context.Response.Write(dt);
            }
            if (request["Action"] == "getUserTree")
            {
                BLL.Sys_online   sol   = new BLL.Sys_online();
                Model.Sys_online model = new Model.Sys_online();


                model.UserName    = emp.GetList("ID =" + int.Parse(request.Cookies["UserID"].Value)).Tables[0].Rows[0]["name"].ToString();
                model.UserID      = int.Parse(request.Cookies["UserID"].Value);
                model.LastLogTime = DateTime.Now;

                DataSet ds1 = sol.GetList(" UserID=" + request.Cookies["UserID"].Value);

                //添加当前用户信息
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    sol.Update(model, " UserID=" + request.Cookies["UserID"].Value);
                }
                else
                {
                    sol.Add(model);
                }
                //}

                //删除超时用户
                sol.Delete(" LastLogTime<DATEADD(MI,-2,getdate())");

                //context.Response.Write(Common.GetGridJSON.DataTableToJSON(sol.GetAllList().Tables[0]));

                BLL.hr_department dep = new BLL.hr_department();
                BLL.hr_post       hp  = new BLL.hr_post();

                DataSet       ds  = dep.GetList(0, "", " convert(int,[d_order])");
                StringBuilder str = new StringBuilder();
                str.Append("[");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["d_name"] + "',d_icon:'" + ds.Tables[0].Rows[i]["d_icon"] + "'},");
                    DataSet dsp = hp.GetList("dep_id=" + ds.Tables[0].Rows[i]["id"]);
                    for (int j = 0; j < dsp.Tables[0].Rows.Count; j++)
                    {
                        if (!string.IsNullOrEmpty(dsp.Tables[0].Rows[j]["emp_name"].ToString()))
                        {
                            DataSet dso      = sol.GetList("UserID=" + dsp.Tables[0].Rows[j]["emp_id"]);
                            string  posticon = "../images/icon/93.png";
                            if (dso.Tables[0].Rows.Count > 0)
                            {
                                posticon = "../images/icon/37.png";//95
                            }

                            str.Append("{id:-" + dsp.Tables[0].Rows[j]["post_id"].ToString() + ",pid:" + dsp.Tables[0].Rows[j]["dep_id"].ToString() + ",text:'" + dsp.Tables[0].Rows[j]["emp_name"] + "',d_icon:'" + posticon + "'},");
                        }
                    }
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            if (request["Action"] == "GetUserInfo")
            {
                string dt = Common.DataToJson.DataToJSON(dsemp);

                context.Response.Write(dt);
            }
            if (request["Action"] == "GetOnline")
            {
                BLL.Sys_online   sol   = new BLL.Sys_online();
                Model.Sys_online model = new Model.Sys_online();


                model.UserName    = empname;
                model.UserID      = emp_id;
                model.LastLogTime = DateTime.Now;

                DataSet ds1 = sol.GetList(" UserID=" + int.Parse(request.Cookies["UserID"].Value));

                //添加当前用户信息
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    sol.Update(model, " UserID=" + int.Parse(request.Cookies["UserID"].Value));
                }
                else
                {
                    sol.Add(model);
                }
                //}

                //删除超时用户
                sol.Delete(" LastLogTime<DATEADD(MI,-2,getdate())");

                context.Response.Write(Common.GetGridJSON.DataTableToJSON(sol.GetAllList().Tables[0]));
            }
            if (request["Action"] == "GetIcons")
            {
                try
                {
                    var icontype = request["icontype"];

                    var rootPath = context.Server.MapPath("~/images/icon/");
                    Common.ObjectListToJSON objtojson = new Common.ObjectListToJSON();
                    List <FileInfo>         lp        = GetAllFilesInDirectory(rootPath);
                    string a = objtojson.toJSON(lp);
                    context.Response.Write(a);
                }
                catch (Exception err)
                {
                    context.Response.Write("系统错误:" + err.Message);
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_Button   btn   = new BLL.Sys_Button();
            Model.Sys_Button model = new Model.Sys_Button();
            if (request["Action"] == "GetGrid")
            {
                string menuid = request["menuid"];
                if (!string.IsNullOrEmpty(menuid))
                {
                    DataSet ds = btn.GetList(0, "Menu_id=" + (Common.PageValidate.IsNumber(menuid) ? menuid : "-1"), "Btn_order");

                    context.Response.Write(Common.GetGridJSON.DataTableToJSON(ds.Tables[0]));
                }
            }
            //Form JSON
            if (request["Action"] == "form")
            {
                string btnid = request["btnid"];
                if (!string.IsNullOrEmpty(btnid))
                {
                    DataSet ds = btn.GetList("Btn_id=" + (Common.PageValidate.IsNumber(btnid) ? btnid : "-1"));

                    string dt = Common.DataToJson.DataToJSON(ds);

                    context.Response.Write(dt);
                }
            }
            //save
            if (request["Action"] == "save")
            {
                string Menu_id = request["menuid"];
                if (string.IsNullOrEmpty(Menu_id))
                {
                    Menu_id = "0";
                }
                model.Menu_id = int.Parse(Menu_id);

                BLL.Sys_Menu menu = new BLL.Sys_Menu();

                model.Menu_name   = menu.GetList("Menu_id=" + Menu_id).Tables[0].Rows[0]["Menu_name"].ToString();
                model.Btn_name    = Common.PageValidate.InputText(request["T_btn_name"], 255);
                model.Btn_icon    = Common.PageValidate.InputText(request["T_btn_icon"], 255);
                model.Btn_handler = Common.PageValidate.InputText(request["T_btn_handler"], 255);
                model.Btn_order   = Common.PageValidate.InputText(request["T_btn_order"], 255);

                string id = request["btnid"];

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    model.Btn_id = int.Parse(id);
                    btn.Update(model);
                }
                else
                {
                    int btnid = btn.Add(model);
                }
            }
            //del
            if (request["Action"] == "del")
            {
                int    btnid         = -1;
                string context_btnid = context.Request["btnid"];
                if (!string.IsNullOrEmpty(context_btnid))
                {
                    btnid = Common.PageValidate.IsNumber(context_btnid) ? int.Parse(context_btnid) : -1;
                }

                DataSet ds    = btn.GetList("Btn_id=" + btnid);
                bool    isdel = btn.Delete(btnid);
                if (isdel)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_Menu menu = new BLL.Sys_Menu();

            var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
            string CoockiesID = ticket.UserData;

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(CoockiesID);
            DataSet         dsemp   = emp.GetList("id=" + emp_id);
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "GetSysApp")
            {
                DataSet ds = null;

                int appid = int.Parse(request["appid"]);

                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        ds = menu.GetList(0, "App_id=" + appid, "Menu_order");
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string menus = getauth.GetAuthority(emp_id.ToString(), "Menus");
                        ds = menu.GetList(0, "App_id=" + appid + " and Menu_id in " + menus, "Menu_order");
                    }
                }

                string dt = "[" + GetTasksString(0, ds.Tables[0]) + "]";

                context.Response.Write(dt);
            }
            if (request["Action"] == "getUserTree")
            {
                BLL.Sys_online   sol   = new BLL.Sys_online();
                Model.Sys_online model = new Model.Sys_online();

                model.UserName    = PageValidate.InputText(empname, 250);
                model.UserID      = emp_id;
                model.LastLogTime = DateTime.Now;

                DataSet ds1 = sol.GetList(" UserID=" + emp_id);

                //添加当前用户信息
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    sol.Update(model, " UserID=" + emp_id);
                }
                else
                {
                    sol.Add(model);
                }

                //删除超时用户
                //sol.Delete(" LastLogTime<DATEADD(MI,-2,getdate())");//SQL Server使用
                sol.Delete(" LastLogTime<date_sub(now(),interval 2 day)");

                BLL.hr_department dep = new BLL.hr_department();
                BLL.hr_post       hp  = new BLL.hr_post();

                DataSet       ds  = dep.GetList(0, "", "d_order");
                StringBuilder str = new StringBuilder();
                str.Append("[");
                str.Append(GetTreeString(0, ds.Tables[0], 1));
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            if (request["Action"] == "GetUserInfo")
            {
                string dt = Common.DataToJson.DataToJSON(dsemp);

                context.Response.Write(dt);
            }
            if (request["Action"] == "GetOnline")
            {
                BLL.Sys_online   sol   = new BLL.Sys_online();
                Model.Sys_online model = new Model.Sys_online();


                model.UserName    = empname;
                model.UserID      = emp_id;
                model.LastLogTime = DateTime.Now;

                DataSet ds1 = sol.GetList(" UserID=" + emp_id);

                //添加当前用户信息
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    sol.Update(model, " UserID=" + emp_id);
                }
                else
                {
                    sol.Add(model);
                }
                //}

                //删除超时用户
                //sol.Delete(" LastLogTime<DATEADD(MI,-2,getdate())");//SQL Server使用
                sol.Delete(" LastLogTime<date_sub(now(),interval 2 day)");

                context.Response.Write(Common.GetGridJSON.DataTableToJSON(sol.GetAllList().Tables[0]));
            }
            if (request["Action"] == "GetIcons")
            {
                try
                {
                    var icontype = request["icontype"];

                    var rootPath = context.Server.MapPath("~/images/icon/");
                    Common.ObjectListToJSON objtojson = new Common.ObjectListToJSON();
                    List <FileInfo>         lp        = GetAllFilesInDirectory(rootPath);
                    string a = objtojson.toJSON(lp);
                    context.Response.Write(a);
                }
                catch (Exception err)
                {
                    context.Response.Write("系统错误:" + err.Message);
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_role    role  = new BLL.Sys_role();
            Model.Sys_role  model = new Model.Sys_role();
            BLL.hr_employee emp   = new BLL.hr_employee();

            //save
            if (request["Action"] == "SysSave")
            {
                model.RoleName    = PageValidate.InputText(request["T_role"], 250);
                model.RoleSort    = PageValidate.InputText(request["T_RoleOrder"], 10);
                model.RoleDscript = PageValidate.InputText(request["T_Descript"], 255);

                string id = request["id"];

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = role.GetList("RoleID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.RoleID     = int.Parse(id);
                    model.CreateID   = int.Parse(dr["CreateID"].ToString());
                    model.CreateDate = DateTime.Parse(dr["CreateDate"].ToString());
                    model.UpdateDate = DateTime.Now;
                    model.UpdateID   = int.Parse(request.Cookies["UserID"].Value);
                    role.Update(model);
                }
                else
                {
                    model.CreateID   = int.Parse(request.Cookies["UserID"].Value);
                    model.CreateDate = DateTime.Now;
                    role.Add(model);
                }
            }

            //validate
            if (request["Action"] == "Exist")
            {
                DataSet ds1 = role.GetList(" RoleName='" + Common.PageValidate.InputText(request["T_role"], 250) + "'");
                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");
            }

            //表格json
            if (request["Action"] == "grid")
            {
                DataSet ds = role.GetList(0, "", " RoleSort");

                string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);

                context.Response.Write(dt);
            }

            //Form JSON
            if (request["Action"] == "form")
            {
                DataSet ds = role.GetList(" RoleID=" + int.Parse(request["id"]));

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "del")
            {
                bool isdel = role.Delete(int.Parse(request["id"]));
                if (isdel)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
            //auth
            if (request["Action"] == "treegrid")
            {
                int          appid = int.Parse(request["appid"]);
                BLL.Sys_Menu menu  = new BLL.Sys_Menu();

                //string dt1 =
                DataTable dt = menu.GetList("App_id=" + appid).Tables[0];
                dt.Columns.Add(new DataColumn("Sysroler", typeof(string)));

                BLL.Sys_Button btn = new BLL.Sys_Button();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataSet ds    = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString(), " convert(int,[Btn_order])");
                    string  roler = "";
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            roler += ds.Tables[0].Rows[j]["Btn_id"].ToString() + "|" + ds.Tables[0].Rows[j]["Btn_name"].ToString();
                            roler += ",";
                        }
                    }
                    dt.Rows[i][dt.Columns.Count - 1] = roler;
                }
                string dt1 = "{Rows:[" + GetTasksString(0, dt) + "]}";
                context.Response.Write(dt1);
                context.Response.End();
            }
            //get auth
            if (request["Action"] == "getauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = sa.app;
                modelauth.Menu_ids   = sa.menu;
                modelauth.Button_ids = sa.btn;

                BLL.Sys_authority sysau    = new BLL.Sys_authority();
                DataSet           ds       = sysau.GetList("Role_id=" + modelauth.Role_id + " and App_ids='a" + modelauth.App_ids + ",'");
                DataRow           dr       = ds.Tables[0].Rows[0];
                string            roledata = dr["Menu_ids"] + "|" + dr["Button_ids"];
                context.Response.Write(roledata);
            }
            // save auth
            if (request["Action"] == "saveauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = sa.app;
                modelauth.Menu_ids   = sa.menu;
                modelauth.Button_ids = sa.btn;

                BLL.Sys_authority sysau = new BLL.Sys_authority();

                if (!string.IsNullOrEmpty(postdata))
                {
                    sysau.DeleteWhere("Role_id=" + modelauth.Role_id + " and App_ids='" + modelauth.App_ids + "'");
                    sysau.Add(modelauth);

                    context.Response.Write("{sucess:sucess}");

                    //日志
                    BLL.Sys_log   log      = new BLL.Sys_log();
                    Model.Sys_log modellog = new Model.Sys_log();

                    DataSet dsemp = emp.GetList("id=" + request.Cookies["UserID"].Value);
                    modellog.EventDate = DateTime.Now;
                    modellog.UserID    = int.Parse(request.Cookies["UserID"].Value);
                    modellog.UserName  = dsemp.Tables[0].Rows[0]["name"].ToString();
                    modellog.IPStreet  = request.UserHostAddress;

                    modellog.EventType = "权限修改";
                    modellog.EventID   = modelauth.Role_id.ToString();
                    log.Add(modellog);
                }
            }
        }
Exemple #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_Menu menu = new BLL.Sys_Menu();

            BLL.hr_employee emp = new BLL.hr_employee();
            int emp_id = int.Parse(request.Cookies["UserID"].Value);
            DataSet dsemp = emp.GetList("id=" + int.Parse( request.Cookies["UserID"].Value));
            string empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string uid = dsemp.Tables[0].Rows[0]["uid"].ToString();

            if (request["Action"] == "GetSysApp")
            {
                DataSet ds = null;

                int appid = int.Parse(request["appid"]);

                if (dsemp.Tables[0].Rows.Count > 0)
                {
                    if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin")
                    {
                        ds = menu.GetList(0, "App_id=" + appid, "Menu_order");
                    }
                    else
                    {
                        Data.GetAuthorityByUid getauth = new Data.GetAuthorityByUid();
                        string menus = getauth.GetAuthority(request.Cookies["UserID"].Value, "Menus");
                        ds = menu.GetList(0, "App_id=" + appid + " and Menu_id in " + menus, "Menu_order");
                    }
                }

                string dt = "[" + GetTasksString(0, ds.Tables[0]) + "]";

                context.Response.Write(dt);
            }
            if (request["Action"] == "getUserTree")
            {
                BLL.Sys_online sol = new BLL.Sys_online();
                Model.Sys_online model = new Model.Sys_online();

                model.UserName = emp.GetList("ID =" + int.Parse(request.Cookies["UserID"].Value)).Tables[0].Rows[0]["name"].ToString();
                model.UserID = int.Parse(request.Cookies["UserID"].Value);
                model.LastLogTime = DateTime.Now;

                DataSet ds1 = sol.GetList(" UserID=" + request.Cookies["UserID"].Value);

                //添加当前用户信息
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    sol.Update(model, " UserID=" + request.Cookies["UserID"].Value);
                }
                else
                {
                    sol.Add(model);
                }
                //}

                //删除超时用户
                sol.Delete(" LastLogTime<DATEADD(MI,-2,getdate())");

                //context.Response.Write(Common.GetGridJSON.DataTableToJSON(sol.GetAllList().Tables[0]));

                BLL.hr_department dep = new BLL.hr_department();
                BLL.hr_post hp = new BLL.hr_post();

                DataSet ds = dep.GetList(0, "isDelete=0 ", " convert(int,[d_order])");
                StringBuilder str = new StringBuilder();
                str.Append("[");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["d_name"] + "',d_icon:'" + ds.Tables[0].Rows[i]["d_icon"] + "'},");
                    DataSet dsp = hp.GetList("dep_id=" + ds.Tables[0].Rows[i]["id"]);
                    for (int j = 0; j < dsp.Tables[0].Rows.Count; j++)
                    {
                        if (!string.IsNullOrEmpty(dsp.Tables[0].Rows[j]["emp_name"].ToString()))
                        {
                            DataSet dso = sol.GetList("UserID=" + dsp.Tables[0].Rows[j]["emp_id"]);
                            string posticon = "img_crm/icon/93.png";
                            if (dso.Tables[0].Rows.Count > 0)
                            {
                                posticon = "img_crm/icon/38.png";//95
                            }

                            str.Append("{id:-" + dsp.Tables[0].Rows[j]["post_id"].ToString() + ",pid:" + dsp.Tables[0].Rows[j]["dep_id"].ToString() + ",text:'" + dsp.Tables[0].Rows[j]["emp_name"] + "',d_icon:'" + posticon + "'},");
                        }
                    }
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);

            }
            if (request["Action"] == "GetUserInfo")
            {
                string dt = Common.DataToJson.DataToJSON(dsemp);

                context.Response.Write(dt);

            }
            if (request["Action"] == "GetOnline")
            {
                BLL.Sys_online sol = new BLL.Sys_online();
                Model.Sys_online model = new Model.Sys_online();

                model.UserName = empname;
                model.UserID = emp_id;
                model.LastLogTime = DateTime.Now;

                DataSet ds1 = sol.GetList(" UserID=" + int.Parse( request.Cookies["UserID"].Value));

                //添加当前用户信息
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    sol.Update(model, " UserID=" + int.Parse( request.Cookies["UserID"].Value));
                }
                else
                {
                    sol.Add(model);
                }
                //}

                //删除超时用户
                sol.Delete(" LastLogTime<DATEADD(MI,-2,getdate())");

                context.Response.Write(Common.GetGridJSON.DataTableToJSON(sol.GetAllList().Tables[0]));
            }
            if (request["Action"] == "GetIcons")
            {
                try
                {
                    var icontype = request["icontype"];

                    var rootPath = context.Server.MapPath("~/img_crm/icon/");
                    Common.ObjectListToJSON objtojson = new Common.ObjectListToJSON();
                    List<FileInfo> lp = GetAllFilesInDirectory(rootPath);
                    string a = objtojson.toJSON(lp);
                    context.Response.Write(a);

                }
                catch (Exception err)
                {
                    context.Response.Write("系统错误:" + err.Message);
                }
            }
        }
Exemple #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            HttpRequest request = context.Request;

            if (request["Action"] == "GetMenu")
            {
                BLL.Sys_Menu menu  = new BLL.Sys_Menu();
                int          appid = Common.PageValidate.IsNumber(request["appid"]) ? int.Parse(request["appid"]) : 0;

                DataSet ds = menu.GetList(0, "App_id=" + appid, "Menu_order");
                //string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                string dt = "{Rows:[" + GetTasksString(0, ds.Tables[0]) + "]}";
                context.Response.Write(dt);
            }
            //Form JSON
            if (request["Action"] == "form")
            {
                BLL.Sys_Menu menu = new BLL.Sys_Menu();
                DataSet      ds   = menu.GetList("Menu_id=" + int.Parse(request["menuid"]));

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            if (request["Action"] == "SysTree")
            {
                BLL.Sys_Menu menu = new BLL.Sys_Menu();

                int appid = int.Parse(request["appid"]);

                DataSet ds = menu.GetList(0, "parentid=0 and App_id=" + appid, "Menu_order");

                StringBuilder str = new StringBuilder();
                str.Append("[{id:0,pid:0,text:'无',Menu_icon:''},");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["menu_id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["menu_name"] + "',Menu_icon:'" + ds.Tables[0].Rows[i]["Menu_icon"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            //save
            if (request["Action"] == "save")
            {
                BLL.Sys_Menu   menu  = new BLL.Sys_Menu();
                Model.Sys_Menu model = new Model.Sys_Menu();

                model.Menu_name  = Common.PageValidate.InputText(request["T_menu_name"], 255);
                model.Menu_url   = Common.PageValidate.InputText(request["T_menu_url"], 255);
                model.Menu_icon  = Common.PageValidate.InputText(request["T_menu_icon"], 255);
                model.Menu_order = int.Parse(request["T_menu_order"]);
                model.Menu_type  = "sys";
                model.parentid   = int.Parse(request["T_menu_parent_val"]);
                model.parentname = Common.PageValidate.InputText(request["T_menu_parent"], 255);
                model.App_id     = int.Parse(request["appid"]);

                BLL.hr_employee emp = new BLL.hr_employee();

                string id = request["menuid"];

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    model.Menu_id = int.Parse(id);
                    DataSet ds = menu.GetList("Menu_id=" + model.Menu_id);
                    DataRow dr = ds.Tables[0].Rows[0];

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        model.Menu_type = ds.Tables[0].Rows[0]["Menu_type"].ToString();
                    }
                    menu.Update(model);
                }
                else
                {
                    int mid = menu.Add(model);
                }
            }
        }
Exemple #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_role   role  = new BLL.Sys_role();
            Model.Sys_role model = new Model.Sys_role();

            var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
            string CoockiesID = ticket.UserData;

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(CoockiesID);
            DataSet         dsemp   = emp.GetList("id=" + emp_id);
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            //save
            if (request["Action"] == "SysSave")
            {
                model.RoleName    = PageValidate.InputText(request["T_role"], 250);
                model.RoleSort    = int.Parse(request["T_RoleOrder"]);
                model.RoleDscript = PageValidate.InputText(request["T_Descript"], 255);

                string id = PageValidate.InputText(request["id"], 50);

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = role.GetList("RoleID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.RoleID     = int.Parse(id);
                    model.UpdateDate = DateTime.Now;
                    model.UpdateID   = emp_id;
                    role.Update(model);
                }
                else
                {
                    model.CreateID   = emp_id;
                    model.CreateDate = DateTime.Now;
                    int rid = role.Add(model);

                    BLL.Sys_data_authority   auth     = new BLL.Sys_data_authority();
                    Model.Sys_data_authority modelsda = new Model.Sys_data_authority();

                    //默认数据权限
                    modelsda.Role_id  = rid;
                    modelsda.Sys_view = 1;
                    modelsda.Sys_add  = 1;
                    modelsda.Sys_edit = 1;
                    modelsda.Sys_del  = 1;

                    modelsda.option_id  = 1;
                    modelsda.Sys_option = "客户管理";
                    auth.Add(modelsda);

                    modelsda.option_id  = 2;
                    modelsda.Sys_option = "跟进管理";
                    auth.Add(modelsda);

                    modelsda.option_id  = 3;
                    modelsda.Sys_option = "订单管理";
                    auth.Add(modelsda);

                    modelsda.option_id  = 4;
                    modelsda.Sys_option = "合同管理";
                    auth.Add(modelsda);
                }
            }

            //validate
            if (request["Action"] == "Exist")
            {
                DataSet ds1 = role.GetList(" RoleName='" + Common.PageValidate.InputText(request["T_role"], 250) + "'");
                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");
            }

            //表格json
            if (request["Action"] == "grid")
            {
                DataSet ds = role.GetList(0, "", " RoleSort");

                string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);

                context.Response.Write(dt);
            }

            //Form JSON
            if (request["Action"] == "form")
            {
                DataSet ds = role.GetList(" RoleID=" + int.Parse(request["id"]));

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "del")
            {
                string rid   = request["id"];
                bool   isdel = role.Delete(int.Parse(rid));
                if (isdel)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }

                //角色下员工删除
                BLL.Sys_role_emp rm = new BLL.Sys_role_emp();
                rm.Delete("RoleID=" + int.Parse(rid));

                //角色下数据权限删除
                BLL.Sys_data_authority auth = new BLL.Sys_data_authority();
                auth.Delete("Role_id=" + int.Parse(rid));
            }
            //auth
            if (request["Action"] == "treegrid")
            {
                int          appid = int.Parse(request["appid"]);
                BLL.Sys_Menu menu  = new BLL.Sys_Menu();

                //string dt1 =
                DataTable dt = menu.GetList("App_id=" + appid).Tables[0];
                dt.Columns.Add(new DataColumn("Sysroler", typeof(string)));

                BLL.Sys_Button btn = new BLL.Sys_Button();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //DataSet ds = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString(), " convert(int,[Btn_order])");//sqlserver 专用
                    DataSet ds    = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString(), " cast(Btn_order AS signed)");
                    string  roler = "";
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            roler += ds.Tables[0].Rows[j]["Btn_id"].ToString() + "|" + ds.Tables[0].Rows[j]["Btn_name"].ToString();
                            roler += ",";
                        }
                    }
                    dt.Rows[i][dt.Columns.Count - 1] = roler;
                }
                string dt1 = "{Rows:[" + GetTasksString(0, dt) + "]}";
                context.Response.Write(dt1);
                context.Response.End();
            }
            //get auth
            if (request["Action"] == "getauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = sa.app;
                modelauth.Menu_ids   = sa.menu;
                modelauth.Button_ids = sa.btn;

                BLL.Sys_authority sysau = new BLL.Sys_authority();

                string  roledata = "0|0";
                DataSet ds       = sysau.GetList("Role_id=" + modelauth.Role_id + " and App_ids='a" + PageValidate.InputText(modelauth.App_ids, int.MaxValue) + ",'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    roledata = dr["Menu_ids"] + "|" + dr["Button_ids"];
                }
                context.Response.Write(roledata);
            }
            // save auth
            if (request["Action"] == "saveauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = PageValidate.InputText(sa.app, 50);
                modelauth.Menu_ids   = PageValidate.InputText(sa.menu, int.MaxValue);
                modelauth.Button_ids = PageValidate.InputText(sa.btn, int.MaxValue);

                BLL.Sys_authority sysau = new BLL.Sys_authority();

                if (!string.IsNullOrEmpty(postdata))
                {
                    sysau.DeleteWhere("Role_id=" + modelauth.Role_id + " and App_ids='" + PageValidate.InputText(modelauth.App_ids, int.MaxValue) + "'");
                    sysau.Add(modelauth);

                    context.Response.Write("{sucess:sucess}");

                    //日志
                    BLL.Sys_log   log      = new BLL.Sys_log();
                    Model.Sys_log modellog = new Model.Sys_log();

                    DataSet dsemp1 = emp.GetList("id=" + emp_id);
                    modellog.EventDate = DateTime.Now;
                    modellog.UserID    = emp_id;
                    modellog.UserName  = dsemp1.Tables[0].Rows[0]["name"].ToString();
                    modellog.IPStreet  = request.UserHostAddress;

                    modellog.EventType = "权限修改";
                    modellog.EventID   = modelauth.Role_id.ToString();
                    log.Add(modellog);
                }
            }
        }
Exemple #8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_Button btn = new BLL.Sys_Button();
            Model.Sys_Button model = new Model.Sys_Button();
            if (request["Action"] == "GetGrid")
            {
                string menuid = request["menuid"];
                if (!string.IsNullOrEmpty(menuid))
                {
                    DataSet ds = btn.GetList(0, "Menu_id=" + (Common.PageValidate.IsNumber(menuid) ? menuid : "-1"), "Btn_order");

                    context.Response.Write(Common.GetGridJSON.DataTableToJSON(ds.Tables[0]));
                }
            }
            //Form JSON
            if (request["Action"] == "form")
            {
                string btnid = request["btnid"];
                if (!string.IsNullOrEmpty(btnid))
                {
                    DataSet ds = btn.GetList("Btn_id=" + (Common.PageValidate.IsNumber(btnid) ? btnid : "-1"));

                    string dt = Common.DataToJson.DataToJSON(ds);

                    context.Response.Write(dt);
                }
            }
            //save
            if (request["Action"] == "save")
            {
                string Menu_id = request["menuid"];
                if (string.IsNullOrEmpty(Menu_id))
                    Menu_id = "0";
                model.Menu_id = int.Parse(Menu_id);

                BLL.Sys_Menu menu = new BLL.Sys_Menu();

                model.Menu_name = menu.GetList("Menu_id=" + Menu_id).Tables[0].Rows[0]["Menu_name"].ToString();
                model.Btn_name = Common.PageValidate.InputText(request["T_btn_name"], 255);
                model.Btn_icon = Common.PageValidate.InputText(request["T_btn_icon"], 255);
                model.Btn_handler = Common.PageValidate.InputText(request["T_btn_handler"], 255);
                model.Btn_order = Common.PageValidate.InputText(request["T_btn_order"], 255);

                string id = request["btnid"];

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    model.Btn_id = int.Parse(id);
                    btn.Update(model);
                }
                else
                {
                    int btnid = btn.Add(model);
                }
            }
            //del
            if (request["Action"] == "del")
            {
                int btnid = -1;
                string context_btnid = context.Request["btnid"];
                if (!string.IsNullOrEmpty(context_btnid))
                {
                    btnid = Common.PageValidate.IsNumber(context_btnid) ? int.Parse(context_btnid) : -1;
                }

                DataSet ds = btn.GetList("Btn_id=" + btnid);
                bool isdel = btn.Delete(btnid);
                if (isdel)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
        }
Exemple #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            HttpRequest request = context.Request;

            if (request["Action"] == "GetMenu")
            {
                BLL.Sys_Menu menu = new BLL.Sys_Menu();
                int appid = Common.PageValidate.IsNumber(request["appid"]) ? int.Parse(request["appid"]) : 0;

                DataSet ds = menu.GetList(0, "App_id=" + appid, "Menu_order");
                //string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                string dt = "{Rows:[" + GetTasksString(0, ds.Tables[0]) + "]}";
                context.Response.Write(dt);
            }
            //Form JSON
            if (request["Action"] == "form")
            {
                BLL.Sys_Menu menu = new BLL.Sys_Menu();
                DataSet ds = menu.GetList("Menu_id=" + int.Parse( request["menuid"]));

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            if (request["Action"] == "SysTree")
            {
                BLL.Sys_Menu menu = new BLL.Sys_Menu();

                int appid = int.Parse(request["appid"]);

                DataSet ds = menu.GetList(0, "parentid=0 and App_id=" + appid, "Menu_order");

                StringBuilder str = new StringBuilder();
                str.Append("[{id:0,pid:0,text:'无',Menu_icon:''},");
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{id:" + ds.Tables[0].Rows[i]["menu_id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["menu_name"] + "',Menu_icon:'" + ds.Tables[0].Rows[i]["Menu_icon"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            //save
            if (request["Action"] == "save")
            {
                BLL.Sys_Menu menu = new BLL.Sys_Menu();
                Model.Sys_Menu model = new Model.Sys_Menu();

                model.Menu_name = Common.PageValidate.InputText(request["T_menu_name"], 255);
                model.Menu_url = Common.PageValidate.InputText(request["T_menu_url"], 255);
                model.Menu_icon = Common.PageValidate.InputText(request["T_menu_icon"], 255);
                model.Menu_order = int.Parse(request["T_menu_order"]);
                model.Menu_type = "sys";
                model.parentid = int.Parse(request["T_menu_parent_val"]);
                model.parentname = Common.PageValidate.InputText(request["T_menu_parent"], 255);
                model.App_id = int.Parse(request["appid"]);

                BLL.hr_employee emp = new BLL.hr_employee();

                string id = request["menuid"];

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    model.Menu_id = int.Parse(id);
                    DataSet ds = menu.GetList("Menu_id=" + model.Menu_id);
                    DataRow dr = ds.Tables[0].Rows[0];

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        model.Menu_type = ds.Tables[0].Rows[0]["Menu_type"].ToString();
                    }
                    menu.Update(model);
                }
                else
                {
                    int mid = menu.Add(model);
                }
            }
        }
Exemple #10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_role role = new BLL.Sys_role();
            Model.Sys_role model = new Model.Sys_role();
            BLL.hr_employee emp = new BLL.hr_employee();

            //save
            if (request["Action"] == "SysSave")
            {

                model.RoleName = PageValidate.InputText(request["T_role"], 250);
                model.RoleSort = PageValidate.InputText(request["T_RoleOrder"], 10);
                model.RoleDscript = PageValidate.InputText(request["T_Descript"], 255);

                string id = request["id"];

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = role.GetList("RoleID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.RoleID = int.Parse(id);
                    model.CreateID = int.Parse(dr["CreateID"].ToString());
                    model.CreateDate = DateTime.Parse(dr["CreateDate"].ToString());
                    model.UpdateDate = DateTime.Now;
                    model.UpdateID = int.Parse(request.Cookies["UserID"].Value);
                    role.Update(model);
                }
                else
                {
                    model.CreateID = int.Parse(request.Cookies["UserID"].Value);
                    model.CreateDate = DateTime.Now;
                    int rid = role.Add(model);

                    BLL.Sys_data_authority auth = new BLL.Sys_data_authority();
                    Model.Sys_data_authority modelsda = new Model.Sys_data_authority();

                    //默认数据权限
                    modelsda.Role_id = rid;
                    modelsda.Sys_view = 1;
                    modelsda.Sys_add = 1;
                    modelsda.Sys_edit = 1;
                    modelsda.Sys_del = 1;

                    modelsda.option_id = 1;
                    modelsda.Sys_option = "客户管理";
                    auth.Add(modelsda);

                    modelsda.option_id = 2;
                    modelsda.Sys_option = "跟进管理";
                    auth.Add(modelsda);

                    modelsda.option_id = 3;
                    modelsda.Sys_option = "订单管理";
                    auth.Add(modelsda);

                    modelsda.option_id = 4;
                    modelsda.Sys_option = "合同管理";
                    auth.Add(modelsda);

                }
            }

            //validate
            if (request["Action"] == "Exist")
            {
                DataSet ds1 = role.GetList(" RoleName='" + Common.PageValidate.InputText(request["T_role"], 250) + "'");
                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");
            }

            //表格json
            if (request["Action"] == "grid")
            {
                DataSet ds = role.GetList(0, "", " RoleSort");

                string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);

                context.Response.Write(dt);
            }

            //Form JSON
            if (request["Action"] == "form")
            {

                DataSet ds = role.GetList(" RoleID=" + int.Parse(request["id"]));

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "del")
            {
                string rid = request["id"];
                bool isdel = role.Delete(int.Parse(rid));
                if (isdel)
                    context.Response.Write("true");
                else
                    context.Response.Write("false");

                //角色下员工删除
                BLL.Sys_role_emp rm = new BLL.Sys_role_emp();
                rm.Delete("RoleID=" + int.Parse(rid));

                //角色下数据权限删除
                BLL.Sys_data_authority auth = new BLL.Sys_data_authority();
                auth.Delete("Role_id=" + int.Parse(rid));
            }
            //auth
            if (request["Action"] == "treegrid")
            {
                int appid = int.Parse(request["appid"]);
                BLL.Sys_Menu menu = new BLL.Sys_Menu();

                //string dt1 =
                DataTable dt = menu.GetList("App_id=" + appid).Tables[0];
                dt.Columns.Add(new DataColumn("Sysroler", typeof(string)));

                BLL.Sys_Button btn = new BLL.Sys_Button();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataSet ds = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString(), " convert(int,[Btn_order])");
                    string roler = "";
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            roler += ds.Tables[0].Rows[j]["Btn_id"].ToString() + "|" + ds.Tables[0].Rows[j]["Btn_name"].ToString();
                            roler += ",";
                        }
                    }
                    dt.Rows[i][dt.Columns.Count - 1] = roler;
                }
                string dt1 = "{Rows:[" + GetTasksString(0, dt) + "]}";
                context.Response.Write(dt1);
                context.Response.End();
            }
            //get auth
            if (request["Action"] == "getauth")
            {
                string postdata = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize<save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id = int.Parse(sa.role_id);
                modelauth.App_ids = sa.app;
                modelauth.Menu_ids = sa.menu;
                modelauth.Button_ids = sa.btn;

                BLL.Sys_authority sysau = new BLL.Sys_authority();

                string roledata = "0|0";
                DataSet ds = sysau.GetList("Role_id=" + modelauth.Role_id + " and App_ids='a" + modelauth.App_ids + ",'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    roledata = dr["Menu_ids"] + "|" + dr["Button_ids"];
                }
                context.Response.Write(roledata);
            }
            // save auth
            if (request["Action"] == "saveauth")
            {
                string postdata = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize<save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id = int.Parse(sa.role_id);
                modelauth.App_ids = sa.app;
                modelauth.Menu_ids = sa.menu;
                modelauth.Button_ids = sa.btn;

                BLL.Sys_authority sysau = new BLL.Sys_authority();

                if (!string.IsNullOrEmpty(postdata))
                {
                    sysau.DeleteWhere("Role_id=" + modelauth.Role_id + " and App_ids='" + modelauth.App_ids + "'");
                    sysau.Add(modelauth);

                    context.Response.Write("{sucess:sucess}");

                    //日志
                    BLL.Sys_log log = new BLL.Sys_log();
                    Model.Sys_log modellog = new Model.Sys_log();

                    DataSet dsemp = emp.GetList("id=" + request.Cookies["UserID"].Value);
                    modellog.EventDate = DateTime.Now;
                    modellog.UserID = int.Parse(request.Cookies["UserID"].Value);
                    modellog.UserName = dsemp.Tables[0].Rows[0]["name"].ToString();
                    modellog.IPStreet = request.UserHostAddress;

                    modellog.EventType = "权限修改";
                    modellog.EventID = modelauth.Role_id.ToString();
                    log.Add(modellog);
                }
            }
        }