Beispiel #1
0
 /// <summary>
 /// Appends information to the string builder.
 /// </summary>
 public static void AppendInfo(ArcUploadState uploadState, StringBuilder sbInfo)
 {
     if (uploadState == null)
     {
         sbInfo
         .AppendLine(Localization.UseRussian ? "Отключена" : "Disabled")
         .AppendLine();
     }
     else
     {
         uploadState.AppendInfo(sbInfo);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Writes the exporter information to the file.
        /// </summary>
        private void WriteInfo()
        {
            try
            {
                // build text
                StringBuilder sbInfo = new StringBuilder();

                if (Localization.UseRussian)
                {
                    sbInfo
                    .AppendLine("Состояние экспортёра")
                    .AppendLine("--------------------")
                    .Append("Наименование   : ").AppendLine(exporterTitle)
                    .Append("Сервер БД      : ").AppendLine(exporterConfig.ConnectionOptions.Server)
                    .Append("Соединение     : ").AppendLine(ConnStatusNamesRu[(int)connStatus])
                    .AppendLine();

                    void AppendQueueStatsRu(QueueStats queueStats, int?queueSize)
                    {
                        if (queueStats == null)
                        {
                            sbInfo.AppendLine("Очередь не используется");
                        }
                        else
                        {
                            sbInfo
                            .Append("Состояние      : ").AppendLine(queueStats.ErrorState ? "ошибка" : "норма")
                            .Append("В очереди      : ").Append(queueSize).Append(" из ").Append(maxQueueSize).AppendLine()
                            .Append("Экспортировано : ").Append(queueStats.ExportedItems).AppendLine()
                            .Append("Пропущено      : ").Append(queueStats.SkippedItems).AppendLine();
                        }

                        sbInfo.AppendLine();
                    }

                    sbInfo.AppendLine("Текущие данные");
                    sbInfo.AppendLine("--------------");
                    AppendQueueStatsRu(curDataStats, curDataQueue?.Count);

                    sbInfo.AppendLine("Архивные данные");
                    sbInfo.AppendLine("---------------");
                    AppendQueueStatsRu(arcDataStats, arcDataQueue?.Count);

                    sbInfo.AppendLine("События");
                    sbInfo.AppendLine("-------");
                    AppendQueueStatsRu(eventStats, eventQueue?.Count);

                    sbInfo.AppendLine("Передача архивов");
                    sbInfo.AppendLine("----------------");
                    ArcUploadState.AppendInfo(arcUploadState, sbInfo);

                    if (taskUploadState != null)
                    {
                        sbInfo.AppendLine("Передача архивов по заданию");
                        sbInfo.AppendLine("---------------------------");
                        taskUploadState.AppendInfo(sbInfo);
                    }
                }
                else
                {
                    sbInfo
                    .AppendLine("Exporter State")
                    .AppendLine("--------------")
                    .Append("Name       : ").AppendLine(exporterTitle)
                    .Append("DB server  : ").AppendLine(exporterConfig.ConnectionOptions.Server)
                    .Append("Connection : ").AppendLine(ConnStatusNamesEn[(int)connStatus])
                    .AppendLine();

                    void AppendQueueStatsEn(QueueStats queueStats, int?queueSize)
                    {
                        if (queueStats == null)
                        {
                            sbInfo.AppendLine("Queue is not in use");
                        }
                        else
                        {
                            sbInfo
                            .Append("Status     : ").AppendLine(queueStats.ErrorState ? "Error" : "Normal")
                            .Append("In queue   : ").Append(queueSize).Append(" of ").Append(maxQueueSize).AppendLine()
                            .Append("Exported   : ").Append(queueStats.ExportedItems).AppendLine()
                            .Append("Skipped    : ").Append(queueStats.SkippedItems).AppendLine();
                        }

                        sbInfo.AppendLine();
                    }

                    sbInfo.AppendLine("Current Data");
                    sbInfo.AppendLine("------------");
                    AppendQueueStatsEn(curDataStats, curDataQueue?.Count);

                    sbInfo.AppendLine("Archive Data");
                    sbInfo.AppendLine("------------");
                    AppendQueueStatsEn(arcDataStats, arcDataQueue?.Count);

                    sbInfo.AppendLine("Events");
                    sbInfo.AppendLine("------");
                    AppendQueueStatsEn(eventStats, eventQueue?.Count);

                    sbInfo.AppendLine("Archive Uploading");
                    sbInfo.AppendLine("-----------------");
                    ArcUploadState.AppendInfo(arcUploadState, sbInfo);

                    if (taskUploadState != null)
                    {
                        sbInfo.AppendLine("Archive Uploading by Task");
                        sbInfo.AppendLine("-------------------------");
                        taskUploadState.AppendInfo(sbInfo);
                    }
                }

                // write to file
                using (StreamWriter writer = new StreamWriter(infoFileName, false, Encoding.UTF8))
                {
                    writer.Write(sbInfo.ToString());
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                log.WriteException(ex, ModPhrases.WriteInfoError);
            }
        }