Esempio n. 1
0
        public bool UpdateUserGroup(UserGroupRowData userGroup)
        {
            bool success;

            using (var service = new AuthorityManagement())

            {
                var detail = new AuthorityGroupDetail
                {
                    AuthorityGroupRef = new EntityRef(userGroup.Ref),
                    Name        = userGroup.Name,
                    Description = userGroup.Description,
                    DataGroup   = userGroup.DataGroup
                };

                foreach (TokenSummary token in userGroup.Tokens)
                {
                    detail.AuthorityTokens.Add(new AuthorityTokenSummary(token.Name, token.Description));
                }

                service.UpdateAuthorityGroup(detail, userGroup.Password);
                success = true;
            }

            //TODO: Catch exception?
            return(success);
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                using (var service = new AuthorityManagement())
                {
                    IList <AuthorityGroupSummary> list = service.ListAllAuthorityGroups();
                    IList <ListItem> items             = CollectionUtils.Map(
                        list,
                        delegate(AuthorityGroupSummary summary)
                    {
                        return(new ListItem(summary.Name, summary.AuthorityGroupRef.Serialize()));
                    }
                        );
                    UserGroupListBox.Items.AddRange(CollectionUtils.ToArray(items));
                };
            }
            else
            {
                if (ViewState["EditMode"] != null)
                {
                    _editMode = (bool)ViewState["EditMode"];
                }

                if (ViewState["EditedUser"] != null)
                {
                    _user = ViewState["EditedUser"] as UserRowData;
                }
            }
        }
Esempio n. 3
0
 public void DeleteUserGroup(UserGroupRowData userGroup, bool checkIfGroupIsEmpty)
 {
     using (var service = new AuthorityManagement())
     {
         try
         {
             var entityRef = new EntityRef(userGroup.Ref);
             service.DeleteAuthorityGroup(entityRef, checkIfGroupIsEmpty);
         }
         catch (Exception ex)
         {
             Platform.Log(LogLevel.Error, ex, "Unexpected exception deleting user group: {0}.", userGroup.Name);
             throw;
         }
     }
 }
Esempio n. 4
0
        public ActionResult EditAuthorityManagement(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AccountType = new SelectList(db.Roles, "Name", "Name");
            var user  = db.UserToTeachers.Where(a => a.TeacherID == id.Value).SingleOrDefault();
            var user2 = db.Users.Find(user.UserID);
            AuthorityManagement au = new AuthorityManagement();

            au.Id          = id.Value;
            au.AccountType = user2.AccountType;

            return(View(au));
        }
Esempio n. 5
0
        public bool UpdateTokens(List <TokenRowData> tokens)
        {
            bool success;

            using (var service = new AuthorityManagement())
            {
                var tokenList = new List <AuthorityTokenSummary>();

                foreach (TokenRowData token in tokens)
                {
                    tokenList.Add(new AuthorityTokenSummary(token.Name, token.Description));
                }

                service.ImportAuthorityTokens(tokenList);
                success = true;
            }

            //TODO: Catch exception?
            return(success);
        }
Esempio n. 6
0
        public bool AddUserGroup(UserGroupRowData userGroup)
        {
            bool success;

            using (var service = new AuthorityManagement())
            {
                var tokens = new List <AuthorityTokenSummary>();

                foreach (TokenSummary token in userGroup.Tokens)
                {
                    tokens.Add(new AuthorityTokenSummary(token.Name, token.Description));
                }

                service.AddAuthorityGroup(userGroup.Name, userGroup.Description, userGroup.DataGroup, tokens);
                success = true;
            }

            //TODO: Catch exception?
            return(success);
        }
Esempio n. 7
0
        private IList <TokenRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            Array tokenRowData      = null;
            Array tokenRowDataRange = Array.CreateInstance(typeof(TokenRowData), maximumRows);

            resultCount = 0;

            if (maximumRows == 0)
            {
                return(new List <TokenRowData>());
            }

            using (AuthorityManagement service = new AuthorityManagement())
            {
                IList <AuthorityTokenSummary> tokens    = service.ListAuthorityTokens();
                List <TokenRowData>           tokenRows = CollectionUtils.Map <AuthorityTokenSummary, TokenRowData>(
                    tokens, delegate(AuthorityTokenSummary token)
                {
                    TokenRowData row = new TokenRowData(token);
                    return(row);
                });

                tokenRowData = CollectionUtils.ToArray(tokenRows);

                int copyLength = adjustCopyLength(startRowIndex, maximumRows, tokenRowData.Length);

                Array.Copy(tokenRowData, startRowIndex, tokenRowDataRange, 0, copyLength);

                if (copyLength < tokenRowDataRange.Length)
                {
                    tokenRowDataRange = resizeArray(tokenRowDataRange, copyLength);
                }
            };

            if (tokenRowData != null)
            {
                resultCount = tokenRowData.Length;
            }

            return(CollectionUtils.Cast <TokenRowData>(tokenRowDataRange));
        }
        private DataAccessGroupInfoCollection LoadDataAccessGroupInfo()
        {
            using (AuthorityManagement service = new AuthorityManagement())
            {
                var dataGroups = service.ListDataAccessAuthorityGroupDetails();

                // Include those that are not data access groups but have access to all partitions
                var accessToAllPartitionGroups = CollectionUtils.Select(service.ListAllAuthorityGroupDetails(),
                                                                        g => HasToken(g.AuthorityTokens, ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllPartitions));

                var combinedGroups = new List <AuthorityGroupDetail>();
                combinedGroups.AddRange(dataGroups);
                foreach (var g in accessToAllPartitionGroups)
                {
                    if (combinedGroups.Find(item => item.AuthorityGroupRef.Equals(g.AuthorityGroupRef, true)) == null)
                    {
                        combinedGroups.Add(g);
                    }
                }

                //convert to DataAccessGroupInfo for sorting
                var list = new DataAccessGroupInfoCollection(CollectionUtils.Map <AuthorityGroupDetail, DataAccessGroupInfo>(combinedGroups,
                                                                                                                             (group) =>
                {
                    var authorityRecordRef        = group.AuthorityGroupRef.ToString(false, false);
                    var fullServerPartitionAccess = HasToken(group.AuthorityTokens, ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllPartitions);
                    var allStudiesAccess          = HasToken(group.AuthorityTokens, ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllStudies);
                    return(new DataAccessGroupInfo(authorityRecordRef, group.Name)
                    {
                        Description = group.Description,
                        HasAccessToCurrentPartition = fullServerPartitionAccess || (Partition != null && Partition.Key != null && Partition.IsAuthorityGroupAllowed(authorityRecordRef)),
                        CanAccessAllPartitions = fullServerPartitionAccess,
                        CanAccessAllStudies = allStudiesAccess
                    });
                }));

                list.Sort(new DatagroupComparer());

                return(list);
            }
        }
Esempio n. 9
0
        public bool ExistsUsergroup(string usergroupName)
        {
            bool exists = false;

            using (var service = new AuthorityManagement())
            {
                IList <AuthorityGroupSummary> list = service.ListAllAuthorityGroups();

                if (usergroupName != null)
                {
                    foreach (AuthorityGroupSummary group in list)
                    {
                        if (group.Name.ToLower().Equals(usergroupName.ToLower()))
                        {
                            exists = true;
                            break;
                        }
                    }
                }
            }

            return(exists);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            PasswordConfirmDialog.OKClicked += PasswordConfirmDialog_OKClicked;

            if (Page.IsPostBack == false)
            {
                using (AuthorityManagement service = new AuthorityManagement())
                {
                    IList <AuthorityTokenSummary> tokens = service.ListAuthorityTokens();
                    IList <ListItem> items = CollectionUtils.Map <AuthorityTokenSummary, ListItem>(
                        tokens,
                        delegate(AuthorityTokenSummary token)
                    {
                        return(new ListItem(token.Description, token.Name));
                    });

                    TokenCheckBoxList.Items.AddRange(CollectionUtils.ToArray(items));
                };
            }
            else
            {
                if (ViewState["SaveDataGroup"] != null)
                {
                    _saveDataGroup = (bool)ViewState["SaveDataGroup"];
                }

                if (ViewState["EditMode"] != null)
                {
                    _editMode = (bool)ViewState["EditMode"];
                }

                if (ViewState["EditedUserGroup"] != null)
                {
                    _userGroup = ViewState["EditedUserGroup"] as UserGroupRowData;
                }
            }
        }
Esempio n. 11
0
        public async Task <ActionResult> EditAuthorityManagement(AuthorityManagement user)
        {
            ViewBag.AccountType = new SelectList(db.Roles, "Name", "Name");
            if (user == null)
            {
                return(HttpNotFound());
            }
            var user2 = db.UserToTeachers.Where(a => a.TeacherID == user.Id).SingleOrDefault();
            var user3 = db.Users.Find(user2.UserID);

            if (user2 == null)
            {
                return(HttpNotFound());
            }
            await UserManager.RemoveFromRoleAsync(user3.Id, user3.AccountType);

            await UserManager.AddToRoleAsync(user3.Id, user.AccountType);

            user3.AccountType     = user.AccountType;
            db.Entry(user3).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("AuthorityManagement"));
        }
Esempio n. 12
0
        void FrmSaddleMetail_Load(object sender, EventArgs e)
        {
            auth               = FrameContext.Instance.GetPlugin <IAuthorization>() as IAuthorization;
            this.Deactivate   += new EventHandler(frmSaddleDetail_Deactivate);
            txtSaddleNo.Text   = saddleInfo.SaddleNo;
            txtSaddleName.Text = saddleInfo.SaddleName;
            txtCoilNo.Text     = saddleInfo.Mat_No;
            txtXCenter.Text    = saddleInfo.X_Center.ToString();
            txtYCenter.Text    = saddleInfo.Y_Center.ToString();
            txtZCenter.Text    = saddleInfo.Z_Center.ToString();
            label6.Text        = saddleInfo.Row_No.ToString() + "-" + saddleInfo.Col_No.ToString();


            #region 转换状态(垃圾)
            switch (saddleInfo.Stock_Status)
            {
            case 0:
                txtStatus.Text = "无卷";
                break;

            case 1:
                txtStatus.Text = "预定";
                break;

            case 2:
                txtStatus.Text = "占用";
                break;

            default:
                txtStatus.Text = "无";
                break;
            }
            switch (saddleInfo.Lock_Flag)
            {
            case 0:
                txtflag.Text = "可用";
                break;

            case 1:
                txtflag.Text = "待判";
                break;

            case 2:
                txtflag.Text = "封锁";
                break;

            default:
                txtflag.Text = "无";
                break;
            }
            #endregion

            AuthorityManagement authority = new AuthorityManagement();
            if (authority.isUserJudgeEqual("D308", "D202", "scal", "D212"))
            {
                btnCoilMessage.Visible    = false;
                txtMatNo.Visible          = false;
                btnUpStockByCoil.Visible  = false;
                btnByNoCoil.Visible       = false;
                btnByReserve.Visible      = false;
                btnByOccupy.Visible       = false;
                btnNoCoilByUsable.Visible = false;
                btnByUsable.Visible       = false;
                btnByStay.Visible         = false;
                btnByBlock.Visible        = false;
                label7.Visible            = false;
                txtPassWord.Visible       = false;
                txtPopupMessage.Visible   = false;
            }
        }
Esempio n. 13
0
        private IList <UserGroupRowData> InternalSelect(int startRowIndex, int maximumRows, out int resultCount)
        {
            Array authorityRowData;
            Array authorityRowDataRange = Array.CreateInstance(typeof(UserGroupRowData), maximumRows);

            resultCount = 0;

            if (maximumRows == 0)
            {
                return(new List <UserGroupRowData>());
            }

            using (AuthorityManagement service = new AuthorityManagement())
            {
                IList <AuthorityGroupSummary> list         = service.ListAllAuthorityGroups();
                IList <AuthorityGroupSummary> filteredList = new List <AuthorityGroupSummary>();

                if (!string.IsNullOrEmpty(GroupName))
                {
                    string matchString = GroupName;

                    while (matchString.StartsWith("*") || matchString.StartsWith("?"))
                    {
                        matchString = matchString.Substring(1);
                    }
                    while (matchString.EndsWith("*") || matchString.EndsWith("?"))
                    {
                        matchString = matchString.Substring(0, matchString.Length - 1);
                    }

                    matchString = matchString.Replace("*", "[A-Za-z0-9]*");
                    matchString = matchString.Replace("?", ".");

                    foreach (AuthorityGroupSummary group in list)
                    {
                        if (Regex.IsMatch(group.Name, matchString, RegexOptions.IgnoreCase))
                        {
                            filteredList.Add(group);
                        }
                    }
                }
                else
                {
                    filteredList = list;
                }

                List <UserGroupRowData> rows = CollectionUtils.Map <AuthorityGroupSummary, UserGroupRowData>(
                    filteredList, delegate(AuthorityGroupSummary group)
                {
                    UserGroupRowData row =
                        new UserGroupRowData(service.LoadAuthorityGroupDetail(group.AuthorityGroupRef));
                    return(row);
                });

                authorityRowData = CollectionUtils.ToArray(rows);

                int copyLength = adjustCopyLength(startRowIndex, maximumRows, authorityRowData.Length);

                Array.Copy(authorityRowData, startRowIndex, authorityRowDataRange, 0, copyLength);

                if (copyLength < authorityRowDataRange.Length)
                {
                    authorityRowDataRange = resizeArray(authorityRowDataRange, copyLength);
                }
            };

            resultCount = authorityRowData.Length;

            return(CollectionUtils.Cast <UserGroupRowData>(authorityRowDataRange));
        }