Esempio n. 1
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);
        }
Esempio n. 2
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);
        }