Ejemplo n.º 1
0
        private static Dictionary <ServerEntityKey, AuthorityGroupDetail> LoadAuthorityGroups(out List <AuthorityGroupDetail> otherList)
        {
            Dictionary <ServerEntityKey, AuthorityGroupDetail> dic = new Dictionary <ServerEntityKey, AuthorityGroupDetail>();
            var list = new List <AuthorityGroupDetail>();

            using (var service = new AuthorityRead())
            {
                IList <AuthorityGroupDetail> tokens = service.ListDataAccessAuthorityGroupDetails();
                CollectionUtils.ForEach(tokens, delegate(AuthorityGroupDetail group)
                {
                    DataAccessGroupSelectCriteria select = new DataAccessGroupSelectCriteria();
                    select.AuthorityGroupOID.EqualTo(new ServerEntityKey("AuthorityGroupOID", new Guid(group.AuthorityGroupRef.ToString(false, false))));
                    IDataAccessGroupEntityBroker broker = HttpContextData.Current.ReadContext.GetBroker <IDataAccessGroupEntityBroker>();
                    DataAccessGroup accessGroup         = broker.FindOne(select);
                    if (accessGroup != null)
                    {
                        dic.Add(accessGroup.Key, group);
                    }
                    else
                    {
                        list.Add(group);
                    }
                });
            }

            otherList = list;

            return(dic);
        }
Ejemplo n.º 2
0
        public bool AddStudyAuthorityGroups(string studyInstanceUid, string accessionNumber, ServerEntityKey studyStorageKey, IList <string> assignedGroupOids)
        {
            List <AuthorityGroupDetail> nonAddedSummaries;
            Dictionary <ServerEntityKey, AuthorityGroupDetail> dic = LoadAuthorityGroups(out nonAddedSummaries);
            IList <AuthorityGroupStudyAccessInfo> assignedList     = ListDataAccessGroupsForStudy(dic, studyStorageKey);

            List <string> assignedGroups = new List <string>();

            foreach (var oid in assignedGroupOids)
            {
                bool found = false;
                foreach (AuthorityGroupStudyAccessInfo group in assignedList)
                {
                    if (group.AuthorityOID.Equals(oid))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    DataAccessGroup accessGroup = AddDataAccessIfNotExists(oid);

                    using (IUpdateContext updateContext = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
                    {
                        StudyDataAccessUpdateColumns insertColumns = new StudyDataAccessUpdateColumns
                        {
                            DataAccessGroupKey = accessGroup.Key,
                            StudyStorageKey    = studyStorageKey
                        };

                        IStudyDataAccessEntityBroker insert = updateContext.GetBroker <IStudyDataAccessEntityBroker>();
                        insert.Insert(insertColumns);
                        updateContext.Commit();
                    }

                    AuthorityGroupDetail detail;
                    if (dic.TryGetValue(accessGroup.Key, out detail))
                    {
                        assignedGroups.Add(detail.Name);
                    }
                }
            }
            if (assignedGroups.Count > 0)
            {
                ServerAuditHelper.AddAuthorityGroupAccess(studyInstanceUid, accessionNumber, assignedGroups);
            }
            return(true);
        }
        /// <summary>
        /// Do the insertion of the AutoRoute.
        /// </summary>
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            var criteria = new DataAccessGroupSelectCriteria();

            criteria.AuthorityGroupOID.EqualTo(new ServerEntityKey("AuthorityGroupOID", _authorityGroupOid));

            var authorityGroup = updateContext.GetBroker <IDataAccessGroupEntityBroker>();

            DataAccessGroup group = authorityGroup.FindOne(criteria);

            if (group == null)
            {
                Platform.Log(LogLevel.Warn,
                             "AuthorityGroupOID '{0}' on partition {1} not in database for GrantAccess request!  Ignoring request.", _authorityGroupOid,
                             _context.ServerPartition.AeTitle);

                ServerPlatform.Alert(
                    AlertCategory.Application, AlertLevel.Warning,
                    SR.AlertComponentDataAccessRule, AlertTypeCodes.UnableToProcess, null, TimeSpan.FromMinutes(5),
                    SR.AlertDataAccessUnknownAuthorityGroup, _authorityGroupOid, _context.ServerPartition.AeTitle);
                return;
            }


            var entityBroker = updateContext.GetBroker <IStudyDataAccessEntityBroker>();

            var selectStudyDataAccess = new StudyDataAccessSelectCriteria();

            selectStudyDataAccess.DataAccessGroupKey.EqualTo(group.Key);
            selectStudyDataAccess.StudyStorageKey.EqualTo(_context.StudyLocationKey);

            if (entityBroker.Count(selectStudyDataAccess) == 0)
            {
                var insertColumns = new StudyDataAccessUpdateColumns
                {
                    DataAccessGroupKey = group.Key,
                    StudyStorageKey    = _context.StudyLocationKey
                };

                entityBroker.Insert(insertColumns);
            }
        }
Ejemplo n.º 4
0
        private DataAccessGroup AddDataAccessIfNotExists(string oid)
        {
            DataAccessGroup theGroup = FindDataAccessGroup(oid);

            if (theGroup == null)
            {
                using (IUpdateContext update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
                {
                    var insert = new DataAccessGroupUpdateColumns
                    {
                        AuthorityGroupOID =
                            new ServerEntityKey("AuthorityGroupOID",
                                                new Guid(oid)),
                        Deleted = false
                    };
                    var broker = update.GetBroker <IDataAccessGroupEntityBroker>();
                    theGroup = broker.Insert(insert);
                    update.Commit();
                }
            }
            return(theGroup);
        }
Ejemplo n.º 5
0
        public bool UpdateStudyAuthorityGroups(string studyInstanceUid, string accessionNumber, ServerEntityKey studyStorageKey, IList <string> assignedGroupOids)
        {
            List <AuthorityGroupDetail> nonAddedAuthorityGroups;
            Dictionary <ServerEntityKey, AuthorityGroupDetail> dic = LoadAuthorityGroups(out nonAddedAuthorityGroups);
            IList <AuthorityGroupStudyAccessInfo> assignedList     = ListDataAccessGroupsForStudy(dic, studyStorageKey);

            List <string> groupList = new List <string>();

            foreach (AuthorityGroupStudyAccessInfo group in assignedList)
            {
                bool found = false;
                foreach (var oid in assignedGroupOids)
                {
                    if (group.AuthorityOID.Equals(oid))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    using (IUpdateContext update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
                    {
                        IStudyDataAccessEntityBroker broker = update.GetBroker <IStudyDataAccessEntityBroker>();
                        broker.Delete(group.StudyDataAccess.Key);
                        update.Commit();
                    }

                    groupList.Add(group.Description);
                }
            }

            if (groupList.Count > 0)
            {
                ServerAuditHelper.RemoveAuthorityGroupAccess(studyInstanceUid, accessionNumber, groupList);
                groupList.Clear();
            }

            foreach (var oid in assignedGroupOids)
            {
                bool found = false;
                foreach (AuthorityGroupStudyAccessInfo group in assignedList)
                {
                    if (group.AuthorityOID.Equals(oid))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    DataAccessGroup accessGroup = AddDataAccessIfNotExists(oid);

                    using (IUpdateContext updateContext = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
                    {
                        StudyDataAccessUpdateColumns insertColumns = new StudyDataAccessUpdateColumns
                        {
                            DataAccessGroupKey = accessGroup.Key,
                            StudyStorageKey    = studyStorageKey
                        };

                        IStudyDataAccessEntityBroker insert = updateContext.GetBroker <IStudyDataAccessEntityBroker>();
                        insert.Insert(insertColumns);
                        updateContext.Commit();
                    }

                    foreach (AuthorityGroupDetail group in nonAddedAuthorityGroups)
                    {
                        if (group.AuthorityGroupRef.ToString(false, false).Equals(accessGroup.AuthorityGroupOID.Key.ToString()))
                        {
                            groupList.Add(group.Name);
                        }
                    }
                }
            }

            if (groupList.Count > 0)
            {
                ServerAuditHelper.AddAuthorityGroupAccess(studyInstanceUid, accessionNumber, groupList);
            }

            return(true);
        }