private async void lstData_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem != null) { string obj = e.SelectedItem.ToString(); obj = obj.Substring(obj.LastIndexOf(',') + 1).Replace("IdResultParticipation = ", string.Empty).Replace("}", string.Empty); string res = await DisplayActionSheet("Выберите операцию", "Отмена", null, "Обновить данные", "Удалить данные"); switch (res) { // case "Подробнее": // await PopupNavigation.Instance.PushAsync(new MoreInfoParticipationsPage()); // break; case "Обновить данные": await Navigation.PushModalAsync(new AddResultParticipationPagePage(Convert.ToInt32(obj)), animate); break; case "Удалить данные": bool result = await DisplayAlert("Подтвердить действие", "Вы хотите удалить элемент?", "Да", "Нет"); if (result == true) { ResultParticipant Del = await resultParticipationServise.Delete(Convert.ToInt32(obj)); await showEmployeeAsync(); await DisplayAlert("Уведомление", "Итог соревнования удален", "Ok"); } break; } lstData.SelectedItem = null; } }
public async Task Criate() { if (ID_Partisipant != 0) { //await Positions(ID_Partisipant); ResultParticipant resultParticipant = new ResultParticipant { IdParticipation = ID_Partisipant, Mesto = Convert.ToInt32(Mesto_Entry.Text), ResultTime = ID_Time }; await resultParticipationServise.Add(resultParticipant); if (!await DisplayAlert("", "Добавить еще одну запись", "Да", "Нет")) { await Navigation.PopModalAsync(); } } else { if (!await DisplayAlert("Ошибка", "Вы заполнили не все поля", "Заполнить", "Выйти")) { await Navigation.PopModalAsync(); } } }
public async Task Update(int id) { if (ID_Partisipant != 0) { //await Positions(ID_Partisipant); IEnumerable <ResultParticipant> resultParticipations = await resultParticipationServise.Get(); var info = resultParticipations.FirstOrDefault(x => x.IdResultParticipation == id); ResultParticipant resultParticipant = new ResultParticipant { IdResultParticipation = id, IdParticipation = ID_Partisipant, Mesto = info.Mesto, ResultTime = ID_Time }; await resultParticipationServise.Update(resultParticipant); await Navigation.PopModalAsync(); } else { if (!await DisplayAlert("Ошибка", "Вы заполнили не все поля", "Заполнить", "Выйти")) { await Navigation.PopModalAsync(); } } }
// CTOR FOR NV INSERT. public CveCreditor(string dataBaseName, IProgress <HPgModel> progress, ResultParticipant userParticipant) { Mode = TipoTask.Creditor; IsRuning = true; StringLogging = new StringBuilder(); Conn = new Conexion(dataBaseName); PgModel = new HPgModel(); Progress = progress; UserParticipant = userParticipant; }
private async void lstData_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem != null) { Distantion obj = (Distantion)e.SelectedItem; string res = await DisplayActionSheet("Выберите операцию", "Отмена", null, "Обновить данные", "Удалить данные"); switch (res) { case "Обновить данные": await Navigation.PushModalAsync(new AddDistantionsPage(obj.IdDistantion), animate); break; case "Удалить данные": bool result = await DisplayAlert("Подтвердить действие", "Вы хотите удалить элемент?", "Да", "Нет"); if (result == true) { Distantion Del_Distantion = await distantionsServise.Delete(obj.IdDistantion); IEnumerable <Competentions> competentions = await competentionsServise.Get(); var selectad_del_compitentions = competentions.FirstOrDefault(p => p.IdDistantion == obj.IdDistantion); if (selectad_del_compitentions != null) { Competentions Del_compitentions = await competentionsServise.Delete(selectad_del_compitentions.IdCompetentions); IEnumerable <Participation> participations = await participationService.Get(); var selectad = participations.FirstOrDefault(p => p.IdCompetentions == selectad_del_compitentions.IdCompetentions); if (selectad != null) { int id_part = selectad.IdParticipation; IEnumerable <ResultParticipant> res_participations = await resultParticipationServise.Get(); Participation Del_Participation = await participationService.Delete(id_part); var res_selectad = res_participations.FirstOrDefault(p => p.IdParticipation == id_part); if (res_selectad != null) { int id_res_part = res_selectad.IdResultParticipation; ResultParticipant Del_ResultPartisipation = await resultParticipationServise.Delete(id_res_part); } } } await showEmployeeAsync(); await DisplayAlert("Уведомление", "Дистанция успешно удалена", "Ok"); } break; } lstData.SelectedItem = null; } }
public CveDebtor(string dBName, IProgress <HPgModel> progress, string tokenCen, string tokenSii, ResultParticipant userParticipant) { DBName = dBName; Progress = progress; TokenCen = tokenCen; TokenSii = tokenSii; UserParticipant = userParticipant; Mode = TipoTask.Debtor; PgModel = new HPgModel(); Progress = progress; Conn = new Conexion(dBName); IsRuning = true; }
// добавляем информацию public async Task <ResultParticipant> Add(ResultParticipant resultParticipation) { HttpClient client = getClientServise.GetClient(); var response = await client.PostAsync("http://90.189.158.10/api/ResultParticipations/", new StringContent(JsonConvert.SerializeObject(resultParticipation), Encoding.UTF8, "application/json")); if (response.StatusCode != HttpStatusCode.OK) { return(null); } return(JsonConvert.DeserializeObject <ResultParticipant>(await response.Content.ReadAsStringAsync())); }
public CveCreditor(ResultParticipant userParticipant, IProgress <HPgModel> progress, string dataBaseName, string tokenSii, string tokenCen) { DBName = dataBaseName; TokenCen = tokenCen; UserParticipant = userParticipant; TokenSii = tokenSii; Mode = TipoTask.Creditor; PgModel = new HPgModel(); Conn = new Conexion(dataBaseName); Progress = progress; IsRuning = true; DetalleList = new List <Detalle>(); }
private async void lstData_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem != null) { string obj = e.SelectedItem.ToString(); obj = obj.Substring(obj.LastIndexOf(',') + 1).Replace("IdCompetentions = ", string.Empty).Replace("}", string.Empty); string res = await DisplayActionSheet("Выберите операцию", "Отмена", null, "Обновить данные", "Удалить данные"); switch (res) { case "Обновить данные": await Navigation.PushModalAsync(new AddCompitentionsPage(Convert.ToInt32(obj)), animate); break; case "Удалить данные": bool result = await DisplayAlert("Подтвердить действие", "Вы хотите удалить элемент?", "Да", "Нет"); if (result == true) { IEnumerable <Participation> participations = await participationService.Get(); Competentions Del_compitentions = await competentionsServise.Delete(Convert.ToInt32(obj)); var selectad = participations.FirstOrDefault(p => p.IdCompetentions == Convert.ToInt32(obj)); if (selectad != null) { int id_part = selectad.IdParticipation; IEnumerable <ResultParticipant> res_participations = await resultParticipationServise.Get(); Participation Del_Participation = await participationService.Delete(id_part); var res_selectad = res_participations.FirstOrDefault(p => p.IdParticipation == id_part); if (res_selectad != null) { int id_res_part = res_selectad.IdResultParticipation; ResultParticipant Del_ResultPartisipation = await resultParticipationServise.Delete(id_res_part); } } await showEmployeeAsync(false); await DisplayAlert("Уведомление", "Компетенция успешно удалена", "Ok"); } break; } lstData.SelectedItem = null; } }
private async void lstData_ItemSelected(object sender, SelectedItemChangedEventArgs e) { if (e.SelectedItem != null) { string obj = e.SelectedItem.ToString(); obj = obj.Substring(obj.LastIndexOf(',') + 1).Replace("IdParticipation = ", string.Empty).Replace("}", string.Empty); string res = await DisplayActionSheet("Выберите операцию", "Отмена", null, "Подробнее", "Обновить данные", "Удалить данные"); switch (res) { case "Подробнее": await PopupNavigation.Instance.PushAsync(new MoreInfoParticipationsPage()); break; case "Обновить данные": await Navigation.PushModalAsync(new AddPaticipationsPage(Convert.ToInt32(obj)), animate); break; case "Удалить данные": bool result = await DisplayAlert("Подтвердить действие", "Вы хотите удалить элемент?", "Да", "Нет"); if (result == true) { IEnumerable <ResultParticipant> participations = await resultParticipationServise.Get(); var selectad = participations.FirstOrDefault(p => p.IdParticipation == Convert.ToInt32(obj)); Participation Del_Participation = await participationService.Delete(Convert.ToInt32(obj)); if (selectad != null) { ResultParticipant Del_ResultPartisipation = await resultParticipationServise.Delete(selectad.IdResultParticipation); } await showEmployeeAsync(false); await DisplayAlert("Уведомление", "Соревнование удалено", "Ok"); } break; } lstData.SelectedItem = null; } }
public async Task SendMailToParticipantAsync(Detalle detalle, ResultParticipant participant, string EmailInDte) { Progress.Report(ProgressReport); BodyBuilder bodyBuilder = new BodyBuilder(); StringBuilder builderCEN = new StringBuilder(); TextInfo ti = CultureInfo.CurrentCulture.TextInfo; string RutReceptorEmail = null; string nameReceptorEmail = null; if (detalle.Instruction != null) { RutReceptorEmail = string.Format(CultureInfo.CurrentCulture, "{0:N0}", detalle.Instruction.ParticipantCreditor.Rut).Replace(',', '.'); nameReceptorEmail = ti.ToTitleCase(detalle.Instruction.ParticipantCreditor.BusinessName.ToLower()); } string rutDebtor = string.Format(CultureInfo.CurrentCulture, "{0:N0}", UserParticipant.Rut).Replace(',', '.'); string dv = UserParticipant.VerificationCode; string nameDebtor = ti.ToTitleCase(UserParticipant.BusinessName.ToLower()); nameReceptorEmail = ti.ToTitleCase(detalle.RznSocRecep.ToLower()); RutReceptorEmail = detalle.RutReceptor + "-" + detalle.DvReceptor; if (detalle.ValidatorFlag != null) { if (detalle.ValidatorFlag.FmaPago) // FORMA PAGO { builderCEN.AppendLine(" -No se encuentra el Tag : <FmaPago>" + "<br/>"); } if (detalle.ValidatorFlag.Flag == Helpers.HFlagValidator.LetterFlag.Blue) // MONTO { builderCEN.AppendLine(" -Monto no corresponde." + "<br/>"); } if (detalle.ValidatorFlag.FolioRef) // DE01724A17C14S0015 { builderCEN.AppendLine(" -No se encuentra el Tag : <FolioRef>" + "<br/>"); } if (detalle.ValidatorFlag.RazonRef) // SEN_[RBPA][Ene18-Dic18][R][V02] { builderCEN.AppendLine(" -No se encuentra el Tag : <RazonRef>" + "<br/>"); } } if (detalle.DTEDef == null) { builderCEN.AppendLine(" -El archivo XML no ha sido recepcionado en nuestra casilla de correos."); } bodyBuilder.HtmlBody += $"<p>Señores: <span style=\"text-decoration: underline;\">{nameReceptorEmail}</span> </p>\r\n<p>Rut: {RutReceptorEmail}</p>\r\n" + $"<p> </p>\r\n<p>La empresa \"{nameDebtor}\" Rut: {rutDebtor}-{dv} " + "informa que la factura que se individualiza a continuación fue rechazada en el SII por el motivo que se señala:</p>\r\n<p> </p>\r\n" + $"<p>Folio: {detalle.Folio}</p>\r\n" + $"<p>Fecha: {detalle.FechaEmision}</p>\r\n" + $"<p>Monto neto: $ {detalle.MntNeto:#,##}</p>\r\n" + $"<p>Motivo del rechazo: <br/> {builderCEN}</p>\r\n" + "<p> </p>\r\n<p> </p>\r\n" + "<p> </p>\r\n<p>*Para mayor información sobre las exigencias del CEN: " + "<a href=\"https://www.coordinador.cl/corta/6\">https://www.coordinador.cl</a> " + "</p>\r\n<hr />\r\n<p><strong><span style=\"color: #0000ff;\">" + "Una herramienta Centralizador.</span></strong></p>"; try { MailboxAddress ffrom = new MailboxAddress(Properties.Settings.Default.User365, Properties.Settings.Default.Password365); MailboxAddress cc = new MailboxAddress(Properties.Settings.Default.UserCC365, Properties.Settings.Default.UserCC365); MimeMessage message = new MimeMessage(); message.From.Add(ffrom); // TESTER //MailboxAddress tto = new MailboxAddress("*****@*****.**", "*****@*****.**"); //message.To.Add(tto); //message.To.Add(tto); message.Cc.Add(cc); message.Subject = "Notifica rechazo factura CEN"; message.Priority = MessagePriority.Urgent; message.Importance = MessageImportance.High; message.ReplyTo.Add(new MailboxAddress(Properties.Settings.Default.UserCC365, Properties.Settings.Default.UserCC365)); // TO ADDRESS. if (detalle.Instruction != null) { if (detalle.Instruction.ParticipantCreditor.BillsContact.Email != null) { message.To.Add(new MailboxAddress(detalle.Instruction.ParticipantCreditor.BillsContact.Email, detalle.Instruction.ParticipantCreditor.BillsContact.Email)); } if (detalle.Instruction.ParticipantCreditor.PaymentsContact.Email != null) { message.To.Add(new MailboxAddress(detalle.Instruction.ParticipantCreditor.PaymentsContact.Email, detalle.Instruction.ParticipantCreditor.PaymentsContact.Email)); } } else { if (participant.DteReceptionEmail != null) { message.To.Add(new MailboxAddress(participant.DteReceptionEmail, participant.DteReceptionEmail)); } if (participant.BillsContact.Email != null) { message.To.Add(new MailboxAddress(participant.BillsContact.Email, participant.BillsContact.Email)); } if (participant.PaymentsContact.Email != null) { message.To.Add(new MailboxAddress(participant.PaymentsContact.Email, participant.PaymentsContact.Email)); } } if (EmailInDte != null) { message.To.Add(new MailboxAddress(EmailInDte, EmailInDte)); } message.Body = bodyBuilder.ToMessageBody(); if (message.To.Count > 0) { using (SmtpClient client = new SmtpClient()) { client.MessageSent += Client_MessageSent; await client.ConnectAsync("smtp.office365.com", 587, false); await client.AuthenticateAsync(Properties.Settings.Default.User365, Properties.Settings.Default.Password365); await client.SendAsync(message); await client.DisconnectAsync(true); } } } catch (Exception) { throw; } finally { } }
public SendEmailTo(ResultParticipant userParticipant, IProgress <HPgModel> progress) { UserParticipant = userParticipant; Progress = progress; ProgressReport = new HPgModel(); }
public async Task <DataEvento> GetStatusDteAsync(string tipoUser, string token, string tipoDoc, Detalle detalle, ResultParticipant userParticipant) { string rutToken; rutToken = RutToken.Substring(RutToken.IndexOf('=') + 1, 10); MetaData metaData = new MetaData { Namespace = "cl.sii.sdi.lob.diii.registrorechazodtej6.data.api.interfaces.FacadeService/validarAccesoReceptor", ConversationId = token, TransactionId = "0" }; Data data = new Data(); if (tipoUser == "Debtor") { data.RutEmisor = detalle.RutReceptor.ToString(); data.DvEmisor = detalle.DvReceptor; data.TipoDoc = tipoDoc; data.Folio = detalle.Folio.ToString(); data.RutToken = rutToken.Split('-').GetValue(0).ToString(); data.DvToken = rutToken.Split('-').GetValue(1).ToString(); } else if (tipoUser == "Creditor") { data.RutEmisor = userParticipant.Rut.ToString(); data.DvEmisor = userParticipant.VerificationCode; data.TipoDoc = tipoDoc; data.Folio = detalle.Folio.ToString(); data.RutToken = rutToken.Split('-').GetValue(0).ToString(); data.DvToken = rutToken.Split('-').GetValue(1).ToString(); } string url = "https://www4.sii.cl/registrorechazodtej6ui/services/data/facadeService/validarAccesoReceptor"; ServiceEvento serviceEvento = new ServiceEvento(data, metaData); try { using (WebClient wc = new WebClient() { Encoding = Encoding.UTF8 }) { string jSon = JsonConvert.SerializeObject(serviceEvento, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); wc.Headers[HttpRequestHeader.ContentType] = "application/json"; wc.Encoding = Encoding.UTF8; wc.Headers[HttpRequestHeader.Cookie] = $"TOKEN={token}"; string result = await wc.UploadStringTaskAsync(url, WebRequestMethods.Http.Post, jSon); if (result != null) { ResultEvent detalleLibro = JsonConvert.DeserializeObject <ResultEvent>(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); if (detalleLibro.MetaData.Errors == null) { return(detalleLibro.DataEvento); } } } } catch (WebException ex) when(ex.Status == WebExceptionStatus.ProtocolError || ex.Status == WebExceptionStatus.ReceiveFailure) { throw; } catch (Exception) { throw; } return(null); }
public async Task <DataEvento> GetStatusDteAsync2(string tipoUser, string token, string tipoDoc, Detalle detalle, ResultParticipant userParticipant) { string rutToken; rutToken = RutToken.Substring(RutToken.IndexOf('=') + 1, 10); MetaData metaData = new MetaData { Namespace = "cl.sii.sdi.lob.diii.registrorechazodtej6.data.api.interfaces.FacadeService/validarAccesoReceptor", ConversationId = token, TransactionId = "0" }; Data data = new Data(); if (tipoUser == "Debtor") { data.RutEmisor = detalle.RutReceptor.ToString(); data.DvEmisor = detalle.DvReceptor; data.TipoDoc = tipoDoc; data.Folio = detalle.Folio.ToString(); data.RutToken = rutToken.Split('-').GetValue(0).ToString(); data.DvToken = rutToken.Split('-').GetValue(1).ToString(); } else if (tipoUser == "Creditor") { data.RutEmisor = userParticipant.Rut.ToString(); data.DvEmisor = userParticipant.VerificationCode; data.TipoDoc = tipoDoc; data.Folio = detalle.Folio.ToString(); data.RutToken = rutToken.Split('-').GetValue(0).ToString(); data.DvToken = rutToken.Split('-').GetValue(1).ToString(); } string url = "https://www4.sii.cl/registrorechazodtej6ui/services/data/facadeService/validarAccesoReceptor"; ServiceEvento serviceEvento = new ServiceEvento(data, metaData); try { ResultEvent detalleLibro = null; // request.AddHeader("Cookie", "TOKEN=XAUCXIUL7IYNG"); //using (WebClient wc = new WebClient() { Encoding = Encoding.UTF8 }) //{ string jSon = JsonConvert.SerializeObject(serviceEvento, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); StringContent content = new StringContent(jSon.ToString(), Encoding.UTF8, "application/json"); //using (var httpClient = new HttpClient(new HttpClientHandler { UseCookies = false })) //{ wc.DefaultRequestHeaders.Add("Cookie", $"TOKEN={Token}"); await Task.Run(async() => { HttpResponseMessage response = await wc.PostAsync(url, content); //await Task.Delay(1000); string s = await response.Content.ReadAsStringAsync(); if (response.IsSuccessStatusCode) { detalleLibro = JsonConvert.DeserializeObject <ResultEvent>(s, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); } }); if (detalleLibro != null && detalleLibro.MetaData.Errors == null) { return(detalleLibro.DataEvento); } // } // wc.Headers[HttpRequestHeader.Cookie] = $"TOKEN={token}"; //if (result != null) //{ // ResultEvent detalleLibro = JsonConvert.DeserializeObject<ResultEvent>(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); // if (detalleLibro.MetaData.Errors == null) // { // return detalleLibro.DataEvento; // } //} // } } catch (WebException ex) when(ex.Status == WebExceptionStatus.ProtocolError || ex.Status == WebExceptionStatus.ReceiveFailure) { throw; } catch (Exception) { throw; } return(null); }
public ServiceExcel(List <Detalle> detalles, ResultParticipant userParticipant, string tokenCen) { Detalles = detalles; UserParticipant = userParticipant; TokenCen = tokenCen; }
public ServiceExcel(ResultParticipant userParticipant) { UserParticipant = userParticipant; }
public static async Task <List <Detalle> > GetLibroAsync(string tipoUser, ResultParticipant userParticipant, string tipoDoc, string periodo, string token, IProgress <HPgModel> progress) { Progress = progress; string ns = "", url = "", op = ""; switch (tipoUser) { case "Debtor": ns = "cl.sii.sdi.lob.diii.consemitidos.data.api.interfaces.FacadeService/getDetalleRecibidos"; op = "2"; url = "https://www4.sii.cl/consemitidosinternetui/services/data/facadeService/getDetalleRecibidos"; break; case "Creditor": ns = "cl.sii.sdi.lob.diii.consemitidos.data.api.interfaces.FacadeService/getDetalle"; op = "1"; url = "https://www4.sii.cl/consemitidosinternetui/services/data/facadeService/getDetalle"; break; } MetaData metaData = new MetaData { Namespace = ns, ConversationId = token, TransactionId = "0" }; Data data = new Data { TipoDoc = tipoDoc, Rut = userParticipant.Rut.ToString(), Dv = userParticipant.VerificationCode, Periodo = periodo, Operacion = op, DerrCodigo = tipoDoc, RefNCD = "0" }; ServiceDetalle apiDetalleLibroReq = new ServiceDetalle(metaData, data); try { string jSon = JsonConvert.SerializeObject(apiDetalleLibroReq, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); using (WebClient wc = new WebClient() { Encoding = Encoding.UTF8 }) { wc.Headers[HttpRequestHeader.ContentType] = "application/json"; wc.Headers[HttpRequestHeader.Cookie] = $"RUT_NS={userParticipant.Rut}; DV_NS={userParticipant.VerificationCode};TOKEN={token}"; string result = await wc.UploadStringTaskAsync(url, WebRequestMethods.Http.Post, jSon); if (result != null) { DetalleLibro detalleLibro = JsonConvert.DeserializeObject <DetalleLibro>(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); switch (detalleLibro.RespEstado.CodRespuesta) { case 2: await ReportProgress(0, $"There are no documents registered for the period {periodo}."); //MessageBox.Show($"There are no documents registered for the period {periodo}.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); case 0: return(detalleLibro.DataResp.Detalles); case 99: MessageBox.Show($"{detalleLibro.RespEstado.MsgeRespuesta}", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); break; case 1: // MessageBox.Show("This option only maintains the detail of the last six months", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop); await ReportProgress(0, "This option only maintains the detail of the last six months."); break; } } } } catch (Exception) { throw; } return(null); }
public async Task <List <Detalle> > GetDebtor(List <Detalle> detalles, string p) { int c = 0; ServiceEvento dataEvento = new ServiceEvento(TokenSii); List <Detalle> detallesFinal = new List <Detalle>(); List <Task <List <Detalle> > > tareas = new List <Task <List <Detalle> > >(); tareas = detalles.Select(async item => { DTEDefType xmlObjeto = null; string nameFile = null; // GET XML FILE nameFile = p + $"\\{UserParticipant.Rut}-{UserParticipant.VerificationCode}\\{item.RutReceptor}-{item.DvReceptor}__{item.Tipo}__{item.Folio}.xml"; if (File.Exists(nameFile)) { xmlObjeto = HSerialize.DTE_To_Object(nameFile); } // GET PARTICPANT INFO FROM CEN ResultParticipant participant = await Participant.GetParticipantByRutAsync(item.RutReceptor.ToString()); if (participant != null && participant.Id > 0) { item.IsParticipant = true; item.ParticipantMising = participant; } if (xmlObjeto != null) { item.DTEDef = xmlObjeto; if (item.IsParticipant) { // GET REFERENCE SEN. DTEDefTypeDocumentoReferencia r = null; GetReferenceCen doc = new GetReferenceCen(item); if (doc != null) { r = doc.DocumentoReferencia; } if (r != null && r.RazonRef != null) { // GET WINDOW. ResultBillingWindow window = await BillingWindow.GetBillingWindowByNaturalKeyAsync(r); // GET MATRIX. if (window != null && window.Id > 0) { List <ResultPaymentMatrix> matrices = await PaymentMatrix.GetPaymentMatrixByBillingWindowIdAsync(window); if (matrices != null && matrices.Count > 0) { ResultPaymentMatrix matrix = matrices.FirstOrDefault(x => x.NaturalKey.Equals(r.RazonRef.Trim(), StringComparison.OrdinalIgnoreCase)); if (matrix != null) { ResultInstruction instruction = await Instruction.GetInstructionDebtorAsync(matrix, participant, UserParticipant); if (instruction != null && instruction.Id > 0) { item.Instruction = instruction; item.Instruction.ParticipantCreditor = participant; item.Instruction.ParticipantDebtor = UserParticipant; } } } } } } } // FLAGS IF EXISTS XML FILE item.ValidatorFlag = new HFlagValidator(item, false); // EVENTS FROM SII item.DataEvento = await dataEvento.GetStatusDteAsync2("Debtor", TokenSii, "33", item, UserParticipant); // STATUS DOC if (item.DataEvento != null) { item.StatusDetalle = GetStatus(item); } // INSERT IN CEN if (item.StatusDetalle == StatusDetalle.Accepted && item.Instruction != null) { // 1 No Facturado y cuando hay más de 1 dte informado 2 Facturado 3 Facturado // con retraso Existe el DTE? ResultDte doc = await Dte.GetDteAsync(item, false); if (doc == null) { // Enviar el DTE ResultDte resultDte = await Dte.SendDteDebtorAsync(item, TokenCen); if (resultDte != null && resultDte.Folio > 0) { item.Instruction.Dte = resultDte; } } else { item.Instruction.Dte = doc; } } detallesFinal.Add(item); c++; float porcent = (float)(100 * c) / detalles.Count; await ReportProgress(porcent, $"Processing 'Pay Instructions' {item.Folio}, wait please. ({c}/{detalles.Count})"); return(detalles); }).ToList(); await Task.WhenAll(tareas); return(detalles.OrderBy(x => x.FechaRecepcion).ToList()); }