/// <summary> /// Build string with new content. /// </summary> /// <param name="filePath"></param> /// <param name="fileDestination"></param> /// <param name="result">extract 6 fields from b lines to string</param> /// <param name="isIncludeAgurot">sum include agurot or not(if yes it will insert '.')</param> /// <param name="Ignore2DigitOffice">ignore the last 2 digit in office field(in case it already contain the action code)</param> /// <returns>True - extract the fields to string and save new BLL file, False - otherwise</returns> public bool Build6FieldsBLL(string filePath, string fileDestination, ref string result, bool isIncludeAgurot, bool Ignore2DigitOffice = false) { bool success = true; try { StringBuilder sb = new StringBuilder(); const string TAB = "\t"; const int digitForDelete = 2; BllParser bp = new BllParser(); Tuple <bool, List <string> > resTuple = bp.Parser(filePath); success = resTuple.Item1; if (success) { foreach (BD bd in bp.BDList) { string date = bd.MaturityDate != null?bd.MaturityDate?.ToString("dd/MM/yy") : "00/00/00"; string office = DeletePaddingZero(bd.Office); string officeWithoutActionCode = Ignore2DigitOffice == true && office.Length >= digitForDelete?office.Substring(0, office.Length - digitForDelete) : office; string sum = DeletePaddingZero(bd.CheckSumWithAgorot); sum = isIncludeAgurot == true?sum.Insert(sum.Length - 2, ".") : sum; string b = DeletePaddingZero(bd.CheckNumber) + TAB + PaddingLeftZero(DeletePaddingZero(bd.Bank), 2) + TAB + PaddingLeftZero(officeWithoutActionCode, 3) + bd.ActionCode + TAB + DeletePaddingZero(bd.AccountNumber) + TAB + sum + TAB + date + Environment.NewLine; sb.Append(b); } result = sb.ToString(); result = result.Remove(result.LastIndexOf(Environment.NewLine)); } if (success && !string.IsNullOrEmpty(fileDestination)) { success = CreateFile(fileDestination, result); } } catch (Exception e) { Trace.Write(e.Message); success = false; } return(success); }
/// <summary> /// Return update file content according to file path /// </summary> /// <param name="filePath"></param> /// <param name="bIsMehuyavAgaa"></param> /// <returns></returns> public string BuildNewBllForSlikaElectronit(string filePath, bool bIsMehuyavAgaa = false) { string result = string.Empty; BllParser bp = new BllParser(); if (bp.Parser(filePath).Item1) { bp.A.N = "N"; foreach (BD bd in bp.BDList) { bd.Type = "D"; bd.Credit = "00"; bd.FutureUse = "00000"; bd.DepositType = bIsMehuyavAgaa ? "1" : "0"; } bp.CE.Type = "E"; result = bp.ToString(); } return(result); }