public UserFormAccessList GetAuthorisedForms(SecureSession session, RoleList roleList) { IEnumerable<string> keys = AssemblyResourceReader.GetResourceKeys(); string pattern = string.Format("Test_Data.ApplicationPermissions.FORM-([a-z0-9-]*)-USER-{0}", session.AuthenticatedUser.Id); Dictionary<string, List<string>> forms = new Dictionary<string, List<string>>(); foreach (string key in keys) { Match match = Regex.Match(key, pattern, RegexOptions.IgnoreCase); if (!match.Success) { continue; } string content = AssemblyResourceReader.ReadAsString(key); string formId = match.Groups[1].Value; ApplicationEntitlementList applicationEntitlements = JsonConvert.DeserializeObject<ApplicationEntitlementList>(content); foreach (ApplicationEntitlement entitlement in applicationEntitlements) { if (entitlement.AccessLevel > AccessLevel.NoAccess) { if (!forms.ContainsKey(formId)) { forms.Add(formId, new List<string>()); } forms[formId].Add(entitlement.StateName); } } } return new UserFormAccessList(forms.Select(kvp => new UserFormAccess(kvp.Key, kvp.Value.ToList()))); }
/// <summary> /// Gets the base <see cref="AccessLevel" /> applicable for a combination of user & application. /// </summary> /// <param name="session">Contains session and user information used to determine access rights.</param> /// <param name="application">The application.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number of the form being accessed.</param> /// <returns>The base <see cref="AccessLevel" /> applicable for a combination of user & application.</returns> public virtual AccessLevel GetApplicationAccess(SecureSession session, Application application, RoleList roleList, int versionNumber) { if (this.IsAdministrator(session)) { return AccessLevel.Write; } if (!this.IsOrganisationEntitled(session, application)) { return AccessLevel.NoAccess; } string userId = this.GetSessionUserId(session); bool viewAllDrafts = session.AuthenticatedUser != null && this.GetSystemEntitlements(userId)[SystemEntitlementAccess.VIEW_DRAFT_APPLICATIONS] > AccessLevel.NoAccess; if (application.Draft && application.AssignedTo != userId && !viewAllDrafts) { return AccessLevel.NoAccess; } var systemEntitlements = this.GetSystemEntitlements(session.AuthenticatedUser != null ? session.AuthenticatedUser.Id : null); if (application.Draft && application.AssignedTo != userId && systemEntitlements[SystemEntitlementAccess.VIEW_DRAFT_APPLICATIONS] == AccessLevel.NoAccess) { return AccessLevel.NoAccess; } Dictionary<string, string> userRoles = this.DetermineRolesForUser(session, roleList, application); ApplicationEntitlementList applicationEntitlements = this.securityService.GetApplicationEntitlements(application.FormId, versionNumber, application.WorkflowState, userRoles.Keys); return applicationEntitlements.Any() ? applicationEntitlements.Max(e => e.AccessLevel) : AccessLevel.NoAccess; }
/// <summary> /// Gets the base <see cref="AccessLevel" /> applicable for a combination of user & application. /// </summary> /// <param name="session">Contains session and user information used to determine access rights.</param> /// <param name="application">The application.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number of the form being accessed.</param> /// <returns>The base <see cref="AccessLevel" /> applicable for a combination of user & application.</returns> public AccessLevel GetApplicationAccess(SecureSession session, Application application, RoleList roleList, int versionNumber) { if (this.ImpersonatedSession != null && string.IsNullOrWhiteSpace(application.Id)) { this.ImpersonateEntitlements(session); } return this.wrappedProvider.GetApplicationAccess(session, application, roleList, versionNumber); }
public AccessLevel GetApplicationAccess(SecureSession session, Application application, RoleList roleList, int versionNumber) { string resourceString; string userId = session.AuthenticatedUser == null ? string.Empty : session.AuthenticatedUser.Id; string formName = string.Format("Test_Data.ApplicationPermissions.FORM-{0}-USER-{1}.json", application.FormId.PadLeft(2, '0'), userId); if (AssemblyResourceReader.TryReadAsString(formName, out resourceString)) { var applicationEntitlements = JsonConvert.DeserializeObject<ApplicationEntitlementList>(resourceString); applicationEntitlements = new ApplicationEntitlementList(applicationEntitlements.Where(e => e.ProductId == application.FormId && e.ProductVersion == application.FormVersion && e.StateName == application.WorkflowState && roleList.Contains(e.RoleId))); return applicationEntitlements.Max(e => e.AccessLevel); } return AccessLevel.NoAccess; }
public List<ControlAccess> GetControlsAccess( SecureSession session, Application application, ControlList controlList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { string resourceString; if (AssemblyResourceReader.TryReadAsString(string.Format("Test_Data.ControlPermissions.FORM-{0}-USER-{1}.json", application.FormId.PadLeft(2, '0'), session.AuthenticatedUser.Id), out resourceString)) { var entitlements = JsonConvert.DeserializeObject<ControlEntitlementList>(resourceString); entitlements.Merge(); return new List<ControlAccess>(entitlements.Select(e => new ControlAccess(e.ControlId, e.AccessLevel))); } return new List<ControlAccess>(); }
internal override void ExecuteCommand() { base.ExecuteCommand(); if (!string.IsNullOrEmpty(ServiceName) && CurrentDeployment == null) { return; } List<PersistentVMRoleContext> roles = new List<PersistentVMRoleContext>(); RoleList vmRoles = null; if (string.IsNullOrEmpty(ServiceName)) { ListAllVMs(); return; } if (string.IsNullOrEmpty(Name)) { vmRoles = CurrentDeployment.RoleList; } else { vmRoles = new RoleList(CurrentDeployment.RoleList.Where(r => r.RoleName.Equals(Name, StringComparison.InvariantCultureIgnoreCase))); } foreach (Role role in vmRoles) { string lastVM = string.Empty; try { lastVM = role.RoleName; var vm = (PersistentVMRole)role; var roleInstance = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName); var vmContext = new PersistentVMRoleContext { ServiceName = ServiceName, Name = vm.RoleName, DeploymentName = CurrentDeployment.Name, AvailabilitySetName = vm.AvailabilitySetName, Label = vm.Label, InstanceSize = vm.RoleSize, InstanceStatus = roleInstance.InstanceStatus, IpAddress = roleInstance.IpAddress, InstanceStateDetails = roleInstance.InstanceStateDetails, PowerState = roleInstance.PowerState, InstanceErrorCode = roleInstance.InstanceErrorCode, InstanceName = roleInstance.InstanceName, InstanceFaultDomain = roleInstance.InstanceFaultDomain.HasValue ? roleInstance.InstanceFaultDomain.Value.ToString(CultureInfo.InvariantCulture) : null, InstanceUpgradeDomain = roleInstance.InstanceUpgradeDomain.HasValue ? roleInstance.InstanceUpgradeDomain.Value.ToString(CultureInfo.InvariantCulture) : null, OperationDescription = CommandRuntime.ToString(), OperationId = GetDeploymentOperation.OperationTrackingId, OperationStatus = GetDeploymentOperation.Status, VM = new PersistentVM { AvailabilitySetName = vm.AvailabilitySetName, ConfigurationSets = vm.ConfigurationSets, DataVirtualHardDisks = vm.DataVirtualHardDisks, Label = vm.Label, OSVirtualHardDisk = vm.OSVirtualHardDisk, RoleName = vm.RoleName, RoleSize = vm.RoleSize, RoleType = vm.RoleType, DefaultWinRmCertificateThumbprint = vm.DefaultWinRmCertificateThumbprint }, }; if (CurrentDeployment != null) { vmContext.DNSName = CurrentDeployment.Url.AbsoluteUri; } roles.Add(vmContext); } catch (Exception e) { throw new ApplicationException(string.Format(Resources.VMPropertiesCanNotBeRead, lastVM), e); } } WriteObject(roles, true); }
/// <summary> /// Gets the control access level for each control in <paramref name="metadataControlsList"/>. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="metadataControlsList">The metadata controls list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a metadata control. If not set it will default to the application base access level.</param> /// <returns> /// The metadata controls entitlements that the user has. /// </returns> public List<MetadataControlAccess> GetMetadataControlsAccess(SecureSession session, Application application, MetadataControlList metadataControlsList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { var userRoles = this.DetermineRolesForUser(session, roleList, application); var metadataControlEntitlements = this.securityService.GetMetadataEntitlements(application.FormId, versionNumber, application.WorkflowState, userRoles.Keys); metadataControlEntitlements.Merge(); if (session.AuthenticatedUser.IsAdministrator()) { defaultAccessLevel = AccessLevel.Read; } else { defaultAccessLevel = defaultAccessLevel ?? AccessLevel.NoAccess; } return metadataControlsList.MetadataControls.Select( controlName => { var entitlement = metadataControlEntitlements.FirstOrDefault(e => e.ControlName == controlName); if (entitlement == null) { return new MetadataControlAccess(controlName, defaultAccessLevel.Value); } return new MetadataControlAccess(controlName, entitlement.AccessLevel); }).ToList(); }
public void TestInitialize() { string json = AssemblyResourceReader.ReadAsString(string.Format("Mock.TestData.Role.roles.json")); this.roleList = JsonConvert.DeserializeObject<RoleList>(json); }
/// <summary> /// Imports the users. /// </summary> /// <param name="sessionData">The session data.</param> /// <param name="users">The list of users to import.</param> /// <param name="allRoles">A list of all roles in the system.</param> /// <param name="allOrganisations">A list of all organisations in the system.</param> /// <param name="systemRoleMap">A map of role ids, where the old id is the key and the new id is the value.</param> /// <param name="organisationMap">A map of organisation ids, where the old id is the key and the new id is the value.</param> /// <param name="validationResults">A list of validation results.</param> /// <param name="migrationResults">A list to which import results will be appended.</param> private void ImportUsers(SessionData sessionData, UserList users, RoleList allRoles, OrganisationList allOrganisations, Dictionary<string, string> systemRoleMap, Dictionary<string, string> organisationMap, MigrationDataResults validationResults, MigrationDataResults migrationResults) { foreach (User user in users) { if (!validationResults.GetNotificationsFor(user).CanImport) { migrationResults.AddNotification(user, MessageType.Information, string.Format(Messages.Import_UserSkipped, user.DisplayName)); continue; } foreach (KeyValuePair<string, string> kvp in systemRoleMap) { if (user.Roles.ContainsKey(kvp.Key)) { user.Roles.Remove(kvp.Key); user.Roles.Add(kvp.Value, allRoles[kvp.Value].RoleName); } } foreach (KeyValuePair<string, string> kvp in organisationMap) { if (user.Organisations.ContainsKey(kvp.Key)) { user.Organisations.Remove(kvp.Key); user.Organisations.Add(kvp.Value, allOrganisations[kvp.Value].Name); } } user.Id = null; User savedUser = this.securityGateway.SaveUser(sessionData, user); if (string.IsNullOrEmpty(user.ExternalId)) { migrationResults.AddNotification(savedUser, MessageType.Information, string.Format(Messages.Import_UserSuccess, savedUser.DisplayName)); } else { migrationResults.AddNotification(savedUser, MessageType.Information, string.Format(Messages.Import_UserSuccessNoPasswordChange, savedUser.DisplayName)); } } }
/// <summary> /// Gets the list of roles. /// </summary> /// <returns>The list of roles.</returns> protected override RoleList DoGetRoleList() { MongoCollection<BsonDocument> collection = this.database.GetCollection(iApplyDb.Role._COLLECTION_NAME); MongoCursor<BsonDocument> documents = collection.FindAll(); if (documents == null) { return new RoleList(); } RoleList roles = new RoleList(); roles.AddRange(documents.Select(document => BsonConverter.ConvertToObjectViaJson<Role>(document))); return roles; }
/// <summary> /// /// </summary> private void displayRolesInGrid() { RoleList.DataSource = m_adminEngine.getIdentityRoleList(); RoleList.DataBind(); }
/// <summary> /// Gets a list of forms the user is authorised for and in what states. /// </summary> /// <param name="session">Contains session and user information used to determine access rights.</param> /// <param name="roleList">The list of roles.</param> /// <returns>A list of forms the user is authorised for and in what states, serialized as JSON.</returns> /// <remarks> /// A user is deemed to be authorised for a form if they have <see cref="AccessLevel.Read"/> access or greater /// to the form in at least one state. /// </remarks> public UserFormAccessList GetAuthorisedForms(SecureSession session, RoleList roleList) { return this.wrappedProvider.GetAuthorisedForms(session, roleList); }
public List<PageAccess> GetPagesAccess( SecureSession session, Application application, IEnumerable<int> pageIds, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { throw new NotImplementedException(); }
/// <summary> /// Gets the page access level for each page in <paramref name="pageIds"/>. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="pageIds">The page IDs list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a page. If not set it will default to the application base access level.</param> /// <returns>The page entitlements that the user has.</returns> public List<PageAccess> GetPagesAccess(SecureSession session, Application application, IEnumerable<int> pageIds, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { if (this.ImpersonatedSession != null && string.IsNullOrWhiteSpace(application.Id)) { this.ImpersonateEntitlements(session); } return this.wrappedProvider.GetPagesAccess(session, application, pageIds, roleList, versionNumber); }
public void GetList() { var obj = RoleList.GetList(); Assert.IsTrue(obj.Count > 0); }
/// <summary> /// Gets the page access level for each page in <paramref name="pageList"/>. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="pageList">The page list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a page. If not set it will default to the application base access level.</param> /// <returns>The page entitlements that the user has.</returns> public List<PageAccess> GetPagesAccess(SecureSession session, Application application, PageList pageList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { return this.wrappedProvider.GetPagesAccess(session, application, pageList, roleList, versionNumber); }
/// <summary> /// Gets the control access level for each control in <paramref name="metadataControlsList"/>. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="metadataControlsList">The control list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a metadata control. If not set it will default to the application base access level.</param> /// <returns> /// The control entitlements that the user has. /// </returns> public List<MetadataControlAccess> GetMetadataControlsAccess(SecureSession session, Application application, MetadataControlList metadataControlsList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { return this.wrappedProvider.GetMetadataControlsAccess(session, application, metadataControlsList, roleList, versionNumber); }
/// <summary> /// Gets the control access level for each control in <paramref name="controlList"/>. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="controlList">The control list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a control. If not set it will default to the application base access level.</param> /// <returns> /// The control entitlements that the user has. /// </returns> public List<ControlAccess> GetControlsAccess(SecureSession session, Application application, ControlList controlList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { if (this.ImpersonatedSession != null && string.IsNullOrWhiteSpace(application.Id)) { this.ImpersonateEntitlements(session); } return this.wrappedProvider.GetControlsAccess(session, application, controlList, roleList, versionNumber); }
/// <summary> /// Gets the page access level for each page in <paramref name="pageIds"/>. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="pageIds">The page IDs list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a page. If not set it will default to the application base access level.</param> /// <returns>The page entitlements that the user has.</returns> public List<PageAccess> GetPagesAccess(SecureSession session, Application application, IEnumerable<int> pageIds, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { var userRoles = this.DetermineRolesForUser(session, roleList, application); var pageEntitlements = this.securityService.GetPageEntitlements(application.FormId, versionNumber, application.WorkflowState, userRoles.Keys); pageEntitlements.Merge(); if (session.AuthenticatedUser.IsAdministrator()) { return pageIds.Select(pageId => new PageAccess(pageId, AccessLevel.Read)).ToList(); } if (!defaultAccessLevel.HasValue) { defaultAccessLevel = this.GetApplicationAccess(session, application, roleList, versionNumber); } return pageIds.Select( pageId => { var entitlement = pageEntitlements.FirstOrDefault(e => e.PageId == pageId); if (entitlement == null) { return new PageAccess(pageId, defaultAccessLevel.Value); } return new PageAccess(pageId, entitlement.AccessLevel); }).ToList(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var userId = SessionHelper.FetchUserId(Session); using (QuizBookDbEntities1 _db = new QuizBookDbEntities1()) { var user = _db.AdminUsers.FirstOrDefault(s => s.Id == userId); if (user != null) { var tenantID = long.Parse(SessionHelper.GetTenantID(Session)); var rl = _db.Roles.FirstOrDefault(s => s.Description == "Admin"); var roles = _db.Roles.AsEnumerable().Where(x => x.Active && x.TenantId.HasValue && x.TenantId == tenantID); if (user.Role.HasValue && user.Role.Value != rl.Id) { roles = roles.Where(x => x.Id == user.Role.Value || x.CreatedBy == user.Id.ToString()); } var rls = roles.OrderBy(s => s.Description).Select(a => new { Id = a.Id, Name = a.Description }).ToList(); int count = rls.Count(); rls.Insert(0, new { Id = long.Parse("-1"), Name = "--Roles--" }); var memSelRole = Session["NewSelRole"]; var longmemSelRole = memSelRole == null ? "-1" : memSelRole.ToString(); RoleList.DataSource = rls; RoleList.SelectedValue = longmemSelRole; RoleList.DataBind(); EnableRegBtn(count); var admins = new List <AdminUser>(); //&& x.Role.HasValue && (x.Role == user.Role || x.Role == rl.Id) if (user.Role.HasValue && user.Role == rl.Id && (user.Supervisor ?? false)) { admins = _db.AdminUsers.AsEnumerable().Where(x => x.TenantId.HasValue && x.TenantId == tenantID).ToList(); } else if ((user.Supervisor ?? false)) { admins = _db.AdminUsers.AsEnumerable().Where(x => x.TenantId.HasValue && x.TenantId == tenantID && x.Role.HasValue && x.Role.Value == user.Role.Value && (user.Supervisor ?? false) || x.Role1.CreatedBy == user.Id.ToString()).ToList(); } AdminGridModel objm = new AdminGridModel(); var adm = new List <AdminGridModel>(); var rCount = 0; foreach (var a in admins) { objm = new AdminGridModel(); objm.adminId = a.Id; objm.username = a.Username; objm.firstname = a.FirstName; objm.lastname = a.LastName; objm.email = a.Email; objm.role = a.Role.HasValue?a.Role1.Description:"-"; objm.supervisor = a.Supervisor.HasValue ?a.Supervisor.Value?"Yes":"No": "No"; objm.edittxt = a.Id == user.Id ? "" :"Edit"; //if (a.Id == user.Id) //{ // objm.ends = string.Empty; //} //else //{ // if (a.Supervisor.HasValue) // { // if (a.Supervisor.Value) // { // if (a.Status.Trim() != "Active".Trim()) // { // objm.ends = "Enable"; // } // else // { // objm.ends = "Disable"; // } // } // else // { // objm.ends = string.Empty; // } // } // else // { // objm.ends = string.Empty; // } //} objm.ends = a.Id == user.Id ? string.Empty: (user.Supervisor ?? false)? a.Status.Trim() != "Active"?"Enable":"Disable":string.Empty; adm.Add(objm); rCount++; } TotalRecCount.Text = rCount + " Administrator(s)"; GridView1.DataSource = adm; GridView1.DataBind(); if (!string.IsNullOrEmpty(user.Location)) { country.Attributes.Add("data-default-value", user.Location); } else { country.Attributes.Add("data-default-value", "Nigeria"); } } } } }
public void GetRoleProcess() { Operation getDeploymentOperation; var currentDeployment = this.GetCurrentDeployment(out getDeploymentOperation); if (currentDeployment != null) { if (this.InstanceDetails.IsPresent == false) { var roleContexts = new Collection <RoleContext>(); RoleList roles = null; if (string.IsNullOrEmpty(this.RoleName)) { roles = currentDeployment.RoleList; } else { roles = new RoleList(currentDeployment.RoleList.Where(r => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase))); } foreach (var r in roles.Select(role => new RoleContext { InstanceCount = currentDeployment.RoleInstanceList.Count(ri => ri.RoleName.Equals(role.RoleName, StringComparison.OrdinalIgnoreCase)), RoleName = role.RoleName, OperationDescription = this.CommandRuntime.ToString(), OperationStatus = getDeploymentOperation.Status, OperationId = getDeploymentOperation.OperationTrackingId, ServiceName = this.ServiceName, DeploymentID = currentDeployment.PrivateID })) { roleContexts.Add(r); } WriteObject(roleContexts, true); } else { Collection <RoleInstanceContext> instanceContexts = new Collection <RoleInstanceContext>(); RoleInstanceList roleInstances = null; if (string.IsNullOrEmpty(this.RoleName)) { roleInstances = currentDeployment.RoleInstanceList; } else { roleInstances = new RoleInstanceList(currentDeployment.RoleInstanceList.Where(r => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase))); } foreach (RoleInstance role in roleInstances) { var context = new RoleInstanceContext() { ServiceName = this.ServiceName, OperationId = getDeploymentOperation.OperationTrackingId, OperationDescription = this.CommandRuntime.ToString(), OperationStatus = getDeploymentOperation.Status, InstanceErrorCode = role.InstanceErrorCode, InstanceFaultDomain = role.InstanceFaultDomain, InstanceName = role.InstanceName, InstanceSize = role.InstanceSize, InstanceStateDetails = role.InstanceStateDetails, InstanceStatus = role.InstanceStatus, InstanceUpgradeDomain = role.InstanceUpgradeDomain, RoleName = role.RoleName, DeploymentID = currentDeployment.PrivateID, InstanceEndpoints = role.InstanceEndpoints }; instanceContexts.Add(context); } WriteObject(instanceContexts, true); } } }
private void UpdateGuildUIs(GuildData guild) { if (guild == null) { return; } memberAmount = guild.CountMember(); UpdateUIs(); var selectedIdx = MemberSelectionManager.SelectedUI != null?MemberSelectionManager.IndexOf(MemberSelectionManager.SelectedUI) : -1; MemberSelectionManager.DeselectSelectedUI(); MemberSelectionManager.Clear(); SocialCharacterData[] members; byte[] memberRoles; guild.GetSortedMembers(out members, out memberRoles); MemberList.Generate(members, (index, guildMember, ui) => { var guildMemberEntity = new SocialCharacterEntityTuple(); guildMemberEntity.socialCharacter = guildMember; var uiGuildMember = ui.GetComponent <UIGuildCharacter>(); uiGuildMember.uiSocialGroup = this; uiGuildMember.Setup(guildMemberEntity, memberRoles[index], guild.GetRole(memberRoles[index])); uiGuildMember.Show(); MemberSelectionManager.Add(uiGuildMember); if (selectedIdx == index) { uiGuildMember.OnClickSelect(); } }); selectedIdx = RoleSelectionManager.SelectedUI != null?RoleSelectionManager.IndexOf(RoleSelectionManager.SelectedUI) : -1; RoleSelectionManager.DeselectSelectedUI(); RoleSelectionManager.Clear(); RoleList.Generate(guild.GetRoles(), (index, guildRole, ui) => { var uiGuildRole = ui.GetComponent <UIGuildRole>(); uiGuildRole.Data = guildRole; uiGuildRole.Show(); RoleSelectionManager.Add(uiGuildRole); if (selectedIdx == index) { uiGuildRole.OnClickSelect(); } }); selectedIdx = SkillSelectionManager.SelectedUI != null?SkillSelectionManager.IndexOf(SkillSelectionManager.SelectedUI) : -1; SkillSelectionManager.DeselectSelectedUI(); SkillSelectionManager.Clear(); SkillList.Generate(GameInstance.GuildSkills.Values, (index, guildSkill, ui) => { var uiGuildSkill = ui.GetComponent <UIGuildSkill>(); uiGuildSkill.Data = new GuildSkillTuple(guildSkill, guild.GetSkillLevel(guildSkill.DataId)); uiGuildSkill.Show(); SkillSelectionManager.Add(uiGuildSkill); if (selectedIdx == index) { uiGuildSkill.OnClickSelect(); } }); }
public void Page_Load() { if (!IsPostBack) { try { r = (RolePrincipal)User; rolesArray = r.GetRoles(); } catch (HttpException e) { Msg.Text = "There is no current logged on user. Role information cannot be retrieved."; return; } for (int i = 0; i < rolesArray.Length; i++) { Msg.Text = Msg.Text + rolesArray.GetValue(i); } if (rolesArray.Contains("Basic")) { Price.Text = "99kr/month"; currentRole = "Basic"; } else if (rolesArray.Contains("Plus")) { Price.Text = "199kr/month"; currentRole = "Plus"; } else if (rolesArray.Contains("Prime")) { Price.Text = "499kr/month"; currentRole = "Prime"; } else if (rolesArray.Contains("admin")) { Price.Text = "No monthly price for admin account"; currentRole = "admin"; RoleList.Visible = false; PriceLabel.Visible = false; Price.Visible = false; MembershipLabel.Visible = false; ConfirmButton.Visible = false; } else if (rolesArray.Contains("Instructor")) { Price.Text = "No monthly price for Instructor account"; currentRole = "Instructor"; RoleList.Visible = false; PriceLabel.Visible = false; Price.Visible = false; MembershipLabel.Visible = false; ConfirmButton.Visible = false; } // Bind the set of roles to RoleList RoleList.Items.Add(new ListItem("Basic 99kr/month", "Basic")); RoleList.Items.Add(new ListItem("Plus 199kr/month", "Plus")); RoleList.Items.Add(new ListItem("Prime 499kr/month", "Prime")); RoleList.DataBind(); } }
public ProjectViewModel(Project project, RoleList roleList, ResourceList resourceList) { Project = project; RoleList = roleList; ResourceList = resourceList; }
private ProjectViewModel ToViewModel(Project project) { return(new ProjectViewModel(project, RoleList.GetList(), ResourceList.GetResourceList())); }
protected void Page_Init(object sender, System.EventArgs e) { RoleList.DataSource = SecurityUtility.GetManagableRoles(); RoleList.DataBind(); trRoles.Visible = RoleList.Items.Count > 0; }
private void Roles_Saved(object sender, Csla.Core.SavedEventArgs e) { // this runs on the client and invalidates // the RoleList cache RoleList.InvalidateCache(); }
private void DisplayRolesInGrid() { RoleList.DataSource = Roles.GetAllRoles(); RoleList.DataBind(); }
/// <summary> /// Imports the roles. /// </summary> /// <param name="userId">The user making the request.</param> /// <param name="roles">The list of roles to import.</param> /// <param name="allRoles">A list of all roles already in the system.</param> /// <param name="validationResults">A list of validation results.</param> /// <param name="migrationResults">A list to which import results will be appended.</param> /// <returns>A map of role ids, where the old id is the key and the new id is the value.</returns> private Dictionary<string, string> ImportRoles(string userId, RoleList roles, RoleList allRoles, MigrationDataResults validationResults, MigrationDataResults migrationResults) { Dictionary<string, string> systemRoleMap = new Dictionary<string, string>(); foreach (Role role in roles) { if (role.SystemDefined) { string mappedValue = allRoles.FirstOrDefault(r => r.RoleName == role.RoleName).Id; systemRoleMap.Add(role.Id, mappedValue); migrationResults.AddNotification(role, MessageType.Information, string.Format(Messages.Import_RoleSkipped, role.RoleName)); continue; } if (!validationResults.GetNotificationsFor(role).CanImport) { migrationResults.AddNotification(role, MessageType.Information, string.Format(Messages.Import_RoleSkipped, role.RoleName)); continue; } this.manager.SaveRole(userId, role, true); migrationResults.AddNotification(role, MessageType.Information, string.Format(Messages.Import_RoleSuccess, role.RoleName)); } return systemRoleMap; }
public ResourceViewModel(Resource resource, RoleList roleList, ProjectList projectList) { Resource = resource; RoleList = roleList; ProjectList = projectList; }
{ Console.WriteLine(" RoleName: {0}", obj.RoleName); Console.WriteLine(" InstanceName: {0}", obj.InstanceName); Console.WriteLine(" InstanceStatus: {0}", obj.InstanceStatus); } } internal static void LogObject(UpgradeStatus upgradeStatus) { if (upgradeStatus == null) return; Console.WriteLine("UpgradeType: {0}", upgradeStatus.UpgradeType); Console.WriteLine("CurrentUpgradeDomain: {0}", upgradeStatus.CurrentUpgradeDomain);
private void dataBind() { roles = AccountsTool.GetRoleList(); RoleList.DataSource = roles.Tables["Roles"]; RoleList.DataBind(); }
/// <summary> /// Gets the control access level for each control in <paramref name="controlList"/>. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="controlList">The control list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a control. If not set it will default to the application base access level.</param> /// <returns> /// The control entitlements that the user has. /// </returns> public List<ControlAccess> GetControlsAccess(SecureSession session, Application application, ControlList controlList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { IEnumerable<Control> allControls = controlList.Flatten(); Dictionary<string, string> userRoles = this.DetermineRolesForUser(session, roleList, application); ControlEntitlementList controlEntitlements = this.securityService.GetControlEntitlements(application.FormId, versionNumber, application.WorkflowState, userRoles.Keys); controlEntitlements.Merge(); if (!defaultAccessLevel.HasValue) { defaultAccessLevel = this.GetApplicationAccess(session, application, roleList, versionNumber); } if (session.AuthenticatedUser.IsAdministrator()) { return allControls.Select(control => new ControlAccess(control.Id, control.Type == ControlType.Calculation ? AccessLevel.Read : AccessLevel.Write)).ToList(); } return allControls.Select( control => { var entitlement = controlEntitlements.FirstOrDefault(e => e.ControlId == control.Id); if (control.Type == ControlType.Calculation) { AccessLevel calcAccessLevel; if (entitlement == null) { calcAccessLevel = AccessLevel.Read; } else { calcAccessLevel = entitlement.AccessLevel == AccessLevel.NoAccess ? AccessLevel.NoAccess : AccessLevel.Read; } return new ControlAccess(control.Id, calcAccessLevel); } if (entitlement == null) { return new ControlAccess(control.Id, defaultAccessLevel.Value); } return new ControlAccess(control.Id, entitlement.AccessLevel); }).ToList(); }
private void DisplayRolesInGrid() { //Cargando Clase predeterminada de roles consulndo la base de dato RoleList.DataSource = Roles.GetAllRoles(); RoleList.DataBind(); }
/// <summary> /// Gets the page entitlements that the user has. /// </summary> /// <param name="session">The session.</param> /// <param name="application">The application the user is trying to access.</param> /// <param name="pageList">The page list.</param> /// <param name="roleList">The list of roles.</param> /// <param name="versionNumber">The version number.</param> /// <param name="defaultAccessLevel">The default access level to use when there is no entitlement for a page. If not set it will default to the application base access level.</param> /// <returns> /// The page entitlements that the user has. /// </returns> public virtual List<PageAccess> GetPagesAccess(SecureSession session, Application application, PageList pageList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { return this.GetPagesAccess(session, application, pageList.Select(p => p.PageId), roleList, versionNumber, defaultAccessLevel); }
private ResourceViewModel ToViewModel(Resource resource) { return(new ResourceViewModel(resource, RoleList.GetList(), ProjectList.GetProjectList())); }
/// <summary> /// Determines the applicable roles for <paramref name="session"/>. /// </summary> /// <param name="session">Contains session and user information used to determine access rights.</param> /// <param name="roleList">The list of roles.</param> /// <param name="application">The application, if relevant Defaults to <see langword="null"/>.</param> /// <returns>The applicable roles for <paramref name="session"/>.</returns> private Dictionary<string, string> DetermineRolesForUser(SecureSession session, RoleList roleList, Application application = null) { session = session ?? new SecureSession(); application = application ?? new Application(); Role publicRole = roleList.FirstOrDefault(r => r.SystemDefined && r.RoleName == SecurityConstants.PublicRoleName); Dictionary<string, string> roleDict = publicRole == null ? new Dictionary<string, string>() : new Dictionary<string, string> { { publicRole.Id, publicRole.RoleName } }; string compareTo = this.GetSessionUserId(session); if (application.IsCreatedBy(compareTo)) { Role originatorRole = roleList.FirstOrDefault(r => r.SystemDefined && r.RoleName == SecurityConstants.OriginatorRoleName); if (originatorRole != null) { roleDict.Add(originatorRole.Id, originatorRole.RoleName); } } if (session.AuthenticatedUser == null) { return roleDict; } if (session.AuthenticatedUser.IsAdministrator()) { foreach (var role in roleList) { if (roleDict.ContainsKey(role.Id)) { continue; } roleDict.Add(role.Id, role.RoleName); } return roleDict; } foreach (var userRole in session.AuthenticatedUser.Roles) { if (roleList.Exists(role => role.Id == userRole.Key && role.Enabled)) { roleDict.Add(userRole.Key, userRole.Value); } } if (!string.IsNullOrEmpty(application.AssignedTo) && session.AuthenticatedUser.Id == application.AssignedTo) { Role assigneeRole = roleList.FirstOrDefault(r => r.SystemDefined && r.RoleName == SecurityConstants.AssigneeRoleName); if (assigneeRole != null) { roleDict.Add(assigneeRole.Id, assigneeRole.RoleName); } } return roleDict; }
public List<MetadataControlAccess> GetMetadataControlsAccess( SecureSession session, Application application, MetadataControlList metadataControlsList, RoleList roleList, int versionNumber, AccessLevel? defaultAccessLevel = null) { throw new NotImplementedException(); }
/// <summary> /// Gets a list of forms the user is authorised for and in what states. /// </summary> /// <param name="session">Contains session and user information used to determine access rights.</param> /// <param name="roleList">The list of roles.</param> /// <returns>A list of forms the user is authorised for and in what states, serialized as JSON.</returns> /// <remarks> /// A user is deemed to be authorised for a form if they have <see cref="AccessLevel.Read"/> access or greater /// to the form in at least one state. /// </remarks> public virtual UserFormAccessList GetAuthorisedForms(SecureSession session, RoleList roleList) { session = session ?? new SecureSession(); var organisationIds = session.AuthenticatedUser == null ? new string[0] : session.AuthenticatedUser.Organisations.Select(o => o.Key).ToArray(); Dictionary<string, string> roles = this.DetermineRolesForUser(session, roleList); var applicationEntitlements = this.securityService.GetApplicationEntitlements(organisationIds, null).GroupBy(e => new { e.ProductId, e.ProductVersion }); if (this.IsAdministrator(session)) { UserFormAccessList returnList = new UserFormAccessList(); foreach (var entitlement in applicationEntitlements) { List<string> allStates = entitlement.Select(e => e.StateName).Distinct().ToList(); returnList.Add(new UserFormAccess(entitlement.Key.ProductId, allStates)); } return returnList; } UserFormAccessList formAccessList = new UserFormAccessList(); string originatorRoleId = roleList.FirstOrDefault(r => r.RoleName == SecurityConstants.OriginatorRoleName && r.SystemDefined).Id; string assigneeRoleId = roleList.FirstOrDefault(r => r.RoleName == SecurityConstants.AssigneeRoleName && r.SystemDefined).Id; foreach (var entitlements in applicationEntitlements) { List<string> explicitStates = entitlements.Where(e => roles.ContainsKey(e.RoleId) && e.AccessLevel > AccessLevel.NoAccess) .Select(e => e.StateName).ToList(); List<string> ownedStates = new List<string>(); List<string> originatorStates = new List<string>(); if (session.AuthenticatedUser != null) { ownedStates = entitlements.Where(e => e.RoleId == assigneeRoleId && e.AccessLevel > AccessLevel.NoAccess).Select(e => e.StateName).ToList(); originatorStates = entitlements.Where(e => e.RoleId == originatorRoleId && e.AccessLevel > AccessLevel.NoAccess).Select(e => e.StateName).ToList(); } if (explicitStates.Count > 0 || ownedStates.Count > 0 || originatorStates.Count > 0) { Dictionary<string, List<string>> implicitStates = new Dictionary<string, List<string>> { { SecurityConstants.AssigneeRoleName, ownedStates }, { SecurityConstants.OriginatorRoleName, originatorStates } }; formAccessList.Add(new UserFormAccess(entitlements.Key.ProductId, explicitStates, implicitStates)); } } return formAccessList; }
public void GetRoleProcess() { Operation getDeploymentOperation; var currentDeployment = this.GetCurrentDeployment(out getDeploymentOperation); if (currentDeployment != null) { if (this.InstanceDetails.IsPresent == false) { var roleContexts = new Collection<RoleContext>(); RoleList roles = null; if (string.IsNullOrEmpty(this.RoleName)) { roles = currentDeployment.RoleList; } else { roles = new RoleList(currentDeployment.RoleList.Where(r => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase))); } foreach (var r in roles.Select(role => new RoleContext { InstanceCount = currentDeployment.RoleInstanceList.Count(ri => ri.RoleName.Equals(role.RoleName, StringComparison.OrdinalIgnoreCase)), RoleName = role.RoleName, OperationDescription = this.CommandRuntime.ToString(), OperationStatus = getDeploymentOperation.Status, OperationId = getDeploymentOperation.OperationTrackingId, ServiceName = this.ServiceName, DeploymentID = currentDeployment.PrivateID })) { roleContexts.Add(r); } WriteObject(roleContexts, true); } else { Collection<RoleInstanceContext> instanceContexts = new Collection<RoleInstanceContext>(); RoleInstanceList roleInstances = null; if (string.IsNullOrEmpty(this.RoleName)) { roleInstances = currentDeployment.RoleInstanceList; } else { roleInstances = new RoleInstanceList(currentDeployment.RoleInstanceList.Where(r => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase))); } foreach (RoleInstance role in roleInstances) { var context = new RoleInstanceContext() { ServiceName = this.ServiceName, OperationId = getDeploymentOperation.OperationTrackingId, OperationDescription = this.CommandRuntime.ToString(), OperationStatus = getDeploymentOperation.Status, InstanceErrorCode = role.InstanceErrorCode, InstanceFaultDomain = role.InstanceFaultDomain, InstanceName = role.InstanceName, InstanceSize = role.InstanceSize, InstanceStateDetails = role.InstanceStateDetails, InstanceStatus = role.InstanceStatus, InstanceUpgradeDomain = role.InstanceUpgradeDomain, RoleName = role.RoleName, DeploymentID = currentDeployment.PrivateID, InstanceEndpoints = role.InstanceEndpoints }; instanceContexts.Add(context); } WriteObject(instanceContexts, true); } } }
/// <summary> /// Used to create a deployment and add any persistent vm role to the deployment /// </summary> /// <param name="role">The PersistentVMRole</param> /// <param name="cloudServiceName">The Name of the cloud service which the role is present in</param> /// <returns>The Deployment that is being used</returns> private static Deployment AddPersistentVMRole(string cloudServiceName, PersistentVMRole role) { var namer = new RandomAccountName(); var deployment = new Deployment { Name = cloudServiceName, // Label = Convert.ToBase64String(Encoding.UTF8.GetBytes(cloudServiceName)) Label = cloudServiceName }; role.RoleName = namer.GetPureRandomValue(); var roleList = new RoleList(); roleList.Roles.Add(role); deployment.RoleList = roleList; return deployment; }
protected override async void OnStart() { await Library.Security.PTPrincipal.LoginAsync("manager", "manager"); await RoleList.CacheListAsync(); }
public override void Persist() { Contact cnt = contact.SelectSingle(); EPEmployee currentEmployee = (cnt != null) ? Employee.Select(cnt.ContactID) : null; cnt = (Contact)contact.Cache.CreateCopy(cnt); if (UserList.Current != null) { UserList.Current.IsAssigned = cnt != null; foreach (Contact existing in PXSelect <Contact, Where <Contact.userID, Equal <Current <Users.pKID> > > > .Select(this)) { existing.UserID = null; contact.Update(existing); EPEmployee emp = Employee.Select(existing.ContactID); if (emp != null) { emp = PXCache <EPEmployee> .CreateCopy(emp); emp.UserID = null; Employee.Update(emp); } } if (cnt != null) { cnt.UserID = UserList.Current.PKID; contact.Update(cnt); if (currentEmployee != null) { currentEmployee = PXCache <EPEmployee> .CreateCopy(currentEmployee); currentEmployee.UserID = UserList.Current.PKID; Employee.Update(currentEmployee); } } } foreach (Users user in UserList.Cache.Deleted) { cnt = (Contact)contact.View.SelectSingleBound(new object[] { user }); if (cnt != null) { cnt.UserID = null; contact.Update(cnt); EPEmployee emp = Employee.Select(cnt.ContactID); if (emp != null) { emp = PXCache <EPEmployee> .CreateCopy(emp); emp.UserID = null; Employee.Update(emp); } } } if (UserList.Current != null && UserList.Current.OverrideADRoles != true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory) { //notice that this select returns nothing if called on AccessUsers. AccessUsers::roleList() returns empty list; foreach (UsersInRoles userrole in RoleList.Select()) { RoleList.Delete(userrole); } } //if no local roles selected - disable override. if (UserList.Current != null && UserList.Current.OverrideADRoles == true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory) { if (RolesByUser.SelectSingle() == null) { UserListCurrent.Current.OverrideADRoles = false; } } base.Persist(); }
private void DisplayRolesInGrid() { RoleList.DataSource = RoleManager.Roles.ToArray(); RoleList.DataBind(); }
public void GetRoleProcess() { RoleList roleList; RoleInstanceList roleInstanceList; Func<Role, bool> func = null; Func<RoleInstance, bool> func1 = null; this.GetCurrentDeployment(); if (this.currentDeployment != null) { SwitchParameter instanceDetails = this.InstanceDetails; if (instanceDetails.IsPresent) { Collection<RoleInstanceContext> roleInstanceContexts = new Collection<RoleInstanceContext>(); if (!string.IsNullOrEmpty(this.RoleName)) { RoleInstanceList roleInstanceList1 = this.currentDeployment.RoleInstanceList; if (func1 == null) { func1 = (RoleInstance r) => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase); } roleInstanceList = new RoleInstanceList(roleInstanceList1.Where<RoleInstance>(func1)); } else { roleInstanceList = this.currentDeployment.RoleInstanceList; } foreach (RoleInstance roleInstance in roleInstanceList) { RoleInstanceContext roleInstanceContext = new RoleInstanceContext(); roleInstanceContext.ServiceName = this.ServiceName; roleInstanceContext.set_OperationId(this.getDeploymentOperation.OperationTrackingId); roleInstanceContext.set_OperationDescription(base.CommandRuntime.ToString()); roleInstanceContext.set_OperationStatus(this.getDeploymentOperation.Status); roleInstanceContext.InstanceErrorCode = roleInstance.InstanceErrorCode; roleInstanceContext.InstanceFaultDomain = roleInstance.InstanceFaultDomain; roleInstanceContext.InstanceName = roleInstance.InstanceName; roleInstanceContext.InstanceSize = roleInstance.InstanceSize; roleInstanceContext.InstanceStateDetails = roleInstance.InstanceStateDetails; roleInstanceContext.InstanceStatus = roleInstance.InstanceStatus; roleInstanceContext.InstanceUpgradeDomain = roleInstance.InstanceUpgradeDomain; roleInstanceContext.RoleName = roleInstance.RoleName; roleInstanceContext.DeploymentID = this.currentDeployment.PrivateID; roleInstanceContext.InstanceEndpoints = roleInstance.InstanceEndpoints; RoleInstanceContext roleInstanceContext1 = roleInstanceContext; roleInstanceContexts.Add(roleInstanceContext1); } base.WriteObject(roleInstanceContexts, true); } else { Collection<RoleContext> roleContexts = new Collection<RoleContext>(); if (!string.IsNullOrEmpty(this.RoleName)) { RoleList roleList1 = this.currentDeployment.RoleList; if (func == null) { func = (Role r) => r.RoleName.Equals(this.RoleName, StringComparison.OrdinalIgnoreCase); } roleList = new RoleList(roleList1.Where<Role>(func)); } else { roleList = this.currentDeployment.RoleList; } List<Role>.Enumerator enumerator = roleList.GetEnumerator(); try { Func<RoleInstance, bool> func2 = null; while (enumerator.MoveNext()) { Role current = enumerator.Current; RoleContext roleContext = new RoleContext(); RoleContext roleContext1 = roleContext; RoleInstanceList roleInstanceList2 = this.currentDeployment.RoleInstanceList; if (func2 == null) { func2 = (RoleInstance ri) => ri.RoleName.Equals(current.RoleName, StringComparison.OrdinalIgnoreCase); } roleContext1.InstanceCount = roleInstanceList2.Where<RoleInstance>(func2).Count<RoleInstance>(); roleContext.RoleName = current.RoleName; roleContext.set_OperationDescription(base.CommandRuntime.ToString()); roleContext.set_OperationStatus(this.getDeploymentOperation.Status); roleContext.set_OperationId(this.getDeploymentOperation.OperationTrackingId); roleContext.ServiceName = this.ServiceName; roleContext.DeploymentID = this.currentDeployment.PrivateID; RoleContext roleContext2 = roleContext; roleContexts.Add(roleContext2); } } finally { enumerator.Dispose(); } base.WriteObject(roleContexts, true); return; } } }
public UserInputDialog(string question, string mode = "", User user = null) { InitializeComponent(); ObjBranchService = new APIService(); Result = new User(); tbkQuestion.Text = question; GetRoleList(); GetActiveBranchList(); if (mode == "add") { tbUsername.Text = "Sample_username"; tbPassword.Text = "Sample_password"; cbRoleList.SelectedItem = "Staff"; cbBranchList.SelectedItem = Properties.Settings.Default.CurrentBranch; } else if (mode == "update") { tbUsername.IsReadOnly = true; tbUsername.Focusable = false; tbUsername.Text = user.Username; tbPassword.Text = "Sample_password"; tbPassword.SelectAll(); tbPassword.Focus(); if (user.Role == "Super Admin") { RoleList.Add("Super Admin"); cbRoleList.SelectedItem = "Super Admin"; cbRoleList.IsHitTestVisible = false; cbRoleList.Focusable = false; tbkBranch.Visibility = Visibility.Collapsed; cbBranchList.Visibility = Visibility.Collapsed; } else { cbRoleList.SelectedItem = user.Role; cbBranchList.SelectedItem = user.Branch_name != null ? user.Branch_name : ""; } } else if (mode == "delete") { tbUsername.Text = user.Username; tbUsername.IsReadOnly = true; tbUsername.Focusable = false; tbPassword.Text = "{Encrypted}"; tbPassword.IsReadOnly = true; tbPassword.Focusable = false; cbRoleList.SelectedItem = user.Role; cbRoleList.IsReadOnly = true; cbRoleList.IsEnabled = false; cbBranchList.SelectedItem = user.Branch_name; cbBranchList.IsReadOnly = true; cbBranchList.IsEnabled = false; } else if (mode == "forceLogout") { tbUsername.Text = user.Username; tbUsername.IsReadOnly = true; tbUsername.Focusable = false; tbPassword.Text = "{Encrypted}"; tbPassword.IsReadOnly = true; tbPassword.Focusable = false; RoleList.Add("Super Admin"); cbRoleList.SelectedItem = user.Role; cbRoleList.IsReadOnly = true; cbRoleList.IsEnabled = false; cbBranchList.SelectedItem = user.Branch_name; cbBranchList.IsReadOnly = true; cbBranchList.IsEnabled = false; } }
internal override void ExecuteCommand() { base.ExecuteCommand(); if (!string.IsNullOrEmpty(ServiceName) && CurrentDeployment == null) { return; } List<PersistentVMRoleContext> roles = new List<PersistentVMRoleContext>(); RoleList vmRoles = null; if (string.IsNullOrEmpty(ServiceName)) { ListAllVMs(); return; } if (string.IsNullOrEmpty(Name)) { vmRoles = CurrentDeployment.RoleList; } else { vmRoles = new RoleList(CurrentDeployment.RoleList.Where(r => r.RoleName.Equals(Name, StringComparison.InvariantCultureIgnoreCase))); } foreach (Role role in vmRoles) { string lastVM = string.Empty; try { lastVM = role.RoleName; PersistentVMRole vm = (PersistentVMRole)role; PersistentVMRoleContext vmContext = new PersistentVMRoleContext(); if (CurrentDeployment != null) { vmContext.DNSName = CurrentDeployment.Url.AbsoluteUri; } vmContext.ServiceName = ServiceName; vmContext.Name = vm.RoleName; vmContext.DeploymentName = CurrentDeployment.Name; vmContext.VM = new PersistentVM(); vmContext.VM.AvailabilitySetName = vm.AvailabilitySetName; vmContext.AvailabilitySetName = vm.AvailabilitySetName; vmContext.Label = vm.Label; vmContext.VM.ConfigurationSets = vm.ConfigurationSets; vmContext.VM.DataVirtualHardDisks = vm.DataVirtualHardDisks; vmContext.VM.Label = vm.Label; vmContext.VM.OSVirtualHardDisk = vm.OSVirtualHardDisk; vmContext.VM.RoleName = vm.RoleName; vmContext.Name = vm.RoleName; vmContext.VM.RoleSize = vm.RoleSize; vmContext.InstanceSize = vm.RoleSize; vmContext.VM.RoleType = vm.RoleType; vmContext.InstanceStatus = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName).InstanceStatus; vmContext.IpAddress = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName).IpAddress; vmContext.InstanceStateDetails = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName).InstanceStateDetails; vmContext.PowerState = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName).PowerState; vmContext.InstanceErrorCode = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName).InstanceErrorCode; vmContext.InstanceName = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName).InstanceName; vmContext.InstanceFaultDomain = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName).InstanceFaultDomain.Value.ToString(CultureInfo.InvariantCulture); vmContext.InstanceUpgradeDomain = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName).InstanceUpgradeDomain.Value.ToString(CultureInfo.InvariantCulture); vmContext.OperationDescription = CommandRuntime.ToString(); vmContext.OperationId = GetDeploymentOperation.OperationTrackingId; vmContext.OperationStatus = GetDeploymentOperation.Status; roles.Add(vmContext); } catch (Exception) { WriteObject(string.Format("Could not read properties for virtual machine: {0}. It may still be provisioning.", lastVM)); } } if (!string.IsNullOrEmpty(Name) && roles != null && roles.Count > 0) { SaveRoleState(roles[0].VM); } WriteObject(roles, true); }
public IEnumerable <PersistentVMRoleContext> GetVirtualMachineProcess() { RoleList roleList; GetAzureVMCommand.GetAzureVMCommand variable = null; IEnumerable <PersistentVMRoleContext> persistentVMRoleContexts; Func <Role, bool> func = null; if (string.IsNullOrEmpty(this.ServiceName) || base.CurrentDeployment != null) { using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { List <PersistentVMRoleContext> persistentVMRoleContexts1 = new List <PersistentVMRoleContext>(); if (!string.IsNullOrEmpty(this.ServiceName)) { if (!string.IsNullOrEmpty(this.Name)) { RoleList roleList1 = base.CurrentDeployment.RoleList; if (func == null) { func = (Role r) => r.RoleName.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase); } roleList = new RoleList(roleList1.Where <Role>(func)); } else { roleList = base.CurrentDeployment.RoleList; } for (int i = 0; i < roleList.Count; i++) { string empty = string.Empty; try { empty = roleList[i].RoleName; PersistentVMRole item = (PersistentVMRole)roleList[i]; PersistentVMRoleContext persistentVMRoleContext = new PersistentVMRoleContext(); if (base.CurrentDeployment != null) { persistentVMRoleContext.DNSName = base.CurrentDeployment.Url.AbsoluteUri; } persistentVMRoleContext.ServiceName = this.ServiceName; persistentVMRoleContext.Name = item.RoleName; persistentVMRoleContext.DeploymentName = base.CurrentDeployment.Name; persistentVMRoleContext.VM = new PersistentVM(); persistentVMRoleContext.VM.AvailabilitySetName = item.AvailabilitySetName; persistentVMRoleContext.AvailabilitySetName = item.AvailabilitySetName; persistentVMRoleContext.Label = item.Label; persistentVMRoleContext.VM.ConfigurationSets = item.ConfigurationSets; persistentVMRoleContext.VM.ConfigurationSets.OfType <NetworkConfigurationSet>().SingleOrDefault <NetworkConfigurationSet>(); persistentVMRoleContext.VM.DataVirtualHardDisks = item.DataVirtualHardDisks; persistentVMRoleContext.VM.Label = item.Label; persistentVMRoleContext.VM.OSVirtualHardDisk = item.OSVirtualHardDisk; persistentVMRoleContext.VM.RoleName = item.RoleName; persistentVMRoleContext.Name = item.RoleName; persistentVMRoleContext.VM.RoleSize = item.RoleSize; persistentVMRoleContext.InstanceSize = item.RoleSize; persistentVMRoleContext.VM.RoleType = item.RoleType; persistentVMRoleContext.InstanceStatus = base.CurrentDeployment.RoleInstanceList.Where <RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First <RoleInstance>().InstanceStatus; persistentVMRoleContext.IpAddress = base.CurrentDeployment.RoleInstanceList.Where <RoleInstance>((RoleInstance r) => r.RoleName == this.vm.RoleName).First <RoleInstance>().IpAddress; persistentVMRoleContext.InstanceStateDetails = base.CurrentDeployment.RoleInstanceList.Where <RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First <RoleInstance>().InstanceStateDetails; persistentVMRoleContext.PowerState = base.CurrentDeployment.RoleInstanceList.Where <RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First <RoleInstance>().PowerState; persistentVMRoleContext.InstanceErrorCode = base.CurrentDeployment.RoleInstanceList.Where <RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First <RoleInstance>().InstanceErrorCode; persistentVMRoleContext.InstanceName = base.CurrentDeployment.RoleInstanceList.Where <RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First <RoleInstance>().InstanceName; int?instanceFaultDomain = base.CurrentDeployment.RoleInstanceList.Where <RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First <RoleInstance>().InstanceFaultDomain; int value = instanceFaultDomain.Value; persistentVMRoleContext.InstanceFaultDomain = value.ToString(); int?instanceUpgradeDomain = base.CurrentDeployment.RoleInstanceList.Where <RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First <RoleInstance>().InstanceUpgradeDomain; int num = instanceUpgradeDomain.Value; persistentVMRoleContext.InstanceUpgradeDomain = num.ToString(); persistentVMRoleContext.set_OperationDescription(base.CommandRuntime.ToString()); persistentVMRoleContext.set_OperationId(base.GetDeploymentOperation.OperationTrackingId); persistentVMRoleContext.set_OperationStatus(base.GetDeploymentOperation.Status); persistentVMRoleContexts1.Add(persistentVMRoleContext); } catch (Exception exception) { base.WriteObject(string.Format("Could not read properties for virtual machine: {0}. It may still be provisioning.", empty)); } } if (!string.IsNullOrEmpty(this.Name) && persistentVMRoleContexts1 != null && persistentVMRoleContexts1.Count > 0) { this.SaveRoleState(persistentVMRoleContexts1[0].VM); } persistentVMRoleContexts = persistentVMRoleContexts1; return(persistentVMRoleContexts); } else { this.ListAllVMs(); persistentVMRoleContexts = null; return(persistentVMRoleContexts); } } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; if (communicationException as EndpointNotFoundException == null || base.IsVerbose()) { this.WriteErrorDetails(communicationException); } else { persistentVMRoleContexts = null; return(persistentVMRoleContexts); } } persistentVMRoleContexts = null; } return(persistentVMRoleContexts); } else { return(null); } }
internal override void ExecuteCommand() { base.ExecuteCommand(); if (!string.IsNullOrEmpty(ServiceName) && CurrentDeployment == null) { return; } List <PersistentVMRoleContext> roles = new List <PersistentVMRoleContext>(); RoleList vmRoles = null; if (string.IsNullOrEmpty(ServiceName)) { ListAllVMs(); return; } if (string.IsNullOrEmpty(Name)) { vmRoles = CurrentDeployment.RoleList; } else { vmRoles = new RoleList(CurrentDeployment.RoleList.Where(r => r.RoleName.Equals(Name, StringComparison.InvariantCultureIgnoreCase))); } foreach (Role role in vmRoles) { string lastVM = string.Empty; try { lastVM = role.RoleName; var vm = (PersistentVMRole)role; var roleInstance = CurrentDeployment.RoleInstanceList.First(r => r.RoleName == vm.RoleName); var vmContext = new PersistentVMRoleContext { ServiceName = ServiceName, Name = vm.RoleName, DeploymentName = CurrentDeployment.Name, AvailabilitySetName = vm.AvailabilitySetName, Label = vm.Label, InstanceSize = vm.RoleSize, InstanceStatus = roleInstance.InstanceStatus, IpAddress = roleInstance.IpAddress, InstanceStateDetails = roleInstance.InstanceStateDetails, PowerState = roleInstance.PowerState, InstanceErrorCode = roleInstance.InstanceErrorCode, InstanceName = roleInstance.InstanceName, InstanceFaultDomain = roleInstance.InstanceFaultDomain.HasValue ? roleInstance.InstanceFaultDomain.Value.ToString(CultureInfo.InvariantCulture) : null, InstanceUpgradeDomain = roleInstance.InstanceUpgradeDomain.HasValue ? roleInstance.InstanceUpgradeDomain.Value.ToString(CultureInfo.InvariantCulture) : null, OperationDescription = CommandRuntime.ToString(), OperationId = GetDeploymentOperation.OperationTrackingId, OperationStatus = GetDeploymentOperation.Status, VM = new PersistentVM { AvailabilitySetName = vm.AvailabilitySetName, ConfigurationSets = vm.ConfigurationSets, DataVirtualHardDisks = vm.DataVirtualHardDisks, Label = vm.Label, OSVirtualHardDisk = vm.OSVirtualHardDisk, RoleName = vm.RoleName, RoleSize = vm.RoleSize, RoleType = vm.RoleType, DefaultWinRmCertificateThumbprint = vm.DefaultWinRmCertificateThumbprint }, }; if (CurrentDeployment != null) { vmContext.DNSName = CurrentDeployment.Url.AbsoluteUri; } roles.Add(vmContext); } catch (Exception e) { throw new ApplicationException(string.Format(Resources.VMPropertiesCanNotBeRead, lastVM), e); } } WriteObject(roles, true); }