Ejemplo n.º 1
0
        public void Add_log(int uid, string uname, string ip, string EventTitle, string EventType, int EventID, string Remind_name, string Original_txt, string Current_txt)
        {
            BLL.Sys_log   log      = new BLL.Sys_log();
            Model.Sys_log modellog = new Model.Sys_log();

            modellog.EventDate = DateTime.Now;
            modellog.UserID    = uid;
            modellog.UserName  = PageValidate.InputText(uname, 255);
            modellog.IPStreet  = PageValidate.InputText(ip, 255);

            modellog.EventTitle = PageValidate.InputText(EventTitle, 255);

            modellog.EventType    = PageValidate.InputText(EventType, 255);
            modellog.EventID      = EventID.ToString();
            modellog.Original_txt = "¡¾" + PageValidate.InputText(Remind_name, 255) + "¡¿" + PageValidate.InputText(Original_txt, 255);
            modellog.Current_txt  = "¡¾" + PageValidate.InputText(Remind_name, 255) + "¡¿" + PageValidate.InputText(Current_txt, 255);

            log.Add(modellog);
        }
Ejemplo n.º 2
0
        public void Add_log(int uid, string uname, string ip, string EventTitle, string EventType, int EventID, string Remind_name,string Original_txt, string Current_txt)
        {
            BLL.Sys_log log = new BLL.Sys_log();
            Model.Sys_log modellog = new Model.Sys_log();

            modellog.EventDate = DateTime.Now;
            modellog.UserID = uid;
            modellog.UserName = PageValidate.InputText(uname, 255);
            modellog.IPStreet = PageValidate.InputText(ip, 255);

            modellog.EventTitle = PageValidate.InputText(EventTitle, 255);

            modellog.EventType = PageValidate.InputText(EventType,255);
            modellog.EventID = EventID.ToString();
            modellog.Original_txt = "¡¾" + PageValidate.InputText(Remind_name, 255) + "¡¿" + PageValidate.InputText(Original_txt, 255);
            modellog.Current_txt = "¡¾" + PageValidate.InputText(Remind_name, 255) + "¡¿" + PageValidate.InputText(Current_txt, 255);

            log.Add(modellog);
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset = "utf-8";
            HttpRequest request = context.Request;

            if (request["Action"] == "login")
            {
                BLL.hr_employee emp = new BLL.hr_employee();

                string username = PageValidate.InputText(request["username"], 255);
                //string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");
                string password = PageValidate.InputText(request["password"], 255);
                string validate = PageValidate.InputText(request["validate"], 255);

                if (!string.IsNullOrEmpty(validate) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    if (validate == context.Session["CheckCode"].ToString() || validate.ToLower() == context.Session["CheckCode"].ToString().ToLower())
                    {
                        DataSet ds = emp.GetList(" uid='" + username + "' and pwd='" + password + "'");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["canlogin"].ToString() == "1")
                            {
                                string userid = ds.Tables[0].Rows[0]["ID"].ToString();
                                context.Response.Cookies["UserID"].Value = userid;
                                //FormsAuthentication.RedirectFromLoginPage(userid, false);
                                FormsAuthentication.SetAuthCookie(userid, true);

                                //日志
                                BLL.Sys_log log = new BLL.Sys_log();
                                Model.Sys_log modellog = new Model.Sys_log();
                                modellog.EventType = "系统登录";

                                modellog.EventDate = DateTime.Now;
                                modellog.UserID = int.Parse(userid);
                                modellog.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                                modellog.IPStreet = request.UserHostAddress;

                                log.Add(modellog);

                                //online
                                BLL.Sys_online sol = new BLL.Sys_online();
                                Model.Sys_online model = new Model.Sys_online();

                                model.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                                model.UserID = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                                model.LastLogTime = DateTime.Now;

                                DataSet ds1 = sol.GetList(" UserID=" + ds.Tables[0].Rows[0]["id"].ToString());

                                //添加当前用户信息
                                if (ds1.Tables[0].Rows.Count > 0)
                                {
                                    sol.Update(model, " UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                                }
                                else
                                {
                                    sol.Add(model);
                                }
                                //删除超时用户
                                sol.Delete(" LastLogTime<DATEADD(MI,-1,getdate())");

                                //验证完毕,允许登录
                                context.Response.Write("2");
                            }
                            else
                            {
                                context.Response.Write("4");//不允许登录
                            }
                        }
                        else
                        {
                            context.Response.Write("1");//用户名或密码错误
                        }
                    }
                    else
                    {
                        context.Response.Write("0");//验证码错误
                    }
                }
                else
                {
                    context.Response.Write("999");//系统数据错误
                }
            }
            if (request["Action"] == "logout")
            {
                HttpCookie oldcookie = request.Cookies["UserID"];
                context.Response.Cookies["UserID"].Value = "";
                FormsAuthentication.SignOut();
                context.Response.Write("true");

                //online
                BLL.Sys_online sol = new BLL.Sys_online();
                try
                {
                    if (!string.IsNullOrEmpty(oldcookie.Value))
                    {
                        sol.Delete(" UserID=" + oldcookie.Value);
                    }
                }
                catch
                {
                }
            }
            if (request["Action"] == "checkpwd")
            {
                BLL.hr_employee emp = new BLL.hr_employee();

                int emp_id = int.Parse(request.Cookies["UserID"].Value.ToString());
                string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");

                DataSet ds = emp.GetList(string.Format("ID={0} and pwd='{1}'", emp_id, password));

                if (ds.Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("{sucess:sucess}");
                }
                else
                {
                    context.Response.Write("{sucess:false}");
                }
            }
        }
Ejemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            HttpRequest request = context.Request;

            if (request["Action"] == "login")
            {
                BLL.hr_employee emp = new BLL.hr_employee();

                string username = PageValidate.InputText(request["username"], 255);
                //string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");
                string password = PageValidate.InputText(request["password"], 255);
                string validate = PageValidate.InputText(request["validate"], 255);

                if (!string.IsNullOrEmpty(validate) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    if (validate == context.Session["CheckCode"].ToString() || validate.ToLower() == context.Session["CheckCode"].ToString().ToLower())
                    {
                        DataSet ds = emp.GetList(" uid='" + username + "' and pwd='" + password + "'");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["canlogin"].ToString() == "1")
                            {
                                string userid = ds.Tables[0].Rows[0]["ID"].ToString();
                                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                                    1,
                                    username,
                                    DateTime.Now,
                                    DateTime.Now.AddMinutes(20),
                                    true,
                                    userid,
                                    "/"
                                    );
                                var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                                cookie.HttpOnly = true;
                                context.Response.Cookies.Add(cookie);

                                //FormsAuthentication.SetAuthCookie(userid, true);

                                //日志
                                BLL.Sys_log   log      = new BLL.Sys_log();
                                Model.Sys_log modellog = new Model.Sys_log();
                                modellog.EventType = "系统登录";

                                modellog.EventDate = DateTime.Now;
                                modellog.UserID    = int.Parse(userid);
                                modellog.UserName  = ds.Tables[0].Rows[0]["name"].ToString();
                                modellog.IPStreet  = request.UserHostAddress;

                                log.Add(modellog);

                                //online
                                BLL.Sys_online   sol   = new BLL.Sys_online();
                                Model.Sys_online model = new Model.Sys_online();

                                model.UserName    = ds.Tables[0].Rows[0]["name"].ToString();
                                model.UserID      = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                                model.LastLogTime = DateTime.Now;

                                DataSet ds1 = sol.GetList(" UserID=" + ds.Tables[0].Rows[0]["id"].ToString());

                                //添加当前用户信息
                                if (ds1.Tables[0].Rows.Count > 0)
                                {
                                    sol.Update(model, " UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                                }
                                else
                                {
                                    sol.Add(model);
                                }
                                //删除超时用户
                                //sol.Delete(" LastLogTime<DATEADD(MI,-1,getdate())");//SQL Server使用
                                sol.Delete(" LastLogTime<date_sub(now(),interval 1 day)");

                                //验证完毕,允许登录
                                context.Response.Write("2");
                            }
                            else
                            {
                                context.Response.Write("4");//不允许登录
                            }
                        }
                        else
                        {
                            context.Response.Write("1");//用户名或密码错误
                        }
                    }
                    else
                    {
                        context.Response.Write("0");//验证码错误
                    }
                }
                else
                {
                    context.Response.Write("999");//系统数据错误
                }
            }

            if (request["Action"] == "logout")
            {
                var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName];

                if (null != cookie)
                {
                    var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
                    string CoockiesID = ticket.UserData;

                    FormsAuthentication.SignOut();
                    context.Response.Write("true");

                    //online
                    BLL.Sys_online sol = new BLL.Sys_online();
                    try
                    {
                        if (!string.IsNullOrEmpty(CoockiesID))
                        {
                            sol.Delete(" UserID=" + int.Parse(CoockiesID));
                        }
                    }
                    catch
                    {
                    }
                }
            }
            if (request["Action"] == "checkpwd")
            {
                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);
                string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");


                DataSet ds = emp.GetList(string.Format("ID={0} and pwd='{1}'", emp_id, password));

                if (ds.Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("{sucess:sucess}");
                }
                else
                {
                    context.Response.Write("{sucess:false}");
                }
            }
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            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"] == "grid")
            {
                BLL.Sys_log log = new BLL.Sys_log();

                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname  = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                {
                    sortname = " EventDate";
                }
                if (string.IsNullOrEmpty(sortorder))
                {
                    sortorder = " desc";
                }

                string sorttext = " " + sortname + " " + sortorder;

                string Total = "0";

                DataSet ds = null;

                string serchtext = " 1=1 ";

                if (!string.IsNullOrEmpty(request["stype"]))
                {
                    serchtext += " and EventType = '" + Common.PageValidate.InputText(request["stype"], 255) + "'";
                }

                if (!string.IsNullOrEmpty(request["sstart"]))
                {
                    serchtext += " and EventDate >= '" + Common.PageValidate.InputText(request["sstart"], 255) + "'";
                }

                if (!string.IsNullOrEmpty(request["sdend"]))
                {
                    DateTime enddate = DateTime.Parse(request["sdend"]);
                    serchtext += " and EventDate <= '" + DateTime.Parse(request["sdend"]).AddHours(23).AddMinutes(59).AddSeconds(59) + "'";
                }

                if (!string.IsNullOrEmpty(request["stext"]))
                {
                    string stext = Common.PageValidate.InputText(request["stext"], 10000);
                    serchtext += " and (EventID like N'%" + stext + "%'";
                    serchtext += " or EventTitle like N'%" + stext + "%'";
                    serchtext += " or Original_txt like N'%" + stext + "%'";
                    serchtext += " or Current_txt like N'%" + stext + "%'";
                    serchtext += " or IPStreet like N'%" + stext + "%'";
                    serchtext += " or UserName like N'%" + stext + "%')";
                }

                ds = log.GetList(PageSize, PageIndex, serchtext, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            if (request["Action"] == "logtype")
            {
                BLL.Sys_log log = new BLL.Sys_log();

                DataSet ds = log.GetLogtype();

                StringBuilder str = new StringBuilder();

                str.Append("[");

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{value:'" + ds.Tables[0].Rows[i]["EventType"].ToString() + "',text:'" + ds.Tables[0].Rows[i]["EventType"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);
            }
        }
Ejemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (context.Request.Params["Action"] == "save")
            {
                BLL.Sys_role_emp   rm         = new BLL.Sys_role_emp();
                Model.Sys_role_emp model      = new Model.Sys_role_emp();
                string             rid        = context.Request.Params["rid"];
                string             savestring = context.Request.Params["savestring"];
                model.RoleID = int.Parse(rid);

                rm.Delete("RoleID=" + rid);

                JavaScriptSerializer json  = new JavaScriptSerializer();
                List <RoleEmp>       _list = json.Deserialize <List <RoleEmp> >(savestring);

                foreach (RoleEmp emp1 in _list)
                {
                    model.empID = emp1.ID;
                    rm.Add(model);
                }
                //日志
                BLL.Sys_log   log      = new BLL.Sys_log();
                Model.Sys_log modellog = new Model.Sys_log();

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

                modellog.EventType = "权限人员调整";
                modellog.EventID   = model.RoleID.ToString();
                log.Add(modellog);

                context.Response.Write("true");
            }

            if (context.Request.Params["Action"] == "get")
            {
                string rid = context.Request["rid"];
                if (!string.IsNullOrEmpty(rid))
                {
                    BLL.Sys_role_emp re = new BLL.Sys_role_emp();
                    DataSet          ds = re.GetList("RoleID=" + int.Parse(rid));
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string sql = "";

                        sql += "ID in (";
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            sql += row["empID"] + ",";
                        }
                        sql  = sql.Substring(0, sql.Length - 1);
                        sql += ")";

                        BLL.hr_employee emp = new BLL.hr_employee();
                        string          dt  = Common.GetGridJSON.DataTableToJSON(emp.GetList(sql).Tables[0]);
                        context.Response.Write(dt);
                    }
                    else
                    {
                        context.Response.Write("{ Rows: [] }");
                    }
                }
                else
                {
                    context.Response.Write("test" + rid);
                }
            }
        }
Ejemplo n.º 7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            HttpRequest request = context.Request;

            if (request["Action"] == "login")
            {
                BLL.hr_employee     emp = new BLL.hr_employee();
                BLL.Sys_FactoryInfo fty = new BLL.Sys_FactoryInfo();

                string username = PageValidate.InputText(request["username"], 255);
                //string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");
                string password = PageValidate.InputText(request["password"], 255);
                string validate = PageValidate.InputText(request["validate"], 255);

                //SQL注入式攻击过滤===========================================================================================
                string path = context.Server.MapPath(@"../file/SQLFile.txt");
                if (CommonData.getSQLPercolation(username.ToUpper(), path))
                {
                    context.Response.Write("999");//系统错误
                    return;
                }
                //============================================================================================================

                if (!string.IsNullOrEmpty(validate) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    if (validate == context.Session["CheckCode"].ToString() || validate.ToLower() == context.Session["CheckCode"].ToString().ToLower())
                    {
                        //DataSet ds = emp.GetList(" uid='" + username + "' and pwd='" + password + "'");
                        Model.hr_employee empModel = emp.LoginUser(username);
                        //IP 限制====================================================================================================
                        string vrip = GetClientIPv4Address();

                        List <string> lstIp = new List <string>();
                        lstIp.Add("219.146.197.91");    //电信IP地址
                        lstIp.Add("60.213.50.226");     //联通IP地址

                        lstIp.Add("172.178.1.118");     //本地(邢荣)
                        lstIp.Add("172.178.1.211");     //本地(陈伟)
                        lstIp.Add("172.178.1.100");     //本地(陈伟)
                        lstIp.Add("172.178.1.203");     //本地(robert)
                        lstIp.Add("172.178.1.201");     //本地(李明)
                        lstIp.Add("172.178.1.79");      //本地(王德胜)
                        lstIp.Add("172.178.1.117");     //本地(王立全)
                        lstIp.Add("172.178.1.243");     //本地(王虎)
                        //if (!lstIp.Contains(vrip))
                        //{
                        //    //修改:robert, 2016-06-04     过滤特殊人群,当前:王频频wpp6274========
                        //    if (username.Trim() != "wpp6274" && username.Trim() != "gjc1010")
                        //    {
                        //        context.Response.Write("6");//ip受限制
                        //        return;
                        //    }
                        //    //=======================================================================
                        //}
                        //============================================================================================================

                        if (empModel != null && empModel.pwd == password.ToUpper())
                        {
                            //只允许李辉、郭建传,李艳梅,admin登录
                            //if (username.Trim() != "li5001" && username.Trim() != "1010" && username.Trim() != "lym5007" && username.Trim() != "admin" && username.Trim() != "yqy5062" && username.Trim() != "lgh1128" && username.Trim() != "lc1271" && username.Trim() != "zf6346")
                            //{
                            //    context.Response.Write("6");//ip受限制
                            //    return;
                            //}
                            //=======================================================================
                            //存在该 uid的用户,并且 pwd-密码正确;执行以下内容
                            //if (ds.Tables[0].Rows.Count > 0)
                            //{
                            if (empModel.uid.Trim() == "admin")
                            {
                                #region
                                //string userid = empModel.ID.ToString();
                                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                                    1,
                                    empModel.uid,
                                    DateTime.Now,
                                    DateTime.Now.AddMinutes(20),
                                    true,
                                    empModel.ID.ToString(),
                                    "/"
                                    );
                                var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                                cookie.HttpOnly = true;
                                context.Response.Cookies.Add(cookie);

                                //FormsAuthentication.SetAuthCookie(userid, true);

                                //日志
                                //BLL.Sys_log log = new BLL.Sys_log();
                                //Model.Sys_log modellog = new Model.Sys_log();
                                //modellog.EventType = "系统登录";

                                //modellog.EventDate = DateTime.Now;
                                //modellog.UserID = empModel.ID;
                                //modellog.UserName = empModel.name;
                                //modellog.IPStreet = request.UserHostAddress;
                                //modellog.Factory_Id = empModel.factory_Id;

                                //log.Add(modellog);

                                //online
                                BLL.Sys_online   sol   = new BLL.Sys_online();
                                Model.Sys_online model = new Model.Sys_online();

                                model.UserName    = empModel.name;
                                model.UserID      = empModel.ID;
                                model.LastLogTime = DateTime.Now;

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

                                //添加当前用户信息
                                if (ds1.Tables[0].Rows.Count > 0)
                                {
                                    sol.Update(model, " UserID=" + empModel.ID);
                                }
                                else
                                {
                                    sol.Add(model);
                                }
                                //删除超时用户
                                //2分钟用户失效,删除 --Robert 2015-11-24
                                sol.Delete(" LastLogTime<date_sub(now(), interval 5 minute)");

                                //验证完毕,允许登录
                                context.Response.Write("2");
                                #endregion
                            }
                            else
                            {
                                #region
                                DataSet dsfty    = fty.GetList("Factory_Id='" + empModel.factory_Id + "'");
                                string  isDelete = dsfty.Tables[0].Rows[0]["IsDelete"].ToString();
                                if (int.Parse(isDelete) == 0)
                                {
                                    if (empModel.canlogin.ToString() == "1")
                                    {
                                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                                            1,
                                            username,
                                            DateTime.Now,
                                            DateTime.Now.AddMinutes(20),
                                            true,
                                            empModel.ID.ToString(),
                                            "/"
                                            );
                                        var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                                        cookie.HttpOnly = true;
                                        context.Response.Cookies.Add(cookie);

                                        //FormsAuthentication.SetAuthCookie(userid, true);

                                        //日志
                                        BLL.Sys_log   log      = new BLL.Sys_log();
                                        Model.Sys_log modellog = new Model.Sys_log();
                                        modellog.EventType = "系统登录";

                                        modellog.EventDate   = DateTime.Now;
                                        modellog.UserID      = empModel.ID;
                                        modellog.UserName    = empModel.name;
                                        modellog.IPStreet    = request.UserHostAddress;
                                        modellog.Current_txt = "DAS 用户登录";
                                        modellog.Factory_Id  = empModel.factory_Id;

                                        log.Add(modellog);

                                        //online
                                        BLL.Sys_online   sol   = new BLL.Sys_online();
                                        Model.Sys_online model = new Model.Sys_online();

                                        model.UserName    = empModel.name;
                                        model.UserID      = empModel.ID;
                                        model.LastLogTime = DateTime.Now;

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

                                        //添加当前用户信息
                                        if (ds1.Tables[0].Rows.Count > 0)
                                        {
                                            sol.Update(model, " UserID=" + empModel.ID);
                                        }
                                        else
                                        {
                                            sol.Add(model);
                                        }
                                        //删除超时用户
                                        //2分钟用户失效,删除 --Robert 2015-11-24
                                        sol.Delete(" LastLogTime<date_sub(now(), interval 5 minute)");


                                        //验证完毕,允许登录
                                        context.Response.Write("2");
                                    }
                                    else
                                    {
                                        context.Response.Write("4");//不允许登录
                                    }
                                }
                                else
                                {
                                    context.Response.Write("5");//不允许登录
                                }
                                #endregion
                            }

                            #region 历史2016-04-15前

                            /*
                             * string factory_Id = ds.Tables[0].Rows[0]["Factory_Id"].ToString();
                             *
                             * if (ds.Tables[0].Rows[0]["uid"].ToString() == "admin")
                             * {
                             #region
                             *  string userid = ds.Tables[0].Rows[0]["ID"].ToString();
                             *  FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                             *      1,
                             *      username,
                             *      DateTime.Now,
                             *      DateTime.Now.AddMinutes(20),
                             *      true,
                             *      userid,
                             *      "/"
                             *      );
                             *  var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                             *  cookie.HttpOnly = true;
                             *  context.Response.Cookies.Add(cookie);
                             *
                             *  //FormsAuthentication.SetAuthCookie(userid, true);
                             *
                             *  //日志
                             *  BLL.Sys_log log = new BLL.Sys_log();
                             *  Model.Sys_log modellog = new Model.Sys_log();
                             *  modellog.EventType = "系统登录";
                             *
                             *  modellog.EventDate = DateTime.Now;
                             *  modellog.UserID = int.Parse(userid);
                             *  modellog.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                             *  modellog.IPStreet = request.UserHostAddress;
                             *  modellog.Factory_Id = factory_Id;
                             *
                             *  log.Add(modellog);
                             *
                             *  //online
                             *  BLL.Sys_online sol = new BLL.Sys_online();
                             *  Model.Sys_online model = new Model.Sys_online();
                             *
                             *  model.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                             *  model.UserID = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                             *  model.LastLogTime = DateTime.Now;
                             *
                             *  DataSet ds1 = sol.GetList(" UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                             *
                             *  //添加当前用户信息
                             *  if (ds1.Tables[0].Rows.Count > 0)
                             *  {
                             *      sol.Update(model, " UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                             *  }
                             *  else
                             *  {
                             *      sol.Add(model);
                             *  }
                             *  //删除超时用户
                             *  //2分钟用户失效,删除 --Robert 2015-11-24
                             *  sol.Delete(" LastLogTime<date_sub(now(), interval 2 minute)");
                             *
                             *
                             *  //验证完毕,允许登录
                             *  context.Response.Write("2");
                             #endregion
                             * }
                             * else
                             * {
                             #region
                             *  DataSet dsfty = fty.GetList("Factory_Id='" + factory_Id + "'");
                             *  string isDelete = dsfty.Tables[0].Rows[0]["IsDelete"].ToString();
                             *  if (int.Parse(isDelete) == 0)
                             *  {
                             *      if (ds.Tables[0].Rows[0]["canlogin"].ToString() == "1")
                             *      {
                             *          string userid = ds.Tables[0].Rows[0]["ID"].ToString();
                             *          FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                             *              1,
                             *              username,
                             *              DateTime.Now,
                             *              DateTime.Now.AddMinutes(20),
                             *              true,
                             *              userid,
                             *              "/"
                             *              );
                             *          var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket));
                             *          cookie.HttpOnly = true;
                             *          context.Response.Cookies.Add(cookie);
                             *
                             *          //FormsAuthentication.SetAuthCookie(userid, true);
                             *
                             *          //日志
                             *          BLL.Sys_log log = new BLL.Sys_log();
                             *          Model.Sys_log modellog = new Model.Sys_log();
                             *          modellog.EventType = "系统登录";
                             *
                             *          modellog.EventDate = DateTime.Now;
                             *          modellog.UserID = int.Parse(userid);
                             *          modellog.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                             *          modellog.IPStreet = request.UserHostAddress;
                             *          modellog.Factory_Id = factory_Id;
                             *
                             *          log.Add(modellog);
                             *
                             *          //online
                             *          BLL.Sys_online sol = new BLL.Sys_online();
                             *          Model.Sys_online model = new Model.Sys_online();
                             *
                             *          model.UserName = ds.Tables[0].Rows[0]["name"].ToString();
                             *          model.UserID = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                             *          model.LastLogTime = DateTime.Now;
                             *
                             *          DataSet ds1 = sol.GetList(" UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                             *
                             *          //添加当前用户信息
                             *          if (ds1.Tables[0].Rows.Count > 0)
                             *          {
                             *              sol.Update(model, " UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                             *          }
                             *          else
                             *          {
                             *              sol.Add(model);
                             *          }
                             *          //删除超时用户
                             *          //2分钟用户失效,删除 --Robert 2015-11-24
                             *          sol.Delete(" LastLogTime<date_sub(now(), interval 2 minute)");
                             *
                             *
                             *          //验证完毕,允许登录
                             *          context.Response.Write("2");
                             *      }
                             *      else
                             *      {
                             *          context.Response.Write("4");//不允许登录
                             *      }
                             *  }
                             *  else
                             *  {
                             *      context.Response.Write("5");//不允许登录
                             *  }
                             #endregion
                             * }
                             */
                            #endregion
                        }
                        else
                        {
                            context.Response.Write("1");//用户名或密码错误
                        }
                    }
                    else
                    {
                        context.Response.Write("0");//验证码错误
                    }
                }
                else
                {
                    context.Response.Write("999");//系统数据错误
                }
            }

            else if (request["Action"] == "logout")
            {
                #region
                var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName];

                if (null != cookie)
                {
                    var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
                    string CoockiesID = ticket.UserData;

                    FormsAuthentication.SignOut();
                    context.Response.Write("true");

                    //online
                    BLL.Sys_online sol = new BLL.Sys_online();
                    try
                    {
                        if (!string.IsNullOrEmpty(CoockiesID))
                        {
                            sol.Delete(" UserID=" + int.Parse(CoockiesID));
                        }
                    }
                    catch
                    {
                    }
                }
                #endregion
            }
            else if (request["Action"] == "checkpwd")
            {
                #region
                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);
                string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");

                DataSet ds = emp.GetList(string.Format("ID={0} and pwd='{1}'", emp_id, password));

                if (ds.Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("{sucess:sucess}");
                }
                else
                {
                    context.Response.Write("{sucess:false}");
                }
                #endregion
            }
        }
Ejemplo n.º 8
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;
                    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);
                }
            }
        }
Ejemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (context.Request.Params["Action"] == "save")
            {
                BLL.Sys_role_emp rm = new BLL.Sys_role_emp();
                Model.Sys_role_emp model = new Model.Sys_role_emp();
                string rid = context.Request.Params["rid"];
                string savestring = context.Request.Params["savestring"];
                model.RoleID = int.Parse(rid);

                rm.Delete("RoleID=" + rid);

                JavaScriptSerializer json = new JavaScriptSerializer();
                List<RoleEmp> _list = json.Deserialize<List<RoleEmp>>(savestring);

                foreach (RoleEmp emp1 in _list)
                {
                    model.empID = emp1.ID;
                    rm.Add(model);
                }
                //日志
                BLL.Sys_log log = new BLL.Sys_log();
                Model.Sys_log modellog = new Model.Sys_log();

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

                modellog.EventType = "权限人员调整";
                modellog.EventID = model.RoleID.ToString();
                log.Add(modellog);

                context.Response.Write("true");
            }

            if (context.Request.Params["Action"] == "get")
            {
                string rid = context.Request["rid"];
                if (!string.IsNullOrEmpty(rid))
                {
                    BLL.Sys_role_emp re = new BLL.Sys_role_emp();
                    DataSet ds = re.GetList("RoleID=" + int.Parse( rid));
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        string sql = "";

                        sql += "ID in (";
                        foreach (DataRow row in ds.Tables[0].Rows)
                        {
                            sql += row["empID"] + ",";
                        }
                        sql = sql.Substring(0, sql.Length - 1);
                        sql += ")";

                        BLL.hr_employee emp = new BLL.hr_employee();
                        string dt = Common.GetGridJSON.DataTableToJSON(emp.GetList(sql).Tables[0]);
                        context.Response.Write(dt);
                    }
                    else
                    {
                        context.Response.Write("{ Rows: [] }");
                    }
                }
                else
                {
                    context.Response.Write("test" + rid);
                }
            }
        }
Ejemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_role_emp   rm    = new BLL.Sys_role_emp();
            Model.Sys_role_emp model = new Model.Sys_role_emp();

            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"] == "add")
            {
                string rid    = PageValidate.InputText(request["role_id"], 50);
                string empids = Common.PageValidate.InputText(request["empids"], int.MaxValue);
                //rm.Delete(string.Format("RoleID={0} and empID in ({1})", int.Parse(rid), empids));
                string[] emplist = empids.Split(',');
                model.RoleID = int.Parse(rid);
                for (int i = 0; i < emplist.Length; i++)
                {
                    model.empID = int.Parse(emplist[i].ToString());
                    rm.Add(model);
                }

                BLL.Sys_log   log      = new BLL.Sys_log();
                Model.Sys_log modellog = new Model.Sys_log();

                modellog.EventDate = DateTime.Now;
                modellog.UserID    = emp_id;
                modellog.UserName  = PageValidate.InputText(empname, 255);
                modellog.IPStreet  = context.Request.UserHostAddress;

                modellog.EventType = "权限人员调整";
                modellog.EventID   = rid.ToString();
                log.Add(modellog);
            }
            if (request["Action"] == "remove")
            {
                string rid    = PageValidate.InputText(request["role_id"], 50);
                string empids = Common.PageValidate.InputText(request["empids"], int.MaxValue);
                rm.Delete(string.Format("RoleID={0} and empID in ({1})", int.Parse(rid), empids));

                BLL.Sys_log   log      = new BLL.Sys_log();
                Model.Sys_log modellog = new Model.Sys_log();

                modellog.EventDate = DateTime.Now;
                modellog.UserID    = emp_id;
                modellog.UserName  = PageValidate.InputText(empname, 255);
                modellog.IPStreet  = context.Request.UserHostAddress;

                modellog.EventType = "权限人员调整";
                modellog.EventID   = rid.ToString();
                log.Add(modellog);
            }
            if (request["Action"] == "emplist")
            {
                string rid = PageValidate.InputText(request["role_id"], 50);

                string sql = (string.Format("ID not in (select empID from Sys_role_emp where RoleID={0}) and ID !=1 ", rid));
                if (!string.IsNullOrEmpty(request["stext"]))
                {
                    sql += " and name like N'%" + PageValidate.InputText(request["stext"], 255) + "%'";
                }

                int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname  = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                {
                    sortname = " ID";
                }
                if (string.IsNullOrEmpty(sortorder))
                {
                    sortorder = " desc";
                }

                string sorttext = " " + sortname + " " + sortorder;

                string Total;

                dsemp = emp.GetList(PageSize, PageIndex, sql, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(dsemp.Tables[0], Total);
                context.Response.Write(dt);
            }
            if (request["Action"] == "get")
            {
                string rid = PageValidate.InputText(request["role_id"], 50);
                if (!string.IsNullOrEmpty(rid))
                {
                    string sql = (string.Format("ID in (select empID from Sys_role_emp where RoleID={0})", int.Parse(rid)));
                    if (!string.IsNullOrEmpty(request["stext"]))
                    {
                        sql += " and name like N'%" + PageValidate.InputText(request["stext"], 255) + "%'";
                    }
                    int    PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                    int    PageSize  = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                    string sortname  = request["sortname"];
                    string sortorder = request["sortorder"];

                    if (string.IsNullOrEmpty(sortname))
                    {
                        sortname = " ID";
                    }
                    if (string.IsNullOrEmpty(sortorder))
                    {
                        sortorder = " desc";
                    }

                    string sorttext = " " + sortname + " " + sortorder;

                    string Total;

                    dsemp = emp.GetList(PageSize, PageIndex, sql, sorttext, out Total);

                    string dt = Common.GetGridJSON.DataTableToJSON1(dsemp.Tables[0], Total);
                    context.Response.Write(dt);
                }
                else
                {
                    context.Response.Write("test" + rid);
                }
            }
        }
Ejemplo n.º 11
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);
                }
            }
        }
Ejemplo n.º 12
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.hr_employee emp = new BLL.hr_employee();
            int emp_id = int.Parse(request.Cookies["UserID"].Value);
            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"] == "grid")
            {
                BLL.Sys_log log = new BLL.Sys_log();

                int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]);
                int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]);
                string sortname = request["sortname"];
                string sortorder = request["sortorder"];

                if (string.IsNullOrEmpty(sortname))
                    sortname = " EventDate";
                if (string.IsNullOrEmpty(sortorder))
                    sortorder = " desc";

                string sorttext = " " + sortname + " " + sortorder;

                string Total = "0";

                DataSet ds = null;

                string serchtext = " 1=1 ";

                if (!string.IsNullOrEmpty(request["stype"]))
                    serchtext += " and EventType = '" + Common.PageValidate.InputText( request["stype"],255) + "'";

                if (!string.IsNullOrEmpty(request["sstart"]))
                    serchtext += " and EventDate >= '" + Common.PageValidate.InputText( request["sstart"],255) + "'";

                if (!string.IsNullOrEmpty(request["sdend"]))
                {
                    DateTime enddate = DateTime.Parse(request["sdend"]);
                    serchtext += " and EventDate <= '" + DateTime.Parse(request["sdend"]).AddHours(23).AddMinutes(59).AddSeconds(59) + "'";
                }

                if (!string.IsNullOrEmpty(request["stext"]))
                {
                    string stext = Common.PageValidate.InputText(request["stext"], 10000);
                    serchtext += " and (EventID like N'%" + stext + "%'";
                    serchtext += " or EventTitle like N'%" + stext + "%'";
                    serchtext += " or Original_txt like N'%" + stext + "%'";
                    serchtext += " or Current_txt like N'%" + stext + "%'";
                    serchtext += " or IPStreet like N'%" + stext + "%'";
                    serchtext += " or UserName like N'%" + stext + "%')";
                }

                ds = log.GetList(PageSize, PageIndex, serchtext, sorttext, out Total);

                string dt = Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total);
                context.Response.Write(dt);
            }
            if (request["Action"] == "logtype")
            {
                BLL.Sys_log log = new BLL.Sys_log();

                DataSet ds = log.GetLogtype();

                StringBuilder str = new StringBuilder();

                str.Append("[");

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    str.Append("{value:'" + ds.Tables[0].Rows[i]["EventType"].ToString() + "',text:'" + ds.Tables[0].Rows[i]["EventType"] + "'},");
                }
                str.Replace(",", "", str.Length - 1, 1);
                str.Append("]");

                context.Response.Write(str);
            }
        }
Ejemplo n.º 13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            HttpRequest request = context.Request;

            if (request["Action"] == "login")
            {
                BLL.hr_employee emp = new BLL.hr_employee();

                string username = PageValidate.InputText(request["username"], 255);
                //string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");
                string password = PageValidate.InputText(request["password"], 255);
                string validate = PageValidate.InputText(request["validate"], 255);

                if (!string.IsNullOrEmpty(validate) && !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
                {
                    if (validate == context.Session["CheckCode"].ToString() || validate == context.Session["CheckCode"].ToString().ToLower())
                    {
                        DataSet ds = emp.GetList(" uid='" + username + "' and pwd='" + password + "'");
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            if (ds.Tables[0].Rows[0]["canlogin"].ToString() == "1")
                            {
                                string userid = ds.Tables[0].Rows[0]["ID"].ToString();
                                context.Response.Cookies["UserID"].Value = userid;
                                //FormsAuthentication.RedirectFromLoginPage(userid, false);
                                FormsAuthentication.SetAuthCookie(userid, true);

                                //日志
                                BLL.Sys_log   log      = new BLL.Sys_log();
                                Model.Sys_log modellog = new Model.Sys_log();
                                modellog.EventType = "系统登录";

                                modellog.EventDate = DateTime.Now;
                                modellog.UserID    = int.Parse(userid);
                                modellog.UserName  = ds.Tables[0].Rows[0]["name"].ToString();
                                modellog.IPStreet  = request.UserHostAddress;

                                log.Add(modellog);

                                //online
                                BLL.Sys_online   sol   = new BLL.Sys_online();
                                Model.Sys_online model = new Model.Sys_online();

                                model.UserName    = ds.Tables[0].Rows[0]["name"].ToString();
                                model.UserID      = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                                model.LastLogTime = DateTime.Now;

                                DataSet ds1 = sol.GetList(" UserID=" + ds.Tables[0].Rows[0]["id"].ToString());

                                //添加当前用户信息
                                if (ds1.Tables[0].Rows.Count > 0)
                                {
                                    sol.Update(model, " UserID=" + ds.Tables[0].Rows[0]["id"].ToString());
                                }
                                else
                                {
                                    sol.Add(model);
                                }
                                //删除超时用户
                                sol.Delete(" LastLogTime<DATEADD(MI,-1,getdate())");

                                //验证完毕,允许登录
                                context.Response.Write("2");
                            }
                            else
                            {
                                context.Response.Write("4");//不允许登录
                            }
                        }
                        else
                        {
                            context.Response.Write("1");//用户名或密码错误
                        }
                    }
                    else
                    {
                        context.Response.Write("0");//验证码错误
                    }
                }
                else
                {
                    context.Response.Write("999");//系统数据错误
                }
            }
            if (request["Action"] == "logout")
            {
                HttpCookie oldcookie = request.Cookies["UserID"];
                context.Response.Cookies["UserID"].Value = "";
                FormsAuthentication.SignOut();
                context.Response.Write("true");

                //online
                BLL.Sys_online sol = new BLL.Sys_online();
                try
                {
                    if (!string.IsNullOrEmpty(oldcookie.Value))
                    {
                        sol.Delete(" UserID=" + oldcookie.Value);
                    }
                }
                catch
                {
                }
            }
            if (request["Action"] == "checkpwd")
            {
                BLL.hr_employee emp = new BLL.hr_employee();

                int    emp_id   = int.Parse(request.Cookies["UserID"].Value.ToString());
                string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5");


                DataSet ds = emp.GetList(string.Format("ID={0} and pwd='{1}'", emp_id, password));

                if (ds.Tables[0].Rows.Count > 0)
                {
                    context.Response.Write("{sucess:sucess}");
                }
                else
                {
                    context.Response.Write("{sucess:false}");
                }
            }
        }
Ejemplo n.º 14
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);
                }
            }
        }