private AddUserOptions GetOptions() { AddUserOptions options = new AddUserOptions(); UserTypeInfo info = UserTypeInfo.GetTypeInfoFromCode(lbxUserType.SelectedValue); options.UserType = info.UserType; if (String.IsNullOrEmpty(ddlQuantity.SelectedValue)) { options.Quantity = 1; } else { options.Quantity = System.Convert.ToInt32(ddlQuantity.SelectedValue); } if (chkCreateFromProfile.Checked) { options.CreateFromProfile = true; if (rdoProfileFrom.SelectedValue == "U") { if (string.IsNullOrEmpty(lueAddUser.LookupResultValue.ToString())) { throw new ValidationException(GetLocalResourceObject("lueAddUser.Validate").ToString()); } options.TemplateID = lueAddUser.LookupResultValue.ToString(); } else { options.TemplateID = lbxTemplates.SelectedValue; } } else { options.CreateFromProfile = false; options.TemplateID = string.Empty; } options.UseGeneralProfile = chkGeneral.Checked; options.UseEmployeeProfile = chkEmployee.Checked; options.UseCalendarProfile = chkCalender.Checked; options.UseClientOptionsProfile = chkClientOptions.Checked; options.UseSecurityProfile = chkSecurity.Checked; options.UseSupportProfile = chkServiceAndSupport.Checked; options.UseTeamsProfile = chkTeams.Checked; return(options); }
private void LoadView() { if (lbxUserType.Items.Count < 1) { var userTypes = UserTypeInfo.GetUserTypes(); foreach (UserTypeInfo info in userTypes.Values) { if ((info.UserType != UserType.Admin) && (info.UserType != UserType.Retired)) { ListItem item = new ListItem(info.DisplayName, info.Code); lbxUserType.Items.Add(item); } } lbxUserType.SelectedIndex = 0; lbxUserType.Focus(); } if (lbxTemplates.Items.Count < 1) { var templateList = UserManagementService.GetTemplates(); foreach (IUser temp in templateList) { lbxTemplates.Items.Add(new ListItem(temp.UserInfo.UserName, temp.Id.ToString())); } if (lbxTemplates.Items.Count > 0) { lbxTemplates.SelectedIndex = 0; } } if (rdoProfileFrom.SelectedValue == "U") { div_Templates_lbl.Style.Add("display", "none"); div_Users_lbl.Style.Add("display", "block"); div_Templates_Ctrl.Style.Add("display", "none"); div_Users_Ctrl.Style.Add("display", "block"); } else { div_Templates_lbl.Style.Add("display", "block"); div_Users_lbl.Style.Add("display", "none"); div_Templates_Ctrl.Style.Add("display", "block"); div_Users_Ctrl.Style.Add("display", "none"); } SetProfileTabs(chkCreateFromProfile.Checked); bool canAdd = false; if (lbxUserType.SelectedItem != null) { UserTypeInfo utInfo = UserTypeInfo.GetTypeInfoFromCode(lbxUserType.SelectedItem.Value); int addCount = System.Convert.ToInt32(ddlQuantity.SelectedValue); int licCount = UserManagementService.GetLicenseAvailableCount(utInfo.UserType); if (addCount < 1) { canAdd = false; } else { if (UserManagementService.IsLicenseAvailable(utInfo.UserType, addCount)) { canAdd = true; } } if (utInfo.UserType == UserType.Template) { lblAvailableLic.Text = GetLocalResourceObject("LicNotRequired").ToString(); } else { if (utInfo.UserType == UserType.Concurrent) { lblAvailableLic.Style.Remove("color"); lblAvailableLic.Text = string.Format(GetLocalResourceObject("LicAvailable").ToString(), UserManagementService.GetLicenseCount(UserType.Concurrent)); } else { if (licCount >= addCount) { lblAvailableLic.Style.Remove("color"); lblAvailableLic.Text = string.Format(GetLocalResourceObject("LicAvailable").ToString(), licCount); } else { lblAvailableLic.Style.Add("color", "Red"); lblAvailableLic.Text = string.Format(GetLocalResourceObject("LicTooFewAvailable").ToString(), licCount); } } } } int addCount2 = System.Convert.ToInt32(ddlQuantity.SelectedValue); string plural = string.Empty; if (addCount2 > 1) { plural = GetLocalResourceObject("plural").ToString(); } string processMsg = string.Format(GetLocalResourceObject("lblProcessing.Text").ToString(), System.Convert.ToInt32(ddlQuantity.SelectedValue), lbxUserType.SelectedItem.Text, plural); btnOk.OnClientClick = string.Format("addUser_OkClick('{0}', '{1}','{2}')", divStep1.ClientID, divStep2.ClientID, Sage.Platform.WebPortal.PortalUtil.JavaScriptEncode(processMsg)); div_Req.Style.Add("display", "none"); if (chkCreateFromProfile.Checked) { if (rdoProfileFrom.SelectedValue == "U") { if (string.IsNullOrEmpty(lueAddUser.LookupResultValue.ToString())) { div_Req.Style.Add("display", "block"); canAdd = false; } } else { if (string.IsNullOrEmpty(lbxTemplates.SelectedValue)) { div_Req.Style.Add("display", "block"); canAdd = false; } } } btnOk.Enabled = canAdd; }