private void fourrowparse(string line, ref WrapConto item) { line = line.Replace("|", "").Replace("обекта", "обекта:"); var splitline = line.Split(':'); item.Conto.NumberObject = int.Parse(splitline[1].Trim()); }
private void thirthrowparse(string line, ref WrapConto item) { line = line.Replace("|", "").Replace("ЗАБ.", ":ЗАБ."); var splitline = line.Split(':'); item.Conto.Reason = splitline[1].Trim(); item.Conto.Note = splitline.Length > 3 ? splitline[3].Trim() : ""; }
private void secondrowparse(string line, ref WrapConto item) { line = line.Replace("|", "").Replace("Поделение", ":Поделение").Replace("Дата на док", ":Дата на док"); var splitline = line.Split(':'); item.Conto.DataInvoise = ParseData(splitline[5].Trim()); item.CodeDds = splitline[1].Trim(); }
private void fivehrowparse(string line, ref WrapConto item) { line = line.Replace("|", "").Replace("ОБОРОТ", ":ОБОРОТ").Replace("К.СМ.", ":К.СМ."); var splitline = line.Split(':'); item.Conto.Oborot = decimal.Parse(splitline[3].Trim()); item.Conto.DebitAccount = readsmetka(splitline[1].Trim(), true); item.Conto.CreditAccount = readsmetka(splitline[5].Trim(), false); item.ItemsDebits = new List <SaldoItem>(LoadCreditAnaliticAtributes(context.LoadAllAnaliticfields(item.Conto.DebitAccount), 1)); item.ItemsCredits = new List <SaldoItem>(LoadCreditAnaliticAtributes(context.LoadAllAnaliticfields(item.Conto.CreditAccount), 2)); }
private void firstrowparse(string line, ref WrapConto item) { line = line.Replace("|", "").Replace("НОМЕР", ":НОМЕР").Replace("ДАТА", ":ДАТА").Replace("ПАПКА", ":ПАПКА").Replace("СЧ.", ":СЧ."); var splitline = line.Split(':'); item.Conto.CartotekaDebit = int.Parse(splitline[1].Trim()); item.Conto.CartotecaCredit = All; item.Conto.DocNum = splitline[3].Trim(); item.Conto.Data = new DateTime(2014, 10, int.Parse(splitline[5].Trim())); item.Conto.Folder = splitline[7].Trim(); item.Conto.UserId = int.Parse(splitline[9].Trim()); }
private void SaveDds(WrapConto CurrentConto) { if (CurrentConto.TypeDds == 0) { return; } DdsDnevnikModel ddsDnevnikModel = new DdsDnevnikModel(); ddsDnevnikModel.DetailItems = new List <DdsItemModel>(GetAllDnevItems(CurrentConto.TypeDds)); var item = ddsDnevnikModel.DetailItems.FirstOrDefault(e => e.Code == "ДК"); if (item != null) { item.Dds = CurrentConto.Conto.Oborot; if (CurrentConto.Suma > 0) { item.DdsSuma = CurrentConto.Suma; } else { item.DdsSuma = item.Dds * (item.DdsPercent / 100); } } ddsDnevnikModel.Date = CurrentConto.Conto.Data; ddsDnevnikModel.DataF = CurrentConto.Conto.Data; ddsDnevnikModel.DocId = CurrentConto.Fn; ddsDnevnikModel.KindActivity = CurrentConto.TypeDds; ddsDnevnikModel.Nzdds = CurrentConto.Bulstad; ddsDnevnikModel.Bulstat = CurrentConto.Bulstad; ddsDnevnikModel.NameKontr = CurrentConto.Cn; ddsDnevnikModel.KindDoc = 1; ddsDnevnikModel.CodeDoc = "01"; ddsDnevnikModel.A8 = 0; ddsDnevnikModel.IsSuma = 0; ddsDnevnikModel.Num = CurrentConto.Conto.Id; SaveDdsDnevnicModel(ddsDnevnikModel); }
private void sixandmorerowparse(string line, ref WrapConto item, int numrow) { line = line.Replace("|", ""); var splitline = line.Split(':'); bool ebane = false; string[] splitline1 = { "" }; if (splitline.Length > 2) { ebane = true; var half = line.Substring(1, line.Length / 2 - 1); var secondhalf = line.Substring(line.Length / 2, line.Length / 2 - 1); splitline = half.Split(':'); splitline1 = secondhalf.Split(':'); } if (numrow == 5 && CAccountsModel != null && CAccountsModel.Short == "410") { var saldo = item.ItemsCredits.FirstOrDefault(e => e.Name == "Контрагент"); if (saldo != null) { saldo.Value = !ebane ? splitline[1].Trim() : splitline1[1].Trim(); var tag = saldo.GetFilters().ToList()[0]; var mainrez = saldo.GetDictionary(string.Format("AND \"{0}\"='{1}'", tag.FilterField, saldo.Value), string.Format(" order by \"{0}\"", tag.FilterField)); if (mainrez != null && mainrez.Count > 1 && mainrez[1].Count > 1) { saldo.Lookupval = mainrez[1][1]; } } } if (numrow == 5 && DAccountsModel != null && DAccountsModel.Short == "410") { var saldo = item.ItemsDebits.FirstOrDefault(e => e.Name == "Контрагент"); if (saldo != null) { saldo.Value = splitline[1].Trim(); var tag = saldo.GetFilters().ToList()[0]; var mainrez = saldo.GetDictionary(string.Format("AND \"{0}\"='{1}'", tag.FilterField, saldo.Value), string.Format(" order by \"{0}\"", tag.FilterField)); if (mainrez != null && mainrez.Count > 1 && mainrez[1].Count > 1) { saldo.Lookupval = mainrez[1][1]; } } } if (CAccountsModel != null && CAccountsModel.Short == "453/2") { item.Conto.IsDdsSales = 1; item.Conto.IsSales = 1; item.Conto.VopSales = "ДК"; item.TypeDds = 2; if (numrow == 5) { item.Fn = !ebane?splitline[1].Trim():splitline1[1].Trim(); if (!Rgx.IsMatch(item.Fn)) { string[] numbers; numbers = Regex.Split(item.Fn, @"\D+"); item.Fn = numbers[0]; } if (item != null) { var saldo = item.ItemsDebits.FirstOrDefault(e => e.Name == "Номер фактура"); if (saldo != null) { saldo.Value = item.Fn; } } } if (numrow == 6) { item.Cn = !ebane ? splitline[1].Trim() : splitline1[1].Trim(); } if (numrow == 7) { item.Bulstad = !ebane ? splitline[1].Trim() : splitline1[1].Trim(); } if (numrow == 8) { decimal sum; if (decimal.TryParse(!ebane ? splitline[1].Trim() : splitline1[1].Trim(), out sum)) { item.Suma = sum; } } } if (DAccountsModel != null && DAccountsModel.Short == "453/1") { item.Conto.IsDdsPurchases = 1; item.Conto.IsPurchases = 1; item.Conto.VopPurchases = "ДК"; if (numrow == 5) { item.Fn = splitline[1].Trim(); if (!Rgx.IsMatch(item.Fn)) { string[] numbers; numbers = Regex.Split(item.Fn, @"\D+"); item.Fn = numbers[0]; } if (item != null) { var saldo = item.ItemsCredits.FirstOrDefault(e => e.Name == "Номер фактура"); if (saldo != null) { saldo.Value = item.Fn; } } } if (numrow == 6) { item.Cn = splitline[1].Trim(); } if (numrow == 7) { item.Bulstad = splitline[1].Trim(); } if (numrow == 8) { decimal sum; if (decimal.TryParse(splitline[1].Trim(), out sum)) { item.Suma = sum; } } } }
private List <WrapConto> ReadCont() { Rgx = new Regex(@"^\d*\.{0,1}\d+$", RegexOptions.IgnoreCase); List <WrapConto> rez = new List <WrapConto>(); var enc = Encoding.GetEncoding("Windows-1251"); string[] lines = System.IO.File.ReadAllLines(@"E:\Samples\TempoSvn\Tempo2012\Documents\hronologia_s_kartoni.txt", enc); WrapConto item = new WrapConto { Conto = new Conto { FirmId = 2 } }; int numrow = 0; int total = 0; foreach (string line in lines.Skip(1)) { if (line == "----------------------------------------------------------------------------------------") { rez.Add(item); item = new WrapConto { Conto = new Conto { FirmId = 2 } }; numrow = 0; DAccountsModel = null; CAccountsModel = null; total++; continue; } if (numrow == 0) { firstrowparse(line, ref item); } if (numrow == 1) { secondrowparse(line, ref item); } if (numrow == 2) { thirthrowparse(line, ref item); } if (numrow == 3) { fourrowparse(line, ref item); } if (numrow == 4) { fivehrowparse(line, ref item); } if (numrow >= 5) { sixandmorerowparse(line, ref item, numrow); } numrow++; } return(rez); }
private void SaveConto(WrapConto CurrentConto) { CurrentConto.Conto.CDetails = ""; CurrentConto.Conto.DDetails = ""; foreach (SaldoItem currentsaldos in CurrentConto.ItemsCredits) { if (currentsaldos.Fieldkey == 30) { CurrentConto.Conto.OborotValutaK = currentsaldos.Valuedecimal; } if (currentsaldos.Fieldkey == 31) { CurrentConto.Conto.OborotKolK = currentsaldos.Valuedecimal; } CurrentConto.Conto.CDetails += string.Format("{0} - {1} {2}\n", currentsaldos.Name, currentsaldos.Value, currentsaldos.Lookupval); } foreach (SaldoItem currentsaldos in CurrentConto.ItemsDebits) { if (currentsaldos.Fieldkey == 30) { CurrentConto.Conto.OborotValutaD = currentsaldos.Valuedecimal; } if (currentsaldos.Fieldkey == 31) { CurrentConto.Conto.OborotKolD = currentsaldos.Valuedecimal; } CurrentConto.Conto.DDetails += string.Format("{0} - {1} {2}\n", currentsaldos.Name, currentsaldos.Value, currentsaldos.Lookupval); } SaveContoLocal(CurrentConto.Conto); if (CurrentConto.Conto.Id == 0) { return; } if (CurrentConto.ItemsCredits != null) { foreach (SaldoItem currentsaldos in CurrentConto.ItemsCredits) { SaldoAnaliticModel sa = new SaldoAnaliticModel(); sa.ACCFIELDKEY = currentsaldos.Fieldkey; sa.ACCID = CurrentConto.Conto.CreditAccount; sa.DATA = DateTime.Now; //if (currentsaldos.SelectedLookupItem != null && !string.IsNullOrWhiteSpace(currentsaldos.SelectedLookupItem.Key)) //{ // if (currentsaldos.SelectedLookupItem.Key != null) // { // int rez; // sa.LOOKUPFIELDKEY = int.TryParse(currentsaldos.SelectedLookupItem.Key,out rez)?rez:0; // sa.LOOKUPVAL = currentsaldos.SelectedLookupItem.Value; // } //} sa.LOOKUPFIELDKEY = currentsaldos.LiD; sa.LOOKUPVAL = currentsaldos.Lookupval; sa.TYPEACCKEY = 2; sa.VALUEDATE = currentsaldos.ValueDate; sa.VAL = currentsaldos.Value; sa.VALUEMONEY = currentsaldos.Valuedecimal; sa.VALUENUM = currentsaldos.ValueInt; sa.VALUED = currentsaldos.Valuedecimald; sa.KURS = currentsaldos.ValueKurs; sa.KURSM = currentsaldos.MainKurs; sa.VALVAL = currentsaldos.ValueVal; sa.KURSD = currentsaldos.KursDif; sa.TYPE = 2; sa.LOOKUPID = currentsaldos.Relookup; sa.CONTOID = CurrentConto.Conto.Id; SaveContoMovement(sa); } } if (CurrentConto.ItemsDebits != null) { foreach (SaldoItem currentsaldos in CurrentConto.ItemsDebits) { SaldoAnaliticModel sa = new SaldoAnaliticModel(); sa.ACCFIELDKEY = currentsaldos.Fieldkey; sa.ACCID = CurrentConto.Conto.DebitAccount; sa.DATA = DateTime.Now; //if (currentsaldos.SelectedLookupItem != null && !string.IsNullOrWhiteSpace(currentsaldos.SelectedLookupItem.Key)) //{ // if (currentsaldos.SelectedLookupItem.Key != null) // { // int rez; // sa.LOOKUPFIELDKEY = int.TryParse(currentsaldos.SelectedLookupItem.Key,out rez)?rez:0; // sa.LOOKUPVAL = currentsaldos.SelectedLookupItem.Value; // } //} sa.LOOKUPFIELDKEY = currentsaldos.LiD; sa.TYPEACCKEY = 1; sa.VALUEDATE = currentsaldos.ValueDate; sa.VAL = currentsaldos.Value; sa.VALUEMONEY = currentsaldos.Valuedecimal; sa.VALUENUM = currentsaldos.ValueInt; sa.VALUED = currentsaldos.Valuedecimald; sa.KURS = currentsaldos.ValueKurs; sa.KURSM = currentsaldos.MainKurs; sa.VALVAL = currentsaldos.ValueVal; sa.KURSD = currentsaldos.KursDif; sa.TYPE = 1; sa.LOOKUPID = currentsaldos.Relookup; sa.LOOKUPVAL = currentsaldos.Lookupval; sa.CONTOID = CurrentConto.Conto.Id; SaveContoMovement(sa); } } }