Пример #1
0
 public override void Start()
 {
     try
     {
         StartListening(ListenerCallback);
     }
     catch (HttpListenerException e)
     {
         // When the port is tied up by another process, the system throws HttpListenerException with error code = 32
         // and the message "The process cannot access the file because it is being used by another process".
         // For clarity, we make the error message more informative in this case
         if (e.ErrorCode == WindowsErrorCodes.ERROR_SHARING_VIOLATION)
         {
             string errorMessage = string.Format("Unable to start {0} on port {1}. The port is being used by another process", _name, Port);
             Platform.Log(LogLevel.Fatal, errorMessage);
             ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, _name, AlertTypeCodes.UnableToStart, null, TimeSpan.Zero, errorMessage);
         }
         else
         {
             string errorMessage = string.Format("Unable to start {0}. System Error Code={1}", _name, e.ErrorCode);
             Platform.Log(LogLevel.Fatal, e, errorMessage);
             ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, _name, AlertTypeCodes.UnableToStart, null, TimeSpan.Zero, errorMessage);
         }
     }
     catch (Exception e)
     {
         Platform.Log(LogLevel.Fatal, e, "Unable to start {0}", _name);
         ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, _name, AlertTypeCodes.UnableToStart,
                              null, TimeSpan.Zero, "Unable to start {0}: {1}", _name, e.Message);
     }
 }
        public static void BeginInstancesTransferAuditLogger(List <StorageInstance> instances, AssociationParameters parms)
        {
            Dictionary <string, AuditPatientParticipantObject> list = new Dictionary <string, AuditPatientParticipantObject>();

            foreach (StorageInstance instance in instances)
            {
                string key = instance.PatientId + instance.PatientsName;
                if (!list.ContainsKey(key))
                {
                    AuditPatientParticipantObject patient =
                        new AuditPatientParticipantObject(instance.PatientsName, instance.PatientId);
                    list.Add(key, patient);
                }
            }

            foreach (AuditPatientParticipantObject patient in list.Values)
            {
                // Audit Log
                BeginTransferringDicomInstancesAuditHelper audit =
                    new BeginTransferringDicomInstancesAuditHelper(ServerPlatform.AuditSource,
                                                                   EventIdentificationContentsEventOutcomeIndicator.Success,
                                                                   parms, patient);

                foreach (StorageInstance instance in instances)
                {
                    if (patient.PatientId.Equals(instance.PatientId) &&
                        patient.PatientsName.Equals(instance.PatientsName))
                    {
                        audit.AddStorageInstance(instance);
                    }
                }

                ServerPlatform.LogAuditMessage(audit);
            }
        }
Пример #3
0
        public static void SignOut(SessionInfo session)
        {
            FormsAuthentication.SignOut();

            if (session != null)
            {
                try
                {
                    ForceOtherPagesToLogout(session);

                    using (LoginService service = new LoginService())
                    {
                        service.Logout(session.Credentials.SessionToken.Id);
                    }
                }
                catch (NotSupportedException)
                {
                    //ignore this.
                }
                catch (Exception e)
                {
                    Platform.Log(LogLevel.Warn, e, "Failed to log user out.");
                }

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.Success,
                    UserAuthenticationEventType.Logout);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(
                                             session.Credentials.UserName,
                                             null,
                                             session.Credentials.DisplayName));
                ServerPlatform.LogAuditMessage(audit);
            }
        }
Пример #4
0
        private static void AuditLog(Study study, List <UpdateItem> fields)
        {
            Platform.CheckForNullReference(study, "study");
            Platform.CheckForNullReference(fields, "fields");

            var helper =
                new DicomInstancesAccessedAuditHelper(ServerPlatform.AuditSource,
                                                      EventIdentificationContentsEventOutcomeIndicator.Success,
                                                      EventIdentificationContentsEventActionCode.U);

            helper.AddUser(new AuditPersonActiveParticipant(
                               SessionManager.Current.Credentials.UserName,
                               null,
                               SessionManager.Current.Credentials.DisplayName));

            var participant = new AuditStudyParticipantObject(study.StudyInstanceUid, study.AccessionNumber);

            string updateDescription = StringUtilities.Combine(
                fields, ";",
                item => String.Format("Tag=\"{0}\" Value=\"{1}\"", item.DicomTag.Name, item.Value)
                );

            participant.ParticipantObjectDetailString = updateDescription;
            helper.AddStudyParticipantObject(participant);
            ServerPlatform.LogAuditMessage(helper);
        }
Пример #5
0
 public DarkRiftInstallation(string version, ServerTier tier, ServerPlatform platform, string installationPath)
 {
     Version          = version;
     Tier             = tier;
     Platform         = platform;
     InstallationPath = installationPath;
 }
Пример #6
0
        protected void LoginClicked(object sender, EventArgs e)
        {
            if (SessionManager.Current != null)
            {
                // already logged in. Maybe from different page
                HttpContext.Current.Response.Redirect(FormsAuthentication.GetRedirectUrl(SessionManager.Current.Credentials.UserName, false), true);
            }

            try
            {
                SessionManager.InitializeSession(UserName.Text, Password.Text);

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.Success, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, SessionManager.Current.Credentials.DisplayName));
                ServerPlatform.LogAuditMessage(audit);
            }
            catch (PasswordExpiredException)
            {
                Platform.Log(LogLevel.Info, "Password for {0} has expired. Requesting new password.", UserName.Text);
                PasswordExpiredDialog.Show(UserName.Text, Password.Text);

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.Success, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, null));
                ServerPlatform.LogAuditMessage(audit);
            }
            catch (UserAccessDeniedException ex)
            {
                Platform.Log(LogLevel.Error, ex, ex.Message);
                ShowError(ErrorMessages.UserAccessDenied);
                UserName.Focus();

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.SeriousFailureActionTerminated, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, null));
                ServerPlatform.LogAuditMessage(audit);
            }
            catch (CommunicationException ex)
            {
                Platform.Log(LogLevel.Error, ex, "Unable to contact A/A server");
                ShowError(ErrorMessages.CannotContactEnterpriseServer);

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, null));
                ServerPlatform.LogAuditMessage(audit);
            }
            catch (Exception ex)
            {
                Platform.Log(LogLevel.Error, ex, "Login error:");
                ShowError(ex.Message);

                UserAuthenticationAuditHelper audit = new UserAuthenticationAuditHelper(ServerPlatform.AuditSource,
                                                                                        EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable, UserAuthenticationEventType.Login);
                audit.AddUserParticipant(new AuditPersonActiveParticipant(UserName.Text, null, null));
                ServerPlatform.LogAuditMessage(audit);
            }
        }
        /// <summary>
        /// Do the insertion of the AutoRoute.
        /// </summary>
        protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
        {
            DeviceSelectCriteria deviceSelectCriteria = new DeviceSelectCriteria();

            deviceSelectCriteria.AeTitle.EqualTo(_deviceAe);
            deviceSelectCriteria.ServerPartitionKey.EqualTo(_context.ServerPartitionKey);

            IDeviceEntityBroker selectDevice = updateContext.GetBroker <IDeviceEntityBroker>();

            Device dev = selectDevice.FindOne(deviceSelectCriteria);

            if (dev == null)
            {
                Platform.Log(LogLevel.Warn,
                             "Device '{0}' on partition {1} not in database for autoroute request!  Ignoring request.", _deviceAe,
                             _context.ServerPartition.AeTitle);

                ServerPlatform.Alert(
                    AlertCategory.Application, AlertLevel.Warning,
                    SR.AlertComponentAutorouteRule, AlertTypeCodes.UnableToProcess, null, TimeSpan.FromMinutes(5),
                    SR.AlertAutoRouteUnknownDestination, _deviceAe, _context.ServerPartition.AeTitle);

                return;
            }
            if (!dev.AllowAutoRoute)
            {
                Platform.Log(LogLevel.Warn,
                             "Auto-route attempted to device {0} on partition {1} with autoroute support disabled.  Ignoring request.",
                             dev.AeTitle, _context.ServerPartition.AeTitle);

                ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Warning, SR.AlertComponentAutorouteRule, AlertTypeCodes.UnableToProcess, null, TimeSpan.FromMinutes(5),
                                     SR.AlertAutoRouteDestinationAEDisabled, dev.AeTitle, _context.ServerPartition.AeTitle);

                return;
            }

            InsertWorkQueueParameters parms = new InsertWorkQueueParameters
            {
                WorkQueueTypeEnum = WorkQueueTypeEnum.AutoRoute,
                ScheduledTime     = _scheduledTime.HasValue
                                                                                                ? _scheduledTime.Value
                                                                                                : Platform.Time.AddSeconds(10),
                StudyStorageKey    = _context.StudyLocationKey,
                ServerPartitionKey = _context.ServerPartitionKey,
                DeviceKey          = dev.GetKey(),
                SeriesInstanceUid  =
                    _context.Message.DataSet[DicomTags.SeriesInstanceUid].GetString(0, string.Empty),
                SopInstanceUid =
                    _context.Message.DataSet[DicomTags.SopInstanceUid].GetString(0, string.Empty)
            };
            IInsertWorkQueue broker = updateContext.GetBroker <IInsertWorkQueue>();

            if (broker.FindOne(parms) == null)
            {
                throw new ApplicationException("InsertAutoRouteCommand failed");
            }
        }
Пример #8
0
        Packet_ServerEntity ToNetworkEntity(ServerPlatform platform, ServerEntity entity)
        {
            Packet_ServerEntity p = new Packet_ServerEntity();

            if (entity.position != null)
            {
                p.Position = ToNetworkEntityPosition(platform, entity.position);
            }
            if (entity.drawModel != null)
            {
                p.DrawModel              = new Packet_ServerEntityAnimatedModel();
                p.DrawModel.EyeHeight    = platform.FloatToInt(entity.drawModel.eyeHeight * 32);
                p.DrawModel.Model_       = entity.drawModel.model;
                p.DrawModel.ModelHeight  = platform.FloatToInt(entity.drawModel.modelHeight * 32);
                p.DrawModel.Texture_     = entity.drawModel.texture;
                p.DrawModel.DownloadSkin = entity.drawModel.downloadSkin ? 1 : 0;
            }
            if (entity.drawName != null)
            {
                p.DrawName_                    = new Packet_ServerEntityDrawName();
                p.DrawName_.Name               = entity.drawName.name;
                p.DrawName_.Color              = entity.drawName.color;
                p.DrawName_.OnlyWhenSelected   = entity.drawName.onlyWhenSelected;
                p.DrawName_.ClientAutoComplete = entity.drawName.clientAutoComplete;
            }
            if (entity.drawText != null)
            {
                p.DrawText      = new Packet_ServerEntityDrawText();
                p.DrawText.Dx   = platform.FloatToInt(entity.drawText.dx * 32);
                p.DrawText.Dy   = platform.FloatToInt(entity.drawText.dy * 32);
                p.DrawText.Dz   = platform.FloatToInt(entity.drawText.dz * 32);
                p.DrawText.Rotx = platform.FloatToInt(entity.drawText.rotx);
                p.DrawText.Roty = platform.FloatToInt(entity.drawText.roty);
                p.DrawText.Rotz = platform.FloatToInt(entity.drawText.rotz);
                p.DrawText.Text = entity.drawText.text;
            }
            if (entity.push != null)
            {
                p.Push            = new Packet_ServerEntityPush();
                p.Push.RangeFloat = platform.FloatToInt(entity.push.range * 32);
            }
            p.Usable = entity.usable;
            if (entity.drawArea != null)
            {
                p.DrawArea                   = new Packet_ServerEntityDrawArea();
                p.DrawArea.X                 = entity.drawArea.x;
                p.DrawArea.Y                 = entity.drawArea.y;
                p.DrawArea.Z                 = entity.drawArea.z;
                p.DrawArea.Sizex             = entity.drawArea.sizex;
                p.DrawArea.Sizey             = entity.drawArea.sizey;
                p.DrawArea.Sizez             = entity.drawArea.sizez;
                p.DrawArea.VisibleToClientId = entity.drawArea.visibleToClientId;
            }

            return(p);
        }
Пример #9
0
        /// <summary>
        /// Gets the path to a specified installation, or null if it is not installed.
        /// </summary>
        /// <param name="version">The version number required.</param>
        /// <param name="pro">Whether the pro version should be used.</param>
        /// <param name="platform">Whether the .NET Standard build should be used.</param>
        /// <returns>The path to the installation, or null, if it is not installed.</returns>
        public DarkRiftInstallation GetInstallation(string version, ServerTier tier, ServerPlatform platform)
        {
            string path = GetInstallationPath(version, tier, platform);

            if (fileUtility.DirectoryExists(path))
            {
                return(new DarkRiftInstallation(version, tier, platform, path));
            }

            return(null);
        }
Пример #10
0
        internal static void InternalStop()
        {
            _shredHostType.InvokeMember("Stop", BindingFlags.Static | BindingFlags.InvokeMethod | BindingFlags.Public,
                                        null, null, new object[] { });


            ServerPlatform.Alert(AlertCategory.System, AlertLevel.Informational,
                                 SR.AlertComponentName, AlertTypeCodes.Stopped,
                                 null, TimeSpan.Zero,
                                 SR.AlertShredHostServiceStopped);
        }
        protected void DeleteButton_Clicked(object sender, ImageClickEventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    string reason = ReasonListBox.SelectedItem.Text;
                    if (!String.IsNullOrEmpty(SaveReasonAsName.Text))
                    {
                        SaveCustomReason();
                        reason = SaveReasonAsName.Text;
                    }

                    OnDeletingStudies();
                    StudyController controller = new StudyController();
                    foreach (DeleteStudyInfo study in DeletingStudies)
                    {
                        try
                        {
                            controller.DeleteStudy(study.StudyKey, reason + "::" + Comment.Text);

                            // Audit log
                            DicomStudyDeletedAuditHelper helper = new DicomStudyDeletedAuditHelper(
                                ServerPlatform.AuditSource,
                                EventIdentificationContentsEventOutcomeIndicator.Success);
                            helper.AddUserParticipant(new AuditPersonActiveParticipant(
                                                          SessionManager.Current.Credentials.UserName,
                                                          null,
                                                          SessionManager.Current.Credentials.DisplayName));
                            helper.AddStudyParticipantObject(new AuditStudyParticipantObject(
                                                                 study.StudyInstanceUid,
                                                                 study.AccessionNumber ?? string.Empty));
                            ServerPlatform.LogAuditMessage(helper);
                        }
                        catch (Exception ex)
                        {
                            Platform.Log(LogLevel.Error, ex, "DeleteClicked failed: Unable to delete studies");
                            throw;
                        }
                    }

                    OnStudiesDeleted();
                }
                finally
                {
                    Close();
                }
            }
            else
            {
                EnsureDialogVisible();
            }
        }
Пример #12
0
        Packet_PositionAndOrientation ToNetworkEntityPosition(ServerPlatform platform, ServerEntityPositionAndOrientation position)
        {
            Packet_PositionAndOrientation p = new Packet_PositionAndOrientation();

            p.X       = platform.FloatToInt(position.x * 32);
            p.Y       = platform.FloatToInt(position.y * 32);
            p.Z       = platform.FloatToInt(position.z * 32);
            p.Heading = position.heading;
            p.Pitch   = position.pitch;
            p.Stance  = position.stance;
            return(p);
        }
Пример #13
0
        private void ReprocessStudy(StudyStorageLocation restoredLocation, string reason)
        {
            var    reprocessor     = new StudyReprocessor();
            String reprocessReason = String.Format("Restore Validation Error: {0}", reason);

            reprocessor.ReprocessStudy(reprocessReason, restoredLocation, Platform.Time);
            string message = string.Format("Study {0} has been restored but failed the validation. Reprocess Study has been triggered. Reason for validation failure: {1}", restoredLocation.StudyInstanceUid, reason);

            Platform.Log(LogLevel.Warn, message);

            ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Informational, "Restore", 0, null, TimeSpan.Zero, message);
        }
Пример #14
0
 public override void Start()
 {
     try
     {
         ServiceEndpointDescription sed = StartHttpHost <FilesystemService, IFilesystemService>("FilesystemService", SR.FilesystemServiceDisplayDescription);
     }
     catch (Exception e)
     {
         Platform.Log(LogLevel.Error, "Failed to start {0} : {1}", SR.FilesystemServiceDisplayName, e.StackTrace);
         ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Error, SR.FilesystemServiceDisplayName,
                              AlertTypeCodes.UnableToStart, null, TimeSpan.Zero, SR.AlertFilesystemUnableToStart, e.Message);
     }
 }
Пример #15
0
        public void RaiseAlert(Model.WorkQueue queueItem, AlertLevel level, string message)
        {
            WorkQueueTypeProperties prop = _propertiesDictionary[queueItem.WorkQueueTypeEnum];

            if (prop.AlertFailedWorkQueue || level == AlertLevel.Critical)
            {
                ServerPlatform.Alert(AlertCategory.Application, level,
                                     queueItem.WorkQueueTypeEnum.ToString(), AlertTypeCodes.UnableToProcess,
                                     GetWorkQueueContextData(queueItem), TimeSpan.Zero,
                                     "Work Queue item failed: Type={0}, GUID={1}: {2}",
                                     queueItem.WorkQueueTypeEnum,
                                     queueItem.GetKey(), message);
            }
        }
Пример #16
0
 public override void Start()
 {
     try
     {
         ServerPlatform.Alert(AlertCategory.System, AlertLevel.Informational,
                              SR.AlertComponentName, AlertTypeCodes.Starting,
                              null, TimeSpan.Zero,
                              SR.AlertShredHostServiceStarting);
     }
     catch (Exception)
     {
         Platform.Log(LogLevel.Error, "Unexpected exception generating an alert for ShredHost startup");
     }
 }
Пример #17
0
        /// <summary>
        /// Installs a version of DarkRift, if not alredy installed.
        /// </summary>
        /// <param name="version">The version number required.</param>
        /// <param name="pro">Whether the pro version should be used.</param>
        /// <param name="platform">Whether the .NET Standard build should be used.</param>
        /// <returns>The path to the installation, or null, if it is not available</returns>
        public DarkRiftInstallation Install(string version, ServerTier tier, ServerPlatform platform, bool forceRedownload)
        {
            string path = GetInstallationPath(version, tier, platform);

            if (forceRedownload || !fileUtility.DirectoryExists(path))
            {
                if (!remoteRepository.DownloadVersionTo(version, tier, platform, path))
                {
                    return(null);
                }
            }

            return(new DarkRiftInstallation(version, tier, platform, path));
        }
Пример #18
0
 public override void Stop()
 {
     PersistentStoreRegistry.GetDefaultStore().ShutdownRequested = true;
     try
     {
         ServerPlatform.Alert(AlertCategory.System, AlertLevel.Informational,
                              SR.AlertComponentName, AlertTypeCodes.Stopped,
                              null, TimeSpan.Zero,
                              SR.AlertShredHostServiceStopped);
     }
     catch (Exception)
     {
         Platform.Log(LogLevel.Error, "Unexpected exception generating an alert for ShredHost shutdown");
     }
 }
Пример #19
0
        /// <summary>
        /// Gets a list of versions installed with specific tier and platform
        /// </summary>
        /// <param name="tier">The tier</param>
        /// <param name="platform">The platform</param>
        /// <returns>A list of installed versions</returns>
        public List <DarkRiftInstallation> GetVersions(ServerTier tier, ServerPlatform platform)
        {
            string searchPath = Path.Combine(installationDirectory, tier.ToString().ToLower(), platform.ToString().ToLower());

            if (!fileUtility.DirectoryExists(searchPath))
            {
                return(new List <DarkRiftInstallation>());
            }
            else
            {
                return(fileUtility.GetDirectories(searchPath)
                       .Select(path => new DarkRiftInstallation(path, tier, platform, Path.Combine(searchPath, path)))
                       .ToList());
            }
        }
Пример #20
0
        /// <summary>
        /// Gets the path to a specified installation, downloading it if required.
        /// </summary>
        /// <param name="version">The version number required.</param>
        /// <param name="pro">Whether the pro version should be used.</param>
        /// <param name="netStandard">Whether the .NET Standard build should be used.</param>
        /// <returns>The path to the installation, or null, if it cannot be provided.</returns>
        public static string GetInstallationPath(string version, ServerTier tier, ServerPlatform platform)
        {
            string fullPath = Path.Combine(USER_DR_DIR, "installed", tier.ToString().ToLower(), platform.ToString().ToLower(), version);

            if (!Directory.Exists(fullPath))
            {
                Console.WriteLine($"DarkRift {version} - {tier} (.NET {platform}) not installed! Downloading package...");

                string stagingPath = Path.Combine(USER_DR_DIR, "Download.zip");

                string uri = $"https://www.darkriftnetworking.com/DarkRift2/Releases/{version}/{tier}/{platform}/";
                if (tier == ServerTier.Pro)
                {
                    string invoiceNumber = GetInvoiceNumber();
                    if (invoiceNumber == null)
                    {
                        Console.WriteLine(Output.Red($"You must provide an invoice number in order to download Pro DarkRift releases."));
                        return(null);
                    }

                    uri += $"?invoice={invoiceNumber}";
                }

                try
                {
                    using (WebClient myWebClient = new WebClient())
                    {
                        myWebClient.DownloadFile(uri, stagingPath);
                    }
                }
                catch (WebException e)
                {
                    Console.WriteLine(Output.Red($"Could not download DarkRift {version} - {tier} (.NET {platform}):\n\t{e.Message}"));
                    return(null);
                }

                Console.WriteLine($"Extracting package...");

                Directory.CreateDirectory(fullPath);

                ZipFile.ExtractToDirectory(stagingPath, fullPath, true);

                Console.WriteLine(Output.Green($"Successfully downloaded package."));
            }

            return(fullPath);
        }
Пример #21
0
 /// <summary>
 /// Method called when stopping the DICOM SCP.
 /// </summary>
 protected override void Stop()
 {
     lock (_syncLock)
     {
         foreach (DicomScp <DicomScpContext> scp in _listenerList)
         {
             scp.Stop();
             ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
                 ServerPlatform.AuditSource,
                 EventIdentificationContentsEventOutcomeIndicator.Success,
                 ApplicationActivityType.ApplicationStopped,
                 new AuditProcessActiveParticipant(scp.AeTitle));
             ServerPlatform.LogAuditMessage(helper);
         }
         ServerPartitionMonitor.Instance.Changed -= _changedEvent;
     }
 }
        /// <summary>
        /// Called after the specified <see cref="WorkQueueUid"/> has been processed
        /// </summary>
        /// <param name="item">The <see cref="WorkQueue"/> item being processed</param>
        /// <param name="uid">The <see cref="WorkQueueUid"/> being processed</param>
        protected virtual void OnProcessUidEnd(Model.WorkQueue item, WorkQueueUid uid)
        {
            Platform.CheckForNullReference(item, "item");
            Platform.CheckForNullReference(uid, "uid");

            if (uid.Duplicate)
            {
                String dupPath = ServerPlatform.GetDuplicateUidPath(StorageLocation, uid);
                // Delete the container if it's empty
                var f = new FileInfo(dupPath);

                if (f.Directory != null && DirectoryUtility.DeleteIfEmpty(f.Directory.FullName))
                {
                    DirectoryUtility.DeleteIfEmpty(ServerPlatform.GetDuplicateGroupPath(StorageLocation, uid));
                }
            }
        }
Пример #23
0
        public override void Start()
        {
            Platform.Log(LogLevel.Debug, "{0}[{1}]: Start invoked", _className, AppDomain.CurrentDomain.FriendlyName);

            try
            {
                Platform.Log(LogLevel.Info, "Starting {0} using basic Http binding", GetDisplayName());
                StartBasicHttpHost <DicomImportService, IDicomImportService>("DicomImportService", GetDescription());
            }
            catch (Exception e)
            {
                Platform.Log(LogLevel.Fatal, e, "Unexpected exception starting Streaming Server Shred");

                ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, SR.DicomImportServerDisplayName,
                                     AlertTypeCodes.UnableToStart, null, TimeSpan.Zero,
                                     SR.AlertUnableToStart, e.Message);
            }
        }
Пример #24
0
        private void VerifyManifest()
        {
            Platform.Log(LogLevel.Info, "Checking manifest...");
            if (ServerPlatform.IsManifestVerified)
            {
                Platform.Log(LogLevel.Info, "Manifest is OK.");
                return;
            }

            Platform.Log(LogLevel.Warn, "Manifest is broken!");
            var componentName = string.IsNullOrEmpty(ProductInformation.SubComponent)
                                                                        ? ProductInformation.Component
                                                                        : string.Format("{0} {1}", ProductInformation.Component, ProductInformation.SubComponent);

            ServerPlatform.Alert(AlertCategory.Security, AlertLevel.Warning,
                                 SR.ManifestComponentName, AlertTypeCodes.UnableToProcess, null, TimeSpan.FromHours(24),
                                 SR.NonStandardInstallation, componentName);
        }
Пример #25
0
        /// <summary>
        /// Generates a <see cref="StudyAlert"/>.
        /// </summary>
        /// <param name="alert"></param>
        /// <remarks>
        /// If the same alert is generated in the last 30 minutes, the new one will be dropped
        /// </remarks>
        public static void Generate(StudyAlert alert)
        {
            lock (_syncLock)
            {
                if (!_recentAlerts.Contains(alert))
                {
                    _recentAlerts.Add(alert);

                    // TODO: Map StudyAlertCode to system alert code
                    const int code = -1000;
                    ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Warning, alert.ApplicationContext, code,
                                         new StudyAlertContextInfo(alert.ServerPartitionAE, alert.StudyInstanceUid),
                                         TimeSpan.FromMinutes(30), alert.Message);
                }

                _recentAlerts.RemoveAll(a => Platform.Time - a.Timestamp > TimeSpan.FromMinutes(30));
            }
        }
Пример #26
0
        /// <summary>
        /// Downloads and installs a DarkRift version
        /// </summary>
        /// <param name="version">The version to be installed</param>
        /// <param name="tier">The tier</param>
        /// <param name="platform">The platform</param>
        /// <returns>True if installed successfully otherwise false</returns>
        public static bool DownloadVersion(string version, ServerTier tier, ServerPlatform platform)
        {
            string fullPath = GetInstallationPath(version, tier, platform);

            string stagingPath = Path.Combine(Config.USER_DR_DIR, "Download.zip");

            string uri = $"{Config.DR_DR2_RELEASE_URI}/{version}/{tier}/{platform}/";

            if (tier == ServerTier.Pro)
            {
                string invoiceNumber = GetInvoiceNumber();
                if (invoiceNumber == null)
                {
                    Console.Error.WriteLine(Output.Red($"You must provide an invoice number in order to download Pro DarkRift releases."));
                    return(false);
                }

                uri += $"?invoice={invoiceNumber}";
            }

            try
            {
                using (WebClient myWebClient = new WebClient())
                {
                    myWebClient.DownloadFile(uri, stagingPath);
                }
            }
            catch (WebException e)
            {
                Console.Error.WriteLine(Output.Red($"Could not download DarkRift {version} - {tier} (.NET {platform}):\n\t{e.Message}"));
                return(false);
            }

            Console.WriteLine($"Extracting package...");

            Directory.CreateDirectory(fullPath);

            ZipFile.ExtractToDirectory(stagingPath, fullPath, true);

            Console.WriteLine(Output.Green($"Successfully downloaded DarkRift {version} - {tier} (.NET {platform})"));

            return(true);
        }
Пример #27
0
        /// <summary>
        /// Gets a list of versions with specific tier and platform
        /// </summary>
        /// <param name="tier">The tier</param>
        /// <param name="platform">The platform</param>
        /// <returns>List of paths to the versions</returns>
        public static List <string> GetVersions(ServerTier tier, ServerPlatform platform)
        {
            var installationFolder = GetInstallationPath("", tier, platform);

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

            if (Directory.Exists(installationFolder))
            {
                string[] paths = Directory.GetDirectories(installationFolder);

                // This removes the path and just leaves the version number
                for (int i = 0; i < paths.Length; i++)
                {
                    versions.Add(Path.GetFileName(paths[i]));
                }
            }

            return(versions);
        }
        /// <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);
            }
        }
        void CreateDuplicateSIQEntry(WorkQueueUid uid, DicomFile file, List <DicomAttributeComparisonResult> differences)
        {
            Platform.Log(LogLevel.Info, "Duplicate SOP is different from existing copy. Creating duplicate SIQ entry. SOP: {0}", uid.SopInstanceUid);

            using (var processor = new ServerCommandProcessor("Create Duplicate SIQ Entry"))
            {
                var insertCommand = new InsertOrUpdateEntryCommand(
                    uid.GroupID, StorageLocation, file,
                    ServerPlatform.GetDuplicateGroupPath(StorageLocation, uid),
                    string.IsNullOrEmpty(uid.RelativePath)
                        ? Path.Combine(StorageLocation.StudyInstanceUid, uid.SopInstanceUid + "." + uid.Extension)
                        : uid.RelativePath,
                    differences);
                processor.AddCommand(insertCommand);

                processor.AddCommand(new DeleteWorkQueueUidCommand(uid));

                processor.Execute();
            }
        }
Пример #30
0
        private void AuditLog(Study affectedStudy)
        {
            // Audit log
            DicomStudyDeletedAuditHelper helper =
                new DicomStudyDeletedAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.Success);

            helper.AddUserParticipant(new AuditPersonActiveParticipant(
                                          SessionManager.Current.Credentials.
                                          UserName,
                                          null,
                                          SessionManager.Current.Credentials.
                                          DisplayName));
            helper.AddStudyParticipantObject(new AuditStudyParticipantObject(
                                                 affectedStudy.StudyInstanceUid,
                                                 affectedStudy.AccessionNumber ??
                                                 string.Empty));
            ServerPlatform.LogAuditMessage(helper);
        }
Пример #31
0
    Packet_ServerEntity ToNetworkEntity(ServerPlatform platform, ServerEntity entity)
    {
        Packet_ServerEntity p = new Packet_ServerEntity();
        if (entity.position != null)
        {
            p.Position = ToNetworkEntityPosition(platform, entity.position);
        }
        if (entity.drawModel != null)
        {
            p.DrawModel = new Packet_ServerEntityAnimatedModel();
            p.DrawModel.EyeHeight = platform.FloatToInt(entity.drawModel.eyeHeight * 32);
            p.DrawModel.Model_ = entity.drawModel.model;
            p.DrawModel.ModelHeight = platform.FloatToInt(entity.drawModel.modelHeight * 32);
            p.DrawModel.Texture_ = entity.drawModel.texture;
            p.DrawModel.DownloadSkin = entity.drawModel.downloadSkin ? 1 : 0;
        }
        if (entity.drawName != null)
        {
            p.DrawName_ = new Packet_ServerEntityDrawName();
            p.DrawName_.Name = entity.drawName.name;
            p.DrawName_.Color = entity.drawName.color;
            p.DrawName_.OnlyWhenSelected = entity.drawName.onlyWhenSelected;
            p.DrawName_.ClientAutoComplete = entity.drawName.clientAutoComplete;
        }
        if (entity.drawText != null)
        {
            p.DrawText = new Packet_ServerEntityDrawText();
            p.DrawText.Dx = platform.FloatToInt(entity.drawText.dx * 32);
            p.DrawText.Dy = platform.FloatToInt(entity.drawText.dy * 32);
            p.DrawText.Dz = platform.FloatToInt(entity.drawText.dz * 32);
            p.DrawText.Rotx = platform.FloatToInt(entity.drawText.rotx);
            p.DrawText.Roty = platform.FloatToInt(entity.drawText.roty);
            p.DrawText.Rotz = platform.FloatToInt(entity.drawText.rotz);
            p.DrawText.Text = entity.drawText.text;
        }
        if (entity.push != null)
        {
            p.Push = new Packet_ServerEntityPush();
            p.Push.RangeFloat = platform.FloatToInt(entity.push.range * 32);
        }
        p.Usable = entity.usable;
        if (entity.drawArea != null)
        {
            p.DrawArea = new Packet_ServerEntityDrawArea();
            p.DrawArea.X = entity.drawArea.x;
            p.DrawArea.Y = entity.drawArea.y;
            p.DrawArea.Z = entity.drawArea.z;
            p.DrawArea.Sizex = entity.drawArea.sizex;
            p.DrawArea.Sizey = entity.drawArea.sizey;
            p.DrawArea.Sizez = entity.drawArea.sizez;
            p.DrawArea.VisibleToClientId = entity.drawArea.visibleToClientId;
        }

        return p;
    }
Пример #32
0
 Packet_PositionAndOrientation ToNetworkEntityPosition(ServerPlatform platform, ServerEntityPositionAndOrientation position)
 {
     Packet_PositionAndOrientation p = new Packet_PositionAndOrientation();
     p.X = platform.FloatToInt(position.x * 32);
     p.Y = platform.FloatToInt(position.y * 32);
     p.Z = platform.FloatToInt(position.z * 32);
     p.Heading = position.heading;
     p.Pitch = position.pitch;
     p.Stance = position.stance;
     return p;
 }