Ejemplo n.º 1
0
        public ActionResult Login_SureClick(tblUserInfo model)
        {
            //if (DateTime.Now > Convert.ToDateTime("2016-12-1"))
            //{
            //    X.Msg.Alert("注意", "系统已过期!").Show();
            //    return this.Direct();
            //}
            //ScanFoundDelTask task = new ScanFoundDelTask();
            //task.ScanTask();
            UserInfoManage userManage = new UserInfoManage();
            //userManage.Test();
            //return this.Direct();
            string s = userManage.UserLogin(model, Response);

            try
            {
                long lUserID = Convert.ToInt64(s);
                return(RedirectToAction("Index", "MainPage", new { area = "adminMain" }));
            }
            catch
            {
                X.Msg.Alert("错误", s).Show();
                return(this.Direct());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 用户登录成功,将ID等相关重要信息写入cookie中
        /// </summary>
        private void LoginConfirm(tblUserInfo model, HttpResponseBase Response)
        {
            CryptManage crypt  = new CryptManage();
            HttpCookie  cookie = new HttpCookie("LoginUser");

            cookie.Expires = DateTime.Now.AddMinutes(30);

            DepartmentInfoDataTreeManage tree   = new DepartmentInfoDataTreeManage();
            tblDepartmentInfo            parent = tree.GetFirstParent(Convert.ToInt64(model.UserIDepartmentIID));

            cookie.Values.Add("ID", crypt.Encrypto(model.ID.ToString()));
            cookie.Values.Add("UserName", HttpUtility.UrlEncode(model.Name));
            cookie.Values.Add("RegisterName", HttpUtility.UrlEncode(model.UserICode));
            cookie.Values.Add("UserDuty", HttpUtility.UrlEncode(model.DutyInfo.Name));
            cookie.Values.Add("DepartmentID", crypt.Encrypto(model.UserIDepartmentIID.ToString()));
            if (parent != null)
            {
                cookie.Values.Add("ParentDepartmentID", crypt.Encrypto(parent.ID.ToString()));
                cookie.Values.Add("UserGxID", crypt.Encrypto(parent.GxID.ToString()));
            }
            else
            {
                cookie.Values.Add("ParentDepartmentID", crypt.Encrypto("0"));
                cookie.Values.Add("UserGxID", crypt.Encrypto("0"));
            }
            string sUserRoles     = string.Join(CosValue.SPLITOPERATOR2.ToString(), model.authorRelations.Select(x => x.author.ID).ToArray());
            string sUserRoleNames = HttpUtility.UrlEncode(string.Join(CosValue.SPLITOPERATOR1.ToString(), model.authorRelations.Select(x => x.author.Name).ToArray()));

            cookie.Values.Add("UserRoles", crypt.Encrypto(sUserRoles));
            cookie.Values.Add("UserRoleNames", sUserRoleNames);

            Response.Cookies.Add(cookie);
        }
Ejemplo n.º 3
0
        public tblUserInfo GetOneUserModel(string sUserID)
        {
            tblUserInfo model = GetSpecialModelFromCurrentID(sUserID);

            model.UserIPsd = GetRealPass(model.UserIPsd);
            return(model);
        }
Ejemplo n.º 4
0
        private void btnContinue_Click(object sender, EventArgs e)
        {
            try
            {
                newUser = new tblUserInfo();
                //Put code here
                //Go to next page, but check required fields FIRST
                //Also check if username and email are already TAKEN


                if (txtUsername.Text.Trim() != "")  //if something is in it
                {
                    newUser.UserName = txtUsername.Text.Trim();
                }

                newUser.Email       = txtEmail.Text;
                newUser.Password    = txtPassword.Text;
                newUser.First_Name  = "Tri";
                newUser.Middle_Name = "Xuan";
                newUser.Last_Name   = "Le";

                //All good?
                SetContentView(Resource.Layout.RegisterBasicInfo);
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show();
            }
        }
Ejemplo n.º 5
0
        public int UpdatePassword(ChangePasswordViewModel uv)
        {
            tblUserInfo tb = _db.tblUserInfoes.Where(u => u.EmailId == uv.EmailId).FirstOrDefault();

            tb.Password = uv.NewPassword;


            return(_db.SaveChanges());
        }
Ejemplo n.º 6
0
        public ActionResult UserInfo_AddClickDirectMethod(string sData)
        {
            tblUserInfo model = JSON.Deserialize <tblUserInfo>(sData);

            if ((model.UserIDepartmentIID == 0) || (model.UserIDepartmentIID == -1) || (model.UserIDepartmentIID == null))
            {
                X.Msg.Alert("注意", "请先选择部门!").Show();
                return(this.Direct());
            }
            return(OpenMoreWindow("0", null, model.UserIDepartmentIID.ToString()));
        }
Ejemplo n.º 7
0
        public bool checkUser(ChangePasswordViewModel uv)
        {
            tblUserInfo tb = _db.tblUserInfoes.Where(u => u.EmailId == uv.EmailId && u.Password == uv.OldPassword).FirstOrDefault();

            if (tb != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public ActionResult WindowSaveClick(tblUserInfo model, string PanelID, string ParentVariable)
        {
            GetParentVariable(ParentVariable);
            string ss = ParentVar.areaName + CosValue.SPLITOPERATOR1 + ParentVar.controlName + CosValue.SPLITOPERATOR1 + ParentVar.actionName;
            string s  = "var i = 0; var sSelZYs = \"\"; var sSelNames = \"\";";

            s = s + "while (i < App." + PanelID + "_NowZYStore" + ".getCount()) { sSelZYs = sSelZYs + App." + PanelID + "_NowZYStore" + ".getAt(i).get('ID') + \",\";";
            s = s + "sSelNames = sSelNames + App." + PanelID + "_NowZYStore" + ".getAt(i).get('Name') + \",\";i++; } ";
            s = s + "sSelZYs = sSelZYs.slice(0, sSelZYs.length - 1);sSelNames = sSelNames.slice(0, sSelNames.length - 1);";
            s = s + " var ss='" + ss + "'+'|'+sSelZYs+'.'+sSelNames+'|';";
            s = s + "App." + PanelID + "_ParentVariable.setValue(ss);";
            X.AddScript(s);
            SetHiddenValue(PanelID + "_ExitCode", "1");
            return(this.Direct());
        }
        public ActionResult ForgetPassword(string Email)
        {
            if (ModelState.IsValid)
            {
                //https://www.google.com/settings/security/lesssecureapps
                //Make Access for less secure apps=true
                //sender email
                //sending email
                string from = "*****@*****.**";
                using (MailMessage mail = new MailMessage(from, Email))
                {
                    try
                    {
                        mail.Subject = "Password Recovery";
                        tblUserInfo tb = _db.tblUserInfoes.Where(u => u.EmailId == Email).FirstOrDefault();

                        mail.Body = "Your Password:"******"smtp.gmail.com";
                        smtp.EnableSsl = true;

                        //yourpassword
                        NetworkCredential networkCredential = new NetworkCredential(from, "!@#ossrp");
                        smtp.UseDefaultCredentials = false;
                        smtp.Credentials           = networkCredential;
                        smtp.Port = 587;
                        smtp.Send(mail);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        ViewBag.Message = "Sent";
                    }
                }
            }
            else
            {
                return(View());
            }

            return(View());
        }
Ejemplo n.º 10
0
        public int CreateUser(UserViewModel uv)
        {
            UserRole    ur = new UserRole();
            tblUserInfo tb = new tblUserInfo();

            tb.EmailId   = uv.EmailId;
            tb.Password  = uv.Password;
            tb.Firstname = uv.Firstname;
            tb.Lastname  = uv.Lastname;
            _db.tblUserInfoes.Add(tb);

            _db.SaveChanges();

            ur.RoleId = uv.RoleId;
            ur.UserId = tb.UserId;
            _db.UserRoles.Add(ur);
            return(_db.SaveChanges());
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 用户登录的判断函数正数
        /// </summary>
        /// <returns>登录不成功:错误提示字符串;登录成功:用户主ID</returns>
        public string UserLogin(tblUserInfo model, HttpResponseBase Response, string sValidateNum = "")
        {
            if (sValidateNum != "")
            {
                if (model.ValidatePic != sValidateNum)
                {
                    return("验证码输入错误!");
                }
            }

            if (!(string.IsNullOrEmpty(model.UserICode)))
            {
                Expression <Func <tblUserInfo, bool> > where = (c => c.UserICode == model.UserICode && c.DelFlag == false);
                List <tblUserInfo> result = GetRecord(where);
                if ((result == null) || (result.Count == 0))
                {
                    return("用户名不存在!");
                }
                //if (!result[0].VerifyFlag)
                //    return "该用户尚未审核!";
                if (GetRealPass(result[0].UserIPsd) == model.UserIPsd)
                {
                    if (result[0].authorRelations.Count == 0)
                    {
                        return("该用户尚无权限登录后台!");
                    }
                    else //登录成功,同时写入cookie
                    {
                        LoginConfirm(result[0], Response);
                        return(result[0].ID.ToString());
                    }
                }
                else
                {
                    return("密码输入错误!");
                }
            }
            else
            {
                return("用户名不存在!");
            }
        }
Ejemplo n.º 12
0
 private void ClientOnValidateLogin_UserInfoCompleted(object sender, ValidateLogin_UserInfoCompletedEventArgs validateLoginCompletedEventArgs)
 {
     if (validateLoginCompletedEventArgs.Error != null)
     {
         msg = validateLoginCompletedEventArgs.Error.Message;
     }
     else if (validateLoginCompletedEventArgs.Cancelled)
     {
         msg = "Request was cancelled.";
     }
     else
     {
         user = validateLoginCompletedEventArgs.Result;
         user.LastLoginDate  = DateTime.Now;
         user.LastActiveDate = DateTime.Now;
         _client.UpdateRecord_UserInfoAsync(user);
         msg = "Login Successful!";
     }
     RunOnUiThread(() => Toast.MakeText(this, msg, ToastLength.Short).Show());
 }
Ejemplo n.º 13
0
        protected override bool SetSearchWhere(string sData)
        {
            tblUserInfo   model  = JSON.Deserialize <tblUserInfo>(sData);
            List <string> names  = new List <string>();
            List <string> values = new List <string>();
            List <string> signs  = new List <string>();

            if ((model.Name != "") && (model.Name != null))
            {
                names.Add("Name"); values.Add(model.Name); signs.Add(SIGN.Like.ToString());
            }
            if ((model.SearchVerifyFlag != null))
            {
                names.Add("VerifyFlag"); values.Add(model.SearchVerifyFlag.ToString()); signs.Add(SIGN.Equal.ToString());
            }
            if ((model.UserIDutyIID != 0) && (model.UserIDutyIID != null))
            {
                names.Add("UserIDutyIID"); values.Add(model.UserIDutyIID.ToString()); signs.Add(SIGN.Equal.ToString());
            }
            if ((model.SearchDepartmentIDs != "0") && (model.SearchDepartmentIDs != null) && (model.SearchDepartmentIDs != "-1"))
            {
                names.Add("UserIDepartmentIID"); values.Add(model.SearchDepartmentIDs); signs.Add(SIGN.In.ToString());
            }
            if ((model.UserIDepartmentIID != 0) && (model.UserIDepartmentIID != null) && (model.UserIDepartmentIID != -1))
            {
                names.Add("UserIDepartmentIID"); values.Add(GetTreeManage("DepartmentInfo").GetAllLeaf(model.UserIDepartmentIID)); signs.Add(SIGN.In.ToString());
            }

            if ((model.UserIMobilePhone != "") && (model.UserIMobilePhone != null))
            {
                names.Add("UserIMobilePhone"); values.Add(model.UserIMobilePhone); signs.Add(SIGN.Equal.ToString());
            }

            SetHiddenValue(sDataListName + "_NowNames", string.Join(CosValue.SPLITOPERATOR1.ToString(), names.ToArray()));
            SetHiddenValue(sDataListName + "_NowValues", string.Join(CosValue.SPLITOPERATOR1.ToString(), values.ToArray()));
            SetHiddenValue(sDataListName + "_NowSigns", string.Join(CosValue.SPLITOPERATOR1.ToString(), signs.ToArray()));

            return(true);
        }
Ejemplo n.º 14
0
        public ActionResult Login(LoginViewModel l, string ReturnUrl = "")
        {
            //ViewBag.Roles = rdb.GetAllRoles();
            bool i = udb.CheckUserLogin(l);

            if (i)
            {
                Session.Add("emailid", l.EmailId);
                FormsAuthentication.SetAuthCookie(l.EmailId, true);
                if (Url.IsLocalUrl(ReturnUrl))
                {
                    return(Redirect(ReturnUrl));
                }
                else
                {
                    tblUserInfo tb = _db.tblUserInfoes.Where(u => u.EmailId == l.EmailId && u.Password == l.Password).FirstOrDefault();

                    MyRoleProvider mp = new MyRoleProvider();
                    if (mp.IsUserInRole(l.EmailId, "Teacher") == true)
                    {
                        //if (User.IsInRole("Teacher"))
                        //{
                        return(RedirectToAction("Index", "Tutor"));
                    }
                    else if (mp.IsUserInRole(l.EmailId, "Student") == true)
                    {
                        return(RedirectToAction("index", "Student"));
                    }
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalid User");
            }

            return(View());
        }
Ejemplo n.º 15
0
        private async Task <tblUserProfile> getUserProfile()
        {
            long id = session.GetLong("userid", -1);

            if (session.GetLong("userid", -1) > 0)
            {
                _client.ReadRecord_UserProfileAsync(session.GetLong("userid", -1));
                //Figure out a better way to wait and break out
                while (msg == null || msg != "Read UserProfile Successful!")
                {
                    await delayTask();

                    if (msg != null && msg != "Read UserProfile Successful!")
                    {
                        break;  //Error
                    }
                }

                if (msg == "Read UserProfile Successful!")
                {
                    ISharedPreferencesEditor session_editor = session.Edit();
                    session_editor.PutString("UserProfile", JsonConvert.SerializeObject(userProfile));
                    session_editor.Commit();
                    return(userProfile);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                if (Intent.Extras.ContainsKey("UserInfo"))
                {
                    var         resultData = Intent.GetStringExtra("UserInfo");
                    tblUserInfo userInfo   = JsonConvert.DeserializeObject <tblUserInfo>(resultData);
                    _client.ReadRecord_UserProfileAsync(userInfo.UserID);
                    //Figure out a better way to wait and break out
                    while (msg == null || msg != "Read UserProfile Successful!")
                    {
                        await delayTask();

                        if (msg != null && msg != "Read UserProfile Successful!")
                        {
                            break;  //Error
                        }
                    }
                    if (msg == "Read UserProfile Successful!")
                    {
                        ISharedPreferencesEditor session_editor = session.Edit();
                        session_editor.PutString("UserProfile", JsonConvert.SerializeObject(userProfile));
                        session_editor.Commit();
                        return(userProfile);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 16
0
        public override ActionResult WindowCommonShow(string PanelID, string ParentVariable, string ParentKey)
        {
            setParentVariable("UserControl", "WinUserMore", "WinUserMore_SelectDepartmentChange", null, "DepartmentInfo");
            SetHiddenValue(PanelID + "_cmbDepartmentInfo_ParentVariable", ParentVar.DefaultVal);

            setParentVariable("UserControl", "WinUserMore", "WinUserMore_SelectDutyChange", null, "DutyInfo");
            SetHiddenValue(PanelID + "_cmbDutyInfo_ParentVariable", ParentVar.DefaultVal);

            UserInfoManage userMan = new UserInfoManage();

            GetParentVariable(ParentVariable);
            //如果userId中包含Row,说明是从DataList传来的selection
            //否则就应该只是userinfo的一个主键值
            string sUserID = ParentVar.transValue;

            if (ParentVar.transValue.Contains("Row"))
            {
                UserInfoDataListManage userDataListMan = new UserInfoDataListManage();
                userDataListMan.InitSelection(ParentVar.transValue);
                sUserID = userDataListMan.sRowNowID;
            }
            tblUserInfo model = userMan.GetOneUserModel(sUserID);

            //如果是新增,model.ID=0,那么获取传过来的departmentId和DutyId
            if (model.ID == 0)
            {
                string[] ss = ParentKey.Split(CosValue.SPLITOPERATOR1);
                model.UserIDepartmentIID = Convert.ToInt64(ss[0]);
                if (ss.Length > 1)
                {
                    model.UserIDutyIID = Convert.ToInt64(ss[1]);
                }
                else
                {
                    model.UserIDutyIID = 0;
                }
            }
            var form = this.GetCmp <FormPanel>(PanelID + "_Form");

            form.SetValues(model);

            SetHiddenValue(PanelID + "_ExitCode", "0");

            var store = this.GetCmp <Store>(PanelID + "_AllRoleStore");

            store.LoadProxy();
            store = this.GetCmp <Store>(PanelID + "_NowRoleStore");
            store.LoadProxy();

            SetThreeListComboValue(PanelID + "_cmbDepartmentInfo", model.UserIDepartmentIID.ToString());

            if ((model.UserIDutyIID == 0) || (model.UserIDutyIID == null))
            {
                SetComboValue(PanelID + "_cmbDutyInfo", "-1", true);
            }
            else
            {
                SetComboValue(PanelID + "_cmbDutyInfo", model.UserIDutyIID.ToString(), true);
            }

            Paging <object> obj = userMan.GetNowAuthorStore(sUserID);

            SetHiddenValue(PanelID + "_OriginAuthorIDs", string.Join(CosValue.SPLITOPERATOR2.ToString(), userMan.NowAuthorIDs.ToArray()));

            return(this.Direct());
        }
Ejemplo n.º 17
0
        public ActionResult WindowSaveClick(tblUserInfo model, string PanelID, string ParentVariable)//, string sSelAuthors, string sSetAuthors, string sOriginAuthors)
        {
            DirectResult result = new DirectResult();

            result.Success = true;

            UserInfoManage userMan = new UserInfoManage();

            //校验用户名和密码是否填写
            if ((model.UserICode == null) || (model.UserICode == "") || (model.UserIPsd == "") || (model.UserIPsd == null))
            {
                result.ErrorMessage = "用户名和密码不能为空!";
                result.Success      = false;
                return(result);
            }
            //校验如果用户名修改了,是否会有重复
            Expression <Func <tblUserInfo, bool> > where = (c => c.UserICode == model.UserICode && c.DelFlag == false);
            List <tblUserInfo> list = userMan.GetRecord(where);

            if ((list != null) && (list.Count > 0))
            {
                if (list[0].ID != model.ID)
                {
                    result.ErrorMessage = "用户名已经存在,不能使用!";
                    result.Success      = false;
                    return(result);
                }
            }

            model.UserIPsd = userMan.GetSecretPass(model.UserIPsd);
            long lUserID = model.ID;

            if (model.UserIDutyIID == 0)
            {
                model.UserIDutyIID = null;
            }
            if (model.UserIDepartmentIID == 0)
            {
                model.UserIDepartmentIID  = null;
                model.WholeDepartmentName = "";
            }
            else
            {
                DepartmentInfoManage departmentMan = new DepartmentInfoManage();
                model.WholeDepartmentName = departmentMan.GetWholeDepartmentName(Convert.ToInt64(model.UserIDepartmentIID));
            }

            if (lUserID == 0)
            {
                lUserID = userMan.AddOneRecord(model);
            }
            else
            {
                userMan.SaveOneRecord(model);
            }

            if (lUserID == 0)
            {
                result.ErrorMessage = "保存出错!";
                result.Success      = false;
                return(result);
            }
            X.AddScript("var i = 0; var sSelAuthors = \"\"; while (i < App." + PanelID + "_NowRoleStore" + ".getCount()) { sSelAuthors = sSelAuthors + App." + PanelID + "_NowRoleStore" + ".getAt(i).get('ID') + \",\"; i++; } sSelAuthors = sSelAuthors.slice(0, sSelAuthors.length - 1);");
            X.AddScript("App.direct.UserControl.WinUserMore_SaveAuthorsDirectMethod(" + lUserID + ",sSelAuthors, App." + PanelID + "_SetAuthorID" + ".getValue(),App." + PanelID + "_OriginAuthorIDs" + ".getValue(),\"" + PanelID + "\");");
            return(result);
        }