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

            XHD.BLL.ssn_role     role  = new XHD.BLL.ssn_role();
            XHD.BLL.ssn_art_menu menu  = new XHD.BLL.ssn_art_menu();
            XHD.Model.ssn_role   model = new XHD.Model.ssn_role();
            XHD.BLL.ssn_visit    visit = new XHD.BLL.ssn_visit();
            XHD.BLL.ssn_art      art   = new XHD.BLL.ssn_art();
            var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
            string CoockiesID = ticket.UserData;

            XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee();
            int     emp_id          = int.Parse(CoockiesID);
            DataSet dsemp           = emp.GetList("id=" + emp_id);
            string  empname         = string.Empty;
            string  uid             = string.Empty;
            string  factory_Id      = string.Empty;

            if (dsemp != null && dsemp.Tables[0].Rows.Count > 0)
            {
                empname    = dsemp.Tables[0].Rows[0]["name"].ToString();
                uid        = dsemp.Tables[0].Rows[0]["uid"].ToString();
                factory_Id = dsemp.Tables[0].Rows[0]["Factory_Id"].ToString();
            }

            //角色保存
            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);
                model.Factory_Id  = factory_Id;

                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);
                }
            }

            //验证是否唯一
            else if (request["Action"] == "Exist")
            {
                DataSet ds1 = role.GetList(" RoleName='" + XHD.Common.PageValidate.InputText(request["T_role"], 250) + "'" + " and factory_Id='" + factory_Id + "'");
                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");
            }

            //获取角色表格json
            else if (request["Action"] == "grid")
            {
                DataSet ds = role.GetList(0, "factory_Id='" + factory_Id + "'", " RoleSort");

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

                context.Response.Write(dt);
            }

            //获取角色信息
            else if (request["Action"] == "form")
            {
                DataSet ds = role.GetList(" RoleID=" + int.Parse(request["id"]));

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

                context.Response.Write(dt);
            }
            //删除角色
            else 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");
                }

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

                //角色下数据权限删除
                XHD.BLL.ssn_visit data_auth = new XHD.BLL.ssn_visit();
                data_auth.DeleteByRole(int.Parse(rid));

                //角色下功能权限删除
                XHD.BLL.ssn_authority auth = new XHD.BLL.ssn_authority();
                auth.DeleteWhere("Role_id=" + int.Parse(rid));
            }

            #region 权限设置
            //auth
            else if (request["Action"] == "treegrid")
            {
                string appidstr = request["appid"];
                int    appid    = int.Parse(appidstr);

                //获取单位
                string ftyid = PageValidate.InputText(request["factory_id"], 60);
                //设置查询条件
                string wheretext  = "App_id=" + appid; //限制menu
                string wheretext2 = "";                //限制button

                DataTable dt = menu.GetList(wheretext).Tables[0];
                dt.Columns.Add(new DataColumn("Sysroler", typeof(string)));

                XHD.BLL.ssn_button btn = new XHD.BLL.ssn_button();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataSet ds    = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString() + wheretext2, "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
            else if (request["Action"] == "getauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                XHD.Model.ssn_authority modelauth = new XHD.Model.ssn_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = sa.app;
                modelauth.Menu_ids   = sa.menu;
                modelauth.Button_ids = sa.btn;

                XHD.BLL.ssn_authority sysau = new XHD.BLL.ssn_authority();

                string  roledata = "0|0";
                DataSet ds       = sysau.GetList("Role_id=" + modelauth.Role_id + " and App_ids='" + 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
            else if (request["Action"] == "saveauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                XHD.Model.ssn_authority modelauth = new XHD.Model.ssn_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);
                modelauth.Factory_Id = factory_Id;

                XHD.BLL.ssn_authority sysau = new XHD.BLL.ssn_authority();
                //List<string> relstbtn = new List<string>();

                if (!string.IsNullOrEmpty(postdata))
                {
                    //给角色分配权限
                    sysau.DeleteWhere("Role_id=" + modelauth.Role_id + " and App_ids='" + modelauth.App_ids + "'");
                    if (modelauth.Menu_ids != "" || modelauth.Button_ids != ",,")
                    {
                        sysau.Add(modelauth);
                    }
                    context.Response.Write("{sucess:sucess}");
                }
            }
            #endregion

            #region 查看权限设置
            //菜单显示
            else if (request["Action"] == "menuList")
            {
                string appid   = request["appid"];
                string authtxt = PageValidate.InputText(request["auth"], 50);

                if (!string.IsNullOrEmpty(appid))
                {
                    string serchtxt = " App_id=" + int.Parse(appid);
                    //-context.Response.Write(authtxt);
                    DataSet       ds  = menu.GetList(0, serchtxt, " Menu_order");
                    StringBuilder str = new StringBuilder();
                    str.Append("[");
                    str.Append(GetTreeString(0, ds.Tables[0], authtxt));
                    str.Replace(",", "", str.Length - 1, 1);
                    str.Append("]");
                    context.Response.Write(str);
                }
            }

            //显示菜单下的文章
            else if (request["Action"] == "viewgrid")
            {
                //通过菜单id获取旗下的文章
                string menuid = request["menuid"];

                if (!string.IsNullOrEmpty(menuid))
                {
                    string  serchtxt = " Factory_Id='" + factory_Id + "' and Art_Menu_Id=" + int.Parse(menuid) + " and is_del=0 ";
                    DataSet ds       = art.GetList(serchtxt);

                    string dt = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                    context.Response.Write(dt);
                }
            }

            //保存查看权限
            else if (request["Action"] == "saveview")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                view sa = json.Deserialize <view>(postdata);
                XHD.Model.ssn_visit modelview = new XHD.Model.ssn_visit();
                modelview.Role_id     = int.Parse(sa.role_id);
                modelview.App_ids     = PageValidate.InputText(sa.app, 50);
                modelview.Menu_ids    = PageValidate.InputText(sa.menu, int.MaxValue);
                modelview.Art_id      = PageValidate.InputText(sa.art, int.MaxValue);
                modelview.Factory_Id  = factory_Id;
                modelview.Create_id   = emp_id;
                modelview.Create_date = DateTime.Now;

                if (!string.IsNullOrEmpty(postdata))
                {
                    //给角色分配权限
                    visit.DeleteWhere("Role_id=" + modelview.Role_id + " and Menu_ids='" + modelview.Menu_ids + "'");
                    if (modelview.Art_id != "")
                    {
                        visit.Add(modelview);
                    }
                    context.Response.Write("{sucess:sucess}");
                }
            }
            //获取当前角色的权限
            else if (request["Action"] == "getview")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                view sa = json.Deserialize <view>(postdata);
                XHD.Model.ssn_visit modelview = new XHD.Model.ssn_visit();
                modelview.Role_id  = int.Parse(sa.role_id);
                modelview.App_ids  = sa.app;
                modelview.Menu_ids = sa.menu;
                modelview.Art_id   = sa.art;

                string  roledata = "";
                DataSet ds       = visit.GetList("Role_id=" + modelview.Role_id + " and Menu_ids='" + modelview.Menu_ids + "'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    roledata = dr["Art_id"].ToString();
                }
                context.Response.Write(roledata);
            }

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

            XHD.BLL.ssn_art       _art       = new XHD.BLL.ssn_art();
            XHD.BLL.ssn_authority _authority = new XHD.BLL.ssn_authority();
            XHD.BLL.ssn_art_menu  _menu      = new XHD.BLL.ssn_art_menu();
            XHD.BLL.ssn_role      _role      = new XHD.BLL.ssn_role();
            XHD.BLL.ssn_visit     _visit     = new XHD.BLL.ssn_visit();

            C_Sys_log log = new C_Sys_log();

            XHD.Model.ssn_art model = new XHD.Model.ssn_art();

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

            XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee();
            int     emp_id          = int.Parse(CoockiesID);
            DataSet dsemp           = emp.GetList("id=" + emp_id);
            string  empname         = string.Empty;
            string  uid             = string.Empty;
            string  factory_Id      = string.Empty;

            if (dsemp != null && dsemp.Tables[0].Rows.Count > 0)
            {
                empname    = dsemp.Tables[0].Rows[0]["name"].ToString();
                uid        = dsemp.Tables[0].Rows[0]["uid"].ToString();
                factory_Id = dsemp.Tables[0].Rows[0]["Factory_Id"].ToString();
            }

            #region 加载数据grid
            if (request["Action"] == "grid")
            {
                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string Total     = string.Empty;

                string filedOrder = " Art_order desc,Id desc ";
                string strWhere   = " ";

                strWhere += " factory_id ='" + factory_Id + "' and is_del=0 ";

                if (!string.IsNullOrEmpty(request["Art_Menu_Id"]))
                {
                    strWhere += " and  Art_Menu_Id = '" + request["Art_Menu_Id"] + "'";
                }


                DataSet ds = _art.GetList(PageSize, PageIndex, strWhere, filedOrder, out Total);
                string  dt = XHD.Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            #endregion

            #region  加载员工的所能操作的页面 tree
            else if (request["Action"] == "tree")
            {
                DataSet dk = null;
                if (uid != "admin")
                {
                    string serchtxt = " a.factory_Id = '" + factory_Id + "' and  a.App_ids='1' ";

                    serchtxt += "and r.empID='" + emp_id + "'";


                    DataSet ds = _authority.GetListAuth(serchtxt);
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        string menu_ids = "";
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            menu_ids += item["Menu_ids"].ToString();
                        }
                        menu_ids = PageValidate.InputText(menu_ids, int.MaxValue).Replace("m", "");
                        menu_ids = menu_ids.Substring(0, menu_ids.Length - 1);
                        dk       = _menu.GetList(0, " factory_Id='" + factory_Id + "' and  Id in (" + menu_ids + ")", "Menu_order");
                    }
                }
                else
                {
                    dk = _menu.GetList(0, " factory_Id='" + factory_Id + "' and app_id=1", "Menu_order");
                }

                StringBuilder str = new StringBuilder();
                str.Append("[");
                str.Append(GetTreeString(0, dk.Tables[0]));
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");
                context.Response.Write(str);
            }
            #endregion

            #region 保存save
            else if (request["Action"] == "save")
            {
                model.Art_title    = XHD.Common.PageValidate.InputText(request["T_title"], 250);
                model.Art_Content  = PageValidate.InputText(request["T_content"], int.MaxValue);
                model.Art_Content  = HttpUtility.HtmlDecode(model.Art_Content);
                model.Art_title_en = GetSpellCode(model.Art_title);;
                model.image_lst    = PageValidate.InputText(request["images"], int.MaxValue);
                model.Art_order    = int.Parse(request["T_Order"]);
                model.factory_Id   = factory_Id;
                model.Art_Menu_Id  = Convert.ToInt32(PageValidate.InputText(request["art_Menu_Id"], 50));

                string id = PageValidate.InputText(request["nid"], 50);
                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = _art.GetList("Id=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];


                    model.Id = int.Parse(id);

                    if (_art.Update(model))
                    {
                        #region 修改访问权限

                        //查询该文章原来属于哪些角色下
                        DataSet dm = _visit.GetList(" Factory_Id='" + factory_Id + "' and find_in_set('a" + model.Id + "', Art_id)");
                        if (dm != null && dm.Tables[0].Rows.Count > 0)
                        {
                            //此次修改的文章以前已分配过角色
                            string oldRoleId = string.Empty;                                //原来所属的角色
                            string newRoleId = string.Empty;
                            for (int i = 0; i < dm.Tables[0].Rows.Count; i++)
                            {
                                if (i == dm.Tables[0].Rows.Count - 1)
                                {
                                    oldRoleId += dm.Tables[0].Rows[i]["Role_id"].ToString();
                                }
                                else
                                {
                                    oldRoleId += dm.Tables[0].Rows[i]["Role_id"].ToString() + ',';
                                }
                            }

                            string artId = "a" + model.Id + ",";
                            if (!string.IsNullOrEmpty(request["role_Id"].ToString()))
                            {
                                newRoleId = request["role_Id"].ToString();
                                newRoleId = newRoleId.Substring(0, newRoleId.Length - 1);
                                _visit.UpdateN(oldRoleId, newRoleId, artId, factory_Id, model.Art_Menu_Id.Value, emp_id);
                            }
                            else
                            {
                                _visit.UpdateN(oldRoleId, "", artId, factory_Id, model.Art_Menu_Id.Value, emp_id);
                            }

                            log.Add_log(emp_id, empname, request.UserHostAddress, "访问权限修改", "访问权限修改", model.Id, "访问权限修改", oldRoleId, newRoleId, factory_Id);
                        }
                        else
                        {
                            //若所修改的文章原来没有分配角色,若传进来的role_Id不为空,则进行添加
                            if (!string.IsNullOrEmpty(request["role_Id"].ToString()))
                            {
                                string roleId = request["role_Id"].ToString();
                                roleId = roleId.Substring(0, roleId.Length - 1);
                                string[] listRole = roleId.Split(',');
                                foreach (var item in listRole)
                                {
                                    DataSet df = _visit.GetList("Role_id='" + item + "'and Menu_ids='" + model.Art_Menu_Id + "' and Factory_Id='" + factory_Id + "'");
                                    if (df != null && df.Tables[0].Rows.Count > 0)
                                    {
                                        //修改
                                        int    rId    = Convert.ToInt32(df.Tables[0].Rows[0]["id"].ToString());
                                        string art_id = df.Tables[0].Rows[0]["Art_id"].ToString();
                                        art_id += "a" + model.Id + ",";
                                        _visit.Updates(rId, art_id);
                                    }
                                    else
                                    {
                                        //保存
                                        XHD.Model.ssn_visit modelVisit = new XHD.Model.ssn_visit();
                                        modelVisit.Factory_Id  = factory_Id;
                                        modelVisit.Role_id     = Convert.ToInt32(item);
                                        modelVisit.App_ids     = "1";
                                        modelVisit.Menu_ids    = model.Art_Menu_Id.ToString();
                                        modelVisit.Art_id      = "a" + model.Id + ",";
                                        modelVisit.Create_id   = emp_id;
                                        modelVisit.Create_date = DateTime.Now;
                                        _visit.Add(modelVisit);
                                    }
                                }
                            }
                        }
                        #endregion

                        #region 日志

                        int    UserID     = emp_id;
                        string UserName   = empname;
                        string IPStreet   = request.UserHostAddress;
                        string EventTitle = "ssn资料修改";
                        string EventType  = "ssn资料修改";
                        int    EventID    = model.Id;

                        if (dr["Art_title"].ToString() != request["T_title"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "资料名", dr["Art_title"].ToString(), request["T_title"].ToString(), factory_Id);
                        }

                        if (dr["Art_Content"].ToString() != request["T_content"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "内容", dr["Art_Content"].ToString(), model.Art_Content, factory_Id);
                        }

                        if (dr["image_lst"].ToString() != request["images"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "图片", dr["image_lst"].ToString(), request["images"].ToString(), factory_Id);
                        }

                        if (dr["Art_Menu_Id"].ToString() != request["art_Menu_Id"])
                        {
                            log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "页面Id", dr["Art_Menu_Id"].ToString(), request["art_Menu_Id"].ToString(), factory_Id);
                        }

                        #endregion

                        context.Response.Write("2"); //修改成功
                    }
                    else
                    {
                        context.Response.Write("3"); //修改失败
                    }
                }
                else
                {
                    model.is_del       = 0;
                    model.Creater_Uid  = uid;
                    model.Creater_Name = empname;
                    model.Create_Date  = DateTime.Now;
                    model.Creater_Id   = emp_id;
                    int artId = _art.Add(model);

                    if (artId > 0)
                    {
                        #region 保存访问权限
                        if (!string.IsNullOrEmpty(request["role_Id"].ToString()))
                        {
                            string roleId = request["role_Id"].ToString();
                            roleId = roleId.Substring(0, roleId.Length - 1);
                            string[] listRole = roleId.Split(',');
                            foreach (var item in listRole)
                            {
                                //查询该角色是否已有分配的文章记录
                                DataSet df = _visit.GetList("Role_id='" + item + "'and Menu_ids='" + model.Art_Menu_Id + "' and Factory_Id='" + factory_Id + "'");
                                if (df != null && df.Tables[0].Rows.Count > 0)
                                {
                                    //若已经记录,则修改
                                    int    rId    = Convert.ToInt32(df.Tables[0].Rows[0]["id"].ToString());
                                    string art_id = df.Tables[0].Rows[0]["Art_id"].ToString();
                                    art_id += "a" + artId + ",";
                                    if (_visit.Updates(rId, art_id))
                                    {
                                        context.Response.Write("1"); //保存成功
                                    }
                                    else
                                    {
                                        _art.Delete(artId);
                                        context.Response.Write("0"); //保存失败
                                    }
                                }
                                else
                                {
                                    //若没有记录,则保存
                                    XHD.Model.ssn_visit modelVisit = new XHD.Model.ssn_visit();
                                    modelVisit.Factory_Id  = factory_Id;
                                    modelVisit.Role_id     = Convert.ToInt32(item);
                                    modelVisit.App_ids     = "1";
                                    modelVisit.Menu_ids    = model.Art_Menu_Id.ToString();
                                    modelVisit.Art_id      = "a" + artId + ",";
                                    modelVisit.Create_id   = emp_id;
                                    modelVisit.Create_date = DateTime.Now;

                                    if (_visit.Add(modelVisit))
                                    {
                                        context.Response.Write("1"); //保存成功
                                    }
                                    else
                                    {
                                        _art.Delete(artId);
                                        context.Response.Write("0"); //保存失败
                                    }
                                }
                            }
                        }
                        else
                        {
                            context.Response.Write("1"); //保存成功
                        }
                        #endregion
                    }
                    else
                    {
                        context.Response.Write("0"); //保存失败
                    }
                }
            }
            #endregion

            #region form
            else if (request["Action"] == "form")
            {
                string artId = PageValidate.InputText(request["nid"], 50);
                string dt;

                if (PageValidate.IsNumber(artId))
                {
                    DataSet ds = _art.GetList("Id=" + artId);

                    dt = XHD.Common.DataToJson.DataToJSON(ds);
                }
                else
                {
                    dt = "{}";
                }

                context.Response.Write(dt);
            }
            #endregion

            #region  除del
            else if (request["Action"] == "del")
            {
                string artId = PageValidate.InputText(request["id"], 50);

                bool num = _art.Delete(Convert.ToInt32(artId));
                if (num)
                {
                    context.Response.Write("true");
                }
            }
            #endregion

            #region 文章修改时获得查看权限 getRoleLiit
            else if (request["Action"] == "getRoleLiit")
            {
                string dt = string.Empty;

                string artId = PageValidate.InputText(request["nid"], 50);
                artId = "a" + artId;
                DataSet ds = _visit.GetList(" Factory_Id='" + factory_Id + "' and find_in_set('" + artId + "', Art_id)");

                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    dt = XHD.Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], "Total");
                }
                else
                {
                    dt = "{'Rows':[{'id':-9999}],'Total':'Total'}";
                }
                context.Response.Write(dt);
            }
            #endregion

            #region GetRole 获得所有角色
            else if (request["Action"] == "GetRole")
            {
                string dt = string.Empty;

                DataSet ds = _role.GetList(" Factory_Id='" + factory_Id + "'");

                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    dt = XHD.Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], "Total");
                }
                else
                {
                    dt = "{'Rows':[{'id':-9999}],'Total':'Total'}";
                }
                context.Response.Write(dt);
            }
            #endregion

            #region  产文章图片
            else if (request["Action"] == "album")
            {
                string photo        = request["photo"]; //文件路径goods_gallery  商品相册表
                string nowfileName1 = string.Empty;
                if (!string.IsNullOrEmpty(photo))
                {
                    photo = photo.Substring(photo.LastIndexOf('\\') + 1);
                    string   sExt1 = photo.Substring(photo.LastIndexOf(".")).ToLower();
                    DateTime now1  = DateTime.Now;
                    nowfileName1 = XHD.Common.TimeParser.GenerateTimeStamp(DateTime.Now) + sExt1;
                }
                if (request.Files.Count > 0 && (!string.IsNullOrEmpty(photo)))
                {
                    HttpPostedFile uploadFile = request.Files[0];
                    ////生成缩略图
                    //SmallImg(uploadFile.InputStream, uploadFile.FileName, context, nowfileName1);
                    ////生成主图
                    //MainImg(uploadFile.InputStream, uploadFile.FileName, context, nowfileName1);
                    uploadFile.SaveAs(context.Server.MapPath(@"~/file/ssn_artImg/" + nowfileName1));
                }
                context.Response.Write("file/ssn_artImg/" + nowfileName1);
            }
            #endregion

            #region 移除图片
            else if (request["Action"] == "remove")
            {
                string src  = request["srcvalue"];
                string file = System.Web.HttpContext.Current.Server.MapPath("../" + src);
                if (System.IO.File.Exists(file))
                {
                    File.Delete(file);
                }
            }
            #endregion

            #region 判断标题是否重复
            else if (request["Action"] == "validate")
            {
                string title      = request["T_title"];
                string id         = request["T_cid"];
                string artMenu_Id = request["art_Menu_Id"];
                if (string.IsNullOrEmpty(id) || id == "null")
                {
                    id = "0";
                }

                DataSet ds = _art.GetList("Art_title = '" + PageValidate.InputText(title, 255) + "' and Art_Menu_Id='" + artMenu_Id + "' and factory_Id='" + factory_Id + "' and Id!=" + int.Parse(id) + " and is_del=0");

                if (ds.Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("false");
                }
                else
                {
                    context.Response.Write("true");
                }
            }

            #endregion


            //#region 获取文章图片
            //else if (request["Action"] == "formGallery")
            //{
            //    string goods_id = request["goods_id"];
            //    if (!string.IsNullOrEmpty(goods_id))
            //    {
            //        DataSet ds = null;
            //        if (request["type"] == "1")
            //            ds = gallery.GetList(" goods_id='" + goods_id + "'");
            //        else if (request["type"] == "2")
            //            ds = gallery.GetListCopy(" goods_id='" + goods_id + "'");
            //        string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
            //        context.Response.Write(dt);
            //    }
            //}
            //#endregion
        }