Beispiel #1
0
        public string LogOn(string userName, string userPwd)
        {
            /* PersonManagment pm = new PersonManagment();
             * Person_Info p = pm.Get_Person(userName);
             * if (p == null)
             *   return "Index";
             *
             * else
             * {
             *   CWFEngine.authority_params["currentuser"] = userName;
             *   Session["User"] = p;
             *   return "/Main/Index0";
             * }*/
            int             a;
            PersonManagment pm  = new PersonManagment();
            MD5             md5 = new MD5CryptoServiceProvider();

            byte[] result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(userPwd.Trim()));
            // pm.ModifyPerson_Pwd(userName, result);
            Person_Info p = pm.Get_Person(userName);

            if (p == null)
            {
                return("Index");
            }
            else
            {
                byte[] r          = p.Person_Pwd;
                string userPwdMD5 = System.Text.UTF8Encoding.Unicode.GetString(result);
                string userPwDb   = System.Text.UTF8Encoding.Unicode.GetString(r);
                if (!userPwDb.Equals(userPwdMD5))
                {
                    return("Index");
                }
                //// string =System.Text.Encoding.Default.GetString(result);



                else
                {
                    Dictionary <string, object> dict_authority = new Dictionary <string, object>();
                    dict_authority["currentuser"] = userName;

                    Session["authority"] = dict_authority;

                    CWFEngine.authority_params = "authority";

                    Session["User"] = p;
                    return("/Main/Index0");
                }
            }
        }
Beispiel #2
0
 public int AddPerson_info(Person_Info New_Person)
 {
     try
     {
         using (var db = base.NewDB())
         {
             Person_Info newP = db.Persons.Add(New_Person);
             db.SaveChanges();
             return(newP.Person_Id);
         }
     }
     catch
     {
         return(0);
     }
 }
Beispiel #3
0
        /*功能:往数据库添加用户基本信息,并设置用户部门、角色、专业和系统菜单信息
         * 参数: p           新用户Person_Info对象
         *       Depart_id   所属部门Id
         *       Role_IDs    分配的所有角色Id集合
         *       Speciaty_IDs 所属专业Id集合
         *       Menu_IDs     分配系统菜单Id集合
         *返回值:bool
         * */

        public bool Add_Person(Person_Info p, int Depart_id, List <int> Role_IDs, List <int> EquipArchi_IDs, List <int> Speciaty_IDs, List <int> Menu_IDs)
        {
            try
            {
                int NewpP_id = Persons.AddPerson_info(p);
                Persons.Person_LinkDepart(NewpP_id, Depart_id);
                Persons.Person_LinkSpeciaties(NewpP_id, Speciaty_IDs);
                Persons.Person_LinkEAs(NewpP_id, EquipArchi_IDs);
                List <int> Zz_IDs = Get_EquipArchi_Allleafs(EquipArchi_IDs);
                Persons.Person_LinkEquip(NewpP_id, Zz_IDs, Speciaty_IDs);
                Persons.Person_LinkRole(NewpP_id, Role_IDs);
                Persons.Person_LinkMenus(NewpP_id, Menu_IDs);
                return(true);
            }
            catch { return(false); }
        }
Beispiel #4
0
        /*功能:修改用户的基本信息,并设置用户新的部门、角色、专业和系统菜单信息
         * 参数: p          提交的用户基本新信息Person_Info对象
         *       Depart_id   新的所属部门Id
         *       Role_IDs    新分配的所有角色Id集合
         *       Speciaty_IDs 新的所属专业Id集合
         *       Menu_IDs     新分配的系统菜单Id集合
         *返回值:bool
         * */
        public bool Update_Person(Person_Info p, int Depart_id, List <int> Role_IDs, List <int> EquipArchi_IDs, List <int> Speciaty_IDs, List <int> Menu_IDs)
        {
            try
            {
                Persons.ModifyPerson_info(p);

                Persons.Person_LinkDepart(p.Person_Id, Depart_id);
                Persons.Person_LinkSpeciaties(p.Person_Id, Speciaty_IDs);
                Persons.Person_LinkEAs(p.Person_Id, EquipArchi_IDs);
                List <int> Zz_IDs = Get_EquipArchi_Allleafs(EquipArchi_IDs);
                Persons.Person_LinkEquip(p.Person_Id, Zz_IDs, Speciaty_IDs);
                Persons.Person_LinkRole(p.Person_Id, Role_IDs);
                Persons.Person_LinkMenus(p.Person_Id, Menu_IDs);
                return(true);
            }
            catch { return(false); }
        }
Beispiel #5
0
 public bool AttachtoMenu(int personid, int menuid)
 {
     try
     {
         using (var db = base.NewDB())
         {
             Person_Info person = db.Persons.Where(s => s.Person_Id == personid).First();
             Menu        menu   = db.Sys_Menus.Where(s => s.Menu_Id == menuid).First();
             person.Person_Menus.Add(menu);
             db.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
Beispiel #6
0
        public string ModifyPWD(string userName, string userPwd, string newUserPWd)
        {
            int             a;
            PersonManagment pm  = new PersonManagment();
            MD5             md5 = new MD5CryptoServiceProvider();

            byte[] result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(userPwd.Trim()));
            //pm.ModifyPerson_Pwd(userName, result);
            Person_Info p = pm.Get_Person(userName);

            if (p == null)
            {
                return("ModifyPWD_Index");
            }
            else
            {
                byte[] r          = p.Person_Pwd;
                string userPwdMD5 = System.Text.UTF8Encoding.Unicode.GetString(result);
                string userPwDb   = System.Text.UTF8Encoding.Unicode.GetString(r);
                if (!userPwDb.Equals(userPwdMD5))
                {
                    return("ModifyPWD_Index");
                }
                // string =System.Text.Encoding.Default.GetString(result);



                else
                {
                    result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(newUserPWd.Trim()));
                    if (pm.ModifyPerson_Pwd(userName, result))
                    {
                        return("/Main/Home");
                    }
                    else
                    {
                        return("ModifyPWD_Index");
                    }
                }
            }
        }
Beispiel #7
0
 public bool ModifyPerson_info(Person_Info New_Person)
 {
     using (var db = base.NewDB())
     {
         try
         {
             var P = db.Persons.Where(a => a.Person_Id == New_Person.Person_Id).First();
             if (P == null)
             {
                 return(false);
             }
             else
             {
                 P.Person_Name = New_Person.Person_Name;
                 //   P.Person_Pwd = New_Person.Person_Pwd;
                 P.Person_tel  = New_Person.Person_tel;
                 P.Person_mail = New_Person.Person_mail;
                 db.SaveChanges();
                 return(true);
             }
         }
         catch { return(false); }
     }
 }
        public string submitNewUser(string json1)
        {
            try
            {
                SpeciatyManagment SM   = new SpeciatyManagment();
                PersonManagment   PM   = new PersonManagment();
                Person_Info       newP = new Person_Info();
                JObject           item = (JObject)JsonConvert.DeserializeObject(json1);
                newP.Person_Name = item["UserName"].ToString();

                /*0710添加*/
                var    pwd    = item["UserPwd"].ToString();
                MD5    md5    = new MD5CryptoServiceProvider();
                byte[] result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(pwd.Trim()));
                newP.Person_Pwd = result;
                /*0710end*/

                newP.Person_tel  = item["UserTel"].ToString();
                newP.Person_mail = item["UserMail"].ToString();
                var equipArchiStr = item["UserEquipArchiSel"].ToString();
                var roleStr       = item["UserRole"].ToString();
                var speciatyStr   = item["UserSpeciatySel"].ToString();
                var MenuStr       = item["UserMenus"].ToString();

                int Depart_id = Convert.ToInt32(item["UserDepartId"].ToString());

                List <int> EquipArchiList = new List <int>();
                if (equipArchiStr != "")
                {
                    string[] s = equipArchiStr.Split(new char[] { ',' });
                    for (int i = 0; i < s.Length; i++)
                    {
                        EquipArchiList.Add(Convert.ToInt32(s[i]));
                    }
                }

                /* List<int> SpeciatyList = new List<int>();
                 * if (speciatyStr != "")
                 * {
                 *   string[] s = speciatyStr.Split(new char[] { ',' });
                 *   for (int i = 0; i < s.Length; i++)
                 *   { SpeciatyList.Add(Convert.ToInt32(s[i])); }
                 * }*/
                List <int> SpeciatyList = new List <int>();
                if (speciatyStr != "")
                {
                    string[] s = speciatyStr.Split(new char[] { ',' });
                    for (int i = 0; i < s.Length; i++)
                    {
                        int id = Convert.ToInt16(s[i]);
                        List <Speciaty_Info> r = SM.GetChildsspecialty(id);
                        if (r == null)
                        {
                            if (SpeciatyList.Where(x => x == id).Count() == 0)
                            {
                                SpeciatyList.Add(Convert.ToInt32(s[i]));
                            }
                        }
                        else
                        {
                            if (SpeciatyList.Where(x => x == id).Count() == 0)
                            {
                                SpeciatyList.Add(Convert.ToInt32(s[i]));
                            }
                            foreach (var t in r)
                            {
                                if (SpeciatyList.Where(x => x == t.Specialty_Id).Count() == 0)
                                {
                                    SpeciatyList.Add(Convert.ToInt32(t.Specialty_Id));
                                }
                            }
                        }
                    }
                }


                List <int> MenuList = new List <int>();
                if (MenuStr != "")
                {
                    string[] s1 = MenuStr.Split(new char[] { ',' });
                    for (int i = 0; i < s1.Length; i++)
                    {
                        MenuList.Add(Convert.ToInt32(s1[i]));
                    }
                }
                List <int> RoleList = new List <int>();
                if (roleStr != "")
                {
                    string[] s2 = roleStr.Split(new char[] { ',' });
                    for (int i = 0; i < s2.Length; i++)
                    {
                        RoleList.Add(Convert.ToInt32(s2[i]));
                    }
                }
                PM.Add_Person(newP, Depart_id, RoleList, EquipArchiList, SpeciatyList, MenuList);  //保存基础信息

                return("保存成功!");
            }
            catch { return(""); };
        }
        public string submitUpdateUser(string json1)
        {
            try
            {
                SpeciatyManagment SM   = new SpeciatyManagment();
                PersonManagment   PM   = new PersonManagment();
                Person_Info       newP = new Person_Info();
                JObject           item = (JObject)JsonConvert.DeserializeObject(json1);
                newP.Person_Id   = Convert.ToInt32(item["UserId"].ToString());
                newP.Person_Name = item["UserName"].ToString();
                newP.Person_tel  = item["UserTel"].ToString();
                newP.Person_mail = item["UserMail"].ToString();
                var roleStr       = item["UserRole"].ToString();
                var speciatyStr   = item["UserSpeciatySel"].ToString();
                var MenuStr       = item["UserMenus"].ToString();
                var equipArchiStr = item["UserEquipArchiSel"].ToString();

                int        Depart_id      = Convert.ToInt32(item["UserDepartId"].ToString());
                List <int> EquipArchiList = new List <int>();
                if (equipArchiStr != "")
                {
                    string[] s = equipArchiStr.Split(new char[] { ',' });
                    for (int i = 0; i < s.Length; i++)
                    {
                        EquipArchiList.Add(Convert.ToInt32(s[i]));
                    }
                }


                /* List<int> SpeciatyList = new List<int>();
                 * if (speciatyStr != "")
                 * {
                 *   string[] s = speciatyStr.Split(new char[] { ',' });
                 *   for (int i = 0; i < s.Length; i++)
                 *   { SpeciatyList.Add(Convert.ToInt32(s[i])); }
                 * }*/
                List <int> SpeciatyList = new List <int>();
                if (speciatyStr != "")
                {
                    string[] s = speciatyStr.Split(new char[] { ',' });
                    for (int i = 0; i < s.Length; i++)
                    {
                        int id = Convert.ToInt16(s[i]);
                        List <Speciaty_Info> r = SM.GetChildsspecialty(id);
                        if (r == null)
                        {
                            if (SpeciatyList.Where(x => x == id).Count() == 0)
                            {
                                SpeciatyList.Add(Convert.ToInt32(s[i]));
                            }
                        }
                        else
                        {
                            if (SpeciatyList.Where(x => x == id).Count() == 0)
                            {
                                SpeciatyList.Add(Convert.ToInt32(s[i]));
                            }
                            foreach (var t in r)
                            {
                                if (SpeciatyList.Where(x => x == t.Specialty_Id).Count() == 0)
                                {
                                    SpeciatyList.Add(Convert.ToInt32(t.Specialty_Id));
                                }
                            }
                        }
                    }
                }

                List <int> MenuList = new List <int>();
                if (MenuStr != "")
                {
                    string[] s1 = MenuStr.Split(new char[] { ',' });
                    for (int i = 0; i < s1.Length; i++)
                    {
                        MenuList.Add(Convert.ToInt32(s1[i]));
                    }
                }

                List <int> RoleList = new List <int>();
                if (roleStr != "")
                {
                    string[] s2 = roleStr.Split(new char[] { ',' });
                    for (int i = 0; i < s2.Length; i++)
                    {
                        RoleList.Add(Convert.ToInt32(s2[i]));
                    }
                }

                PM.Update_Person(newP, Depart_id, RoleList, EquipArchiList, SpeciatyList, MenuList);     //保存基础信息

                return("用户信息修改成功!");
            }
            catch { return(""); };
        }