// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Запуск EXE-файла в том же каталоге, что и данная программа static bool StartExeCopy(string SrcExeName, string Params) { if ((SrcExeName == null) || (Params == null)) { return(false); } SrcExeName = SrcExeName.Trim(); Params = Params.Trim(); if (SrcExeName == "") { return(false); } string Path = CCommon.GetTaskDir() + "\\"; string Mask = SrcExeName.Substring(0, SrcExeName.Length - 3) + "*"; string ExeName = Path + CCommon.GetFileName(SrcExeName); if (!CCommon.FileExists(ExeName)) { foreach (string FileName in CCommon.GetFileList(Mask)) { if (!CCommon.CopyFile(FileName, Path + CCommon.GetFileName(FileName))) { return(false); } } } if (!CCommon.FileExists(ExeName)) { return(false); } return(CCommon.Run(ExeName, Params)); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Получить имя файла с помощью графической панели открытия файла static string SelectFileNameGUI(string SettingsPath, string DestPath) { string TmpS = CAbc.EMPTY; string Result = CAbc.EMPTY; string SettingsFileName = null; if (SettingsPath != null) { if (SettingsPath.Trim().Length > 0) { SettingsFileName = SettingsPath.Trim() + "\\" + CCommon.GetUserName() + ".ldr"; if (CCommon.FileExists(SettingsFileName)) { TmpS = CCommon.LoadText(SettingsFileName, CAbc.CHARSET_WINDOWS); } if (TmpS == null) { TmpS = CAbc.EMPTY; } } } TmpS = TmpS.Trim(); TmpS = CCommon.OpenFileBox( "Укажите А-файл для загрузки" , TmpS , "А-файлы (?A*.*)|?a*.*" ); if (TmpS == null) { return(Result); } TmpS = TmpS.Trim(); if (TmpS.Length == 0) { return(Result); } if (SettingsFileName != null) { CCommon.SaveText(SettingsFileName, CCommon.GetDirName(TmpS), CAbc.CHARSET_WINDOWS); } Result = DestPath.Trim() + "\\" + CCommon.GetFileName(TmpS); if (CCommon.FileExists(Result)) { CCommon.Print("", "Выбранный файл уже существует в целевом каталоге : ", Result, "", "Нажмите ENTER для выхода..."); CCommon.Input(); Result = CAbc.EMPTY; } else if (!CCommon.CopyFile(TmpS, Result)) { CCommon.Print("Ошибка копирования файла в целевой каталог : ", Result, "", "Нажмите ENTER для выхода..."); CCommon.Input(); Result = CAbc.EMPTY; } return(Result); }
//----------------------------------------------------------------------------------------- // основная программа public static void Main() { const bool DEBUG = false; const int MAX_COLUMNS = 299; // максимальное количество столбцов int[] ColWidth = new int[MAX_COLUMNS]; // ширины столбцов int ColNumber = 0; int ALineNumber = 0; int AFieldNumber = 0; string AFileName = ""; string ModelFileName = CCommon.GetTempDir() + "\\" + "AMaker.mod"; string Now_Date_Str = CCommon.DtoC(CCommon.Today()).Substring(2, 6); string Now_Time_Str = CCommon.Hour(CCommon.Now()).ToString("00") + CCommon.Minute(CCommon.Now()).ToString("00"); CTsvWriter TsvWriter = new CTsvWriter(); CTextReader TextReader = new CTextReader(); string TsvFileName = "$"; string InpFileName = ""; int InpColCount = 0; int I, SourceMode = -2; // откуда читать данные : 0=ClipBoard , 1=CSV , 2=DIF string Tmps = ""; string[] SubTmps; //---------------------------------------------------------- CCommon.Print(" Программа для cоздания А-файлов с платежами на основе форматных данных,"); CCommon.Print(" полученных из электронной таблицы (CVS/DIF). Версия 2.03 от 17.09.2019г."); if (DEBUG) { InpFileName = "F:\\Trash\\Kazna1.csv"; } else if (CCommon.ParamCount() < 2) { CCommon.Print(""); CCommon.Print(" Формат запуска : "); CCommon.Print(" AMaker3 Имя_файла "); CCommon.Print(" где : "); CCommon.Print(" Имя_файла - имя файла данных в формате CSV или DIF "); CCommon.Print(""); return; } else { InpFileName = CAbc.ParamStr[1].Trim(); } if (InpFileName == "*") { SourceMode = 0; } else { switch (CCommon.GetExtension(InpFileName).ToUpper()) { case ".CSV": { SourceMode = 1; break; } case ".DIF": { SourceMode = 2; break; } case ".MOD": { SourceMode = -1; break; } default: { CCommon.Print("Неправильный тип файла !"); SourceMode = -2; break; } } } //---------------------------------------------------------- // если выбран файл с шаблоном, то выводим его на экран if (SourceMode == -1) { if (AModel.LoadFromFile(InpFileName)) { AModel.PrintConstValues(); if (CConsole.GetBoxChoice("Использовать теперь этот шаблон ?", " Да = Enter . Нет = Esc .")) { if (CCommon.FileExists(ModelFileName)) { CCommon.DeleteFile(ModelFileName); } if (CCommon.FileExists(ModelFileName)) { CCommon.Print("Ошибка удаления файла " + ModelFileName); } else if (!CCommon.CopyFile(InpFileName, ModelFileName)) { CCommon.Print("Ошибка записи файла " + ModelFileName); } return; } } } else if (CCommon.FileExists(ModelFileName)) { AModel.LoadFromFile(ModelFileName); } if ((SourceMode < 0) || (SourceMode > 2)) { CCommon.Print("Неправильная строка параметров !"); return; } //---------------------------------------------------------- // скидываем информацию в промежуточный Tsv-файл TsvFileName = CCommon.GetTempName(); if (TsvFileName == null) { TsvFileName = InpFileName + ".$$$"; } else if (TsvFileName.Trim() == "") { TsvFileName = InpFileName + ".$$$"; } if (SourceMode == 0) { TsvWriter.LoadFromClipboard(); if (!TsvWriter.SaveToFile(TsvFileName)) { CCommon.Print("Ошибка записи в файл " + TsvFileName); return; } } if (SourceMode > 0) { if (!CCommon.FileExists(InpFileName)) { CCommon.Print("Не найден файл " + InpFileName); return; } } if (SourceMode == 1) { if (TsvWriter.LoadFromCsvFile(InpFileName)) { if (!TsvWriter.SaveToFile(TsvFileName)) { CCommon.Print("Ошибка записи в файл " + TsvFileName); return; } } else { CCommon.Print("Ошибка чтения файла " + InpFileName); return; } } if (SourceMode == 2) { if (TsvWriter.LoadFromDifFile(InpFileName)) { if (!TsvWriter.SaveToFile(TsvFileName)) { CCommon.Print("Ошибка записи в файл " + TsvFileName); return; } } else { CCommon.Print("Ошибка чтения файла " + InpFileName); return; } } //---------------------------------------------------------- // подсчитываем количество столбцов во входящем файле , а также ширину этих столбцов for (I = 0; I < MAX_COLUMNS; I++) { ColWidth[I] = 0; } for (I = 0; I < (MAX_LINES * MAX_FILES); I++) { Cents[I] = 0; } if (!TextReader.Open(TsvFileName, CAbc.CHARSET_WINDOWS)) { CCommon.Print("Ошибка чтения файла" + TsvFileName); TsvFile.Close(); CCommon.DeleteFile(TsvFileName); return; } if (!TextReader.Read()) { CCommon.Print("Ошибка чтения файла" + TsvFileName); TsvFile.Close(); CCommon.DeleteFile(TsvFileName); return; } for (I = 0; I < 20; I++) { Tmps = TextReader.Value; SubTmps = Tmps.Split(CCommon.Chr(9)); if (SubTmps != null) { if (SubTmps.Length > InpColCount) { InpColCount = SubTmps.Length; } for (ColNumber = 0; ColNumber < SubTmps.Length; ColNumber++) { if (SubTmps[ColNumber].Length > ColWidth[ColNumber]) { ColWidth[ColNumber] = SubTmps[ColNumber].Length; } } } else { InpColCount = 0; } if (!TextReader.Read()) { break; } } TextReader.Close(); if (InpColCount == 0) { CCommon.Print("Не получается распознать входные данные "); CCommon.DeleteFile(TsvFileName); return; } //---------------------------------------------------------- // выводим столбцы на экран и запрос пользователю ( помним , что в Csv - файле нумерация столбцов начинается с 1 ) CConsole.Clear(); if (!TsvFile.Open(TsvFileName, CAbc.CHARSET_WINDOWS)) { CCommon.Print("Ошибка чтения файла " + TsvFileName); return; } for (I = 0; I < (System.Console.WindowHeight - 1); I++) { if (!TsvFile.Read()) { break; } Tmps = ""; for (ColNumber = 0; ColNumber < InpColCount; ColNumber++) { Tmps += CCommon.Left(TsvFile[ColNumber + 1], ColWidth[ColNumber]) + "¦"; } if (Tmps.Length > 0) { if (Tmps.Length < System.Console.WindowWidth - 1) { CCommon.Print(Tmps); } else { CCommon.Print(Tmps.Substring(0, System.Console.WindowWidth - 2)); } } } TsvFile.Close(); if (!CConsole.GetBoxChoice("Для продолжения обработки нажмите Enter.", "", "Для выхода нажмите Esc. ")) { CCommon.DeleteFile(TsvFileName); return; } CConsole.Clear(); //---------------------------------------------------------- // распознавание столбцов во входящем файле ( помним , что в Csv - файле нумерация столбцов начинается с 1 ) for (ColNumber = 0; ColNumber < InpColCount; ColNumber++) { CConsole.Clear(); CCommon.Print(""); if (!TsvFile.Open(TsvFileName, CAbc.CHARSET_WINDOWS)) { CCommon.Print("Ошибка чтения файла " + TsvFileName); TsvFile.Close(); CCommon.DeleteFile(TsvFileName); return; } for (I = 0; I < (System.Console.WindowHeight - 1); I++) { if (!TsvFile.Read()) { break; } else { CCommon.Print(" " + TsvFile[ColNumber + 1]); } } TsvFile.Close(); if (!AModel.RecognizeColumn(ColNumber + 1)) { CCommon.DeleteFile(TsvFileName); return; } } CConsole.Clear(); //---------------------------------------------------------- // запрашиваем у пользователя значения постоянных полей AModel.AskFixedValues(); //---------------------------------------------------------- // подсчитываем количество строк и общую сумму по входному файлу TotalLines = 0; TotalCents = 0; if (!TsvFile.Open(TsvFileName, CAbc.CHARSET_WINDOWS)) { CCommon.Print("Ошибка чтения файла " + TsvFileName); TsvFile.Close(); CCommon.DeleteFile(TsvFileName); return; } while (TsvFile.Read()) { if (IsLineEmpty()) { continue; } Cents[TotalLines] = CCommon.CLng(GetColValue(CSepAFileInfo.L_SUMA).Trim()); TotalCents += Cents[TotalLines]; TotalLines++; } TsvFile.Close(); //----------------------------------------------------------- // запрашиваем у пользователя имя файла , в который будет записан результат string ShortName = ConstPartOfName; CCommon.Write("Краткое имя результирующего файла ( " + ShortName + " ) : "); ShortName = CCommon.Input().Trim(); if (ShortName.Length > 0) { ConstPartOfName = CCommon.Left(ShortName, 8); } //----------------------------------------------------------- // сверяем с пользователем общее количество строк и общую сумму if (!CConsole.GetBoxChoice(" Всего строк : " + CCommon.Right(TotalLines.ToString(), 11) , " Общая сумма : " + CCommon.StrN(TotalBucks, 11).Replace(",", ".") , "_________________________________" , "Для продолжения нажмите Enter." , "Для выхода - Esc. " ) ) { CCommon.DeleteFile(TsvFileName); return; } CConsole.Clear(); //----------------------------------------------------------- // записываем результатов работы программы в файлы if (!TsvFile.Open(TsvFileName, CAbc.CHARSET_WINDOWS)) { CCommon.Print("Ошибка чтения файла " + TsvFileName); TsvFile.Close(); CCommon.DeleteFile(TsvFileName); return; } BatchNum = 0; // while (TotalLines > 0) { AFileName = GetAFileName(); if (!AFile.Create(AFileName, CAbc.CHARSET_DOS)) { CCommon.Print("Ошибка создания файла " + AFileName); break; } else { CCommon.Print(AFileName); } // AFile.Head[CSepAFileInfo.H_EMPTYSTR] = ""; AFile.Head[CSepAFileInfo.H_CRLF1] = CAbc.CRLF; AFile.Head[CSepAFileInfo.H_FILENAME] = CCommon.Left(AFileName, 12); AFile.Head[CSepAFileInfo.H_DATE] = Now_Date_Str; AFile.Head[CSepAFileInfo.H_TIME] = Now_Time_Str; AFile.Head[CSepAFileInfo.H_STRCOUNT] = TotalLinesInBatch().ToString(); AFile.Head[CSepAFileInfo.H_TOTALDEBET] = "0"; AFile.Head[CSepAFileInfo.H_TOTALCREDIT] = TotalCentsInBatch().ToString(); AFile.Head[CSepAFileInfo.H_DES] = "0"; AFile.Head[CSepAFileInfo.H_DES_ID] = "UIAB00"; AFile.Head[CSepAFileInfo.H_DES_OF_HEADER] = ""; AFile.Head[CSepAFileInfo.H_CRLF2] = CAbc.CRLF; // if (!AFile.WriteHeader()) { CCommon.Print("Ошибка записи файла " + AFileName); AFile.Close(); break; } // for (ALineNumber = 0; ALineNumber < TotalLinesInBatch(); ALineNumber++) { do { if (!TsvFile.Read()) { break; } }while (IsLineEmpty()); for (AFieldNumber = 0; AFieldNumber < AModel.TotalFields; AFieldNumber++) { AFile.Line[AFieldNumber] = GetColValue(AFieldNumber); } if (!AFile.WriteLine()) { CCommon.Print("Ошибка записи файла " + AFileName); break; } AModel.IncNumber(); } AFile.Close(); BatchNum++; TotalLines -= TotalLinesInBatch(); } TsvFile.Close(); CCommon.DeleteFile(TsvFileName); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - static void ProcessAFile(CCommand Command, string FileName, bool IsCheckNeeded) { string ShortFileName = null; string BranchCode = null; string TmpFileName = null; string AboutError = null; bool Result = false; byte SavedColor = CConsole.BoxColor; if (FileName == null) { return; } if (FileName.Trim() == "") { return; } ShortFileName = CCommon.GetFileName(FileName); CCommon.AppendText(LogFileName, CCommon.Now() + " " + CCommon.Upper(CCommon.GetUserName()) + " загружает файл " + ShortFileName + CAbc.CRLF, CAbc.CHARSET_WINDOWS); if (ShortFileName.IndexOf("_") < 0) { BranchCode = ""; } else { BranchCode = ShortFileName.Substring(2, 2); } TmpFileName = TodayDir + CAbc.SLASH + ShortFileName; if (!CCommon.FileExists(TmpFileName)) { CCommon.CopyFile(FileName, TmpFileName); } if (!CCommon.FileExists(TmpFileName)) { return; } TmpFileName = TmpDir + CAbc.SLASH + CCommon.Right("0" + CCommon.Hour(CCommon.Clock()).ToString(), 2) + CCommon.Right("0" + CCommon.Minute(CCommon.Clock()).ToString(), 2) + CCommon.Right("0" + CCommon.Second(CCommon.Clock()).ToString(), 2); if (!CCommon.DirExists(TmpFileName)) { CCommon.MkDir(TmpFileName); } TmpFileName = TmpFileName + CAbc.SLASH + ShortFileName; if (CCommon.FileExists(TmpFileName)) { CCommon.DeleteFile(TmpFileName); } if (CCommon.FileExists(TmpFileName)) { CConsole.GetBoxChoice("", "Ошибка при удалении файла ", TmpFileName, "", " Для выхода нажмите Esc."); return; } CCommon.CopyFile(FileName, TmpFileName); if (!CCommon.FileExists(TmpFileName)) { CConsole.GetBoxChoice("", "Ошибка при создании файла ", TmpFileName, "", " Для выхода нажмите Esc."); return; } Err.LogTo(LogFileName); CCommon.DeleteFile(FileName); CConsole.BoxColor = SavedColor; if (IsCheckNeeded) { AboutError = ErcAFile.Check(Command, TmpFileName); CConsole.Clear(); if (AboutError != null) { if (AboutError.Trim() != "") { CCommon.AppendText(LogFileName, AboutError + CAbc.CRLF, CAbc.CHARSET_WINDOWS); CCommon.Print(AboutError); CConsole.BoxColor = CConsole.RED * 16 + CConsole.WHITE; if (!CConsole.GetBoxChoice("Внимание ! При проверке " + ShortFileName + " обнаружены ошибки !" , "", "Для отмены загрузки нажмите Esc , для продолжения - Enter" ) ) { CCommon.CopyFile(TmpFileName, FileName); CCommon.Print(AboutError); CConsole.BoxColor = SavedColor; return; } } } } CConsole.BoxColor = SavedColor; if (WorkMode == WorkModes.OPENGATE) { Result = ErcAFile.Load(Command, TmpFileName, BranchCode, "OpenGate"); if (Result) { // добавление в PayRoll информации о файле CConsole.BoxColor = SavedColor; CConsole.Clear(); CConsole.ShowBox("", " Подождите...", ""); Command.Execute(" exec pMega_OpenGate_PayRoll;2 @FileName='" + CCommon.GetFileName(TmpFileName) + "'"); } } else { Result = ErcAFile.Load(Command, TmpFileName, BranchCode, "ErcGate"); } if (Result) { CCommon.AppendText(LogFileName, CCommon.Now() + " загрузка закончена." + CAbc.CRLF, CAbc.CHARSET_WINDOWS); } else { CCommon.CopyFile(TmpFileName, FileName); CConsole.BoxColor = CConsole.RED * 16 + CConsole.WHITE; CConsole.GetBoxChoice("", " При загрузке " + ShortFileName + " возникли ошибки !", ""); } CConsole.BoxColor = SavedColor; CConsole.Clear(); Err.LogToConsole(); }
public static void Main() { const bool DEBUG = false; int WorkMode = 0; // 1 = выгружать B ; 2 = выгружать V const int WORK_MODE_B = 1; // для WorkMode : 1 = выгружать B const int WORK_MODE_V = 2; // для WorkMode : 2 = выгружать V int DayStatus = 0; // &1 = стоп по B ; &2 = стоп по V int ErcDate = CCommon.Today(); string TmpDir = null; string StatDir = null; string TodayDir = null; string OutputDir = null; string DataBase = null; string ServerName = null; string ScroogeDir = null; string LogFileName = null; string SimpleFileName = null; string ConfigFileName = null; string ConnectionString = null; Err.LogToConsole(); CCommon.Print("", " Создание файлов для ЕРЦ. Версия 3.02 от 23.05.2019г."); if (!DEBUG) { if (CCommon.ParamCount() < 2) { CCommon.Print(" Режим работы программы (задаются в строке запуска программы):"); CCommon.Print(" /E - выполнить выгрузку файлов для ЕРЦ ."); CCommon.Print(" Примеры запуска программы : "); CCommon.Print(" ErcExport /E"); CCommon.Print(" ErcExport /E 2019/05/20"); return; } if (CCommon.Upper(CAbc.ParamStr[1]).Trim() != "/E") { CCommon.Print(" Ошибка ! Неправильный режим работы - " + CAbc.ParamStr[1]); return; } if (CCommon.ParamCount() > 2) { ErcDate = CCommon.GetDate(CAbc.ParamStr[2].Trim()); if (ErcDate < 10000) { CCommon.Print(" Ошибка ! Неправильная дата - " + CAbc.ParamStr[2]); return; } } } else { CCommon.Print("--- DEBUG ---"); } CCommon.Print(" Рабочая дата " + CCommon.StrD(ErcDate, 10, 10)); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Scrooge2Config = new CScrooge2Config(); if (!Scrooge2Config.IsValid) { CCommon.Print(Scrooge2Config.ErrInfo); return; } ScroogeDir = (string)Scrooge2Config["Root"]; ServerName = (string)Scrooge2Config["Server"]; DataBase = (string)Scrooge2Config["DataBase"]; if (ScroogeDir == null) { CCommon.Print(" Не найдена переменная `Root` в настройках `Скрудж-2` "); return; } if (ServerName == null) { CCommon.Print(" Не найдена переменная `Server` в настройках `Скрудж-2` "); return; } if (DataBase == null) { CCommon.Print(" Не найдена переменная `Database` в настройках `Скрудж-2` "); return; } CCommon.Print(" Беру настройки `Скрудж-2` здесь : " + ScroogeDir); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - ConnectionString = "Server=" + ServerName + ";Database=" + DataBase + ";Integrated Security=TRUE;" ; Connection1 = new CConnection(ConnectionString); Connection2 = new CConnection(ConnectionString); if (Connection1.IsOpen()) { CCommon.Print(" Сервер : " + ServerName); CCommon.Print(" База данных : " + DataBase + CAbc.CRLF); } else { CCommon.Print(CAbc.CRLF + " Ошибка подключения к серверу !"); return; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CCommand Command = new CCommand(Connection1); DayStatus = ( int )CCommon.IsNull(Command.GetScalar(" exec dbo.pMega_OpenGate_Days;8 @TaskCode = 'ErcGate' , @DayDate = " + ErcDate.ToString()), (int)0); switch ((DayStatus & 3)) { case 0: { // разрешена отправка и B и V WorkMode = WORK_MODE_B; // отправлять B break; } case 1: { // запрещена отправка B ; разрешена отправка V WorkMode = WORK_MODE_V; // отправлять V break; } case 2: { // разрешена отправка B ; запрещена отправка V WorkMode = WORK_MODE_B; // отправлять B break; } case 3: { CCommon.Print(" На " + CCommon.StrD(ErcDate, 10, 10) + " отправка пачек B и V завершена (см. признак текущего дня)."); Connection1.Close(); Connection2.Close(); return; break; } } SeanceNum = ( int )CCommon.IsNull(Command.GetScalar(" exec dbo.pMega_OpenGate_Days;4 @TaskCode = 'ErcGate' , @ParamCode = 'NumSeance' , @DayDate = " + ErcDate.ToString()), (int)0); if (WorkMode == WORK_MODE_B) { BFileNum = ( int )CCommon.IsNull(Command.GetScalar(" exec dbo.pMega_OpenGate_Days;4 @TaskCode = 'ErcGate' , @ParamCode = 'NumOutFile' , @DayDate = " + ErcDate.ToString()), (int)0); CCommon.Print(" Выполняется формирование B-файлов "); } else { CCommon.Print(" Выполняется формирование V и W -файлов "); } Command.Close(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - ConfigFileName = ScroogeDir + CAbc.SLASH + "EXE" + CAbc.SLASH + "GLOBAL.ERC"; ErcConfig = new CErcConfig(); ErcConfig.Open(ErcDate); if (!ErcConfig.IsValid()) { CCommon.Print(" Ошибка чтения настроек из файла " + ConfigFileName); System.Console.WriteLine(ErcConfig.ErrInfo()); Connection1.Close(); Connection2.Close(); return; } TodayDir = (string)ErcConfig.TodayDir(); StatDir = (string)ErcConfig.StatDir(); TmpDir = (string)ErcConfig.TmpDir(); OutputDir = (string)ErcConfig["OutputDir"]; if ((TodayDir == null) || (OutputDir == null)) { CCommon.Print(" Ошибка чтения настроек из файла " + ConfigFileName); Connection1.Close(); Connection2.Close(); return; } TodayDir = TodayDir.Trim(); OutputDir = OutputDir.Trim(); StatDir = StatDir.Trim(); if ((TodayDir == "") || (OutputDir == "") || (StatDir == "")) { CCommon.Print(" Ошибка чтения настроек из файла " + ConfigFileName); Connection1.Close(); Connection2.Close(); return; } if (!CCommon.DirExists(StatDir)) { CCommon.MkDir(StatDir); } if (!CCommon.SaveText(StatDir + "\\" + "test.dat", "test.dat", CAbc.CHARSET_DOS)) { CCommon.Print(" Ошибка записи в каталог " + StatDir); Connection1.Close(); Connection2.Close(); return; } CCommon.DeleteFile(StatDir + "\\" + "test.dat"); CCommon.Print(" Беру настройки шлюза здесь : " + ConfigFileName); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - TmpDir = TmpDir + "\\" + SeanceNum.ToString("000000"); CCommon.MkDir(TmpDir); if (!CCommon.SaveText(TmpDir + "\\" + "test.dat", "test.dat", CAbc.CHARSET_DOS)) { CCommon.Print(" Ошибка записи в каталог " + TmpDir); Connection1.Close(); Connection2.Close(); } LogFileName = ErcConfig.LogDir() + "\\SE" + SeanceNum.ToString("000000") + ".TXT"; if (!CCommon.AppendText(LogFileName, CCommon.Now() + " , " + CCommon.Upper(CCommon.GetUserName()) + CAbc.CRLF, CAbc.CHARSET_DOS)) { CCommon.Print(" Ошибка записи в файл " + LogFileName); Connection1.Close(); Connection2.Close(); } Err.LogTo(LogFileName); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Отправка B if (WorkMode == WORK_MODE_B) { if (!WriteBFiles(ErcDate, TmpDir)) { CCommon.Print(" Ошибка записи B-файлов!"); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Отправка V if (WorkMode == WORK_MODE_V) { WriteVFiles(ErcDate, TmpDir, 0); WriteVFiles(ErcDate, TmpDir, 1); Command = new CCommand(Connection1); if (!Command.Execute(" exec dbo.pMega_OpenGate_Days;9 @TaskCode = 'ErcGate' , @DayDate = " + ErcDate.ToString())) { CCommon.Print(" Ошибка установки запрета на отправку V-файла!"); CCommon.AppendText(LogFileName, " Ошибка установки запрета на отправку V-файла!", CAbc.CHARSET_DOS); CCommon.AppendText(LogFileName, CAbc.CRLF, CAbc.CHARSET_DOS); Connection1.Close(); Connection2.Close(); return; } Command.Close(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - foreach (string ResultFile in CCommon.GetFileList(TmpDir + "\\" + "!*.*")) { if (ResultFile != null) { SimpleFileName = CCommon.GetFileName(ResultFile); CCommon.CopyFile(ResultFile, TodayDir + "\\" + SimpleFileName); CCommon.CopyFile(ResultFile, OutputDir + "\\" + SimpleFileName); CCommon.AppendText(LogFileName, "Записываю файл " + SimpleFileName, CAbc.CHARSET_DOS); CCommon.Print(" Записываю файл " + SimpleFileName); } } CCommon.AppendText(LogFileName, CAbc.CRLF, CAbc.CHARSET_DOS); Connection1.Close(); Connection2.Close(); }