示例#1
0
        private void LoadUserExtInfo()
        {
            if (BasicUserInfo == null)
            {
                return;
            }
            try
            {
                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.Code    = (int)S1101Codes.GetUserExtInfo;
                webRequest.Data    = BasicUserInfo.UserID.ToString();

                Service11011Client client = new Service11011Client(
                    WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                    WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo,
                                                    "Service11011"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    if (webReturn.Code != Defines.RET_NOT_EXIST)
                    {
                        ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                        return;
                    }
                    ExtUserInfo = new ExtendUserInfo();
                    return;
                }
                OperationReturn optReturn = XMLHelper.DeserializeObject <ExtendUserInfo>(webReturn.Data);
                if (!optReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return;
                }
                ExtUserInfo = optReturn.Data as ExtendUserInfo;
                if (ExtUserInfo == null)
                {
                    ShowException(string.Format("Fail.\t{0}", "ExtUserInfo is null"));
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
示例#2
0
        private void ModifyExtUserInfo(ExtendUserInfo extUserInfo)
        {
            try
            {
                if (extUserInfo == null)
                {
                    return;
                }

                WebRequest webRequest = new WebRequest();
                webRequest.Session = CurrentApp.Session;
                webRequest.Code    = (int)S1101Codes.ModifyUserExtInfo;
                //0     UserID
                //1     Email
                //2     Phone
                //3     Birthday
                //4     HeadIcon
                webRequest.ListData.Add(extUserInfo.UserID.ToString());
                webRequest.ListData.Add(extUserInfo.MailAddress);
                webRequest.ListData.Add(extUserInfo.PhoneNumber);
                webRequest.ListData.Add(extUserInfo.Birthday);
                webRequest.ListData.Add(extUserInfo.HeadIcon);

                Service11011Client client = new Service11011Client(
                    WebHelper.CreateBasicHttpBinding(CurrentApp.Session),
                    WebHelper.CreateEndpointAddress(
                        CurrentApp.Session.AppServerInfo,
                        "Service11011"));
                WebHelper.SetServiceClient(client);
                WebReturn webReturn = client.DoOperation(webRequest);
                client.Close();
                if (!webReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message));
                }
                mAsyncResult = true;
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
示例#3
0
        private void ModifyUserInfo()
        {
            try
            {
                if (BasicUserInfo == null)
                {
                    return;
                }
                string account, fullName, strReset;
                string strLog      = string.Empty;
                string strIsActive = string.Empty;
                string strLock     = string.Empty;
                string UserName    = TxtAccount.Text.Trim();
                if (UserName.Contains("@"))
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1101N041", "User Name is invalid."));
                    return;
                }
                if (TxtAccount.Text.Length > 64 || TxtFullName.Text.Length > 64)
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1101N024", "User Name is invalid."));
                    return;
                }
                if (TxtAccount.Text.Replace(" ", "") == string.Empty || TxtFullName.Text.Replace(" ", "") == string.Empty)
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1101N026", "User Name is invalid."));
                    return;
                }
                account  = TxtAccount.Text.Trim();
                strLog  += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10201"), account);
                fullName = TxtFullName.Text.Trim();
                strLog  += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10202"), fullName);
                //if (BasicUserInfo.LockMethod == "N" && CbLock.IsChecked == true)
                //{
                //    strLock = "U";
                //}
                //else if (BasicUserInfo.LockMethod == "U" && CbLock.IsChecked == false)
                //{
                //    strLock = "C";
                //}
                //else
                //{
                //    strLock = string.Empty;
                //}

                //1为锁,0为未锁
                if (BasicUserInfo.IsLocked == "1")
                {
                    if (CbLock.IsChecked == false)
                    {
                        if (BasicUserInfo.LockMethod == "L")
                        {
                            strLock = "CL";
                        }
                        else
                        {
                            strLock = "CU";
                        }
                    }
                    else
                    {
                        strLock = String.Empty;
                    }
                }
                else if (BasicUserInfo.IsLocked == "0")
                {
                    if (CbLock.IsChecked == true)
                    {
                        strLock = "U";
                    }
                    else
                    {
                        strLock = String.Empty;
                    }
                }
                else
                {
                    strLock = string.Empty;
                }


                if (CbLock.IsChecked == true)
                //if (!string.IsNullOrEmpty(strLock))
                {
                    strLog += string.Format("{0} ", Utils.FormatOptLogString("11011100"));
                }
                strReset = CbResetPwd.IsChecked == true ? "1" : "0";
                if (strReset == "1")
                {
                    strLog += string.Format("{0} ", Utils.FormatOptLogString("11011101"));
                }

                DateTime validTime = DateTime.Parse(dtValidTime.Value.ToString()).ToUniversalTime();
                strLog += string.Format("{0} {1}", Utils.FormatOptLogString("1101T10105"), validTime);
                DateTime inValidTime = DateTime.Parse(dtInValidTime.Value.ToString()).ToUniversalTime();
                strLog += string.Format("{0} {1}", Utils.FormatOptLogString("1101T10106"), inValidTime);


                //0     UserID
                //1     Account
                //2     FullName
                //3     Locked
                //4     ResetPassword
                //5     IsActive
                //6     ValidTime
                //7     InValidTime
                List <string> listParams = new List <string>();
                listParams.Add(BasicUserInfo.UserID.ToString());
                listParams.Add(account);
                listParams.Add(fullName);
                listParams.Add(strLock);
                listParams.Add(strReset);
                strIsActive = chkIsActive.IsChecked == true ? "1" : "0";
                listParams.Add(strIsActive);
                listParams.Add(validTime.ToString("yyy/MM/dd HH:mm:ss"));
                listParams.Add(inValidTime.ToString("yyy/MM/dd HH:mm:ss"));
                if (strIsActive == "1")
                {
                    strLog += string.Format("{0}", Utils.FormatOptLogString("1101T10109"));
                }

                ExtendUserInfo extUserInfo = new ExtendUserInfo();
                if (mIsExtInfoChanged)
                {
                    extUserInfo.UserID      = BasicUserInfo.UserID;
                    extUserInfo.MailAddress = TxtEmail.Text;
                    strLog += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10203"), TxtEmail.Text);
                    extUserInfo.PhoneNumber = TxtPhone.Text;
                    strLog += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10204"), TxtPhone.Text);
                    extUserInfo.Birthday = TxtBirthday.Value.ToString();
                    strLog += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10205"), TxtBirthday.Value);
                    var headIcon = ComboHeadIcon.SelectedItem as HeadIconInfo;
                    if (headIcon != null)
                    {
                        extUserInfo.HeadIcon = headIcon.Icon;
                        strLog += string.Format("{0} {1}  ", Utils.FormatOptLogString("1101T10214"), headIcon.Icon);
                    }
                }
                mAsyncResult = false;
                if (PageParent != null)
                {
                    PageParent.SetBusy(true, string.Empty);
                }
                mBackgroundWorker         = new BackgroundWorker();
                mBackgroundWorker.DoWork += (s, de) =>
                {
                    ModifyUserInfo(listParams);
                    if (mAsyncResult && mIsExtInfoChanged)
                    {
                        mAsyncResult = false;
                        ModifyExtUserInfo(extUserInfo);
                        //px+
                        if (extUserInfo.UserID == CurrentApp.Session.UserID)
                        {
                            //PageParent.RefreshHeadIcon();
                        }
                        //end
                    }
                };
                mBackgroundWorker.RunWorkerCompleted += (s, re) =>
                {
                    mBackgroundWorker.Dispose();
                    if (PageParent != null)
                    {
                        PageParent.SetBusy(false, string.Empty);
                    }
                    if (mAsyncResult)
                    {
                        #region 写操作日志

                        CurrentApp.WriteOperationLog(S1101Consts.OPT_MODIFYUSER.ToString(), ConstValue.OPT_RESULT_SUCCESS, strLog);

                        #endregion

                        if (PageParent != null)
                        {
                            PageParent.ReloadData(ObjParent);
                        }
                        var parent = Parent as PopupPanel;
                        if (parent != null)
                        {
                            parent.IsOpen = false;
                        }
                    }
                };
                mBackgroundWorker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
示例#4
0
        private void AddNewUser()
        {
            try
            {
                string        strLog        = string.Empty;
                BasicUserInfo basicUserInfo = new BasicUserInfo();

                if (TxtAccount.Text.Length > 64 || TxtFullName.Text.Length > 64)
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1101N024", "User Name is invalid."));
                    return;
                }
                if (TxtAccount.Text.Replace(" ", "") == string.Empty || TxtFullName.Text.Replace(" ", "") == string.Empty)
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1101N026", "User Name is invalid."));
                    return;
                }
                if (TxtAccount.Text.Contains("@") || TxtFullName.Text.Contains("@"))
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1101N041", "User Name is Contain @."));
                    return;
                }
                if (TxtAccount.Text.Contains(@"\") || TxtFullName.Text.Contains(@"\"))
                {
                    CurrentApp.ShowInfoMessage(CurrentApp.GetLanguageInfo("1101N042", @"User Name is Contain \."));
                    return;
                }
                basicUserInfo.Account = TxtAccount.Text.Trim();
                strLog += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10201"), TxtAccount.Text);
                basicUserInfo.FullName = TxtFullName.Text.Trim();
                strLog += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10202"), TxtFullName.Text.Trim());
                if (OrgInfo != null)
                {
                    basicUserInfo.OrgID = OrgInfo.OrgID;
                }
                string strIsActive = string.Empty;
                strIsActive             = chkIsActive.IsChecked == true ? "1" : "0";
                basicUserInfo.IsActived = strIsActive;
                if (strIsActive == "1")
                {
                    strLog += string.Format("{0}", Utils.FormatOptLogString("1101T10109"));
                }

                basicUserInfo.SourceFlag = "U";

                basicUserInfo.StartTime    = DateTime.Parse(dtValidTime.Value.ToString());
                basicUserInfo.EndTime      = DateTime.Parse(dtInValidTime.Value.ToString());
                basicUserInfo.StrStartTime = basicUserInfo.StartTime.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss");
                basicUserInfo.StrEndTime   = basicUserInfo.EndTime.ToUniversalTime().ToString("yyyy/MM/dd HH:mm:ss");

                ExtendUserInfo extUserInfo = new ExtendUserInfo();
                if (mIsExtInfoChanged)
                {
                    extUserInfo.MailAddress = TxtEmail.Text.Trim();
                    strLog += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10203"), TxtEmail.Text);
                    extUserInfo.PhoneNumber = TxtPhone.Text.Trim();
                    strLog += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10204"), TxtPhone.Text);
                    extUserInfo.Birthday = TxtBirthday.Value.ToString();
                    strLog += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10205"), TxtBirthday.Value);
                    var headIcon = ComboHeadIcon.SelectedItem as HeadIconInfo;
                    if (headIcon != null)
                    {
                        extUserInfo.HeadIcon = headIcon.Icon;
                        strLog += string.Format("{0} {1} ", Utils.FormatOptLogString("1101T10214"), headIcon.Icon);
                    }
                }
                mAsyncResult = false;
                if (PageParent != null)
                {
                    PageParent.SetBusy(true, string.Empty);
                }
                mBackgroundWorker         = new BackgroundWorker();
                mBackgroundWorker.DoWork += (s, de) =>
                {
                    AddNewUser(basicUserInfo);
                    if (mAsyncResult &&
                        mIsExtInfoChanged &&
                        !string.IsNullOrEmpty(basicUserInfo.UserID.ToString()))
                    {
                        extUserInfo.UserID = basicUserInfo.UserID;
                        mAsyncResult       = false;
                        ModifyExtUserInfo(extUserInfo);
                    }
                };
                mBackgroundWorker.RunWorkerCompleted += (s, re) =>
                {
                    mBackgroundWorker.Dispose();
                    if (PageParent != null)
                    {
                        PageParent.SetBusy(false, string.Empty);
                    }
                    if (mAsyncResult)
                    {
                        #region 写操作日志

                        CurrentApp.WriteOperationLog(S1101Consts.OPT_ADDUSER.ToString(), ConstValue.OPT_RESULT_SUCCESS, strLog);

                        #endregion

                        if (PageParent != null)
                        {
                            PageParent.ReloadData(ObjParent);
                        }
                        var parent = Parent as PopupPanel;
                        if (parent != null)
                        {
                            parent.IsOpen = false;
                        }
                    }
                };
                mBackgroundWorker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }