/// <summary> /// запустить сессию pccomm /// </summary> /// <param name="currentSessionName"></param> /// <param name="filePath"></param> private Process runAlfamos(char currentSessionName, string filePath) { int count = 0; if (Process.GetProcessesByName("pcscm").Length < 1) { Process.Start(_pcscm.Path); } Process newAlfamos = Process.Start(filePath); while (EUCL.Connect($"{currentSessionName}") != 0) { count++; if (count > WAIT_TIME) { throw new Exception("Не удалось запустить сессию Equation."); } Thread.Sleep(1000); } EUCL.Connect($"{currentSessionName}"); enter(); enter(); enter(); return(newAlfamos); }
/// <summary> /// Запустить alfamos и установить подключение /// </summary> /// <param name="anyAlfamos"></param> /// <returns>имя новой сессии</returns> public char OpenConnection(PCCOMM_Path anyAlfamos, out Process alfamos) { char currentSessionName = 'H'; alfamos = null; for (int i = 8; i > 0; i--) { if (EUCL.Connect($"{ currentSessionName }") == 0) { currentSessionName++; alfamos = runAlfamos(currentSessionName, anyAlfamos.Path); return(currentSessionName); } else if (currentSessionName != 'A') { currentSessionName--; } else { alfamos = runAlfamos(currentSessionName, anyAlfamos.Path); } } return(currentSessionName); }
public void EnterUnit(Unit unit) { _fileExportPath = $@"\\alfamos2\ALFAPRODDATA\{unit.Name}\REPORTING\{_currentUserProfile}"; send(unit.Name, 21, 18); enter(); enter(); enter(); EUCL.ClearScreen(); }
/// <summary> /// Записать текущий профайл пользователя в Equation /// </summary> /// <param name="connectionChar">имя сессии</param> internal void GetUserProfile(char connectionChar) { EUCL.Connect(connectionChar.ToString()); EUCL.ClearScreen(); send("Я", 21, 17); enter(); _currentUserProfile = EUCL.ReadScreen(6, 18, 4); EUCL.SendStr("@c"); EUCL.Wait(); EUCL.Disconnect(connectionChar.ToString()); }
/// <summary> /// Заполнить коллекцию счетов данными из equation /// </summary> /// <param name="accounts"></param> /// <param name="connectionChar"></param> internal void FillAccounts(List <Account> accounts, char connectionChar) { EUCL.Connect($"{connectionChar}"); foreach (Account acc in accounts) { DateTime temp; EUCL.ClearScreen(); send("БРХ", 21, 17); enter(); send(acc.Number, 3, 29); enter(); DateTime.TryParse(EUCL.ReadScreen(4, 70, 11), out temp); acc.OpenedDate = temp; if (DateTime.TryParse(EUCL.ReadScreen(5, 70, 11), out temp)) { acc.ClosedDate = temp; } } EUCL.ClearScreen(); EUCL.Disconnect($"{connectionChar}"); }
/// <summary> /// Проверить на наличие оборота /// </summary> /// <param name="account"></param> /// <returns>True в случае, если оборот > 0, False, если == 0 </returns> public bool CheckForTurnover(Account account) { EUCL.ClearScreen(); send("TOO", 21, 17); enter(); send(account.Number, 3, 29); enter(); int row = 0; for (int i = 7; i < 22; i++) { if (EUCL.ReadScreen(i, 8, 6).Equals("ИТОГО:")) { row = i; break; } } if (row == 0) { throw new Exception("Необработанное исключение"); //TODO обработать } string sumDbtStr = EUCL.ReadScreen(row, 33, 20).Replace(" ", string.Empty) .Replace(",", string.Empty) .Replace('.', ','); //сумма дебет string sumCdtStr = EUCL.ReadScreen(row, 58, 20).Replace(" ", string.Empty) .Replace(",", string.Empty) .Replace('.', ','); //сумма дебет double.TryParse(sumDbtStr, out double sumDbrDbl); double.TryParse(sumCdtStr, out double sumCdrDbl); EUCL.ClearScreen(); if (sumDbrDbl == 0 && sumCdrDbl == 0) //оборота нет - просто выходим { return(false); } else { return(true); } }
public Equation() { #region getConnection int attempCount = 0; Console.WriteLine("Connecting to Equation"); Console.WriteLine($"Trying connect to {sessionName}..."); while (EUCL.Connect(sessionName.ToString()) != 0) { if (attempCount++ > 5) { connected = false; Console.WriteLine("Connection failed"); break; } sessionName++; Console.WriteLine($"Trying connect to {sessionName}..."); } if (connected) { ClearScreen(); Console.WriteLine("Connected."); } #endregion }
/// <summary> /// Получает информацию по конкретному физ.лицу /// </summary> /// <param name="pin">ПИН клиента</param> /// <returns>Возвращает объект FL_data</returns> public FL_data ReadData(string pin) { FL_data fl = new FL_data(); fl.Pin = pin; #region ПФ1_function send(21, 17, "ПФ1"); pEnter(); send(3, 34, fl.Pin); pEnter(); fl.Type = EUCL.ReadScreen(4, 34, 2); fl.Identification = ClearWhiteSpacesStr(EUCL.ReadScreen(2, 14, 30));// на чтении экрана в EQ(что бы не пришлось читать экран дважды) fl.ApproveType = ClearWhiteSpacesStr(EUCL.ReadScreen(2, 60, 30)); fl.FIO = $"{ClearWhiteSpacesStr(EUCL.ReadScreen(7, 34, 35))} {ClearWhiteSpacesStr(EUCL.ReadScreen(8, 34, 35))} {ClearWhiteSpacesStr(EUCL.ReadScreen(9, 34, 35))}"; fl.BirthDate = DateTime.Parse(EUCL.ReadScreen(10, 34, 11)); fl.mnemonicFull = ClearWhiteSpacesStr(EUCL.ReadScreen(15, 41, 35)); fl.mnemonicShort = EUCL.ReadScreen(15, 34, 4); fl.regCountry = EUCL.ReadScreen(16, 34, 2); fl.Inn = EUCL.ReadScreen(18, 34, 12); fl.SNILS = EUCL.ReadScreen(18, 57, 18).Replace(" - ", "-"); if (fl.SNILS.Equals(" - - ")) { fl.SNILS = string.Empty; } fl.IsClient = EUCL.ReadScreen(21, 67, 1); DateTime.TryParse(EUCL.ReadScreen(20, 34, 11), out fl.BecomeContragentDate); DateTime.TryParse(EUCL.ReadScreen(21, 34, 11), out fl.BecomeClientDate); pEnter(); fl.DocTypeInt = EUCL.ReadScreen(5, 34, 3); fl.DocTypeStr = ClearWhiteSpacesStr(EUCL.ReadScreen(5, 41, 35)); fl.DocSeries = ClearWhiteSpacesStr(EUCL.ReadScreen(7, 34, 10)); fl.DocNumber = ClearWhiteSpacesStr(EUCL.ReadScreen(8, 34, 35)); DateTime.TryParse(EUCL.ReadScreen(6, 34, 11), out fl.DocOpenDate); DateTime.TryParse(EUCL.ReadScreen(6, 67, 11), out fl.DocClosedDate); fl.DocGiver = $"{ClearWhiteSpacesStr(EUCL.ReadScreen(9, 34, 35))}{ClearWhiteSpacesStr(EUCL.ReadScreen(10, 2, 73))}{ClearWhiteSpacesStr(EUCL.ReadScreen(11, 2, 73))}{ClearWhiteSpacesStr(EUCL.ReadScreen(12, 2, 73))}"; fl.DocKPPCode = EUCL.ReadScreen(13, 34, 7); fl.DocResponsibleUnit = EUCL.ReadScreen(14, 34, 3); fl.DocResponsibleUnitFull = EUCL.ReadScreen(14, 41, 35); fl.Citizenship = EUCL.ReadScreen(16, 34, 2); pEnter(); pEnter(); fl.WorkPhone = ClearWhiteSpacesStr(EUCL.ReadScreen(8, 34, 35)); fl.MobilePhone = ClearWhiteSpacesStr(EUCL.ReadScreen(9, 34, 35)); fl.Email = ClearWhiteSpacesStr(EUCL.ReadScreen(11, 34, 35)); pEnter(); fl.Reserve1 = ClearWhiteSpacesStr(EUCL.ReadScreen(19, 46, 35)); fl.Reserve2 = ClearWhiteSpacesStr(EUCL.ReadScreen(20, 46, 35)); pEnter(); pEnter(); fl.AnyBeneficiary = EUCL.ReadScreen(6, 37, 1); fl.PDL = EUCL.ReadScreen(7, 37, 1); fl.BeneficiaryOwner = EUCL.ReadScreen(8, 37, 1); fl.Reputation = ClearWhiteSpacesStr(EUCL.ReadScreen(14, 37, 35)); fl.FinancialPosition = ClearWhiteSpacesStr(EUCL.ReadScreen(15, 37, 35)); fl.ActualizationDate = parseCustom(EUCL.ReadScreen(18, 37, 6)); fl.ActualizationEmployee = ClearWhiteSpacesStr(EUCL.ReadScreen(18, 45, 35)); fl.UpdateType = ClearWhiteSpacesStr(EUCL.ReadScreen(20, 40, 35)); fl.LastUpdatedDate = parseCustom(EUCL.ReadScreen(21, 37, 6)); fl.UpdateEmployee = EUCL.ReadScreen(21, 73, 4); pEnter(); pEnter(); send(13, 77, "Y"); pEnter(); fl.IsCrossedTheBorder = EUCL.ReadScreen(9, 32, 1); DateTime.TryParse(EUCL.ReadScreen(9, 54, 11), out fl.CrossBorderDate); fl.ResidenceDocTypeInt = EUCL.ReadScreen(15, 5, 2); fl.ResidenceDocTypeStr = ClearWhiteSpacesStr(EUCL.ReadScreen(15, 10, 20)); fl.ResidenceSerieAndNumber = ClearWhiteSpacesStr(EUCL.ReadScreen(16, 10, 20)); fl.ResidenceDateStart = parseCustom(EUCL.ReadScreen(15, 31, 6)); fl.ResidenceDateEnd = parseCustom(EUCL.ReadScreen(16, 31, 6)); fl.MigrationCardTypeInt = EUCL.ReadScreen(15, 41, 2); fl.MigrationCardNumber = ClearWhiteSpacesStr(EUCL.ReadScreen(16, 46, 20)); fl.MigrationCardDateStart = parseCustom(EUCL.ReadScreen(15, 67, 6)); fl.MigrationCardDateEnd = parseCustom(EUCL.ReadScreen(16, 67, 6)); pEnter(); int.TryParse(EUCL.ReadScreen(5, 34, 1), out fl.RiskLevelInt); fl.RiskLevelStr = ClearWhiteSpacesStr(EUCL.ReadScreen(5, 36, 40)); pEnter(); if (EUCL.ReadScreen(1, 31, 24).Equals("Список повторяющихся ИНН")) { pEnter(); } EUCL.SendStr("@3"); #endregion #region ПАД_function send(21, 17, "ПАД"); pEnter(); send(7, 29, "J"); send(3, 29, fl.Pin); pEnter(); StringBuilder builder = new StringBuilder(); if (EUCL.ReadScreen(24, 3, 3).Equals("KSM")) //адрес не существует { fl.RegistrationAddressFull = "Отсутствует"; } else { builder.Append($"гор.{ClearWhiteSpacesStr(EUCL.ReadScreen(12, 29, 50))}, "); builder.Append($"{ClearWhiteSpacesStr(EUCL.ReadScreen(15, 33, 20))} "); builder.Append($"{ClearWhiteSpacesStr(EUCL.ReadScreen(16, 29, 30))}, "); builder.Append($"д. {ClearWhiteSpacesStr(EUCL.ReadScreen(17, 14, 6))}, "); builder.Append($"корп. {ClearWhiteSpacesStr(EUCL.ReadScreen(17, 47, 6))}, "); builder.Append($"кв. {ClearWhiteSpacesStr(EUCL.ReadScreen(17, 73, 6))}"); fl.RegistrationAddressFull = builder.ToString(); fl.Registration_Index = ClearWhiteSpacesStr(EUCL.ReadScreen(7, 29, 15)); fl.Registration_Country = ClearWhiteSpacesStr(EUCL.ReadScreen(8, 29, 35)); fl.Registration_RegionCode = ClearWhiteSpacesStr(EUCL.ReadScreen(9, 29, 35)); fl.Registration_RegionType = ClearWhiteSpacesStr(EUCL.ReadScreen(10, 29, 35)); fl.Registration_RegionName = ClearWhiteSpacesStr(EUCL.ReadScreen(11, 29, 35)); fl.Registration_Town = ClearWhiteSpacesStr(EUCL.ReadScreen(12, 29, 35)); fl.Registration_LocalityType = ClearWhiteSpacesStr(EUCL.ReadScreen(13, 29, 35)); fl.Registration_LocalityName = ClearWhiteSpacesStr(EUCL.ReadScreen(14, 29, 35)); fl.Registration_StreetType = ClearWhiteSpacesStr(EUCL.ReadScreen(15, 29, 35)); fl.Registration_StreetName = ClearWhiteSpacesStr(EUCL.ReadScreen(16, 29, 35)); fl.Registration_HouseNumber = ClearWhiteSpacesStr(EUCL.ReadScreen(17, 14, 8)); fl.Registration_BuildingNumber = ClearWhiteSpacesStr(EUCL.ReadScreen(17, 46, 8)); fl.Registration_FlatNumber = ClearWhiteSpacesStr(EUCL.ReadScreen(17, 73, 8)); builder.Clear(); DateTime.TryParse(EUCL.ReadScreen(5, 37, 11), out fl.RegistrationUpdateDate); pEnter(); fl.RegistrationPhone = ClearWhiteSpacesStr(EUCL.ReadScreen(6, 29, 15)); EUCL.SendStr("@c"); EUCL.Wait(); EUCL.SendStr("@c"); EUCL.Wait(); } send(7, 29, "F"); pEnter(); if (EUCL.ReadScreen(24, 3, 3).Equals("KSM")) //адрес не существует { fl.FactAddress = "Отсутствует"; } else { builder.Append($"гор.{ClearWhiteSpacesStr(EUCL.ReadScreen(12, 29, 50))}, "); builder.Append($"{ClearWhiteSpacesStr(EUCL.ReadScreen(15, 33, 20))} "); builder.Append($"{ClearWhiteSpacesStr(EUCL.ReadScreen(16, 29, 30))}, "); builder.Append($"д. {ClearWhiteSpacesStr(EUCL.ReadScreen(17, 14, 6))}, "); builder.Append($"корп. {ClearWhiteSpacesStr(EUCL.ReadScreen(17, 47, 6))}, "); builder.Append($"кв. {ClearWhiteSpacesStr(EUCL.ReadScreen(17, 73, 6))}"); fl.FactAddress = builder.ToString(); fl.Fact_Index = ClearWhiteSpacesStr(EUCL.ReadScreen(7, 29, 15)); fl.Fact_Country = ClearWhiteSpacesStr(EUCL.ReadScreen(8, 29, 35)); fl.Fact_RegionCode = ClearWhiteSpacesStr(EUCL.ReadScreen(9, 29, 35)); fl.Fact_RegionType = ClearWhiteSpacesStr(EUCL.ReadScreen(10, 29, 35)); fl.Fact_RegionName = ClearWhiteSpacesStr(EUCL.ReadScreen(11, 29, 35)); fl.Fact_Town = ClearWhiteSpacesStr(EUCL.ReadScreen(12, 29, 35)); fl.Fact_LocalityType = ClearWhiteSpacesStr(EUCL.ReadScreen(13, 29, 35)); fl.Fact_LocalityName = ClearWhiteSpacesStr(EUCL.ReadScreen(14, 29, 35)); fl.Fact_StreetType = ClearWhiteSpacesStr(EUCL.ReadScreen(15, 29, 35)); fl.Fact_StreetName = ClearWhiteSpacesStr(EUCL.ReadScreen(16, 29, 35)); fl.Fact_HouseNumber = ClearWhiteSpacesStr(EUCL.ReadScreen(17, 14, 8)); fl.Fact_BuildingNumber = ClearWhiteSpacesStr(EUCL.ReadScreen(17, 46, 8)); fl.Fact_FlatNumber = ClearWhiteSpacesStr(EUCL.ReadScreen(17, 73, 8)); DateTime.TryParse(EUCL.ReadScreen(5, 37, 11), out fl.FactAddressUpdateDate); pEnter(); fl.FactAddressPhone = ClearWhiteSpacesStr(EUCL.ReadScreen(6, 29, 15)); EUCL.SendStr("@c"); EUCL.Wait(); EUCL.SendStr("@c"); EUCL.Wait(); } send(7, 29, " "); pEnter(); if (!EUCL.ReadScreen(24, 3, 3).Equals("KSM")) //адрес не существует { fl.RegistrationAddress = $"{ClearWhiteSpacesStr(EUCL.ReadScreen(7, 29, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(8, 29, 40))}"; fl.PrimePhone = ClearWhiteSpacesStr(EUCL.ReadScreen(14, 29, 35)); } EUCL.SendStr("@c"); EUCL.Wait(); #endregion #region MR9_function send(21, 17, "MR9"); pEnter(); send(3, 17, fl.Pin); pEnter(); if (string.IsNullOrWhiteSpace(EUCL.ReadScreen(4, 4, 11))) { fl.RecordStatus = string.Empty; fl.BirthPlace = string.Empty; fl.BirthPlaceCountryCode = string.Empty; fl.BirthPlaceCountry = string.Empty; fl.BirthPlaceRegionCode = string.Empty; fl.BirthPlaceRegionType = string.Empty; fl.BirthPlaceRegion = string.Empty; fl.BirthPlaceCityType = string.Empty; fl.BirthPlaceCity = string.Empty; fl.BirthPlaceLocalityType = string.Empty; fl.BirthPlaceLocality = string.Empty; fl.BirthPlaceFull = string.Empty; } else { fl.RecordStatus = ClearWhiteSpacesStr(EUCL.ReadScreen(4, 4, 11)); send(4, 2, "1"); EUCL.Wait(); fl.BirthPlace = $"{ClearWhiteSpacesStr(EUCL.ReadScreen(6, 17, 50))}{ClearWhiteSpacesStr(EUCL.ReadScreen(7, 17, 50))}{ClearWhiteSpacesStr(EUCL.ReadScreen(8, 17, 50))}"; pEnter(); fl.BirthPlaceCountryCode = EUCL.ReadScreen(10, 18, 3); fl.BirthPlaceCountry = ClearWhiteSpacesStr(EUCL.ReadScreen(12, 17, 40)); fl.BirthPlaceRegionCode = ClearWhiteSpacesStr(EUCL.ReadScreen(17, 17, 40)); pEnter(); fl.BirthPlaceRegionType = ClearWhiteSpacesStr(EUCL.ReadScreen(10, 27, 30)); fl.BirthPlaceRegion = $"{ClearWhiteSpacesStr(EUCL.ReadScreen(12, 17, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(13, 17, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(14, 17, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(15, 17, 40))}"; pEnter(); fl.BirthPlaceCityType = ClearWhiteSpacesStr(EUCL.ReadScreen(10, 27, 30)); fl.BirthPlaceCity = $"{ClearWhiteSpacesStr(EUCL.ReadScreen(12, 17, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(13, 17, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(14, 17, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(15, 17, 40))}"; pEnter(); fl.BirthPlaceLocalityType = ClearWhiteSpacesStr(EUCL.ReadScreen(10, 40, 0)); fl.BirthPlaceLocality = $"{ClearWhiteSpacesStr(EUCL.ReadScreen(12, 17, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(13, 17, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(14, 17, 40))}{ClearWhiteSpacesStr(EUCL.ReadScreen(15, 17, 40))}"; pEnter(); fl.BirthPlaceFull = ClearWhiteSpacesStr(EUCL.ReadScreen(5, 32, 40)); } ClearScreen(); #endregion return(fl); }
/// <summary> /// Привести экран в начальное положение (закрыть все опции ит.п.) /// </summary> public void ClearScreen() => EUCL.ClearScreen();
/// <summary> /// Закрыть соединение с PCOMM /// </summary> public void CloseConnection() { EUCL.ClearScreen(); EUCL.Disconnect(sessionName.ToString()); Console.WriteLine("Соединение с Equation закрыто"); }
/// <summary> /// Отправить строку или команду по указанным координатам /// </summary> /// <param name="x">координат X</param> /// <param name="y">координат Y</param> /// <param name="Text">Отправляемая строка</param> /// <param name="size">Размер экрана</param> private void send(int x, int y, string Text, int size = 80) { EUCL.SetCursorPos(x, y, size); EUCL.SendStr(Text); }
/// <summary> /// Отправить нажатие Enter и ожидать готовности ввода от PCCOMM /// </summary> private void pEnter() { EUCL.SendStr("@E"); EUCL.Wait(); }
/// <summary> /// Получить информацию о всех счетах с бух.режимом 100 /// </summary> /// <param name="data">Коллекция физ.лиц</param> public void fillAccounts(List <FL_data> data) { EUCL.ClearScreen(); send(21, 17, "ppp"); pEnter(); pEnter(); send(6, 2, "1"); EUCL.Wait(); send(5, 5, "40* "); send(5, 77, "* "); double onePercent = 100.00 / data.Count; double currentProgress = 0.0; int counter = 0; foreach (FL_data item in data) { currentProgress += onePercent; Console.WriteLine($"Done: {currentProgress:F2}% ({counter++}/{data.Count})"); send(7, 69, item.Pin); send(5, 71, "100"); pEnter(); List <Account> accList = new List <Account>(); for (int i = 8; i < 20; i += 2) { Account acc = new Account(); acc.Number = EUCL.ReadScreen(i, 5, 24).Replace(".", string.Empty); acc.OpenDate = parseCustom(EUCL.ReadScreen(i, 56, 6)); if (string.IsNullOrWhiteSpace(acc.Number)) { break; } send(i, 2, "1"); EUCL.Wait(); acc.Type = ClearWhiteSpacesStr(EUCL.ReadScreen(8, 34, 35)); acc.Mnemonic = EUCL.ReadScreen(10, 34, 4); acc.MnemonicFull = ClearWhiteSpacesStr(EUCL.ReadScreen(10, 40, 35)); EUCL.SendStr("@l"); //F21 EUCL.Wait(); acc.AccountingMode = ClearWhiteSpacesStr(EUCL.ReadScreen(8, 18, 35)); DateTime.TryParse(EUCL.ReadScreen(4, 70, 11), out acc.OpenDate); DateTime.TryParse(EUCL.ReadScreen(5, 70, 11), out acc.CloseDate); if (string.IsNullOrWhiteSpace(ClearWhiteSpacesStr(EUCL.ReadScreen(16, 18, 35)))) { acc.EmployeeOpenedFIO = EUCL.ReadScreen(9, 18, 4); } else { send(16, 2, "1"); EUCL.Wait(); acc.EmployeeOpenedFIO = EUCL.ReadScreen(6, 26, 4); EUCL.SendStr("@c"); //F12 EUCL.Wait(); } EUCL.SendStr("@3"); //F3 EUCL.Wait(); EUCL.SendStr("@c"); //F12 EUCL.Wait(); accList.Add(acc); } LogWorker.ClearPrevConsoleLine(); item.Accounts = accList; } }
/// <summary> /// Отправить /// </summary> /// <param name="text"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="size"></param> private void send(string text, int x, int y, int size = 80) { EUCL.SetCursorPos(x, y, size); EUCL.SendStr(text); EUCL.Wait(); }
/// <summary> /// Запросить TZ в Equation /// </summary> /// <param name="account">Счет, для которого получаем выписку</param> /// <param name="alfamos">сессия, которая будет закрыта</param> /// <returns></returns> public List <Operation> GetOperations(Account account, Process alfamos, Unit unit) { List <Operation> exportedOperations = new List <Operation>(); #region направляем в EQ запрос на создание выписки DateTime queryDateTime = DateTime.Now; EUCL.ClearScreen(); send("TZ", 21, 17); enter(); send(account.Number, 3, 29); enter(); EUCL.SendStr("@4"); //F4 EUCL.Wait(); enter(); #endregion #region ждем готового файла if (!Directory.Exists(_fileExportPath)) { throw new Exception($@"У пользователя отсутствует директория экспорта на {_fileExportPath}"); } for (int i = 0; i < WAIT_TIME; i++) { bool done = false; foreach (string fileName in Directory.GetFiles(_fileExportPath, "*.DBF")) { FileInfo file = new FileInfo(fileName); if (file.CreationTime > queryDateTime) { ExcelWorker excel = new ExcelWorker(file); exportedOperations.AddRange(excel.ReadForOperations()); done = true; break; } } if (done) { break; } Thread.Sleep(5000); } #endregion #region Поиск недостающих операций for (int i = 0; i < exportedOperations.Count; i++) { if (string.IsNullOrWhiteSpace(exportedOperations[i].Number) || exportedOperations[i].OperationDate.Year < 1950) { DateTime LastFullDate; // дата последней операции полными данными if (i != 0) { LastFullDate = exportedOperations[i - 1].OperationDate; } else { LastFullDate = account.OpenedDate < unit.DateStart ? unit.DateStart : account.OpenedDate; } DateTime NextFullDate = unit.DateEnd; // дата следующей заполненной опреации for (int j = i; j < exportedOperations.Count; j++) { if (!string.IsNullOrEmpty(exportedOperations[j].Number)) { NextFullDate = exportedOperations[j].OperationDate > unit.DateEnd ? unit.DateEnd : exportedOperations[j].OperationDate; break; } if (j == exportedOperations.Count - 1) { if (account.ClosedDate < unit.DateEnd && account.ClosedDate > unit.DateStart) { NextFullDate = account.ClosedDate; } else { NextFullDate = unit.DateEnd; } } } EUCL.ClearScreen(); send("TT", 21, 17); enter(); send(account.Number, 3, 29); send(LastFullDate.ToString("ddMMyy"), 14, 29); send(NextFullDate.ToString("ddMMyy"), 16, 29); enter(); enter(); #region поиск операций do { EUCL.SendStr("1111111111"); EUCL.SendStr("@v"); EUCL.Wait(); EUCL.SendStr("1111111111"); } while (EUCL.ReadScreen(21, 79, 1).Equals("+")); enter(); while (EUCL.ReadScreen(1, 32, 17).Equals("Просмотр проводки")) { string currentOperationNumber = EUCL.ReadScreen(8, 29, 45).Replace(" ", string.Empty); if (string.IsNullOrWhiteSpace(currentOperationNumber) || !exportedOperations.Any(operation => operation.Number.Equals(currentOperationNumber)) && !exportedOperations[i].IsEdited) { Operation newOperation = new Operation { Number = currentOperationNumber, OperationDate = DateTime.Parse(EUCL.ReadScreen(3, 40, 11)), PayerAccountNumber = EUCL.ReadScreen(9, 15, 24).Replace(".", string.Empty), RecieverAccount = EUCL.ReadScreen(12, 15, 24).Replace(".", string.Empty), PayerName = $"{EUCL.ReadScreen(9, 44, 35).Replace(" ", string.Empty)}{EUCL.ReadScreen(10, 44, 35).Replace(" ", string.Empty)}{EUCL.ReadScreen(11, 44, 35).Replace(" ", string.Empty)}", RecieverName = $"{EUCL.ReadScreen(12, 44, 35).Replace(" ", string.Empty)}{EUCL.ReadScreen(13, 44, 35).Replace(" ", string.Empty)}{EUCL.ReadScreen(14, 44, 35).Replace(" ", string.Empty)}", Comment = $"{EUCL.ReadScreen(18, 10, 70).Replace(" ", string.Empty)}{EUCL.ReadScreen(19, 10, 70).Replace(" ", string.Empty)}", DebetSum = EUCL.ReadScreen(15, 15, 20).Replace(" ", string.Empty), IsEdited = true }; if (newOperation.RecieverAccount.Equals("40911810904000000138") || newOperation.Comment.IndexOf("перевод между счетами") > -1) { newOperation.RecieverBankBIK = newOperation.PayerBankBIK = "044525593"; newOperation.RecieverBankName = newOperation.PayerBankName = "АО \"Альфа-Банк\""; } exportedOperations[i] = newOperation; break; } enter(); enter(); } #endregion } } #endregion alfamos.CloseMainWindow(); alfamos.WaitForExit(10000); return(exportedOperations); }