Exemplo n.º 1
0
        // returns true if uninstalled
        static public bool UninstallAllDicomServersSilent(ServiceAdministrator serviceAdmin)
        {
            if (serviceAdmin == null)
            {
                return(false);
            }

            try
            {
                List <string> keys = new List <string>();

                foreach (KeyValuePair <string, DicomService> kv in serviceAdmin.Services)
                {
                    keys.Add(kv.Key);
                }

                foreach (string key in keys)
                {
                    DicomService service    = serviceAdmin.Services[key];
                    string       serviceDir = service.ServiceDirectory.ToLower();

                    UninstallOneDicomServer(service, false, serviceAdmin);
                }

                return(true);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Assert(false, e.ToString());
                return(false);
            }
        }
Exemplo n.º 2
0
        internal static void UnlockService(string serviceDirectory, string displayName)
        {
            List <string> unlockedSerivces;
            DicomService  service;

            unlockedSerivces = new List <string> ( );

            unlockedSerivces.Add(displayName);

            using (ServiceAdministrator serviceAdmin = new ServiceAdministrator(serviceDirectory))
            {
                //Add the key
#if LEADTOOLS_V175_OR_LATER
                serviceAdmin.Initialize(unlockedSerivces);
#else
                serviceAdmin.Unlock(string.Empty, unlockedSerivces);
#endif

                if (serviceAdmin.Services.ContainsKey(displayName))
                {
                    service = serviceAdmin.Services [displayName];

                    ConfigureSettings(service.Settings);
                }
            }
        }
        public static ServiceAdministrator CreateServiceAdministrator()
        {
            ServiceAdministrator administrator = administrator = new ServiceAdministrator(_baseDir);

#if LEADTOOLS_V175_OR_LATER
            administrator.Initialize();
#else
            administrator.Unlock(Support.MedicalServerKey);
#endif
            return(administrator);
        }
Exemplo n.º 4
0
        private string InitializeServiceAdmin(ServiceAdministrator serverAdmin)
        {
            IOptionsDataAccessAgent  optionsAgent;
            StorageServerInformation serverInfo;
            List <string>            services;
            string serviceName;

            optionsAgent = DataAccessServices.GetDataAccessService <IOptionsDataAccessAgent> ( );
            serverInfo   = optionsAgent.Get <StorageServerInformation> (typeof(StorageServerInformation).Name, null, new Type[0]);
            services     = new List <string> ( );

            ServerState.Instance.IsRemoteServer = false;

            if (null == serverInfo)
            {
                serviceName = DefaultServiceName;

                services.Add(serviceName);
            }
            else
            {
                if (serverInfo.MachineName.ToLower() == Environment.MachineName.ToLower())
                {
                    if (!string.IsNullOrEmpty(serverInfo.ServiceName))
                    {
                        serviceName = serverInfo.ServiceName;
                    }
                    else
                    {
                        serviceName = DefaultServiceName;
                    }

                    services.Add(serverInfo.ServiceName);
                }
                else
                {
                    ServerState.Instance.IsRemoteServer          = true;
                    ServerState.Instance.RemoteServerInformation = serverInfo;

                    serviceName = serverInfo.ServiceName;
                }
            }

            ServerState.Instance.ServiceAdminChanged  += new EventHandler(Instance_ServiceAdminChanged);
            ServerState.Instance.ServerServiceChanged += new EventHandler(Instance_ServerServiceChanged);

            if (services.Count > 0)
            {
                serverAdmin.Initialize(services);
            }

            return(serviceName);
        }
Exemplo n.º 5
0
        public static void GetService(string serviceDirectory, string displayName)
        {
            string dir = serviceDirectory.Replace(displayName, string.Empty);
            ServiceAdministrator _Administrator = new ServiceAdministrator(dir);

            _Administrator.Initialize(new List <string>()
            {
                displayName
            });
            if (_Administrator.Services.ContainsKey(displayName))
            {
                _Service = _Administrator.Services[displayName];
            }
        }
Exemplo n.º 6
0
        static public bool SafeUnInstallService(this ServiceAdministrator serviceAdmin, DicomService service)
        {
            bool success = true;

            if (service != null)
            {
                try
                {
                    serviceAdmin.UnInstallService(service);
                }
                catch (Exception)
                {
                    success = false;
                }
            }
            return(success);
        }
Exemplo n.º 7
0
        public override void Load(string serviceDirectory, string displayName)
        {
            List <string> unlockedSerivces;
            DicomService  service;

            InitializeLicense();
            base.Load(serviceDirectory, displayName);

            unlockedSerivces = new List <string> ( );
            ServiceDirectory = serviceDirectory;
            DisplayName      = displayName;

            RegisterDataAccessAgents(displayName);

            unlockedSerivces.Add(displayName);

            using (ServiceAdministrator serviceAdmin = new ServiceAdministrator(serviceDirectory))
            {
                //Add the key
#if LEADTOOLS_V175_OR_LATER
                serviceAdmin.Initialize(unlockedSerivces);
#else
                serviceAdmin.Unlock(string.Empty, unlockedSerivces);
#endif

                if (serviceAdmin.Services.ContainsKey(displayName))
                {
                    service = serviceAdmin.Services [displayName];

                    ServerAE      = service.Settings.AETitle;
                    ServerAddress = service.Settings.IpAddress;
                    ServerPort    = service.Settings.Port;
                }
            }

            if (!AddInsSession.IsLicenseValid())
            {
                DicomServer server = ServiceLocator.Retrieve <DicomServer>();

                Logger.Global.SystemMessage(LogType.Information, "Worklist license not valid.  Worklist search cannot be performed", server.AETitle);
            }
        }
Exemplo n.º 8
0
        private void CreateServiceAdmin(string serviceName)
        {
            ServiceAdministrator serviceAdmin;
            List <string>        services;


            serviceAdmin = new ServiceAdministrator(ServerState.Instance.BaseDirectory);
            services     = new List <string> ( );



            services.Add(serviceName);

            serviceAdmin.Initialize(services);

            if (serviceAdmin.IsLocked)
            {
                throw new InvalidOperationException("PACS Framework locked.");
            }

            ServerState.Instance.ServiceAdmin = serviceAdmin;
        }
        private void CreateServiceAdmin(string serviceName)
        {
            List <string> services;


            ServiceAdmin = new ServiceAdministrator(BaseDirectory);
            services     = new List <string> ( );

            ServiceAdmin.Error += new EventHandler <Leadtools.Dicom.Server.Admin.ErrorEventArgs> (ServiceAdmin_Error);

            services.Add(serviceName);

#if LEADTOOLS_V175_OR_LATER
            ServiceAdmin.Initialize(services);
#else
            ServiceAdmin.Unlock(ConfigurationData.PacsFrmKey, services);
#endif

            if (ServiceAdmin.IsLocked)
            {
                throw new InvalidOperationException("PACS Framework locked.");
            }
        }
Exemplo n.º 10
0
        static public bool UninstallOneDicomServer(DicomService service, bool removeFromBaseDirectoryOnly, ServiceAdministrator serviceAdmin)
        {
            bool success = false;

            try
            {
                if (service != null)
                {
                    if (removeFromBaseDirectoryOnly)
                    {
                        string serviceDir = Path.GetFullPath(service.ServiceDirectory).ToLower();

                        if (!serviceDir.Contains(Program._baseDir.ToLower( )))
                        {
                            return(false);
                        }
                    }

                    // If this fails to stop the service, we can still proceed to delete it
                    // In this case, the service was marked as 'disabled', marked for deleted, and will be deleted on reboot
                    // (or if the service is stopped, it will be automatically deleted)
                    StopOneDicomServer(service);

                    success = true;
                    string serviceDirectory = service.ServiceDirectory;
                    serviceAdmin.SafeUnInstallService(service);

                    // To remove the service directory and files, uncomment the code below
                    if (success)
                    {
                        try
                        {
                            RemoveOneDicomServerFiles(serviceDirectory);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.Assert(false, e.ToString());
                success = false;
            }
            return(success);
        }
        static int Main(string[] args)
        {
            if (!DicomDemoSettingsManager.Is64Process())
            {
                _demoName = "LEADTOOLS PACS Configuration Demo  (32 bit)";
            }
            else
            {
                _demoName = "LEADTOOLS PACS Configuration Demo  (64 bit)";
            }

            if (DemosGlobal.MustRestartElevated())
            {
                DemosGlobal.TryRestartElevated(args);
                return(0);
            }

            ReadCommandLine(args);
            MySettings mySettings = new MySettings();

            if (_bInitialize)
            {
#if !FOR_DOTNET4
                if (false == DemosGlobal.IsDotNet35Installed())
                {
                    return(0);
                }
#endif

                MyUtils.RemoveConfigurationFiles();
                MyUtils.RemoveGlobalPacsConfig();
                mySettings.Save();
                return(0);
            }

            bool showUI = !_bUninstall && !_bInitialize;

#if !FOR_DOTNET4
            bool dotNet35Installed = DemosGlobal.IsDotNet35Installed();
            if (showUI && !dotNet35Installed)
            {
                Messager.ShowWarning(null, ".NET Framework 3.5 could not be found on this machine.\n\nPlease install the .NET Framework 3.5 runtime and try again. This program will now exit.");
            }
            if (!dotNet35Installed)
            {
                return(0);
            }
#endif

            mySettings.Load();

#if LEADTOOLS_V19_OR_LATER
            if (showUI)
            {
                if (!Support.SetLicense())
                {
                    return(-1);
                }
            }
#endif

            // If calling with the /uninstall flag, do not display the nag message
            if (_bUninstall == false)
            {
                if (RasterSupport.KernelExpired)
                {
                    return(-1);
                }
            }

#if LEADTOOLS_V175_OR_LATER
            if (showUI)
            {
                if (RasterSupport.IsLocked(RasterSupportType.DicomCommunication))
                {
                    MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.DicomCommunication.ToString()), "Warning");
                    return(-1);
                }
            }
#else
            if (RasterSupport.IsLocked(RasterSupportType.MedicalNet))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.MedicalNet.ToString()), "Warning");
                return(-1);
            }

            if (RasterSupport.IsLocked(RasterSupportType.MedicalServer))
            {
                MessageBox.Show(String.Format("{0} Support is locked!", RasterSupportType.MedicalServer.ToString()), "Warning");
                return(-1);
            }
#endif

            //_admin = new ServiceAdministrator(_baseDir);
            //_admin.Unlock(Support.MedicalServerKey);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

#if (LEADTOOLS_V20_OR_LATER)
            if (DemosGlobal.IsDotNet45OrLaterInstalled() == false)
            {
                MessageBox.Show("To run this application, you must first install Microsoft .NET Framework 4.5 or later.",
                                "Microsoft .NET Framework 4.5 or later Required",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation);
                return(-1);
            }
#endif

            //Utils.EngineStartup();
            DicomEngine.Startup();

            if (_bUninstall)
            {
                try
                {
                    using (ServiceAdministrator serviceAdmin = CreateServiceAdministrator())
                    {
                        MyUtils.UninstallAllDicomServersSilent(serviceAdmin);
                        MyUtils.RemoveConfigurationFiles();
                    }
                }
                catch (Exception)
                {
                }
            }
            else
            {
                string       missingDbComponents;
                DialogResult result = DialogResult.Yes;
                Messager.Caption = _demoName;
                string platform = "32-bit";
                if (DicomDemoSettingsManager.Is64Process())
                {
                    platform = "64-bit";
                }

                string [] productsToCheck = new string[] { DicomDemoSettingsManager.ProductNameDemoServer, DicomDemoSettingsManager.ProductNameWorkstation, DicomDemoSettingsManager.ProductNameStorageServer };

                bool isDbConfigured = GlobalPacsUpdater.IsDbComponentsConfigured(productsToCheck, out missingDbComponents);
                if (!isDbConfigured) // databases not configured
                {
                    string message = "The following databases are not configured:\n\n{0}\nRun the {1} CSPacsDatabaseConfigurationDemo to configure the missing databases then run this demo again.\n\nDo you want to run the {2} CSPacsDatabaseConfigurationDemo wizard now?";
                    message = string.Format(message, missingDbComponents, platform, platform);

                    result = Messager.ShowQuestion(null, message, MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == result)
                    {
                        RunDatabaseConfigurationDemo();
                    }
                }

                mySettings._settings.FirstRun = false;
                mySettings.Save();

                // Add event handler for handling UI thread exceptions to the event
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

                // Set the unhandled exception mode to force all Windows Forms errors to go through our handler.
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

                // Add the event handler for handling non-UI thread exceptions to the event.
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                try
                {
                    Application.Run(new MainForm());
                }
                catch (FileNotFoundException ex)
                {
                    MessageBox.Show("File not found exception.\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            DicomEngine.Shutdown();
            return(0);
        }
Exemplo n.º 12
0
        public void Run( )
        {
            try
            {
                StorageServerContainerView      containerPanel     = new StorageServerContainerView( );
                StorageServerContainerPresenter containerPresenter = new StorageServerContainerPresenter();

                RegisterDataAccessLayers( );

                _Form                       = new MainForm( );
                _Form.Text                  = Shell.storageServerName;
                containerPanel.Dock         = DockStyle.Fill;
                containerPanel.GradientMode = LinearGradientMode.Vertical;

                _Form.Controls.Add(containerPanel);

                using (ServiceAdministrator serverAdmin = new ServiceAdministrator(Application.StartupPath))
                {
                    DicomService service = null;


                    string serviceName = InitializeServiceAdmin(serverAdmin);

                    if (serverAdmin.Services.Count > 0)
                    {
                        service = serverAdmin.Services [serviceName];
                    }

                    CreateConfigurationServices(service);


#if TUTORIAL_CUSTOM_DATABASE
                    // To use a custom database schema, you must create and register your CatalogEntity classes (MyPatient, MyStudy, MySeries, MyInstance).
                    // Also, you must register your classes to extract DICOM data from a System.Data.DataRow (MyPatientInfo, MyStudyInfo, MySeriesInfo, MyInstanceInfo
                    // For more details, see the "Changing the LEAD Medical Storage Server to use a different database schema" tutorial.

                    DataAccessServiceLocator.Register <IPatientInfo>(new MyPatientInfo());
                    DataAccessServiceLocator.Register <IStudyInfo>(new MyStudyInfo());
                    DataAccessServiceLocator.Register <ISeriesInfo>(new MySeriesInfo());
                    DataAccessServiceLocator.Register <IInstanceInfo>(new MyInstanceInfo());

                    RegisteredEntities.Items.Add(RegisteredEntities.PatientEntityName, typeof(MyPatient));
                    RegisteredEntities.Items.Add(RegisteredEntities.StudyEntityName, typeof(MyStudy));
                    RegisteredEntities.Items.Add(RegisteredEntities.SeriesEntityName, typeof(MySeries));
                    RegisteredEntities.Items.Add(RegisteredEntities.InstanceEntityName, typeof(MyInstance));
#endif


                    ServerState.Instance.ServerService = service;
#if (LEADTOOLS_V19_OR_LATER_MEDICAL_VERIFY_ADDINS) || (LEADTOOLS_V19_OR_LATER)
                    if (ServerState.Instance.ServerService != null)
                    {
                        ServerState.Instance.ServerService.Message += new EventHandler <MessageEventArgs>(ServerService_Message);
                    }
#endif
                    ServerState.Instance.ServiceAdmin  = serverAdmin;
                    ServerState.Instance.BaseDirectory = Application.StartupPath;
                    ServerState.Instance.ServiceName   = serviceName;

                    ConfigureDataAccessLayers( );

                    LoadLoggingState(service);
                    InitializeLogger( );
#if LEADTOOLS_V18_OR_LATER
                    CheckLicenseFile();
#endif // #if LEADTOOLS_V18_OR_LATER

                    string csPathLogDump = ServerState.Instance.LoggingState.AutoSaveDirectory;

                    containerPresenter.PathLogDump = csPathLogDump;

                    containerPresenter.RunView(containerPanel);

                    SubscribeToEvents( );

                    new AuditLogSubscriber( ).Start( );

                    new CStoreAddIn().Start();

                    LogAudit(string.Format(AuditMessages.UserLogIn.Message, UserManager.User.FriendlyName));

                    Start(_Form);

                    if (UserManager.User != null)
                    {
                        LogAudit(string.Format(AuditMessages.UserLogOff.Message, UserManager.User.FriendlyName));
                    }
                    else
                    {
                        LogAudit("Canceled idle timer re-login");
                    }
                }
            }
            catch (Exception)
            {
                // Console.WriteLine ( ex.Message ) ;
                throw;
            }
        }