Esempio n. 1
0
        public async Task OnGetAsync(string userid)
        {
            User_ID = userid;
            var user = await _userManager.FindByIdAsync(userid);

            var role_user = await _userManager.GetRolesAsync(user);

            ListOfRole = (List <string>)role_user;
            foreach (var role in _roleManager.Roles)
            {
                UserRoleView rolecollection = new UserRoleView
                {
                    RoleId   = role.Id,
                    RoleName = role.Name
                };
                if (ListOfRole.Contains(role.Name))
                {
                    rolecollection.IsSelected = true;
                }
                else
                {
                    rolecollection.IsSelected = false;
                }
                RoleList.Add(rolecollection);
            }
        }
Esempio n. 2
0
        async Task ExecuteLoadItemsCommand()
        {
            try
            {
                RoleService role = new RoleService();
                RoleList.Clear();
                var items = await role.GetSignUpRole();

                foreach (var item in items)
                {
                    if (item.RoleName == "Isolator" || item.RoleName == "Engineer")
                    {
                        RoleList.Add(new RoleModel()
                        {
                            Id = item.Id, RoleName = item.RoleName
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                // IsBusy = false;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// To Get All Role
        /// </summary>
        /// <param name="RoleName"></param>
        /// <returns></returns>
        public RoleList GetAllRole(string RoleName)
        {
            OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString);
            OracleCommand    cmd;
            string           proc = "USP_MST_GET_ALL_ROLES";

            cmd             = new OracleCommand(proc, cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            if (RoleName.ToString() == "")
            {
                cmd.Parameters.Add("@RoleNameIN", DBNull.Value);
            }
            else
            {
                cmd.Parameters.Add("@RoleNameIN", RoleName.ToString());
            }
            cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
            cmd.Connection.Open();
            OracleDataReader dr      = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            RoleBO           objRole = null;
            RoleList         Roles   = new RoleList();

            while (dr.Read())
            {
                objRole                 = new RoleBO();
                objRole.RoleID          = dr.GetInt16(dr.GetOrdinal("RoleId"));
                objRole.RoleName        = dr.GetString(dr.GetOrdinal("RoleName"));
                objRole.RoleDescription = dr.GetString(dr.GetOrdinal("RoleDescription"));
                objRole.IsDeleted       = dr.GetString(dr.GetOrdinal("ISDELETED"));
                Roles.Add(objRole);
            }
            dr.Close();
            return(Roles);
        }
Esempio n. 4
0
        internal Deployment(DeploymentGetResponse response)
            : this()
        {
            if (response.PersistentVMDowntime != null)
            {
                PersistentVMDowntime = new PersistentVMDowntimeInfo(response.PersistentVMDowntime);
            }

            Name           = response.Name;
            DeploymentSlot = response.DeploymentSlot == Management.Compute.Models.DeploymentSlot.Staging ? "Staging" : "Production";
            PrivateID      = response.PrivateId;
            Status         = DeploymentStatusFactory.From(response.Status);
            Label          = response.Label;
            Url            = response.Uri;
            Configuration  = response.Configuration;
            foreach (var roleInstance in response.RoleInstances.Select(ri => new RoleInstance(ri)))
            {
                RoleInstanceList.Add(roleInstance);
            }

            if (response.UpgradeStatus != null)
            {
                UpgradeStatus = new UpgradeStatus(response.UpgradeStatus);
            }

            UpgradeDomainCount = response.UpgradeDomainCount;
            if (response.Roles != null)
            {
                foreach (var role in response.Roles.Select(r => new Role(r)))
                {
                    RoleList.Add(role);
                }
            }
            SdkVersion         = response.SdkVersion;
            Locked             = response.Locked;
            RollbackAllowed    = response.RollbackAllowed;
            VirtualNetworkName = response.VirtualNetworkName;
            CreatedTime        = response.CreatedTime;
            LastModifiedTime   = response.LastModifiedTime;

            if (response.ExtendedProperties != null)
            {
                foreach (var prop in response.ExtendedProperties.Keys)
                {
                    ExtendedProperties[prop] = response.ExtendedProperties[prop];
                }
            }

            if (response.DnsSettings != null)
            {
                Dns = new DnsSettings(response.DnsSettings);
            }
            if (response.VirtualIPAddresses != null)
            {
                foreach (var vip in response.VirtualIPAddresses.Select(v => new VirtualIP(v)))
                {
                    VirtualIPs.Add(vip);
                }
            }
        }
Esempio n. 5
0
        private void addRoleBy(int id)
        {
            object _lock = new object();

            if (RoleModelList != null)
            {
                Role roleFound = RoleModelList.Where(x => x.Role.ID == id).Select(x => x.Role).FirstOrDefault();
                lock (_lock)
                    if (roleFound != null)
                    {
                        if (RoleList == null)
                        {
                            RoleList = new List <Role>();
                        }

                        if (RoleList.Where(x => x.ID == roleFound.ID).Count() == 0)
                        {
                            RoleList.Add(roleFound);
                            RoleToAddList.Add(new RoleModel {
                                Role = roleFound
                            });
                        }
                        else
                        {
                            RoleList = RoleList.Where(x => x.ID != roleFound.ID).ToList();
                            RoleToRemoveList.Add(new RoleModel {
                                Role = roleFound
                            });
                        }
                    }
            }
        }
 private void GetAllRoles()
 {
     RoleList.Clear();
     _roleService.GetAllRoles().ToList().ForEach(x =>
     {
         RoleList.Add(x);
     });
 }
Esempio n. 7
0
 private RoleList GetRoles(Boolean refresh)
 {
     if (_roles.IsNull() || refresh)
     {
         _roles = new RoleList();
         _roles.Add(RoleTest.GetOneRole(GetUserContext()));
     }
     return(_roles);
 }
Esempio n. 8
0
        public RoleList GetUserRoles(IUserContext userContext, int userId, string applicationIdentifier)
        {
            RoleList roleList = new RoleList();

            if (userId == DyntaxaTestSettings.Default.TestApplicationUserId)
            {
                roleList.Add(GetNewRole("TestUser", 1000));
                roleList.Add(GetTaxonRevisionRole("TestUserDyntaxaAdministratorRole", 1003, userContext, DyntaxaTestSettings.Default.TestRevisionOngoingGUID));
            }
            else
            {
                roleList.Add(GetNewRole("TestUser", 1000));
                roleList.Add(GetTaxonAdministratorRole("TestUserDyntaxaAdministratorRole", 1001, userContext));
                roleList.Add(GetTaxonEditorRole("TestUserDyntaxaEditorRole", 1002, userContext));
            }

            return(roleList);
        }
Esempio n. 9
0
        private async void LoadUserRoleList()
        {
            RoleList.Clear();

            IEnumerator <string> e = userManager.GetUserRoleList().GetEnumerator();

            while (await Task.Factory.StartNew(() => e.MoveNext()))
            {
                RoleList.Add(e.Current);
            }
        }
Esempio n. 10
0
        public static RoleList GetList(IWhere whereClause, IOrderBy orderByClause)
        {
            SqlDataReader dataReader = GetListReader(DatabaseEnum.ORDERDB, TABLE, whereClause, orderByClause, true);
            RoleList      list       = new RoleList();

            while (dataReader.Read())
            {
                list.Add(GetDataObjectFromReader(dataReader));
            }
            dataReader.Close();
            return(list);
        }
Esempio n. 11
0
 public static void AddRole(string[] arrId)
 {
     foreach (string Id in arrId)
     {
         Guid rId  = new Guid(Id);
         Role role = RoleNotOfUserCollection.Where(r => r.Id == rId).Single();
         RoleList.Add(role);
         RoleNotOfUserCollection.Remove(role);
         RoleOfUserList.Add(new UserInRole {
             UserId = Args.User.Id, RoleId = rId
         });
     }
 }
Esempio n. 12
0
        /// <summary>
        /// 新增命令
        /// </summary>
        /// <returns></returns>
        public override void ExecuteAdd()
        {
            Sys_Roles role = new Sys_Roles();

            role.ID = new UserInfoBLL().GetMaxRoleID() + 1;
            FrmRoleSettingEdit edit = new FrmRoleSettingEdit(role);

            edit.SaveEvent += (r) =>
            {
                RoleList.Add(r);
            };
            edit.ShowDialog();
        }
Esempio n. 13
0
        public void SquareBracketOperator()
        {
            RoleList newRoleList, oldRoleList;
            Int32    roleIndex;

            oldRoleList = GetRoles(true);
            newRoleList = new RoleList();
            for (roleIndex = 0; roleIndex < oldRoleList.Count; roleIndex++)
            {
                newRoleList.Add(oldRoleList[oldRoleList.Count - roleIndex - 1]);
            }
            for (roleIndex = 0; roleIndex < oldRoleList.Count; roleIndex++)
            {
                Assert.AreEqual(newRoleList[roleIndex], oldRoleList[oldRoleList.Count - roleIndex - 1]);
            }
        }
Esempio n. 14
0
        public RoleList GetRolesBySearchCriteria(IUserContext userContext, IRoleSearchCriteria searchCriteria)
        {
            RoleList roleList = new RoleList();

            if (searchCriteria.Identifier != null && (searchCriteria.Identifier.Equals("%%") || searchCriteria.Identifier.Contains(DyntaxaTestSettings.Default.TestRevisionId.ToString())))

            {
                roleList.Add(GetTaxonRevisionRole(userContext.User.UserName, DyntaxaTestSettings.Default.TestApplicationUserId, userContext, DyntaxaTestSettings.Default.TestRevisionGUID));
            }
            else if (searchCriteria.Identifier != null && searchCriteria.Identifier.Contains(DyntaxaTestSettings.Default.TestRevisionOngoingId.ToString()))
            {
                roleList.Add(GetTaxonRevisionRole(userContext.User.UserName, DyntaxaTestSettings.Default.TestApplicationUserId, userContext, DyntaxaTestSettings.Default.TestRevisionOngoingGUID));
            }
            else if (searchCriteria.Identifier != null && searchCriteria.Identifier.Contains(DyntaxaTestSettings.Default.TestRevisionPublishedId.ToString()))
            {
                roleList.Add(GetTaxonRevisionRole(userContext.User.UserName, DyntaxaTestSettings.Default.TestApplicationUserId, userContext, DyntaxaTestSettings.Default.TestRevisionPublishedGUID));
            }
            else if (searchCriteria.Identifier != null && searchCriteria.Identifier.Equals(Resources.DyntaxaSettings.Default.TaxonRevisionAdministrator))
            {
                roleList.Add(GetTaxonAdministratorRole(userContext.User.UserName, DyntaxaTestSettings.Default.TestDummyUserId, userContext));
            }
            else if (searchCriteria.Identifier != null && searchCriteria.Identifier.Equals(Resources.DyntaxaSettings.Default.DyntaxaTaxonEditor))
            {
                roleList.Add(GetTaxonEditorRole(userContext.User.UserName, DyntaxaTestSettings.Default.TestUserId, userContext));
            }
            else if (searchCriteria.Name != null && searchCriteria.Name.Contains(DyntaxaTestSettings.Default.TestRevisionId.ToString()))
            {
                roleList.Add(GetTaxonRevisionRole(userContext.User.UserName, DyntaxaTestSettings.Default.TestApplicationUserId, userContext, DyntaxaTestSettings.Default.TestRevisionGUID));
            }
            else
            {
                roleList.Add(GetTaxonEditorRole(userContext.User.UserName, DyntaxaTestSettings.Default.TestUserId, userContext));
                roleList.Add(GetTaxonAdministratorRole("TestUser2", DyntaxaTestSettings.Default.TestDummyUserId, userContext));
                roleList.Add(GetTaxonRevisionRole("TestUser3", DyntaxaTestSettings.Default.TestApplicationUserId, userContext, DyntaxaTestSettings.Default.TestRevisionGUID));
            }
            //
            //roleList.Add(GetTaxonRevisionRole(userContext.User.UserName, 2, userContext, DyntaxaTestSettings.Default.TestRevisionGUID));
            return(roleList);
        }
Esempio n. 15
0
        public async Task GetRoles()
        {
            try
            {
                List <RoleResponseModel> Roles = await dashboardRepo.GetRoles();

                RoleList.Clear();

                foreach (var r in Roles)
                {
                    RoleList.Add(r);
                }
            }
            catch (Exception e)
            {
                Toast.ProvideToast().ShowError("Can't load roles");
            }
        }
Esempio n. 16
0
        public static void ReloadRoles()
        {
            if (RoleList.Count > 0)
            {
                RoleList.RemoveAll(v => true);
            }

            JObject config = JObject.Parse(File.ReadAllText("permissions.json"));

            foreach (JProperty role in ((JObject)config.SelectToken("Roles")).Properties())
            {
                Role newRole = new Role(role.Name);
                foreach (JToken command in config.SelectToken($"Roles.{role.Name}"))
                {
                    newRole.Commands.Add(command.ToString());
                }
                RoleList.Add(newRole);
            }
        }
Esempio n. 17
0
        private void OnUserChanged(Models.User user)
        {
            var roleDescriptionList = Enum.GetValues(typeof(Role)).Cast <Role>().Select(x => EnumHelper.GetDescription(x)).ToList();

            foreach (var role in roleDescriptionList)
            {
                if (!User.Roles.Any(x => x.Equals(role, StringComparison.OrdinalIgnoreCase)))
                {
                    RoleList.Add(role);
                }
            }

            var userRole = RoleList.SingleOrDefault(x => x.Equals("user", StringComparison.OrdinalIgnoreCase));

            if (userRole != null)
            {
                RoleList.Remove(userRole);
                User.Roles.Add(userRole);
            }
        }
Esempio n. 18
0
 public bool AddRole(Role role)
 {
     //避免多线程同时修改list.
     lock (RoleList)
     {
         if (RoleList.Count >= MaxRoleNum)
         {
             return(false);
         }
         //初始化角色在房间中的临时数据
         RoleTempData roleTempData = role.roleTempData;
         roleTempData.room   = this;
         roleTempData.status = EnumRoleStatus.Room;
         roleTempData.Camp   = SelectCamp();
         if (RoleList.Count == 0)
         {
             roleTempData.isOwner = true;
         }
         RoleList.Add(role);
     }
     return(true);
 }
Esempio n. 19
0
        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;
            }
        }