void IUIJob.OnNewOperation(IOperationViewer operationViewer, Operation operation)
        {
            // Only print if we don't have already (verrrrrrrrrrrry helpful during debugging, but also a sanity-check)
            if (CheckIsOperationAlreadyPrinted(operation, true))
            {
                return;
            }

            PrintQueue printQueue = _printQueue.Value;
            // If printing is not possible (an error occurred because the print server is not available etc.).
            if (printQueue == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, "Cannot print job because the configured printer seems not available! Check log entries.");
                return;
            }

            // We need to wait for a bit to let the UI "catch a breath".
            // Otherwise, if printing immediately, it may have side-effects that parts of the visual aren't visible (bindings not updated etc.).
            Thread.Sleep(_configuration.WaitInterval);

            PrintDialog dialog = new PrintDialog();
            dialog.PrintQueue = printQueue;
            dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
            dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
            dialog.PrintTicket.CopyCount = _configuration.CopyCount;

            FrameworkElement visual = operationViewer.Visual;
            // Measure and arrange the visual before printing otherwise it looks unpredictably weird and may not fit on the page
            visual.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
            visual.Arrange(new Rect(new Point(0, 0), visual.DesiredSize));

            dialog.PrintVisual(visual, "New alarm " + operation.OperationNumber);
        }
 void IUIJob.OnNewOperation(IOperationViewer operationViewer, Operation operation)
 {
     String[] programms =
         SettingsManager.Instance.GetSetting("ExternalToolUIJob", "ExternalTool")
                      .GetStringArray();
     foreach (var programm in programms)
     {
         Process.Start(programm);
     }
 }
        void IUIJob.OnNewOperation(IOperationViewer operationViewer, Operation operation)
        {
            string[] programs = new string[0];
            using (var service = ServiceFactory.GetCallbackServiceWrapper<ISettingsService>(new SettingsServiceCallback()))
            {
                programs = service.Instance.GetSetting(SettingKeys.ExternalTool).GetStringArray();
            }

            foreach (string program in programs)
            {
                Process.Start(program);
            }
        }
        void IUIJob.OnNewOperation(IOperationViewer operationViewer, Operation operation)
        {
            string[] programs = new string[0];
            using (var service = ServiceFactory.GetCallbackServiceWrapper <ISettingsService>(new SettingsServiceCallback()))
            {
                programs = service.Instance.GetSetting(SettingKeys.ExternalTool).GetStringArray();
            }

            foreach (string program in programs)
            {
                Process.Start(program);
            }
        }
 private void RunUIJobSync(IOperationViewer operationViewer, Operation operation, IUIJob job)
 {
     // Run the job. If the job fails, ignore that exception as well but log it too!
     try
     {
         job.OnNewOperation(operationViewer, operation);
     }
     catch (Exception ex)
     {
         // Be careful when processing the jobs, we don't want a malicious job to terminate the process!
         Logger.Instance.LogFormat(LogType.Warning, this, $"An error occurred while processing UI-job '{job.GetType().Name}'!");
         Logger.Instance.LogException(this, ex);
     }
 }
        private void InitializeOperationViewer()
        {
            string operationViewerAlias = App.GetApp().Configuration.OperationViewer;

            _operationViewer = ExportedTypeLibrary.Import <IOperationViewer>(operationViewerAlias);

            if (_operationViewer == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, Resources.DesiredOperationViewerNotFound, operationViewerAlias);
                _operationViewer = new Views.DummyOperationViewer();
            }

            _busyTemplate = new Lazy <FrameworkElement>(() => _operationViewer.Visual);
        }
 /// <summary>
 /// Calls each <see cref="IUIJob"/> using the given <see cref="IOperationViewer"/> and <see cref="Operation"/> instances.
 /// </summary>
 /// <param name="operationViewer"></param>
 /// <param name="operation"></param>
 public void RunUIJobs(IOperationViewer operationViewer, Operation operation)
 {
     foreach (IUIJob job in _uiJobs)
     {
         if (job.IsAsync)
         {
             RunUIJobAsync(operationViewer, operation, job);
         }
         else
         {
             RunUIJobSync(operationViewer, operation, job);
         }
     }
 }
 /// <summary>
 /// Calls each <see cref="IUIJob"/> using the given <see cref="IOperationViewer"/> and <see cref="Operation"/> instances.
 /// </summary>
 /// <param name="operationViewer"></param>
 /// <param name="operation"></param>
 public void RunUIJobs(IOperationViewer operationViewer, Operation operation)
 {
     foreach (IUIJob job in _uiJobs)
     {
         if (job.IsAsync)
         {
             RunUIJobAsync(operationViewer, operation, job);
         }
         else
         {
             RunUIJobSync(operationViewer, operation, job);
         }
     }
 }
 private void RunUIJobAsync(IOperationViewer operationViewer, Operation operation, IUIJob job)
 {
     ThreadPool.QueueUserWorkItem(o =>
     {
         // Run the job. If the job fails, ignore that exception as well but log it too!
         try
         {
             job.OnNewOperation(operationViewer, operation);
         }
         catch (Exception ex)
         {
             // Be careful when processing the jobs, we don't want a malicious job to terminate the process!
             Logger.Instance.LogFormat(LogType.Warning, this, string.Format("An error occurred while processing the asynchronous UI-job '{0}'!", job.GetType().Name));
             Logger.Instance.LogException(this, ex);
         }
     });
 }
 /// <summary>
 /// Calls each <see cref="IUIJob"/> using the given <see cref="IOperationViewer"/> and <see cref="Operation"/> instances.
 /// </summary>
 /// <param name="operationViewer"></param>
 /// <param name="operation"></param>
 public void RunUIJobs(IOperationViewer operationViewer, Operation operation)
 {
     foreach (IUIJob job in _uiJobs)
     {
         // Run the job. If the job fails, ignore that exception as well but log it too!
         try
         {
             job.OnNewOperation(operationViewer, operation);
         }
         catch (Exception ex)
         {
             // Be careful when processing the jobs, we don't want a malicious job to terminate the process!
             Logger.Instance.LogFormat(LogType.Warning, this, string.Format("An error occurred while processing UI-job '{0}'!", job.GetType().Name));
             Logger.Instance.LogException(this, ex);
         }
     }
 }
Beispiel #11
0
 private void RunUIJobAsync(IOperationViewer operationViewer, Operation operation, IUIJob job)
 {
     ThreadPool.QueueUserWorkItem(o =>
     {
         // Run the job. If the job fails, ignore that exception as well but log it too!
         try
         {
             job.OnNewOperation(operationViewer, operation);
         }
         catch (Exception ex)
         {
             // Be careful when processing the jobs, we don't want a malicious job to terminate the process!
             Logger.Instance.LogFormat(LogType.Warning, this, string.Format("An error occurred while processing the asynchronous UI-job '{0}'!", job.GetType().Name));
             Logger.Instance.LogException(this, ex);
         }
     });
 }
Beispiel #12
0
        private void InitializeOperationViewer()
        {
            string operationViewerAlias = App.GetApp().Configuration.OperationViewer;

            _operationViewer = ExportedTypeLibrary.Import <IOperationViewer>(operationViewerAlias);

            // If there is no operation viewer defined or it could not be found, use the default one and log it
            if (_operationViewer == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, Resources.DesiredOperationViewerNotFound, operationViewerAlias);
                _operationViewer = new Views.DummyOperationViewer();
            }

            _busyTemplate = new Lazy <FrameworkElement>(() =>
            {
                return(_operationViewer.Visual);
            });
        }
Beispiel #13
0
        private void InitializeOperationViewer()
        {
            string operationViewerAlias = App.GetApp().Configuration.OperationViewer;

            _operationViewer = ExportedTypeLibrary.Import <IOperationViewer>(operationViewerAlias);

            // If there is no operation viewer defined or it could not be found, use the default one and log it
            if (_operationViewer == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, "Could not find operation viewer with alias '{0}'. Using the default one. Please check the configuration file!", operationViewerAlias);
                _operationViewer = new Views.DefaultOperationView();
            }

            _controlTemplate = new Lazy <FrameworkElement>(() =>
            {
                return(_operationViewer.Visual);
            });
        }
        void IUIJob.OnNewOperation(IOperationViewer operationViewer, Operation operation)
        {
            string[] programs = new string[0];
            using (var service = ServiceFactory.GetCallbackServiceWrapper<ISettingsService>(new SettingsServiceCallback()))
            {
                programs = service.Instance.GetSetting(SettingKeys.ExternalTool).GetStringArray();
            }

            foreach (string program in programs)
            {
                try
                {
                    Task.Factory.StartNew(() => Starter.StartProgramTask(program, this));
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, this, Resources.CreatingProgramFailed, program);
                    Logger.Instance.LogException(this, ex);
                }
            }
        }
Beispiel #15
0
        void IUIJob.OnNewOperation(IOperationViewer operationViewer, Operation operation)
        {
            string[] programs = new string[0];
            using (var service = ServiceFactory.GetCallbackServiceWrapper <ISettingsService>(new SettingsServiceCallback()))
            {
                programs = service.Instance.GetSetting(SettingKeys.ExternalTool).GetStringArray();
            }

            foreach (string program in programs)
            {
                try
                {
                    Task.Factory.StartNew(() => ProgramStarter.StartProgramTask(program, this));
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, this, Resources.CreatingProgramFailed, program);
                    Logger.Instance.LogException(this, ex);
                }
            }
        }
Beispiel #16
0
        void IUIJob.OnNewOperation(IOperationViewer operationViewer, Operation operation)
        {
            // Only print if we don't have already (verrrrrrrrrrrry helpful during debugging, but also a sanity-check)
            if (CheckIsOperationAlreadyPrinted(operation, true))
            {
                return;
            }

            PrintQueue printQueue = _printQueue.Value;

            // If printing is not possible (an error occurred because the print server is not available etc.).
            if (printQueue == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, "Cannot print job because the configured printer seems not available! Check log entries.");
                return;
            }

            // We need to wait for a bit to let the UI "catch a breath".
            // Otherwise, if printing immediately, it may have side-effects that parts of the visual aren't visible (bindings not updated etc.).
            Thread.Sleep(_configuration.WaitInterval);

            PrintDialog dialog = new PrintDialog();

            dialog.PrintQueue  = printQueue;
            dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
            dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
            dialog.PrintTicket.CopyCount       = _configuration.CopyCount;

            FrameworkElement visual = operationViewer.Visual;

            // Measure and arrange the visual before printing otherwise it looks unpredictably weird and may not fit on the page
            visual.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
            visual.Arrange(new Rect(new Point(0, 0), visual.DesiredSize));

            dialog.PrintVisual(visual, "New alarm " + operation.OperationNumber);
        }
        private void InitializeOperationViewer()
        {
            string operationViewerAlias = App.GetApp().Configuration.OperationViewer;
            _operationViewer = ExportedTypeLibrary.Import<IOperationViewer>(operationViewerAlias);

            // If there is no operation viewer defined or it could not be found, use the default one and log it
            if (_operationViewer == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, "Could not find operation viewer with alias '{0}'. Using the default one. Please check the configuration file!", operationViewerAlias);
                _operationViewer = new Views.DefaultOperationView();
            }

            _busyTemplate = new Lazy<FrameworkElement>(() =>
            {
                return _operationViewer.Visual;
            });
        }
        private void InitializeOperationViewer()
        {
            string operationViewerAlias = App.GetApp().Configuration.OperationViewer;
            _operationViewer = ExportedTypeLibrary.Import<IOperationViewer>(operationViewerAlias);

            // If there is no operation viewer defined or it could not be found, use the default one and log it
            if (_operationViewer == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, Resources.DesiredOperationViewerNotFound, operationViewerAlias);
                _operationViewer = new Views.DummyOperationViewer();
            }

            _busyTemplate = new Lazy<FrameworkElement>(() =>
            {
                return _operationViewer.Visual;
            });
        }
        private void InitializeOperationViewer()
        {
            string operationViewerAlias = App.GetApp().Configuration.OperationViewer;
            _operationViewer = ExportedTypeLibrary.Import<IOperationViewer>(operationViewerAlias);

            if (_operationViewer == null)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, Resources.DesiredOperationViewerNotFound, operationViewerAlias);
                _operationViewer = new Views.DummyOperationViewer();
            }

            _busyTemplate = new Lazy<FrameworkElement>(() => _operationViewer.Visual);
        }