bool SaveToFile(string FileName) { int I; if (FileName == null) { return(false); } else if (FileName.Trim() == "") { return(false); } CTextWriter TextWriter = new CTextWriter(); if (!TextWriter.Create(FileName, CAbc.CHARSET_WINDOWS)) { return(false); } for (I = 0; I < TOTAL_FIELDS; I++) { if ((Kinds[I] == -1) && (Values[I] != null) && (Values[I] != "") && (Aliases[I] != null) && (Aliases[I] != "") ) { TextWriter.Add(Aliases[I] + "=" + Values[I].Trim() + CAbc.CRLF); } } TextWriter.Close(); return(true); }
// ------------------------------------------------------ static void Chk_Misc(int PrevDate, int DayDate) { int Kind = 0; int OldKind = 0; money Acc1200Main = 0; //money Acc1200Brc = 0; money AccVFile = 0; string BugInfo = CAbc.EMPTY; string BugName = CAbc.EMPTY; CTextWriter TextWriter = new CTextWriter(); CConnection Connection2 = null; CRecordSet RecordSet2 = null; string DELIMITER1 = "--------------------------------+--------------------------------------------" + CAbc.CRLF; string DELIMITER2 = "-----------+--------------+-----------------------" + CAbc.CRLF; string DELIMITER3 = "--------------------------------+-------------+------------------+------------------+-------------------------" + CAbc.CRLF; string DELIMITER4 = "--------------+--------------+--------------------+--------------------+--------------------------------------" + CAbc.CRLF; string DELIMITER5 = "---------------------------------------------------+------------------" + CAbc.CRLF; string DELIMITER6 = "...................................................." + CAbc.CRLF; string ReportFileName = ScroogeOut + "\\" + __.StrD(DayDate, 10, 10).Replace("/", "").Replace(".", ""); string VFileName = __.StrD(PrevDate, 8, 8).Substring(6, 2) + __.StrD(PrevDate, 8, 8).Substring(3, 2) + __.StrD(PrevDate, 8, 8).Substring(0, 2); TextWriter.Create(ReportFileName + ".err", CAbc.CHARSET_DOS); TextWriter.Add(__.Now().ToString() + CAbc.CRLF); TextWriter.Close(); // ------------------------------------------------------------- Connection = new CConnection(ConnectionString); if (!Connection.IsOpen()) { __.Print(" Ошибка подключения к серверу !"); return; } LookForSertificates(); RecordSet = new CRecordSet(Connection); RecordSet.Timeout = 599; // ------------------------------------------------------------- if (!MainBank) { goto CHECK_MISC; } // ------------------------------------------------------------- if (RecordSet.Open(" exec dbo.Mega_Day_Open;7 ")) { if (RecordSet.Read()) { VFileName = RecordSet[0].Trim() + "\\" + VFileName; } } VFileName += "\\$V*.G*"; string[] VFiles = __.GetFileList(VFileName); string Tmps = CAbc.EMPTY; VFileName = CAbc.EMPTY; if (VFiles != null) { if (VFiles.Length > 0) { VFileName = VFiles[VFiles.Length - 1]; } } if (VFileName != CAbc.EMPTY) { CVFileReader VFileReader = new CVFileReader(); if (VFileReader.Open(VFileName, CAbc.CHARSET_DOS)) { if (VFileReader.Read()) { AccVFile = __.CCur(VFileReader.Head().Substring(264, 16)) / 100; } } VFileReader.Close(); } // ------------------------------------------------------------- __.Print(" Результаты проверки сводного баланса - в " + ReportFileName + ".err"); if (RecordSet.Open(" exec dbo.Mega_Check_Balance;2 @FromDate = " + PrevDate.ToString() + " , @ToDate = " + PrevDate.ToString())) { if (RecordSet.Read()) { TextWriter.OpenForAppend(ReportFileName + ".err", CAbc.CHARSET_DOS); TextWriter.Add(CAbc.CRLF, CAbc.CRLF, " ОШИБКИ ПРИ ПРОВЕРКЕ СВОДНОГО БАЛАНСА " + CAbc.CRLF); TextWriter.Add(DELIMITER6, CAbc.CRLF); do { TextWriter.Add(RecordSet[0], CAbc.CRLF); }while (RecordSet.Read()); TextWriter.Add(DELIMITER6, CAbc.CRLF, CAbc.CRLF); TextWriter.Close(); } } // ------------------------------------------------------------- __.Print(" Сверяю корсчета на ГК и БРЦ "); if (RecordSet.Open(" exec Mega_Day_Close;4 " + PrevDate.ToString())) { if (RecordSet.Read()) { Acc1200Main = __.CCur(RecordSet[0]); } } /* Сверка корсчета с БРЦ * Connection2 = new CConnection( BrcConnStr ); * if ( Connection.IsOpen() ) { * RecordSet2 = new CRecordSet( Connection2 ); * if ( RecordSet2.Open(" exec Mega_Day_Close;4 " + PrevDate.ToString() ) ) * if ( RecordSet2.Read() ) * Acc1200Brc = __.CCur( RecordSet2[0] ); * if ( Acc1200Brc == 0 ) * __.Print(" Ошибка вычитки корсчета на БРЦ "); * else * if ( Acc1200Brc != Acc1200Main ) * CConsole.GetBoxChoice("","Неравенство корсчетов на ГК и БРЦ !",""); * RecordSet2.Close(); * } * else * __.Print(" Ошибка подключения к БРЦ !"); * Connection2.Close(); */ TextWriter.OpenForAppend(ReportFileName + ".err", CAbc.CHARSET_DOS); TextWriter.Add(CAbc.CRLF + "..... Сверка корсчетов ....." + CAbc.CRLF); TextWriter.Add("Корсчет на конец " + __.StrD(PrevDate, 8, 8) + " ( ГК ) =" + __.StrM(Acc1200Main, 19) + CAbc.CRLF); // TextWriter.Add( "Корсчет на конец " + __.StrD( PrevDate , 8 , 8 ) + " ( БРЦ ) =" + __.StrM( Acc1200Brc , 19 ) + CAbc.CRLF ); if (AccVFile != 0) { TextWriter.Add("Корсчет по последнему V-файлу =" + __.StrM(AccVFile, 19) + CAbc.CRLF); } TextWriter.Add("........................................................." + CAbc.CRLF); TextWriter.Close(); // ------------------------------------------------------------- __.Print(" Вывожу черный список ЕМА в файл " + ReportFileName + ".ema"); if (RecordSet.Open(" exec dbo.Mega_CheckEMA_StopList ")) { if (RecordSet.Read()) { TextWriter.OpenForAppend(ReportFileName + ".ema", CAbc.CHARSET_DOS); TextWriter.Add(CAbc.CRLF + " Клиенты, включеные в черный список ЕМА " + CAbc.CRLF); TextWriter.Add(" По состоянию на " + __.Now().ToString() + CAbc.CRLF); TextWriter.Add(DELIMITER2); TextWriter.Add(" Внутр.код | Идент.код кл.| Имя клиента " + CAbc.CRLF); TextWriter.Add(DELIMITER2); do { TextWriter.Add(__.Left(RecordSet[1], 11)); TextWriter.Add("|"); TextWriter.Add(__.Left(RecordSet[0], 14)); TextWriter.Add("|"); TextWriter.Add(__.Left(__.FixUkrI(RecordSet[2]), 64)); TextWriter.Add(CAbc.CRLF); } while (RecordSet.Read()); TextWriter.Add(DELIMITER2); TextWriter.Close(); } } // ------------------------------------------------------------- CHECK_MISC: __.Print(" Выполняются проверки дня " + __.StrD(PrevDate, 8, 8) + " (Check_Misc) ..."); if (RecordSet.Open(" exec dbo.Mega_Check_Misc " + PrevDate.ToString())) { if (RecordSet.Read()) { TextWriter.OpenForAppend(ReportFileName + ".err", CAbc.CHARSET_DOS); TextWriter.Add(CAbc.CRLF + " Ошибки,обнаруженные при проверке дня " + __.StrD(PrevDate, 8, 8) + CAbc.CRLF); TextWriter.Add(CAbc.CRLF); do { Kind = __.CInt(RecordSet[0]); BugInfo = RecordSet[2]; BugName = __.FixUkrI(RecordSet[3]); if ((OldKind > 0) && (OldKind == Kind)) { BugInfo = CAbc.EMPTY; } else { TextWriter.Add(DELIMITER1); } OldKind = Kind; TextWriter.Add(__.Left(BugInfo, 32)); TextWriter.Add("|"); TextWriter.Add(__.Left(BugName, 44)); TextWriter.Add(CAbc.CRLF); } while (RecordSet.Read()); TextWriter.Add(DELIMITER1); TextWriter.Add(CAbc.CRLF); TextWriter.Close(); } } // ---------------------------------------------------------- __.Print(" Выполняются проверки дня " + __.StrD(PrevDate, 8, 8) + " (Check_Heap) ..."); if (RecordSet.Open(" exec dbo.Mega_Check_Heap " + PrevDate.ToString())) { if (RecordSet.Read()) { TextWriter.OpenForAppend(ReportFileName + ".err", CAbc.CHARSET_DOS); TextWriter.Add(" ...дополнительные проверки... "); TextWriter.Add(CAbc.CRLF); do { Kind = __.CInt(RecordSet[0]); BugInfo = RecordSet[2]; BugName = __.FixUkrI(RecordSet[3]); if ((OldKind > 0) && (OldKind == Kind)) { BugInfo = CAbc.EMPTY; } else { TextWriter.Add(DELIMITER1); } OldKind = Kind; TextWriter.Add(__.Left(BugInfo, 32)); TextWriter.Add("|"); TextWriter.Add(__.Left(BugName, 44)); TextWriter.Add(CAbc.CRLF); } while (RecordSet.Read()); TextWriter.Add(DELIMITER1); TextWriter.Add(CAbc.CRLF); TextWriter.Close(); } } // ---------------------------------------------------------- if (!MainBank) { goto END_OF_PROC; } // ---------------------------------------------------------- __.Print(" Ошибки в настройках регуляных платежей - в " + ReportFileName + ".err"); if (RecordSet.Open(" exec dbo.Mega_Pst_ERC_CheckReport")) { if (RecordSet.Read()) { TextWriter.OpenForAppend(ReportFileName + ".err", CAbc.CHARSET_DOS); TextWriter.Add(CAbc.CRLF + " Ошибки в настройках регуляных платежей " + CAbc.CRLF); TextWriter.Add(DELIMITER3); TextWriter.Add(" Название ошибки | Код клиента | Номер счета | Название клиента " + CAbc.CRLF); TextWriter.Add(DELIMITER3); do { TextWriter.Add(__.Left(RecordSet["ErrorText"], 32)); TextWriter.Add("|"); TextWriter.Add(__.Left(RecordSet["Code"], 12)); TextWriter.Add(" | "); TextWriter.Add(__.Left(RecordSet["Moniker"], 17)); TextWriter.Add("| "); TextWriter.Add(__.FixUkrI(RecordSet["Name"])); TextWriter.Add(CAbc.CRLF); } while (RecordSet.Read()); TextWriter.Add(DELIMITER3); TextWriter.Add(CAbc.CRLF); TextWriter.Close(); } } // -------------------------------------------------------- __.Print(" Ошибки в договорах залогов - в " + ReportFileName + ".err"); if (RecordSet.Open(" exec dbo.Mega_CheckTreatyPawnDate ")) { if (RecordSet.Read()) { TextWriter.OpenForAppend(ReportFileName + ".err", CAbc.CHARSET_DOS); TextWriter.Add(CAbc.CRLF + CAbc.CRLF + " Ошибки в договорах залогов " + CAbc.CRLF); TextWriter.Add(DELIMITER4); TextWriter.Add(" Id договора | Id залога | Номер договора | Номер залога | Название клиента" + CAbc.CRLF); TextWriter.Add(DELIMITER4); do { TextWriter.Add(__.Right(RecordSet[0], 13)); TextWriter.Add(" |"); TextWriter.Add(__.Right(RecordSet[3], 13)); TextWriter.Add(" |"); TextWriter.Add(__.Left(RecordSet[1], 20)); TextWriter.Add("|"); TextWriter.Add(__.Left(RecordSet[4], 20)); TextWriter.Add("|"); TextWriter.Add(__.FixUkrI(RecordSet[2])); TextWriter.Add(CAbc.CRLF); } while (RecordSet.Read()); TextWriter.Add(DELIMITER4); TextWriter.Add(CAbc.CRLF); TextWriter.Close(); } } // -------------------------------------------------------- __.Print(" Ведомость невынесенных на просрочку - в " + ReportFileName + ".err"); if (RecordSet.Open(" exec dbo.Mega_Treaty_Check_Prosroch_Control ")) { if (RecordSet.Read()) { TextWriter.OpenForAppend(ReportFileName + ".err", CAbc.CHARSET_DOS); TextWriter.Add(CAbc.CRLF + " Не вынесенные на просрочку договора " + CAbc.CRLF); TextWriter.Add(DELIMITER5); TextWriter.Add(" Описание ошибки ¦ ID договора " + CAbc.CRLF); TextWriter.Add(DELIMITER5); do { TextWriter.Add(__.Left(RecordSet[0], 51)); TextWriter.Add("| "); TextWriter.Add(__.Right(RecordSet[1], 13)); TextWriter.Add(CAbc.CRLF); } while (RecordSet.Read()); TextWriter.Add(DELIMITER5); TextWriter.Add(CAbc.CRLF); TextWriter.Close(); } } // -------------------------------------------------------- END_OF_PROC: RecordSet.Close(); Connection.Close(); }
} //FOLD00 void CloseOutputStreams() //FOLD00 { if (TextWriter1 != null) { TextWriter1.Close(); } if (TextWriter2 != null) { TextWriter2.Close(); } if ((FileName1 == null) || (FileName2 == null) || (TmpFileName1 == null) || (TmpFileName2 == null) ) { return; } if ((FileName1 != "") && (TmpFileName1 != "")) { if (TextReader.Open(TmpFileName1, CAbc.CHARSET_DOS)) { if (TextReader.Read()) { TextWriter1 = new CTextWriter(); if (TextWriter1.OpenForAppend(FileName1, CAbc.CHARSET_DOS)) { do { TextWriter1.Add(TextReader.Value, CRLF); }while (TextReader.Read()); } TextWriter1.Close(); } } TextReader.Close(); __.DeleteFile(TmpFileName1); TmpFileName1 = ""; } if ((FileName2 != "") && (TmpFileName2 != "")) { if (TextReader.Open(TmpFileName2, CAbc.CHARSET_DOS)) { if (TextReader.Read()) { TextWriter2 = new CTextWriter(); if (TextWriter2.OpenForAppend(FileName2, CAbc.CHARSET_DOS)) { do { TextWriter2.Add(TextReader.Value, CRLF); }while (TextReader.Read()); } TextWriter2.Close(); } } TextReader.Close(); __.DeleteFile(TmpFileName2); TmpFileName2 = ""; } } //FOLD00
//----------------------------------------------------------- // запись Tsv-текста в файл public bool SaveToFile(string FileName) { int I; bool ContainsEmpty; string CurLine; string[] Columns; if (FileName == null) { return(false); } if ((Tsv == null) || (Tsv.Length == 0)) { return(false); } string[] Lines = Tsv.ToString().Split(CCommon.Chr(13)); if (Lines == null) { return(false); } if (Lines.Length == 0) { return(false); } bool Result = false; CTextWriter TextWriter = new CTextWriter(); if (!TextWriter.Create(FileName, CAbc.CHARSET_WINDOWS)) { return(false); } for (I = 0; I < Lines.Length; I++) { Result = true; CurLine = Lines[I].Replace(CAbc.BIG_UKR_I, "I").Replace(CAbc.SMALL_UKR_I, "i").Trim(); if (CurLine.Trim().Length == 0) { continue; } ContainsEmpty = true; Columns = CurLine.Split(CCommon.Chr(9)); if (Columns == null) { ContainsEmpty = true; // есть пустые ячейки ? } else if (Columns.Length < 2) { ContainsEmpty = true; } else { foreach (string Item in Columns) { if (Item.Trim().Length != 0) { ContainsEmpty = false; } } } if (!ContainsEmpty) { if (!TextWriter.Add(CurLine + CAbc.CRLF)) { Result = false; } } } TextWriter.Close(); return(Result); }
} //FOLD00 // Преобразование DIF в CSV bool ConvertDifToCsv() //fold00 { string TmpFileName = __.GetTempName() /* + ".CSV" */; int Char_Set = CAbc.CHARSET_DOS; string DELIMITER = ";"; string QUOTE = CAbc.QUOTE; string DOUBLEQUOTE = CAbc.QUOTE + CAbc.QUOTE; string Value = ""; bool WaitForAValue = false; bool HasDataStarted = false; CTextReader TextReader = new CTextReader(); CTextWriter TextWriter = new CTextWriter(); if (!TextWriter.Create(TmpFileName, CAbc.CHARSET_WINDOWS)) { return(false); } if (TextReader.Open(FileName, Char_Set)) { while (TextReader.Read()) { Value = TextReader.Value.Trim(); if (Value.Length < 3) { continue; } if (CCommon.Upper(Value) == "EOD") { break; } if (CCommon.Upper(Value) == "BOT") { if (HasDataStarted) { TextWriter.Add(CAbc.CRLF); } else { HasDataStarted = true; } } if (!HasDataStarted) { continue; } if (Value.Substring(0, 2) == "0,") { TextWriter.Add(Value.Substring(2).Replace(",", ".") + DELIMITER); } if (Value.Substring(0, 2) == "1,") { WaitForAValue = true; } if (WaitForAValue == true) { if (Value.Substring(0, 1) == QUOTE) { TextWriter.Add(Value.Substring(1, Value.Length - 2).Replace(QUOTE + QUOTE, QUOTE) + DELIMITER); } WaitForAValue = true; } } } else { TextWriter.Close(); return(false); } TextReader.Close(); TextWriter.Close(); FileName = TmpFileName; NeedDelSrcFile = true; return(true); } //FOLD00