Exemplo n.º 1
0
        //组织列表
        public string GetComList()
        {
            try
            {
                JArray arry = new JArray();

                HttpCookie cookie   = GetCookie();
                string     _key     = Tools.Tobyte64(cookie["mobileKey"]);
                string     _name    = cookie["name"];
                string     _comName = Request["comName"].Trim();

                //调用接口
                webService.Service1 wbs = new webService.Service1();
                DataTable           dt  = wbs.Getmidfulllistds(_key);                  //所有组织列表
                DataTable           dt1 = wbs.Getusermidpermds(_name, _key, _comName); //有权限的管理单元

                //比较筛选数据
                if (dt1.Rows.Count > 0 && dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt1.Rows.Count; i++)
                    {
                        for (int j = 0; j < dt.Rows.Count; j++)
                        {
                            if (dt.Rows[j]["Mid"].ToString() == dt1.Rows[i]["Mid"].ToString())
                            {
                                JObject json = new JObject();

                                json.Add("id", dt.Rows[j]["Mid"].ToString());
                                json.Add("pId", dt.Rows[j]["Fatherid"].ToString());
                                json.Add("fatherId", dt.Rows[j]["Fatherid"].ToString());
                                json.Add("name", dt.Rows[j]["Mancompany"].ToString());
                                json.Add("number", dt.Rows[j]["ManNumber"].ToString());
                                json.Add("isSub", dt.Rows[j]["IsSub"].ToString());
                                json.Add("status", dt.Rows[j]["Status"].ToString());
                                json.Add("property", dt.Rows[j]["Property"].ToString());
                                json.Add("EASnumber", dt.Rows[j]["EASnumber"].ToString());
                                json.Add("EASkcnumber", dt.Rows[j]["EASkcnumber"].ToString());

                                if ("远大住工" == json["name"].ToString().Trim())
                                {
                                    json.Add("open", true);//第一级默认展开
                                }

                                arry.Add(json);

                                break;
                            }
                        }
                    }
                }

                return(arry.ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        public string SavePwd()
        {
            try
            {
                HttpCookie cookie = GetCookie();

                string oldPwd  = Request["oldPwd"];
                string newPwd  = Request["newPwd"];
                string newPwd2 = Request["newPwd2"];

                if (newPwd.Contains(" "))
                {
                    return("密码不能存在空格字符!");
                }
                if (newPwd == "")
                {
                    return("密码不能为空!");
                }
                if (newPwd != newPwd2)
                {
                    return("两次密码不一致!");
                }

                //调用接口
                webService.Service1 wbs = new webService.Service1();
                DataTable           dt  = wbs.Getupdatepassdt(cookie["name"], oldPwd, newPwd, newPwd2);

                if (dt.Rows.Count > 0)
                {
                    string result = dt.Rows[0]["passdr"].ToString();
                    if ("密码修改成功!" == result.Trim())
                    {
                        if (System.Web.HttpContext.Current.Request.Cookies["HrLogin123"] != null)
                        {
                            var loginCookie = Request.Cookies["HrLogin123"];
                            loginCookie["pwd"] = Tools.Encrypt(newPwd);
                            Response.AppendCookie(loginCookie);
                        }
                    }

                    return(result);
                }

                return("修改失败!");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Exemplo n.º 3
0
        public string LoginBtn()
        {
            string username = Request["username"].Trim();
            string password = Request["password"].Trim();
            string status   = Request["status"];

            var json = new JObject();

            try
            {
                if (string.IsNullOrWhiteSpace(username) && string.IsNullOrWhiteSpace(password))
                {
                    json.Add("result", false);
                    json.Add("msg", "用户或密码为空!");
                }
                else
                {
                    //调用接口登录方法
                    webService.Service1 wbs     = new webService.Service1();
                    DataTable           logindt = wbs.Getlogindt(username, password);

                    if (logindt.Rows.Count > 0)
                    {
                        int mid = int.Parse(logindt.Rows[0]["mid"].ToString());

                        // 获取有权限管理单元
                        string    mids = "1";
                        DataTable dt   = wbs.Getmidfulllistdsbyusermid(username, int.Parse(logindt.Rows[0]["mid"].ToString()));
                        if (dt.Rows.Count > 0)
                        {
                            mids = dt.Rows[0]["midful"].ToString();
                        }

                        //设置管理单元集合缓存
                        DateTime _now    = DateTime.Now;
                        string   txtName = username + "#" + _now.ToString("yyyy-MM-dd") + "#" + _now.Millisecond;
                        string   txtPath = Server.MapPath("~/MidsTxt/");

                        GisHelper.CheckTxt(username, txtPath);
                        GisHelper.WriteTxt(txtName, mids, txtPath);

                        // 设置cookie
                        SetLoginCookie(username, password, status);
                        SetCookie(logindt, txtName);

                        json.Add("result", true);
                        json.Add("msg", "登录成功!");
                        json.Add("url", "../Main/Index");
                    }
                    else
                    {
                        json.Add("result", false);
                        json.Add("msg", "用户或密码错误!");
                    }
                }
            }
            catch (Exception ex)
            {
                json.Add("result", false);
                json.Add("msg", ex.Message);
            }

            return(json.ToString());
        }