Пример #1
0
 public ApplicationCommands() : base("[ApplicatonCommands]")
 {
     configuration       = SingledToolbox.Get <Configuration <MainAppConfigurationModel> >();
     kbdService          = SingledToolbox.Get <KBDAPIService>();
     filesWorkingService = SingledToolbox.Get <FilesWorkingService>();
 }
Пример #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            _logger.Trace($"{LogTag} OnStartup");
            _AppConfiguration = new ApplicationConfiguration.Configuration <MainAppConfigurationModel>("AppConfiguration.cfg");
            _AppConfiguration.LoadConfiguration();

            SingledToolbox.AddTool(typeof(Configuration <MainAppConfigurationModel>), _AppConfiguration);

            var kbdServiceConfig    = _AppConfiguration.GetPropertyValue <KBDAPIServiceConfig>("ServiceConfig");
            var searchServiceConfig = _AppConfiguration.GetPropertyValue <SearchServiceConfig>("SearchServiceConfig");

            _KBDAPIService = new KBDAPIService(kbdServiceConfig, searchServiceConfig);
            try
            {
                _KBDAPIService.OpenClients();
                SingledToolbox.AddTool(typeof(KBDAPIService), _KBDAPIService);
            }
            catch (Exception ex)
            {
                _logger.Error($"{LogTag} Exception in KBDAPI: {ex.Message}");
                if (ex.InnerException != null)
                {
                    _logger.Error($"{LogTag} InnerEx:{ex.InnerException.Message}");
                }
                MessageBox.Show(ex.Message, "Exception in KBDAPI Service");
                base.Shutdown();
            }

            try
            {
                string tempDirPath = _AppConfiguration.GetPropertyValue <string>("TempDirectoryPath");
                if (string.IsNullOrEmpty(tempDirPath))
                {
                    var currentTempDir = new DirectoryInfo(Directory.GetCurrentDirectory()).CreateSubdirectory("TempAttachments");
                    tempDirPath = currentTempDir.FullName;
                }
                var applicationsForEditingDocuments = _AppConfiguration.GetPropertyValue <ApplicationsForEditingDocuments>("ApplicationsForEditingDocuments");
                _filesWorkingService = new FilesWorkingService(tempDirPath, applicationsForEditingDocuments.UseDefault);
                if (!string.IsNullOrEmpty(applicationsForEditingDocuments.DocumentEditorPath) && File.Exists(applicationsForEditingDocuments.DocumentEditorPath))
                {
                    _filesWorkingService.DocumentEditorPath = applicationsForEditingDocuments.DocumentEditorPath;
                }
                if (!string.IsNullOrEmpty(applicationsForEditingDocuments.PDFDocumentEditorPath) && File.Exists(applicationsForEditingDocuments.PDFDocumentEditorPath))
                {
                    _filesWorkingService.DocumentEditorPath = applicationsForEditingDocuments.PDFDocumentEditorPath;
                }
                SingledToolbox.AddTool(typeof(FilesWorkingService), _filesWorkingService);
            }
            catch (Exception ex)
            {
                _logger.Error($"{LogTag} Exception in FilesWorking Service: {ex.Message}");
                if (ex.InnerException != null)
                {
                    _logger.Error($"{LogTag} InnerEx:{ex.InnerException.Message}");
                }
                MessageBox.Show(ex.Message, "Exception in Files Working Service");
                base.Shutdown();
            }

            _appCommands = new ApplicationCommands();
            SingledToolbox.AddTool(typeof(ApplicationCommands), _appCommands);

            base.OnStartup(e);
        }