public void SaveEdiPure(ref string _EdiPure, string _FileName, int _CheckSeg) { LearPureEdiO = new LearPureEdi() { HashId = EdiBase.GetHashId(), EdiStr = _EdiPure, Fingreso = DateTime.Now.ToString(ApplicationSettings.DateTimeFormat), Reprocesar = true, NombreArchivo = _FileName, CheckSeg = _CheckSeg, InOut = "I" }; DbO.LearPureEdi.Add(LearPureEdiO); DbO.SaveChanges(); }
public static void AddParentChild(this EdiBase _EdiBase, EdiBase _NewChild) { _NewChild.Parent = _EdiBase; _EdiBase.Childs.Add(_NewChild); }
public static void AddLastChild(this List <SHP830> _ListSHP, EdiBase _NewChild) { _ListSHP.LastOrDefault().Childs.Add(_NewChild); }
public static void AddLastChild(this List <LIN830> _ListLIN, EdiBase _NewChild) { _ListLIN.LastOrDefault().Childs.Add(_NewChild); }
public string AutoSendInventary830(ref EdiRepSent EdiSent) { string ThisDate = DateTime.Now.ToString(ApplicationSettings.ToDateTimeFormat); string ThisTime = DateTime.Now.ToString(ApplicationSettings.ToTimeFormat); int ControlNumber = 1, NSeg = 0; IEnumerable <int> IeMaxRep = (from Rs in DbO.EdiRepSent where Rs.Tipo == "830" select Convert.ToInt32(Rs.Code)); if (IeMaxRep.Count() > 0) { ControlNumber = IeMaxRep.Max() + 1; } ISAO = new ISA830(EdiBase.SegmentTerminator) { AuthorizationInformationQualifier = "00", AuthorizationInformation = " ", SecurityInformationQualifier = "00", SecurityInformation = " ", InterchangeSenderIdQualifier = "ZZ", InterchangeSenderId = "GLC503 ", InterchangeReceiverIdQualifier = "ZZ", InterchangeReceiverId = "ICN3660 ", InterchangeDate = ThisDate, InterchangeTime = ThisTime, InterchangeControlStandardsId = "U", InterchangeControlVersion = "00204", AcknowledgmentRequested = "0", UsageIndicator = "P", InterchangeControlNumber = $"{ControlNumber.ToString("D9")}" }; NSeg++; GS830 Gs = new GS830(EdiBase.SegmentTerminator) { FunctionalIdCode = "PS", ApplicationSenderCode = "GLC503", ApplicationReceiverCode = "ICN3660", GsDate = ThisDate, GsTime = ThisTime, ResponsibleAgencyCode = "X", Version = "002040", GroupControlNumber = $"{ControlNumber.ToString("D4")}" }; NSeg++; //Gs.Parent = ISAO; //ISAO.Childs.Add(Gs); ISAO.AddParentChild(Gs); ST830 St = new ST830(EdiBase.SegmentTerminator) { IdCode = "830", ControlNumber = $"{ControlNumber.ToString("D4")}" }; NSeg++; ISAO.AddParentChild(St); BFR830 Bfr = new BFR830(EdiBase.SegmentTerminator) { TransactionSetPurposeCode = "00", ForecastOrderNumber = "", ReleaseNumber = "0000", ForecastTypeQualifier = "ZZ", ForecastQuantityQualifier = "A", ForecastHorizonStart = ThisDate, ForecastHorizonEnd = ThisDate, ForecastGenerationDate = ThisDate, ForecastUpdatedDate = "", ContractNumber = "", PurchaseOrderNumber = "" }; NSeg++; St.AddParentChild(Bfr); IEnumerable <FE830DataAux> IeExistencias = ManualDB.SP_GetExistencias(ref DbO, 618); IEnumerable <LearEquivalencias> learEquivalencias = DbO.LearEquivalencias; foreach (FE830DataAux Producto in IeExistencias) { IEnumerable <LearEquivalencias> Exists = learEquivalencias.Where(E => E.CodProducto == Producto.CodProducto || E.CodProducto + "-" == Producto.CodProducto); if (Exists.Count() == 0) { continue; } LIN830 Lin = new LIN830(EdiBase.SegmentTerminator) { AssignedIdentification = "", ProductIdQualifier = "BP", ProductId = Producto.CodProducto, ProductRefIdQualifier = "", ProductRefId = "", ProductPurchaseIdQualifier = "", ProductPurchaseId = "", }; NSeg++; St.AddParentChild(Lin); UIT830 Uit = new UIT830(EdiBase.SegmentTerminator) { UnitOfMeasure = "FT" }; NSeg++; Lin.AddParentChild(Uit); PRS830 Prs = new PRS830(EdiBase.SegmentTerminator) { StatusCode = "9" }; NSeg++; Lin.AddParentChild(Prs); N1830 N1 = new N1830(EdiBase.SegmentTerminator) { OrganizationId = "ST", Name = "GLC HONDURAS", IdCodeQualifier = "92", IdCode = "GLC503" }; NSeg++; Lin.AddParentChild(N1); N4830 N4 = new N4830(EdiBase.SegmentTerminator) { LocationQualifier = "WH", LocationId = "GLC503" }; NSeg++; Lin.AddParentChild(N4); SDP830 Sdp = new SDP830(EdiBase.SegmentTerminator) { CalendarPatternCode = "Z", PatternTimeCode = "Z" }; NSeg++; Lin.AddParentChild(Sdp); FST830 Fst = new FST830(EdiBase.SegmentTerminator) { Quantity = Math.Round(Convert.ToDecimal(Producto.Existencia), 0).ToString(), ForecastQualifier = "Z", ForecastTimingQualifier = "Z", FstDate = ThisDate }; // Solo el monto actual NSeg++; Sdp.AddParentChild(Fst); } CTT830 Ctt = new CTT830(EdiBase.SegmentTerminator) { TotalLineItems = IeExistencias.Count().ToString(), HashTotal = "" }; ISAO.AddParentChild(Ctt); SE830 Se = new SE830(EdiBase.SegmentTerminator) { NumIncludedSegments = NSeg.ToString(), TransactionSetControlNumber = $"{ControlNumber.ToString("D4")}" }; ISAO.AddParentChild(Se); GE830 Ge = new GE830(EdiBase.SegmentTerminator) { NumTransactionSetsIncluded = "1", GroupControl = $"{ControlNumber.ToString("D4")}" }; ISAO.AddParentChild(Ge); IEA830 Iea = new IEA830(EdiBase.SegmentTerminator) { NumIncludedGroups = "1", InterchangeControlNumber = $"{ControlNumber.ToString("D9")}" }; ISAO.AddParentChild(Iea); string ActualEdiStr = ISAO.Ts(); EdiSent.Log = "Reporte enviado"; EdiSent.Code = ControlNumber.ToString(); EdiSent.EdiStr = ActualEdiStr; EdiBase E1 = new EdiBase(EdiBase.SegmentTerminator) { HashId = EdiSent.HashId }; ISAO.Parent = E1; ISAO.SaveAll830(ref DbO); DbO.EdiRepSent.Update(EdiSent); LearPureEdi Pe = new LearPureEdi() { EdiStr = ActualEdiStr, HashId = E1.HashId, Fingreso = DateTime.Now.ToString(ApplicationSettings.DateTimeFormat), Fprocesado = DateTime.Now.ToString(ApplicationSettings.DateTimeFormat), Reprocesar = false, NombreArchivo = "Inventario", Log = $"{NSeg} segmentos analizados, procesados y guardados", CheckSeg = NSeg, Shp = false, InOut = "O" }; DbO.LearPureEdi.Add(Pe); DbO.SaveChanges(); return(EdiSent.EdiStr); }