示例#1
0
        /// <summary>
        /// Writes application information to the file.
        /// </summary>
        private void WriteInfo()
        {
            try
            {
                // prepare information
                StringBuilder sb          = new StringBuilder((int)(lastInfoLength * 1.1));
                TimeSpan      workSpan    = DateTime.UtcNow - utcStartDT;
                string        workSpanStr = workSpan.Days > 0 ?
                                            workSpan.ToString(@"d\.hh\:mm\:ss") :
                                            workSpan.ToString(@"hh\:mm\:ss");

                if (Locale.IsRussian)
                {
                    sb
                    .AppendLine("Агент")
                    .AppendLine("-----")
                    .Append("Запуск       : ").AppendLine(startDT.ToLocalizedString())
                    .Append("Время работы : ").AppendLine(workSpanStr)
                    .Append("Статус       : ").AppendLine(serviceStatus.ToString(true))
                    .Append("Версия       : ").AppendLine(EngineUtils.AppVersion);
                }
                else
                {
                    sb
                    .AppendLine("Agent")
                    .AppendLine("-----")
                    .Append("Started        : ").AppendLine(startDT.ToLocalizedString())
                    .Append("Execution time : ").AppendLine(workSpanStr)
                    .Append("Status         : ").AppendLine(serviceStatus.ToString(false))
                    .Append("Version        : ").AppendLine(EngineUtils.AppVersion);
                }

                if (listener != null)
                {
                    sb.AppendLine();
                    listener.AppendClientInfo(sb);
                }

                lastInfoLength = sb.Length;

                // write to file
                using (StreamWriter writer = new StreamWriter(infoFileName, false, Encoding.UTF8))
                {
                    writer.Write(sb.ToString());
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                Log.WriteError(ex, CommonPhrases.WriteInfoError);
            }
        }
示例#2
0
        private void Run(object args)
        {
            Arguments arguments = (Arguments)args;

            VerificationServiceSCU echo = new VerificationServiceSCU();

            echo.Syntaxes.Add(Syntax.ImplicitVrLittleEndian);

            Association association = new Association();

            association.AddService(echo);

            SetStatusBarText("Running ...");
            if (association.Open(arguments.Scp, arguments.Scu))
            {
                ServiceStatus status = echo.Echo();
                SetStatusBarText(status.ToString());
            }
            else
            {
                SetStatusBarText("Can't establish association");
            }

            association.Close();
            association.Dispose();
        }
示例#3
0
        public async Task <ServiceStatus> Run(string storageName)
        {
            const string startMessage = "Shell started work.";

            GlobalMessageHandler.OutputMessage(startMessage);
            _logger.Info(startMessage);

            DataflowPipeline dataflowPipeline;

            try
            {
                dataflowPipeline = ConstructPipeline(storageName);

                // Start processing data.
                // And wait for the last block in the pipeline to process all messages.
                await dataflowPipeline.Execute(storageName);
            }
            catch (Exception ex)
            {
                const string failureMessage = "Shell got an exception during data processing.";
                _logger.Error(ex, failureMessage);
                GlobalMessageHandler.OutputMessage(failureMessage);

                return(ServiceStatus.Error);
            }

            ServiceStatus status = await SaveResults(dataflowPipeline.OutputtersFlow);

            if (status != ServiceStatus.Ok)
            {
                string failureMessage = $"Shell got \"{status.ToString()}\" status " +
                                        "during data saving.";
                GlobalMessageHandler.OutputMessage(failureMessage);
                _logger.Info(failureMessage);

                return(status);
            }

            const string successfulMessage = "Shell finished work successfully.";

            _logger.Info(successfulMessage);
            GlobalMessageHandler.OutputMessage(successfulMessage);

            return(ServiceStatus.Ok);
        }
示例#4
0
        /// <summary>
        /// Handles the Click event of the buttonTest control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void buttonTest_Click(object sender, EventArgs e)
        {
            labelTest.Text = Resources.Connecting;
            TicketService testService = new TicketService();

            testService.Url = ServiceUri;
            Application.DoEvents();

            try
            {
                ServiceStatus status = testService.GetServiceState();
                labelTest.Text = status.ToString();
            }
            catch (WebException exp)
            {
                labelTest.Text = exp.Status.ToString();
            }
        }
示例#5
0
        public string GenerateServiceStatusIcon(ServiceStatus status)
        {
            var cssClass   = "label-info";
            var statusText = "NotSet";

            if (status == ServiceStatus.Active)
            {
                cssClass = "label-success";
            }
            else if (status == ServiceStatus.NotRequired)
            {
                cssClass = "label-info";
            }
            else
            {
                cssClass = "label-danger";
            }

            statusText = status.ToString();
            if (status == ServiceStatus.NotRequired)
            {
                statusText = "Not Required";
            }
            if (status == ServiceStatus.NotFound)
            {
                statusText = "Not Found";
            }
            if (status == ServiceStatus.NotSet)
            {
                statusText = "Not Set";
            }

            return(String.Format("<div class=\"label {0} label-mini\">{1}</div>",
                                 cssClass,
                                 statusText
                                 ));
        }
示例#6
0
 internal PathStatus(string FilePath, ServiceStatus FileStatus)
 {
     Path   = FilePath;
     Status = FileStatus.ToString();
 }
示例#7
0
 protected static string GetServiceStatusDescription(ServiceStatus status)
 {
     return(MonitoringResource.ResourceManager.GetString("ServiceStatus" + status) ?? status.ToString());
 }
 protected static string GetServiceStatusDescription(ServiceStatus status)
 {
     return MonitoringResource.ResourceManager.GetString("ServiceStatus" + status) ?? status.ToString();
 }
示例#9
0
 public SqlServiceStatus(ServiceStatus state)
 {
     State    = state;
     AsString = State.ToString().Replace("_", " ");
 }
        private async void Load()
        {
            bool          success = true;
            string        message = "";
            ServiceStatus status  = ServiceStatus.NotRegistered;

            ProgressLoading.IsActive = true;
            await Task.Run(() =>
            {
                var result = Controller.CheckServiceStatus();
                if (result.Status.Success)
                {
                    status = result.Data;
                }
                else
                {
                    success = false;
                    message = result.Status.ErrorMessage;
                }
            });

            if (success)
            {
                BitmapImage image = new BitmapImage(ImageUris[status]);
                ImageServiceStatus.Source = image;
                TextStatus.Text           = status.ToString();
                switch (status)
                {
                case ServiceStatus.NotRegistered:
                    ButtonStart.IsEnabled    = false;
                    ButtonPause.IsEnabled    = false;
                    ButtonContinue.IsEnabled = false;
                    ButtonStop.IsEnabled     = false;
                    break;

                case ServiceStatus.Stopped:
                    ButtonStart.IsEnabled    = true;
                    ButtonPause.IsEnabled    = false;
                    ButtonContinue.IsEnabled = false;
                    ButtonStop.IsEnabled     = false;
                    break;

                case ServiceStatus.Paused:
                    ButtonStart.IsEnabled    = false;
                    ButtonPause.IsEnabled    = false;
                    ButtonContinue.IsEnabled = true;
                    ButtonStop.IsEnabled     = false;
                    break;

                case ServiceStatus.Running:
                    ButtonStart.IsEnabled    = false;
                    ButtonPause.IsEnabled    = true;
                    ButtonContinue.IsEnabled = false;
                    ButtonStop.IsEnabled     = true;
                    break;
                }
            }
            else
            {
                BitmapImage image = new BitmapImage(ImageUris[ServiceStatus.NotRegistered]);
                ImageServiceStatus.Source = image;
                TextStatus.Text           = "Unknown";
                ButtonStart.IsEnabled     = false;
                ButtonPause.IsEnabled     = false;
                ButtonContinue.IsEnabled  = false;
                ButtonStop.IsEnabled      = false;
            }
            ProgressLoading.IsActive = false;
        }
示例#11
0
        private void RefreshServiceStatus(ServiceStatus status)
        {
            this.labelInterfaceName.Text = string.Format("{0} ({1})", Program.ConfigMgr.Config.HL7GatewayInterfaceName, status.ToString());
            switch (status)
            {
            case ServiceStatus.Running:
                this.buttonServiceStop.Enabled   = true;
                this.buttonServiceStart.Enabled  = false;
                this.buttonServiceConfig.Enabled = false;
                this.panelAdapter.Enabled        = false;
                break;

            case ServiceStatus.Stopped:
                this.buttonServiceStop.Enabled   = false;
                this.buttonServiceStart.Enabled  = true;
                this.buttonServiceConfig.Enabled = true;
                this.panelAdapter.Enabled        = true;
                break;

            default:
                this.buttonServiceStop.Enabled   = false;
                this.buttonServiceStart.Enabled  = false;
                this.buttonServiceConfig.Enabled = true;
                this.panelAdapter.Enabled        = true;
                break;
            }
        }
示例#12
0
        private async void StartTask(TaskType taskType)
        {
            bool   success = true;
            string message = "";

            ProgressLoading.IsActive = true;
            ServiceStatus status = ServiceStatus.NotRegistered;

            switch (taskType)
            {
            case TaskType.Start:
                await Task.Run(() =>
                {
                    var result = Controller.StartService();
                    if (!result.Success)
                    {
                        success = false;
                        message = result.ErrorMessage;
                    }
                });

                if (success)
                {
                    status = ServiceStatus.Running;
                }
                else
                {
                    status = ServiceStatus.NotRegistered;
                }
                break;

            case TaskType.Stop:
                await Task.Run(() =>
                {
                    var result = Controller.StopService();
                    if (!result.Success)
                    {
                        success = false;
                        message = result.ErrorMessage;
                    }
                });

                if (success)
                {
                    status = ServiceStatus.Stopped;
                }
                else
                {
                    status = ServiceStatus.NotRegistered;
                }
                break;

            case TaskType.Continue:
                await Task.Run(() =>
                {
                    var result = Controller.ContinueService();
                    if (!result.Success)
                    {
                        success = false;
                        message = result.ErrorMessage;
                    }
                });

                if (success)
                {
                    status = ServiceStatus.Running;
                }
                else
                {
                    status = ServiceStatus.NotRegistered;
                }
                break;

            case TaskType.Pause:
                await Task.Run(() =>
                {
                    var result = Controller.PauseService();
                    if (!result.Success)
                    {
                        success = false;
                        message = result.ErrorMessage;
                    }
                });

                if (success)
                {
                    status = ServiceStatus.Paused;
                }
                else
                {
                    status = ServiceStatus.NotRegistered;
                }
                break;

            case TaskType.Refresh:
                await Task.Run(() =>
                {
                    var result = Controller.RefreshService();
                    if (!result.Success)
                    {
                        success = false;
                        message = result.ErrorMessage;
                    }
                });

                if (success)
                {
                    status = ServiceStatus.Running;
                }
                else
                {
                    status = ServiceStatus.NotRegistered;
                }
                break;
            }

            if (success)
            {
                BitmapImage image = new BitmapImage(ImageUris[status]);
                ImageServiceStatus.Source = image;
                TextStatus.Text           = status.ToString();
                switch (status)
                {
                case ServiceStatus.NotRegistered:
                    ButtonStart.IsEnabled    = false;
                    ButtonPause.IsEnabled    = false;
                    ButtonContinue.IsEnabled = false;
                    ButtonStop.IsEnabled     = false;
                    break;

                case ServiceStatus.Stopped:
                    ButtonStart.IsEnabled    = true;
                    ButtonPause.IsEnabled    = false;
                    ButtonContinue.IsEnabled = false;
                    ButtonStop.IsEnabled     = false;
                    break;

                case ServiceStatus.Paused:
                    ButtonStart.IsEnabled    = false;
                    ButtonPause.IsEnabled    = false;
                    ButtonContinue.IsEnabled = true;
                    ButtonStop.IsEnabled     = false;
                    break;

                case ServiceStatus.Running:
                    ButtonStart.IsEnabled    = false;
                    ButtonPause.IsEnabled    = true;
                    ButtonContinue.IsEnabled = false;
                    ButtonStop.IsEnabled     = true;
                    break;
                }
            }
            else
            {
                BitmapImage image = new BitmapImage(ImageUris[ServiceStatus.NotRegistered]);
                ImageServiceStatus.Source = image;
                TextStatus.Text           = "Unknown";
                ButtonStart.IsEnabled     = false;
                ButtonPause.IsEnabled     = false;
                ButtonContinue.IsEnabled  = false;
                ButtonStop.IsEnabled      = false;
            }
            ProgressLoading.IsActive = false;
        }
示例#13
0
        /// <summary>
        /// Writes application information to the file.
        /// </summary>
        private void WriteInfo()
        {
            try
            {
                // prepare information
                StringBuilder sb = new StringBuilder((int)(lastInfoLength * 1.1));
                sb.AppendLine(Title);
                sb.Append('-', Title.Length).AppendLine();
                string deviceHeader;

                if (Locale.IsRussian)
                {
                    sb.Append("Статус      : ").AppendLine(lineStatus.ToString(true));
                    sb.Append("Канал связи : ").AppendLine(channel.ChannelLogic.StatusText);
                    deviceHeader = $"КП ({devices.Count})";
                }
                else
                {
                    sb.Append("Status                : ").AppendLine(lineStatus.ToString(false));
                    sb.Append("Communication channel : ").AppendLine(channel.ChannelLogic.StatusText);
                    deviceHeader = $"Devices ({devices.Count})";
                }


                channel.ChannelLogic.AppendInfo(sb);
                sb
                .AppendLine()
                .AppendLine(deviceHeader)
                .Append('-', deviceHeader.Length).AppendLine();

                if (devices.Count > 0)
                {
                    foreach (DeviceWrapper deviceWrapper in devices)
                    {
                        DeviceLogic deviceLogic = deviceWrapper.DeviceLogic;
                        sb
                        .Append(deviceLogic.Title)
                        .Append(' ', maxDeviceTitleLength - deviceLogic.Title.Length)
                        .Append(" : ")
                        .AppendLine(deviceLogic.StatusText);
                    }
                }
                else
                {
                    sb.AppendLine(Locale.IsRussian ? "КП нет" : "No devices");
                }

                lastInfoLength = sb.Length;

                // write to file
                using (StreamWriter writer = new StreamWriter(infoFileName, false, Encoding.UTF8))
                {
                    writer.Write(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                Log.WriteException(ex, Locale.IsRussian ?
                                   "Ошибка при записи в файл информации о работе линии связи" :
                                   "Error writing communication line information to the file");
            }
        }
示例#14
0
        public void SetNewAttackServiceState(string serviceName, ServiceStatus newStatus)
        {
            if (this.InvokeRequired == true)
            {
                this.BeginInvoke(new SetNewAttackServiceStateDelegate(this.SetNewAttackServiceState), new object[] { serviceName, newStatus });
                return;
            }

            if (string.IsNullOrEmpty(serviceName) ||
                this.attackServiceHandler?.AttackServices == null)
            {
                return;
            }

            if (this.attackServiceHandler.AttackServices.ContainsKey(serviceName) == false)
            {
                LogCons.Inst.Write(LogLevel.Warning, $"AttackServiceHandler.SetNewState(): Attack service \"{serviceName}\" was never registered");
                return;
            }

            int tmpNewServiceStatus = (newStatus >= 0) ? (int)newStatus : (int)ServiceStatus.NotRunning;

            this.attackServiceMap[serviceName].Image = this.il_AttackServiceStat.Images[tmpNewServiceStatus];
            LogCons.Inst.Write(LogLevel.Info, $"AttackServiceHandler.SetNewState(): {serviceName} has new state \"{newStatus.ToString()}\"");
        }
示例#15
0
        private void buttonStatus_Click(object sender, RoutedEventArgs e)
        {
            ServiceStatus status = service.GetCurrentState();

            textBoxStatus.Text = "Status: " + status.ToString() + Environment.NewLine + textBoxStatus.Text;
        }
示例#16
0
		public static void SetServiceStatus(string name, ServiceStatus status)
		{
			switch (status)
			{
				case ServiceStatus.Started:
					Start(name, StatusChangeTimeout);
				return;
				case ServiceStatus.Stopped:
					Stop(name, StatusChangeTimeout);
				return;
			}

			Debug.Assert(false, status.ToString());
		}