예제 #1
0
        private string SetPassWord(string pID, string pOldPWD, string pNewPWD)
        {
            string error    = "";
            string pNewPass = MD5Helper.Encryption(pNewPWD);

            //pOldPWD = MD5Helper.Encryption(pOldPWD);
            pOldPWD = EncryptManager.Hash(pOldPWD, HashProviderType.MD5);
            string res = "{success:false,msg:'保存失败'}";
            //组装参数
            UserInfo entity     = new UserInfo();
            var      serviceBll = new cUserService(CurrentUserInfo);

            entity = serviceBll.GetUserById(CurrentUserInfo, pID);
            string apPwd = serviceBll.GetPasswordFromAP(CurrentUserInfo.ClientID, pID);

            //if (pOldPWD == entity.User_Password)
            if (pOldPWD == apPwd)
            {
                entity.userRoleInfoList = new cUserService(CurrentUserInfo).GetUserRoles(pID, PageBase.JITPage.GetApplicationId());
                entity.User_Password    = pNewPass;
                entity.ModifyPassword   = true;
                //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error);
                bool bReturn = serviceBll.SetUserPwd(CurrentUserInfo, pNewPass, out error);
                res = "{success:true,msg:'" + error + "'}";
            }
            else
            {
                res = "{success:false,msg:'旧密码不正确'}";
            }
            return(res);
        }
예제 #2
0
        private string SetPassWord(string pRequest)
        {
            var    rp = pRequest.DeserializeJSONTo <APIRequest <SetPassWordRP> >();
            var    loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
            string error    = "";
            string pNewPass = MD5Helper.Encryption(rp.Parameters.pNewPWD);

            //pOldPWD = MD5Helper.Encryption(pOldPWD);
            rp.Parameters.pOldPWD = EncryptManager.Hash(rp.Parameters.pOldPWD, HashProviderType.MD5);
            string res = "{\"success\":\"false\",\"msg\":\"保存失败\"}";

            //组装参数
            JIT.CPOS.BS.Entity.User.UserInfo entity = new JIT.CPOS.BS.Entity.User.UserInfo();
            var serviceBll = new cUserService(loggingSessionInfo);

            entity = serviceBll.GetUserById(loggingSessionInfo, rp.Parameters.pID);
            string apPwd = serviceBll.GetPasswordFromAP(loggingSessionInfo.ClientID, rp.Parameters.pID);

            //if (pOldPWD == entity.User_Password)
            if (rp.Parameters.pOldPWD == apPwd)
            {
                entity.userRoleInfoList = new cUserService(loggingSessionInfo).GetUserRoles(rp.Parameters.pID);//, PageBase.JITPage.GetApplicationId()
                entity.User_Password    = pNewPass;
                entity.ModifyPassword   = true;
                //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error);
                bool bReturn = serviceBll.SetUserPwd(loggingSessionInfo, pNewPass, out error);
                res = "{\"success\":\"true\",\"msg\":\"" + error + "\"}";
            }
            else
            {
                res = "{\"success\":\"false\",\"msg\":\"旧密码不正确\"}";
            }
            return(res);
        }
예제 #3
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetPasswordRP> pRequest)
        {
            //基础数据初始化
            string            error             = "";
            EmptyResponseData emptyResponseData = new EmptyResponseData();

            try
            {
                if (pRequest.Parameters.NewPassword.Length < 6)
                {
                    throw new APIException("新密码不小于6位。")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          };
                }


                string newPassword = MD5Helper.Encryption(pRequest.Parameters.NewPassword);
                string oldPassword = EncryptManager.Hash(pRequest.Parameters.OldPassword, HashProviderType.MD5);

                //组装参数
                UserInfo entity     = new UserInfo();
                var      serviceBll = new cUserService(CurrentUserInfo);
                entity = serviceBll.GetUserById(CurrentUserInfo, CurrentUserInfo.UserID);
                string apPassword = serviceBll.GetPasswordFromAP(CurrentUserInfo.ClientID, CurrentUserInfo.UserID);

                if (oldPassword == apPassword)
                {
                    entity.userRoleInfoList = new cUserService(CurrentUserInfo).GetUserRoles(CurrentUserInfo.UserID, PageBase.JITPage.GetApplicationId());
                    entity.User_Password    = newPassword;
                    entity.ModifyPassword   = true;
                    //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error);
                    bool bReturn = serviceBll.SetUserPwd(CurrentUserInfo, newPassword, out error);
                    if (!bReturn)
                    {
                        throw new APIException(error)
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              };
                    }
                }
                else
                {
                    throw new APIException("旧密码不正确")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          };
                }
                return(emptyResponseData);
            }
            catch (APIException apiEx)
            {
                throw new APIException(apiEx.ErrorCode, apiEx.Message);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #4
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(this.tbOldPwd.Text.Trim()))
        {
            this.InfoBox.ShowPopError("旧密码不能为空");
            this.tbOldPwd.Focus();
            return;
        }
        if (string.IsNullOrEmpty(this.tbNewPwd.Text.Trim()))
        {
            this.InfoBox.ShowPopError("新密码不能为空");
            this.tbNewPwd.Focus();
            return;
        }
        if (this.tbNewPwd.Text.Trim() != this.tbNewPwd2.Text.Trim())
        {
            this.InfoBox.ShowPopError("新密码两次输入不一致");
            this.tbNewPwd2.Focus();
            return;
        }

        cUserService user_service = new cUserService();
        string       user_id      = this.loggingSessionInfo.CurrentUser.User_Id;
        UserInfo     user         = user_service.GetUserById(this.loggingSessionInfo, user_id);

        if (user == null)
        {
            this.InfoBox.ShowPopError("当前用户不存在");
            this.tbNewPwd.Focus();
            return;
        }
        string old_pwd = EncryptManager.Hash(this.tbOldPwd.Text.Trim(), HashProviderType.MD5);

        if (!old_pwd.Equals(user.User_Password))
        {
            this.InfoBox.ShowPopError("旧密码不正确");
            this.tbOldPwd.Focus();
            return;
        }
        string new_pwd = this.tbNewPwd.Text.Trim();

        if (!user_service.IsValidPassword(loggingSessionInfo, user, new_pwd))
        {
            this.InfoBox.ShowPopError("新密码无效");
            this.tbNewPwd.Focus();
            return;
        }

        if (user_service.ModifyUserPassword(this.loggingSessionInfo, user_id, new_pwd))
        {
            this.InfoBox.ShowPopInfo("密码修改成功");
            this.Response.Redirect("~/common/emtpy.aspx");
        }
        else
        {
            this.InfoBox.ShowPopError("密码修改失败");
        }
    }
예제 #5
0
        /// <summary>
        ///返回用户信息、客户信息及用户所属门店的信息集合。(C005-下载用户信息与所属门店关系接口)
        /// </summary>
        /// <param name="User_Id">用户标识</param>
        /// <param name="Customer_Id">客户标识</param>
        /// <returns>返回用户model对象</returns>
        public UserInfo GetUserInfoByUserId(string User_Id, string Customer_Id)
        {
            UserInfo           userInfo           = new UserInfo();
            cUserService       userServices       = new cUserService();
            LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo();

            loggingSessionInfo          = new BaseService().GetLoggingSessionInfoByCustomerId(Customer_Id);
            userInfo                    = userServices.GetUserById(loggingSessionInfo, User_Id);
            userInfo.LoggingManagerInfo = loggingSessionInfo.CurrentLoggingManager;
            userInfo.UnitList           = new UnitService().GetUnitListByUserId(loggingSessionInfo, User_Id);
            return(userInfo);
        }
예제 #6
0
    private void loadUser(string customer_id, string token)
    {
        try
        {
            //获取登录管理平台的用户信息
            AuthService AuthWebService = new AuthService();
            //设置地址
            AuthWebService.Url = ConfigurationManager.AppSettings["sso_url"].ToString() + "/AuthService.asmx";
            string str = AuthWebService.GetLoginUserInfo(token);

            cPos.Model.LoggingManager myLoggingManager = (cPos.Model.LoggingManager)cXMLService.Deserialize(str, typeof(cPos.Model.LoggingManager));

            //判断登录进来的用户是否存在,并且返回用户信息
            cPos.Service.cUserService userService    = new cUserService();
            LoggingSessionInfo        loggingSession = new LoggingSessionInfo();
            loggingSession.CurrentLoggingManager = myLoggingManager;
            if (!userService.IsExistUser(myLoggingManager))
            {
                this.lbErr.Text = "用户不存在,请与管理员联系";
                return;
            }
            cPos.Model.User.UserInfo login_user = userService.GetUserById(loggingSession, myLoggingManager.User_Id);
            loggingSession.CurrentUser = login_user;

            //SessionManager sm = new SessionManager();
            //sm.UserInfo = login_user;
            //sm.LoggingManager = myLoggingManager;
            //sm.loggingSessionInfo = loggingSession;

            this.Session["UserInfo"]           = login_user;
            this.Session["LoggingManager"]     = myLoggingManager;
            this.Session["loggingSessionInfo"] = loggingSession;

            //保存Cookie
            //HttpCookie cookie = new HttpCookie("DRP");
            //cookie.Values.Add("userid", login_user.User_Id);
            //cookie.Values.Add("username", login_user.User_Name);
            //cookie.Values.Add("languageid", ddlLanguage.SelectedItem.Value);
            //cookie.Expires = DateTime.Now.AddDays(7);
            //Response.AppendCookie(cookie);

            //清空密码
            login_user.User_Password = null;
            string go_url = "~/login/SelectRoleUnit.aspx?p=0";
            this.Response.Redirect(go_url);
        }
        catch (Exception ex)
        {
            PageLog.Current.Write(ex);
            lbErr.Text = "登录失败:" + ex.ToString();
        }
    }
        /// <summary>
        /// 获取登录用户的具体信息
        /// </summary>
        /// <param name="cid">客户id</param>
        /// <param name="tid">令牌id</param>
        /// <returns></returns>
        public LoggingSessionInfo GetLoggingSessionInfo(string cid, string tid)
        {
            //获取登录管理平台的用户信息


            var AuthWebService = new JIT.CPOS.BS.WebServices.AuthManagerWebServices.AuthServiceSoapClient();

            AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress(
                ConfigurationManager.AppSettings["sso_url"].ToString() + "/AuthService.asmx");
            string str = AuthWebService.GetLoginUserInfo(tid);


            LoggingManager myLoggingManager = (LoggingManager)cXMLService.Deserialize(str, typeof(LoggingManager));

            //判断用户是否存在,并且返回用户信息
            UserInfo login_user = new UserInfo();


            LoggingSessionInfo loggingSessionInfo1 = new LoggingSessionInfo();

            loggingSessionInfo1.CurrentLoggingManager = myLoggingManager;

            cUserService userService = new cUserService(loggingSessionInfo1);

            //获取用户信息
            if (userService.IsExistUser(loggingSessionInfo1))
            {
                login_user = userService.GetUserById(loggingSessionInfo1, myLoggingManager.User_Id);
            }
            else
            {
                login_user.User_Id = "1";
            }

            LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo();


            loggingSessionInfo.CurrentUser           = login_user;
            loggingSessionInfo.CurrentLoggingManager = myLoggingManager;

            UserRoleInfo ur = new UserRoleInfo();

            ur.RoleId = "7064243380E24B0BA24E4ADC4E03968B";
            ur.UnitId = "1";
            loggingSessionInfo.CurrentUserRole = ur;

            return(loggingSessionInfo);
        }
예제 #8
0
        /// <summary>
        /// 获取登录的model信息
        /// </summary>
        /// <param name="Customer_Id">客户标识</param>
        /// <param name="User_Id">用户标识</param>
        /// <param name="Unit_Id">组织标识</param>
        /// <returns></returns>
        public LoggingSessionInfo GetLoggingSessionInfo(string Customer_Id, string User_Id, string Unit_Id)
        {
            UserInfo           userInfo           = new UserInfo();
            cUserService       userServices       = new cUserService();
            LoggingSessionInfo loggingSessionInfo = new LoggingSessionInfo();
            UserRoleInfo       userRoleInfo       = new UserRoleInfo();

            loggingSessionInfo                 = new BaseService().GetLoggingSessionInfoByCustomerId(Customer_Id);
            userInfo                           = userServices.GetUserById(loggingSessionInfo, User_Id);
            userInfo.LoggingManagerInfo        = loggingSessionInfo.CurrentLoggingManager;
            userRoleInfo.UnitId                = Unit_Id;
            userRoleInfo.RoleId                = "7064243380E24B0BA24E4ADC4E03968B";
            loggingSessionInfo.CurrentUserRole = userRoleInfo;
            loggingSessionInfo.CurrentUser     = userInfo;

            return(loggingSessionInfo);
        }
예제 #9
0
        /// <summary>
        /// 通过ID获取用户信息
        /// </summary>
        public string GetUserInfoByIdData()
        {
            var responseData = new ResponseData();
            LoggingSessionInfo loggingSessionInfo = null;

            if (CurrentUserInfo != null)
            {
                loggingSessionInfo = CurrentUserInfo;
            }
            else
            {
                if (string.IsNullOrEmpty(Request("CustomerID")))
                {
                    responseData.success = false;
                    responseData.msg     = "缺少商户标识";
                    return(responseData.ToString());
                }
                else if (string.IsNullOrEmpty(Request("CustomerUserID")))
                {
                    responseData.success = false;
                    responseData.msg     = "缺少登陆员工的标识";
                    return(responseData.ToString());
                }
                else if (string.IsNullOrEmpty(Request("CustomerUserID")))
                {
                    responseData.success = false;
                    responseData.msg     = "缺少登陆员工的标识";
                    return(responseData.ToString());
                }
                else
                {
                    loggingSessionInfo = Default.GetBSLoggingSession(Request("CustomerID"), Request("CustomerUserID"));
                }
            }

            var      userService = new cUserService(loggingSessionInfo);//使用兼容模式
            UserInfo data;
            string   content = string.Empty;

            string key = string.Empty;

            if (Request("user_id") != null && Request("user_id") != string.Empty)
            {
                key = Request("user_id").ToString().Trim();
            }

            data = userService.GetUserById(CurrentUserInfo, key);
            if (data != null)
            {
                data.userRoleInfoList = userService.GetUserRoles(key);
            }

            var jsonData = new JsonData();

            jsonData.totalCount = "1";
            jsonData.data       = data;
            jsonData.success    = true;
            jsonData.msg        = "";

            content = jsonData.ToJSON();
            return(content);
        }
예제 #10
0
        private void DownloadQRCodeNew()//新的下载二维码的方法
        {
            //string weixinDomain = ConfigurationManager.AppSettings["original_url"];
            //string sourcePath = this.CurrentContext.Server.MapPath("/QRCodeImage/qrcode.jpg");
            //string targetPath = this.CurrentContext.Server.MapPath("/QRCodeImage/");
            //string currentDomain = this.CurrentContext.Request.Url.Host;
            //string itemId = FormatParamValue(Request("item_id"));//商品ID
            //string itemName = FormatParamValue(Request("item_name"));//商品名
            //string imageURL;

            //ObjectImagesBLL objectImagesBLL = new ObjectImagesBLL(CurrentUserInfo);
            ////查找是否已经生成了二维码
            //ObjectImagesEntity[] objectImagesEntityArray = objectImagesBLL.QueryByEntity(new ObjectImagesEntity() { ObjectId = itemId, Description = "自动生成的产品二维码" }, null);

            //if (objectImagesEntityArray.Length == 0)
            //{
            //    //http://api.dev.chainclouds.com
            //    //    http://api.dev.chainclouds.com/WXOAuth/AuthUniversal.aspx?customerId=049b0a8f641f4ca7b17b0b7b6291de1f&applicationId=1D7A01FC1E7D41ECBAC2696D0D363315&goUrl=api.dev.chainclouds.com/HtmlApps/html/public/shop/goods_detail.html?rootPage=true&rootPage=true&goodsId=DBF5326F4C5B4B0F8508AB54B0B0EBD4&ver=1448273310707&scope=snsapi_userinfo

            //    string itemUrl = weixinDomain + "/WXOAuth/AuthUniversal.aspx?customerId=" + CurrentUserInfo.ClientID
            //        + "&goUrl=" + weixinDomain + "/HtmlApps/html/public/shop/goods_detail.html?goodsId="
            //        + itemId + "&scope=snsapi_userinfo";

            //    //  string itemUrl = "http://*****:*****@"\");
            var imagePath = dirPath + imageName;//整个

            try
            {
                //要下载的文件名
                FileInfo DownloadFile = new FileInfo(imagePath);  //imagePath原来是这个,明天试试

                if (DownloadFile.Exists)
                {
                    CurrentContext.Response.Clear();
                    CurrentContext.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + System.Web.HttpUtility.UrlEncode(user.User_Name, System.Text.Encoding.UTF8) + ".jpg" + "\"");
                    CurrentContext.Response.AddHeader("Content-Length", DownloadFile.Length.ToString());
                    CurrentContext.Response.ContentType = "application/octet-stream";
                    CurrentContext.Response.TransmitFile(DownloadFile.FullName);
                    CurrentContext.Response.Flush();
                }
                else
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = "二维码未找到"
                    });
                }
            }
            catch (Exception ex)
            {
                CurrentContext.Response.ContentType = "text/plain";
                CurrentContext.Response.Write(ex.Message);
            }
            finally
            {
                CurrentContext.Response.End();
            }
        }
예제 #11
0
        private void loadUser(string customer_id, string token)
        {
            //try
            //{
            //获取登录管理平台的用户信息
            var AuthWebService = new JIT.CPOS.BS.WebServices.AuthManagerWebServices.AuthServiceSoapClient();

            AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress(
                ConfigurationManager.AppSettings["sso_url"].ToString() + "/AuthService.asmx");
            //   AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:42305/AuthService.asmx");

            //AuthWebService.Endpoint.Address = new System.ServiceModel.EndpointAddress("http://localhost:7335/AuthService.asmx");
            if (token == null)
            {
                token = "";
            }
            string str = AuthWebService.GetLoginUserInfo(token);

            if (string.IsNullOrEmpty(str))
            {
                //this.lbErr.Text = "用户不存在,请与管理员联系";
                //return;
                PageLog.Current.Write("SSO登录失败,AuthWebService.asmx返回空数据");
                //Response.Write("登录失败,请重试!");
                //Response.End();
                var redirectUrl = ConfigurationManager.AppSettings["sso_url"].ToString() + "?errorinfo=" + "网络繁忙,请重新登录!";
                //var redirectUrl = "http://localhost:7335/login.aspx";
                Response.Redirect(redirectUrl, true);
            }

            var myLoggingManager = (JIT.CPOS.BS.Entity.LoggingManager)cXMLService.Deserialize(
                str, typeof(JIT.CPOS.BS.Entity.LoggingManager));

            //判断登录进来的用户是否存在,并且返回用户信息
            LoggingSessionInfo loggingSession = new LoggingSessionInfo();

            loggingSession.CurrentLoggingManager = myLoggingManager;
            cUserService userService = new cUserService(loggingSession);
            UnitService  unitService = new UnitService(loggingSession);

            if (!userService.IsExistUser(loggingSession))
            {
                this.lbErr.Text = "用户不存在,请与管理员联系";
                return;
            }
            var login_user = userService.GetUserById(loggingSession, myLoggingManager.User_Id);

            loggingSession.CurrentUser = login_user;

            // 获取角色
            string applicationId = PageBase.JITPage.GetApplicationId();
            IList <UserRoleInfo> userRoleList = userService.GetUserRoles(login_user.User_Id, applicationId);

            if (userRoleList != null && userRoleList.Count > 0)
            {
                loggingSession.CurrentUserRole          = new UserRoleInfo();
                loggingSession.CurrentUserRole.UserId   = login_user.User_Id;
                loggingSession.CurrentUserRole.UserName = login_user.User_Name;
                loggingSession.CurrentUserRole.RoleId   = userRoleList[0].RoleId;
                loggingSession.CurrentUserRole.RoleCode = userRoleList[0].RoleCode;
                loggingSession.CurrentUserRole.RoleName = userRoleList[0].RoleName;

                loggingSession.ClientID = login_user.customer_id;
                loggingSession.CurrentLoggingManager.Customer_Id = login_user.customer_id;
                loggingSession.UserID = loggingSession.CurrentUser.User_Id;

                try
                {
                    loggingSession.CurrentUserRole.UnitId = userService.GetDefaultUnitByUserIdAndRoleId(
                        loggingSession.CurrentUserRole.UserId, loggingSession.CurrentUserRole.RoleId);
                }
                catch (Exception ex)
                {
                    PageLog.Current.Write(ex);
                    Response.Write("找不到默认单位");
                    Response.End();
                }

                try
                {
                    var unitInfo = unitService.GetUnitById(loggingSession.CurrentUserRole.UnitId);
                    loggingSession.CurrentUserRole.UnitName      = unitInfo.Name;
                    loggingSession.CurrentUserRole.UnitShortName = unitInfo.ShortName;
                }
                catch (Exception ex)
                {
                    PageLog.Current.Write(ex);
                    Response.Write("找不到单位");
                    Response.End();
                }
            }
            else
            {
                //PageLog.Current.Write(ex);
                Response.Write("该用户没有权限登录管理平台");
                Response.End();
            }



            //this.Session["UserInfo"] = login_user;
            //this.Session["LoggingManager"] = myLoggingManager;
            //this.Session["loggingSessionInfo"] = loggingSession;


            //loggingSession.CurrentLoggingManager = myLoggingManager;
            new SessionManager().SetCurrentUserLoginInfo(loggingSession);

            //清空密码
            login_user.User_Password = null;
            //string go_url = "~/login/SelectRoleUnit.aspx?p=0";
            string go_url = "~/Default.aspx";

            if (loggingSession.CurrentUserRole != null && loggingSession.CurrentUserRole.RoleId == "860E69754D3B490F8A5B401DF3F66E15")
            {
                string eventId = string.Empty;
                //switch (loggingSession.CurrentUserRole.UserId.Trim())
                //{
                //    case "FA1BDA8937924D45AFA3123FE4DEE8FA":
                //        eventId = "0326056B219340D5B234BFAD9AF02AF5";
                //        break;
                //    case "4913B21CFD714C7986842B859EC1289B":
                //        eventId = "793150439CF94190A70CF2EC229A951D";
                //        break;
                //    case "BD8079F886BD492E90A335EBC1DE9676":
                //        eventId = "F8A7E2E8807B49558F1A516F23C34473";
                //        break;
                //    default:
                //        eventId = "793150439CF94190A70CF2EC229A951D";
                //        break;
                //}
                LEventsBLL lEventsBLL = new LEventsBLL(loggingSession);
                var        eventList  = lEventsBLL.QueryByEntity(new LEventsEntity()
                {
                    EventManagerUserId = loggingSession.CurrentUserRole.UserId
                }, null);
                if (eventList != null && eventList.Length > 0)
                {
                    eventId = eventList[0].EventID;
                    loggingSession.CurrentUserRole.RoleName = eventId;
                    Response.Redirect("~/Module/MarketEvent/EventList/EventAnalysisList4.aspx", true);
                }
            }
            else
            {
                //loggingSession.CurrentUserRole.RoleName = "793150439CF94190A70CF2EC229A951D";
                Response.Redirect(go_url, true);
            }
            //}
            //catch (Exception ex)
            //{
            //    PageLog.Current.Write(ex);
            //    lbErr.Text = "登录失败";
            //}
        }