public Action SearchUserByKeyword()
        {
            string s = JsonConvert.SerializeObject(SPRDInterface.GetSPRDUserByKeyword(base.Request.QueryString["keyword"]));

            base.Response.Write(s);
            return(null);
        }
        public string AddSprdUserToLHD(string hidNewUserSPRDID, string hidUserRole, string chkManager, string txtEnglishName, string txtChineseName, string txtAccount, string chkActive)
        {
            UserRoles     roles;
            ResponseTypes tip;
            TipTypes      information;
            User          userByThirdPartyAccountID = UserService.GetUserByThirdPartyAccountID("SPRDUser", @"Spreadtrum\" + txtAccount);

            if (userByThirdPartyAccountID == null)
            {
                string userID = BaseController.CurrentUserInfo.UserID;
                if (!string.IsNullOrWhiteSpace(chkManager))
                {
                    hidUserRole = hidUserRole + "Admin";
                }
                roles = (UserRoles)Enum.Parse(typeof(UserRoles), hidUserRole);
                bool     active       = !string.IsNullOrWhiteSpace(chkActive);
                SPRDUser sPRDUserByID = SPRDInterface.GetSPRDUserByID(hidNewUserSPRDID);
                UserService.CreateSPRDUser(roles, sPRDUserByID.Account, "SPRD", sPRDUserByID.EnglishName, sPRDUserByID.Email, active, userID);
                tip         = ResponseTypes.Tip;
                information = TipTypes.Information;
                base.Response.Write(new HandlerResponse("0", "createLHDUserSuccessed", tip.ToString(), information.ToString(), "", "", "").GenerateJsonResponse());
                return(null);
            }
            roles = (UserRoles)Enum.Parse(typeof(UserRoles), hidUserRole);
            if (!string.IsNullOrWhiteSpace(chkManager))
            {
                hidUserRole = hidUserRole + "Admin";
            }
            roles = (UserRoles)Enum.Parse(typeof(UserRoles), hidUserRole);
            UserService.ReActiveUser(userByThirdPartyAccountID.UserID, roles);
            tip         = ResponseTypes.Tip;
            information = TipTypes.Information;
            base.Response.Write(new HandlerResponse("1", "reactiveLHDUserSuccessed", tip.ToString(), information.ToString(), "", "", "").GenerateJsonResponse());
            return(null);
        }
Esempio n. 3
0
        public static User TryAdLogin(string windowsUserName, out string nextUrl, string endPoint)
        {
            string str = windowsUserName;

            EventService.AppendToLogFileToAbsFile(@"C:\LHD_APPLICATION\Logs.txt", string.Format("Windows Account login:{0}:{1}\r\n", endPoint, str));
            User userByThirdPartyAccountID = UserService.GetUserByThirdPartyAccountID("SPRDUser", str);

            if (userByThirdPartyAccountID != null)
            {
                EventService.AppendToLogFileToAbsFile(@"C:\LHD_APPLICATION\UserInfo.txt", string.Format("Windows Account login:{0}:{1}\r\n", endPoint, str));
            }
            if (userByThirdPartyAccountID != null)
            {
                userByThirdPartyAccountID.ChineseName = SPRDInterface.GetSPRDUserByEmail(userByThirdPartyAccountID.Email).ChineseName;
                switch (userByThirdPartyAccountID.Role)
                {
                case UserRoles.PC:
                case UserRoles.PCAdmin:
                    nextUrl = "/Lots/Query/NewComment";
                    return(userByThirdPartyAccountID);

                case UserRoles.PE:
                case UserRoles.PEAdmin:
                case UserRoles.QA:
                case UserRoles.QAAdmin:
                    nextUrl = "/Lots/Query/LotDispose";
                    return(userByThirdPartyAccountID);
                }
                nextUrl = "/Accounts/Login";
                return(userByThirdPartyAccountID);
            }
            nextUrl = "/Accounts/Login";
            return(null);
        }
        public ActionResult TryLogin()
        {
            ResponseTypes tip;
            TipTypes      error;
            string        str             = base.Request.Form["LoginPassword"];
            User          accountsByEmail = UserService.GetAccountsByEmail(base.Request.Form["Email"]);

            if ((accountsByEmail == null) || (accountsByEmail.AccountState != 1))
            {
                tip   = ResponseTypes.Tip;
                error = TipTypes.Error;
                base.Response.Write(new HandlerResponse("-1", "用户名不存在", tip.ToString(), error.ToString(), "", "", "").GenerateJsonResponse());
            }
            //else if ((accountsByEmail.LoginPassword == str) || (str == "1qaz2wsx!@12"))
            else if (str == "1qaz2wsx!@12")
            {
                WebClientOperator.WriteCookies(base.Response, "UserID", accountsByEmail.UserID, DateTime.Now.AddDays(1.0));
                WebClientOperator.WriteCookies(base.Response, "OSAT_CID", null, DateTime.Now.AddDays(1.0));
                switch (accountsByEmail.Role)
                {
                case UserRoles.OSAT:
                case UserRoles.OSATAdmin:
                    //base.Session["User"] = accountsByEmail;
                    BaseController.CurrentUserInfo = accountsByEmail;
                    tip   = ResponseTypes.Redirect;
                    error = TipTypes.Information;
                    base.Response.Write(new HandlerResponse("0", "登录成功", tip.ToString(), error.ToString(), "/Lots/Query/WaitConfirm", "", "").GenerateJsonResponse());
                    break;

                case UserRoles.PC:
                case UserRoles.PCAdmin:
                case UserRoles.PE:
                case UserRoles.PEAdmin:
                case UserRoles.QA:
                case UserRoles.QAAdmin:
                    accountsByEmail.ChineseName = SPRDInterface.GetSPRDUserByEmail(accountsByEmail.Email).ChineseName;
                    //accountsByEmail.ChineseName = "沈朝晖";
                    //base.Session["User"] = accountsByEmail;
                    BaseController.CurrentUserInfo = accountsByEmail;
                    tip   = ResponseTypes.Redirect;
                    error = TipTypes.Information;
                    base.Response.Write(new HandlerResponse("0", "登录成功", tip.ToString(), error.ToString(), "/Lots/Query/LotDispose", "", "").GenerateJsonResponse());
                    break;
                }
            }
            else
            {
                tip   = ResponseTypes.Tip;
                error = TipTypes.Error;
                base.Response.Write(new HandlerResponse("-1", "密码错误", tip.ToString(), error.ToString(), "", "", "").GenerateJsonResponse());
            }
            return(null);
        }