private void LoadAvaliableOrgs(ObjectItem parentItem, string parentID) { try { WebRequest webRequest = new WebRequest(); webRequest.Code = (int)S1101Codes.GetOrganizationList; webRequest.Session = CurrentApp.Session; webRequest.ListData.Add(CurrentApp.Session.UserInfo.UserID.ToString()); webRequest.ListData.Add(parentID); 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("InitControledOrgs Fail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } List <ObjectItem> listChild = new List <ObjectItem>(); for (int i = 0; i < webReturn.ListData.Count; i++) { OperationReturn optReturn = XMLHelper.DeserializeObject <BasicOrgInfo>(webReturn.ListData[i]); if (!optReturn.Result) { ShowException(string.Format("InitControledOrgs Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } BasicOrgInfo orgInfo = optReturn.Data as BasicOrgInfo; if (orgInfo != null) { ObjectItem item = new ObjectItem(); item.ObjType = S1101Consts.OBJTYPE_ORG; item.ObjID = orgInfo.OrgID; orgInfo.OrgName = orgInfo.OrgName; orgInfo.StrStartTime = DateTime.Parse(orgInfo.StrStartTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); orgInfo.StrEndTime = orgInfo.StrEndTime; if (!orgInfo.StrEndTime.ToUpper().Equals("UNLIMITED")) { orgInfo.EndTime = DateTime.Parse(orgInfo.StrEndTime).ToLocalTime(); orgInfo.StrEndTime = DateTime.Parse(orgInfo.StrEndTime).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); } orgInfo.CreateTime = orgInfo.CreateTime.ToLocalTime(); item.Name = orgInfo.OrgName; item.FullName = item.Name; item.Description = orgInfo.Description; item.State = Convert.ToInt32(orgInfo.IsActived); item.ObjParentID = orgInfo.ParentID; if (item.State == 1) { item.TipState = CurrentApp.GetLanguageInfo("1101T10109", "IsActived"); } else { item.TipState = CurrentApp.GetLanguageInfo("1101T10110", "Disable"); } if (item.ObjID == ConstValue.ORG_ROOT) { item.Icon = "Images/root.ico"; } else { item.Icon = "Images/org.ico"; } item.Data = orgInfo; LoadAvaliableOrgs(item, orgInfo.OrgID.ToString()); Dispatcher.Invoke(new Action(() => parentItem.AddChild(item))); } } } catch (Exception ex) { ShowException(ex.Message); } }
private void Init() { if (IsAddUser) { if (ObjParent == null) { return; } OrgInfo = ObjParent.Data as BasicOrgInfo; TxtAccount.Text = string.Empty; TxtFullName.Text = string.Empty; if (OrgInfo != null) { TxtOrg.Text = OrgInfo.OrgName; } TxtEmail.Text = string.Empty; TxtPhone.Text = string.Empty; TxtBirthday.Text = string.Empty; //px屏蔽 //ComboHeadIcon.SelectedItem = null; //Px+ ComboHeadIcon.SelectedIndex = 0; chkIsActive.IsChecked = true; BorderSetting.Visibility = Visibility.Collapsed; dtValidTime.Value = DateTime.Now; dtInValidTime.Value = DateTime.Parse(S1101Consts.Default_StrEndTime); } else { if (UserItem == null) { return; } BasicUserInfo = UserItem.Data as BasicUserInfo; if (BasicUserInfo != null) { TxtAccount.Text = BasicUserInfo.Account; TxtFullName.Text = BasicUserInfo.FullName; if (BasicUserInfo.SourceFlag == "L") { TxtAccount.IsEnabled = false; TxtAccount.Text = BasicUserInfo.Account.Replace("@", @"\"); //TxtFullName.IsEnabled = false; } if (BasicUserInfo.IsLocked != "0") { CbLock.IsChecked = true; } else { CbLock.IsChecked = false; } //if (BasicUserInfo.LockMethod == "U") //{ // CbLock.IsChecked = true; //} //else //{ // CbLock.IsChecked = false; //} CbResetPwd.IsChecked = false; chkIsActive.IsChecked = BasicUserInfo.IsActived.Equals("1"); //dtValidTime.Value = DateTime.Parse(BasicUserInfo.StrStartTime); dtValidTime.Value = BasicUserInfo.StartTime; //BasicUserInfo.StartTime if (BasicUserInfo.StrEndTime.ToUpper().Equals("UNLIMITED")) { dtInValidTime.Value = DateTime.Parse(S1101Consts.Default_StrEndTime); } else { dtInValidTime.Value = BasicUserInfo.EndTime; ///DateTime.Parse(BasicUserInfo.StrEndTime); } if (PageParent != null) { PageParent.SetBusy(true, string.Empty); } mBackgroundWorker = new BackgroundWorker(); mBackgroundWorker.DoWork += (s, de) => LoadUserExtInfo(); mBackgroundWorker.RunWorkerCompleted += (s, re) => { mBackgroundWorker.Dispose(); if (PageParent != null) { PageParent.SetBusy(false, string.Empty); } if (ExtUserInfo != null) { TxtEmail.Text = ExtUserInfo.MailAddress; TxtPhone.Text = ExtUserInfo.PhoneNumber; DateTime birthday; if (DateTime.TryParse(ExtUserInfo.Birthday, out birthday)) { TxtBirthday.Value = birthday; } else { TxtBirthday.Value = null; } var headIcon = mListHeadIcons.FirstOrDefault(h => h.Icon == ExtUserInfo.HeadIcon); if (headIcon != null) { ComboHeadIcon.SelectedItem = headIcon; } //px+ else { ComboHeadIcon.SelectedIndex = 0; } //end } mIsExtInfoChanged = false; }; mBackgroundWorker.RunWorkerAsync(); } ObjParent = UserItem.Parent as ObjectItem; if (ObjParent != null) { OrgInfo = ObjParent.Data as BasicOrgInfo; if (OrgInfo != null) { TxtOrg.Text = OrgInfo.OrgName; } } BorderSetting.Visibility = Visibility.Visible; IsSelf(); } }