using DigitalSystem.Neuronas; using DigitalSystem.WebPortales; using Microsoft.Maui.Controls; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SIPSorcery.Net; using System.Collections; using System.Data; using System.Reflection; using System.Text; using System.Text.Json.Nodes; using System.Text.RegularExpressions; namespace DigitalSystem.Servicios { public class ServiceDataClipboardClase { public string client_id { get; set; } public ServociosGmt serviciosGmt { get; set; } public async void DeCopiado() { MainThread.BeginInvokeOnMainThread(async () => { var negocios = new CapaDeNegocio.CapaDeNegocio(); negocios.commandText = "entry_get_clipboard_portal"; var dt = negocios.ProcesarSolicitudes(); negocios.commandText = "get_clipboard_adjust"; var dt1 = negocios.ProcesarSolicitudes(); negocios.commandText = "get_clipboard_adjust1"; var dt2 = negocios.ProcesarSolicitudes(); var estructurarTextoclipboar = await Clipboard.GetTextAsync(); estructurarTextoclipboar = estructurarTextoclipboar.Replace("\t", "").Replace("\r", ""); foreach (string palabra in estructurarTextoclipboar.Split(' ')) { if (palabra.Contains((char)65533)) { try { var correcta = await SpellClase.instance.Correcciones1(palabra.Replace("\\n", "").Replace("\\t", "")); estructurarTextoclipboar = estructurarTextoclipboar.Replace(palabra, correcta); } catch { } } } estructurarTextoclipboar = Regex.Replace(estructurarTextoclipboar.Normalize(NormalizationForm.FormD), @"\p{Mn}", ""); estructurarTextoclipboar = estructurarTextoclipboar.Normalize(NormalizationForm.FormC); estructurarTextoclipboar = estructurarTextoclipboar.ToUpper(); if (client_id == "9" || client_id == "25") { estructurarTextoclipboar = $"EXPEDIENTE: {estructurarTextoclipboar}"; } var estructurarTexto = estructurarTextoclipboar.Split('\n').ToList(); string estructurarTextoclipboar1 = ""; foreach (string strline in estructurarTexto) { if (estructurarTexto.IndexOf(strline) > 0) { if (estructurarTexto[estructurarTexto.IndexOf(strline) - 1].StartsWith("ID FACTURACION:")) { estructurarTextoclipboar1 += $"\nTITULAR: {Regex.Replace(strline, @"^\s+", "")}"; } else if (estructurarTexto.IndexOf(strline) > 1 && estructurarTexto[estructurarTexto.IndexOf(strline) - 2].StartsWith("ID FACTURACION:")) { estructurarTextoclipboar1 += $"\nMARCA: {Regex.Replace(strline, @"^\s+", "")}"; } else if (estructurarTexto.IndexOf(strline) > 2 && estructurarTexto[estructurarTexto.IndexOf(strline) - 3].StartsWith("ID FACTURACION:")) { estructurarTextoclipboar1 += $"\nREPORTA: {Regex.Replace(strline, @"^\s+", "")}"; } else { estructurarTextoclipboar1 += $"\n{Regex.Replace(strline, @"^\s+", "")}"; } } else { estructurarTextoclipboar1 += $"\n{Regex.Replace(strline, @"^\s+", "")}"; } } estructurarTextoclipboar = estructurarTextoclipboar1; foreach (DataRow dtr in dt2.Rows) { var iniRep = dtr["string_reference"].ToString(); var endRep = dtr["string_reference1"].ToString(); if (!string.IsNullOrEmpty(endRep)) { if (iniRep != "" && endRep != "" && estructurarTextoclipboar.Contains(iniRep) && estructurarTextoclipboar.Contains(endRep)) { var initxReplace = estructurarTextoclipboar.IndexOf(iniRep); var endtxReplace = estructurarTextoclipboar.IndexOf(endRep); if (endtxReplace < initxReplace) { endtxReplace = estructurarTextoclipboar.Substring(initxReplace).IndexOf(endRep) + initxReplace; } if (endtxReplace > initxReplace) { var txReplace = estructurarTextoclipboar.Substring(initxReplace, endtxReplace - initxReplace); var txReplace1 = txReplace.Replace("\n", " "); txReplace1 = txReplace1.Replace(endRep.Replace("\n", ""), $"\n{endRep}"); estructurarTextoclipboar = estructurarTextoclipboar.Replace(txReplace, txReplace1); } } } else { if (iniRep != "" && estructurarTextoclipboar.Contains(iniRep)) { var initxReplace = estructurarTextoclipboar.IndexOf(iniRep); var endtxReplace = estructurarTextoclipboar.Length; if (endtxReplace < initxReplace) { endtxReplace = estructurarTextoclipboar.Substring(initxReplace).IndexOf(endRep) + initxReplace; } if (endtxReplace > initxReplace) { var txReplace = estructurarTextoclipboar.Substring(initxReplace, endtxReplace - initxReplace); var txReplace1 = txReplace.Replace("\n", " "); estructurarTextoclipboar = estructurarTextoclipboar.Replace(txReplace, txReplace1); } } } } foreach (DataRow dtr in dt1.Rows) { estructurarTextoclipboar = estructurarTextoclipboar.Replace(dtr["string_reference"].ToString(), dtr["string_replace"].ToString()); }//ID FACTURACION: await Clipboard.SetTextAsync(estructurarTextoclipboar); estructurarTexto = estructurarTextoclipboar.Split('\n').ToList(); var estructurarTextoX = estructurarTexto.Where(item => item.Contains(":")); foreach (string strline in estructurarTextoX) { var valField = dt.Select($"string_reference like '{strline.Substring(0, strline.IndexOf(":") + 1)}%'"); if (valField.Length > 0) { var valor = strline.Replace(strline.Substring(0, strline.IndexOf(":") + 1), ""); foreach (DataRow dtr in valField) { var campo = serviciosGmt.FindByName(dtr["field"].ToString()); if (dtr["field"].ToString() == "Pentry_municipio_dx" && ((Picker)campo).SelectedIndex > 0) { dtr["field"] = "Pentry_d_municipio_dx"; campo = serviciosGmt.FindByName(dtr["field"].ToString()); } if (dtr["field"].ToString() == "Pentry_colonia_dx" && !string.IsNullOrEmpty(((Entry)campo).Text)) { dtr["field"] = "Pentry_d_colonia_dx"; campo = serviciosGmt.FindByName(dtr["field"].ToString()); } if (dtr["field"].ToString() == "Pentry_calle_dx" && !string.IsNullOrEmpty(((Entry)campo).Text)) { dtr["field"] = "Pentry_d_calle_dx"; campo = serviciosGmt.FindByName(dtr["field"].ToString()); } if (campo != null) { if (campo.GetType().Name == "Entry") { switch (dtr["field"].ToString()) { case "Pentry_colonia_dx": case "Pentry_d_colonia_dx": case "Pentry_calle_dx": case "Pentry_d_calle_dx": case "Pentry_vehiculo": if (dtr["field"].ToString() == "Pentry_colonia_dx") { if (strline.Contains("COLONIA:")) { ((Entry)campo).Text = valor; } else { var endwait = DateTime.Now.Add(TimeSpan.FromSeconds(2)); while (serviciosGmt.sugerenciasColoniaOrigen == null || serviciosGmt.sugerenciasColoniaOrigen.Count == 0) { if (DateTime.Now == endwait) break; } if (serviciosGmt.sugerenciasColoniaOrigen != null) { foreach (var colonias in serviciosGmt.sugerenciasColoniaOrigen) { if (strline.Contains(colonias.colony_dx) && colonias.colony_dx.Length > 4) { ((Entry)campo).Text = colonias.colony_dx; break; } } } else { ((Entry)campo).Text = strline; } } } else if (dtr["field"].ToString() == "Pentry_calle_dx") { if (strline.Contains("CALLE:")) { ((Entry)campo).Text = valor; } else { var endwait = DateTime.Now.Add(TimeSpan.FromSeconds(2)); while (serviciosGmt.sugerenciasCalleOrigen == null || serviciosGmt.sugerenciasCalleOrigen.Count == 0) { if (DateTime.Now == endwait) break; } if (serviciosGmt.sugerenciasCalleOrigen != null) { foreach (var colonias in serviciosGmt.sugerenciasCalleOrigen) { if (strline.Contains(colonias.street_dx) && colonias.street_dx.Length > 4) { ((Entry)campo).Text = colonias.street_dx; break; } } } else { ((Entry)campo).Text = strline; } } } else if (dtr["field"].ToString() == "Pentry_d_colonia_dx") { if (strline.Contains("COLONIA:")) { ((Entry)campo).Text = valor; } else { var endwait = DateTime.Now.Add(TimeSpan.FromSeconds(2)); while (serviciosGmt.sugerenciasColoniaDestino == null || serviciosGmt.sugerenciasColoniaDestino.Count == 0) { if (DateTime.Now == endwait) break; } if (serviciosGmt.sugerenciasColoniaDestino != null) { foreach (var colonias in serviciosGmt.sugerenciasColoniaDestino) { if (strline.Contains(colonias.colony_dx) && colonias.colony_dx.Length > 4) { ((Entry)campo).Text = colonias.colony_dx; break; } } } else { ((Entry)campo).Text = strline; } } } else if (dtr["field"].ToString() == "Pentry_d_calle_dx") { if (strline.Contains("CALLE:")) { ((Entry)campo).Text = valor; } else { var endwait = DateTime.Now.Add(TimeSpan.FromSeconds(2)); while (serviciosGmt.sugerenciasCalleDestino == null || serviciosGmt.sugerenciasCalleDestino.Count == 0) { if (DateTime.Now == endwait) break; } if (serviciosGmt.sugerenciasCalleDestino != null) { foreach (var colonias in serviciosGmt.sugerenciasCalleDestino) { if (strline.Contains(colonias.street_dx) && colonias.street_dx.Length > 4) { ((Entry)campo).Text = colonias.street_dx; break; } } } else { ((Entry)campo).Text = strline; } } } else { ((Entry)campo).Text = valor; } break; default: ((Entry)campo).Text = valor; break; } } else if (campo.GetType().Name == "Picker") { switch (dtr["field"].ToString()) { case "Pentry_municipio_dx": case "Pentry_d_municipio_dx": case "Pentry_brand_id": if (((Picker)campo).SelectedIndex <= 0 && ((Picker)campo).Items.Count > 0) { var valores = ((Picker)campo).Items; if (valor.Contains(",")) { if (dtr["field"].ToString() == "Pentry_municipio_dx" || dtr["field"].ToString() == "Pentry_d_municipio_dx") { if (valor.Split(',').Length > 3) { foreach (var xitems in valores) { if (valor.Split(',').Length > 2) if (valor.Split(',')[2].Contains(xitems)) { { ((Picker)campo).SelectedIndex = valores.IndexOf(xitems); break; } } } if (((Picker)campo).SelectedIndex <= 0 && valor.Split(',').Length > 3) { foreach (var xitems in valores) { if (valor.Split(',')[3].Contains(xitems)) { ((Picker)campo).SelectedIndex = valores.IndexOf(xitems); break; } } } } else { foreach (var xitems in valores) { if (valor.Contains(xitems)) { ((Picker)campo).SelectedIndex = valores.IndexOf(xitems); break; } } } } } else { foreach (var xitems in valores) { if (valor.Contains(xitems)) { ((Picker)campo).SelectedIndex = valores.IndexOf(xitems); break; } } } } else if (((Picker)campo).Items.Count > 0) { var valores = ((Picker)campo).Items; if (valor.Contains(",")) { if (dtr["field"].ToString() == "Pentry_d_municipio_dx") { foreach (var xitems in valores) { if (valor.Split(',').Length > 2) { if (valor.Split(',')[2].Contains(xitems)) { ((Picker)campo).SelectedIndex = valores.IndexOf(xitems); break; } } } if (((Picker)campo).SelectedIndex <= 0 && valor.Split(',').Length > 3) { foreach (var xitems in valores) { if (valor.Split(',')[3].Contains(xitems) && valor.Split(',').Length > 3) { ((Picker)campo).SelectedIndex = valores.IndexOf(xitems); break; } } } } } else { if (dtr["field"].ToString() == "Pentry_d_municipio_dx") { foreach (var xitems in valores) { if (valor.Contains(xitems)) { ((Picker)campo).SelectedIndex = valores.IndexOf(xitems); break; } } } } } break; default: var valoresx = ((Picker)campo).Items; foreach (var xitems in valoresx) { if (valor.Contains(xitems)) { ((Picker)campo).SelectedIndex = valoresx.IndexOf(xitems); break; } } break; } } } } } } var vehiculo = (Entry)serviciosGmt.FindByName("Pentry_vehiculo"); var modelo = (Picker)serviciosGmt.FindByName("Pentry_modelo"); var color = (Picker)serviciosGmt.FindByName("Pentry_color"); if (!string.IsNullOrEmpty(vehiculo.Text)) { if (modelo.SelectedIndex > 0) vehiculo.Text = vehiculo.Text.Replace(modelo.Items[modelo.SelectedIndex], ""); if (color.SelectedIndex > 0) vehiculo.Text = vehiculo.Text.Replace(color.Items[color.SelectedIndex], ""); } ((Entry)serviciosGmt.FindByName("Pentry_autoriza")).Text = "PORTAL"; ((Entry)serviciosGmt.FindByName("Pentry_falla")).Text = "MECANICA"; ((Picker)serviciosGmt.FindByName("Pentry_tiempo_arribo_id")).SelectedIndex = 2; serviciosGmt.OcultarCampos(); await Task.Delay(2000); ((Entry)serviciosGmt.FindByName("Pentry_vehiculo")).Focus(); await Task.Delay(500); ((Entry)serviciosGmt.FindByName("Pentry_falla")).Focus(); }); } public async void DeCopiado1() { var negocio = new CapaDeNegocio.CapaDeNegocio(); negocio.commandText = "entry_get_clipboard_portal"; var dt = negocio.ProcesarSolicitudes(); var clipboardData = await Clipboard.GetTextAsync(); clipboardData = clipboardData.ToUpper().Replace("\r", "").Replace("\t", " "); if (clipboardData.Contains((char)65533)) { var palabrasori = clipboardData.Split(' ').ToList().Where(item => item.Contains((char)65533)); if (palabrasori.Count() > 0) { foreach (var palabra in palabrasori) { try { var correcta = await SpellClase.instance.Correcciones1(palabra.Replace("\\n", "").Replace("\\t", "")); clipboardData = clipboardData.Replace(palabra, correcta); } catch { } } } } clipboardData = Regex.Replace(clipboardData.Normalize(NormalizationForm.FormD), @"\p{Mn}", ""); clipboardData = clipboardData.Normalize(NormalizationForm.FormC); clipboardData = clipboardData.ToUpper(); if (clipboardData.Contains("ESPECIFICACIONES GENERALES\n")) { clipboardData = $"DETALLE DEL REPORTE:{clipboardData}"; } var valsData = new List>(); foreach (DataRow dtr in dt.Rows) { var Pentry_expediente = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_titular = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_modelo = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_color = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_municipio_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_calle_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_colonia_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_ubicacion = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_QuienRecibe = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_vehiculo = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_brand_id = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_destino = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_placas = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_vin = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_falla = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_marca = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var sSubClient = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_contacto = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var sExpediente = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_d_municipio_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_d_colonia_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_d_calle_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_placa = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_autoriza = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_d_destino = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); if (dtr["string_next"].ToString() != "") { if (!string.IsNullOrEmpty(Pentry_expediente.Groups[1].Value)) { Pentry_expediente = Regex.Match(Pentry_expediente.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_titular.Groups[1].Value)) { Pentry_titular = Regex.Match(Pentry_titular.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_modelo.Groups[1].Value)) { Pentry_modelo = Regex.Match(Pentry_modelo.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_color.Groups[1].Value)) { Pentry_color = Regex.Match(Pentry_color.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_municipio_dx.Groups[1].Value)) { Pentry_municipio_dx = Regex.Match(Pentry_municipio_dx.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_calle_dx.Groups[1].Value)) { Pentry_calle_dx = Regex.Match(Pentry_calle_dx.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_colonia_dx.Groups[1].Value)) { Pentry_colonia_dx = Regex.Match(Pentry_colonia_dx.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_ubicacion.Groups[1].Value)) { Pentry_ubicacion = Regex.Match(Pentry_ubicacion.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_QuienRecibe.Groups[1].Value)) { Pentry_QuienRecibe = Regex.Match(Pentry_QuienRecibe.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_vehiculo.Groups[1].Value)) { Pentry_vehiculo = Regex.Match(Pentry_vehiculo.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_brand_id.Groups[1].Value)) { Pentry_brand_id = Regex.Match(Pentry_brand_id.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_destino.Groups[1].Value)) { Pentry_destino = Regex.Match(Pentry_destino.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_placas.Groups[1].Value)) { Pentry_placas = Regex.Match(Pentry_placas.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_vin.Groups[1].Value)) { Pentry_vin = Regex.Match(Pentry_vin.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_falla.Groups[1].Value)) { Pentry_falla = Regex.Match(Pentry_falla.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_marca.Groups[1].Value)) { Pentry_marca = Regex.Match(Pentry_marca.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(sSubClient.Groups[1].Value)) { sSubClient = Regex.Match(sSubClient.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_contacto.Groups[1].Value)) { Pentry_contacto = Regex.Match(Pentry_contacto.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(sExpediente.Groups[1].Value)) { sExpediente = Regex.Match(sExpediente.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_d_municipio_dx.Groups[1].Value)) { Pentry_d_municipio_dx = Regex.Match(Pentry_d_municipio_dx.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_d_colonia_dx.Groups[1].Value)) { Pentry_d_colonia_dx = Regex.Match(Pentry_d_colonia_dx.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_d_calle_dx.Groups[1].Value)) { Pentry_d_calle_dx = Regex.Match(Pentry_d_calle_dx.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_placa.Groups[1].Value)) { Pentry_placa = Regex.Match(Pentry_placa.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_autoriza.Groups[1].Value)) { Pentry_autoriza = Regex.Match(Pentry_autoriza.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } if (!string.IsNullOrEmpty(Pentry_d_destino.Groups[1].Value)) { Pentry_d_destino = Regex.Match(Pentry_d_destino.Groups[1].Value, $@"(\w.+)\s+{dtr["string_next"].ToString()}"); } } if (!string.IsNullOrEmpty(Pentry_expediente.Groups[1].Value)) { valsData.Add(new List { Pentry_expediente.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_titular.Groups[1].Value)) { valsData.Add(new List { Pentry_titular.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_modelo.Groups[1].Value)) { valsData.Add(new List { Pentry_modelo.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_color.Groups[1].Value)) { valsData.Add(new List { Pentry_color.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_municipio_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_municipio_dx.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_calle_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_calle_dx.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_colonia_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_colonia_dx.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_ubicacion.Groups[1].Value)) { valsData.Add(new List { Pentry_ubicacion.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_QuienRecibe.Groups[1].Value)) { valsData.Add(new List { Pentry_QuienRecibe.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_vehiculo.Groups[1].Value)) { valsData.Add(new List { Pentry_vehiculo.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_brand_id.Groups[1].Value)) { valsData.Add(new List { Pentry_brand_id.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_destino.Groups[1].Value)) { valsData.Add(new List { Pentry_destino.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_placas.Groups[1].Value)) { valsData.Add(new List { Pentry_placas.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_vin.Groups[1].Value)) { valsData.Add(new List { Pentry_vin.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_falla.Groups[1].Value)) { valsData.Add(new List { Pentry_falla.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_marca.Groups[1].Value)) { valsData.Add(new List { Pentry_marca.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(sSubClient.Groups[1].Value)) { valsData.Add(new List { sSubClient.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_contacto.Groups[1].Value)) { valsData.Add(new List { Pentry_contacto.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(sExpediente.Groups[1].Value)) { valsData.Add(new List { sExpediente.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_d_municipio_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_d_municipio_dx.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_d_colonia_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_d_colonia_dx.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_d_calle_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_d_calle_dx.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_placa.Groups[1].Value)) { valsData.Add(new List { Pentry_placa.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_autoriza.Groups[1].Value)) { valsData.Add(new List { Pentry_autoriza.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_d_destino.Groups[1].Value)) { valsData.Add(new List { Pentry_d_destino.Groups[1].Value.Replace("\n", " "), dtr["field"].ToString() }); } } var valsData1 = valsData.GroupBy(item => item[1]); var valsData2 = new List>(); foreach (var dataX in valsData1) { valsData2.Add(dataX.ToList()[0]); } foreach (var dataX in valsData2) { var data = (List)dataX; var campo = (View)serviciosGmt.FindByName(data[1]); if (campo != null) { switch (campo.GetType().Name) { case "Entry": ((Entry)campo).Text = data[0]; break; case "Picker": var marca = ((Picker)campo).Items.IndexOf(((Picker)campo).Items.FirstOrDefault(item => data[0].Contains(item))); ((Picker)campo).SelectedIndex = marca; break; } } } } public async void DeCopiado2() { var negocio = new CapaDeNegocio.CapaDeNegocio(); negocio.commandText = "entry_get_clipboard_portal"; var dt = negocio.ProcesarSolicitudes(); var clipboardData = await Clipboard.GetTextAsync(); clipboardData = clipboardData.ToUpper().Replace("\r","").Replace("\t"," "); if (clipboardData.Contains((char)65533)) { var palabrasori = clipboardData.Split(' ').ToList().Where(item => item.Contains((char)65533)); if (palabrasori.Count() > 0) { foreach (var palabra in palabrasori) { try { var correcta = await SpellClase.instance.Correcciones1(palabra.Replace("\\n", "").Replace("\\t", "")); clipboardData = clipboardData.Replace(palabra, correcta); } catch { } } } } var valsData = new List>(); foreach (DataRow dtr in dt.Rows) { var Pentry_expediente = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_titular = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_modelo = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_color = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_municipio_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_calle_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_colonia_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_ubicacion = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_QuienRecibe = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_vehiculo = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_brand_id = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_destino = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_placas = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_vin = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_falla = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_marca = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var sSubClient = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_contacto = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var sExpediente = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_d_municipio_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_d_colonia_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_d_calle_dx = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_placa = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_autoriza = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); var Pentry_d_destino = Regex.Match(clipboardData, $@"{dtr["string_reference"].ToString()}\s*(\w.+)"); if (dtr["string_next"].ToString() != "") { if (!string.IsNullOrEmpty(Pentry_expediente.Groups[1].Value)) { Pentry_expediente = Regex.Match(Pentry_expediente.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_titular.Groups[1].Value)) { Pentry_titular = Regex.Match(Pentry_titular.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_modelo.Groups[1].Value)) { Pentry_modelo = Regex.Match(Pentry_modelo.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_color.Groups[1].Value)) { Pentry_color = Regex.Match(Pentry_color.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_municipio_dx.Groups[1].Value)) { Pentry_municipio_dx = Regex.Match(Pentry_municipio_dx.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_calle_dx.Groups[1].Value)) { Pentry_calle_dx = Regex.Match(Pentry_calle_dx.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_colonia_dx.Groups[1].Value)) { Pentry_colonia_dx = Regex.Match(Pentry_colonia_dx.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_ubicacion.Groups[1].Value)) { Pentry_ubicacion = Regex.Match(Pentry_ubicacion.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_QuienRecibe.Groups[1].Value)) { Pentry_QuienRecibe = Regex.Match(Pentry_QuienRecibe.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_vehiculo.Groups[1].Value)) { Pentry_vehiculo = Regex.Match(Pentry_vehiculo.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_brand_id.Groups[1].Value)) { Pentry_brand_id = Regex.Match(Pentry_brand_id.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_destino.Groups[1].Value)) { Pentry_destino = Regex.Match(Pentry_destino.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_placas.Groups[1].Value)) { Pentry_placas = Regex.Match(Pentry_placas.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_vin.Groups[1].Value)) { Pentry_vin = Regex.Match(Pentry_vin.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_falla.Groups[1].Value)) { Pentry_falla = Regex.Match(Pentry_falla.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_marca.Groups[1].Value)) { Pentry_marca = Regex.Match(Pentry_marca.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(sSubClient.Groups[1].Value)) { sSubClient = Regex.Match(sSubClient.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_contacto.Groups[1].Value)) { Pentry_contacto = Regex.Match(Pentry_contacto.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(sExpediente.Groups[1].Value)) { sExpediente = Regex.Match(sExpediente.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_d_municipio_dx.Groups[1].Value)) { Pentry_d_municipio_dx = Regex.Match(Pentry_d_municipio_dx.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_d_colonia_dx.Groups[1].Value)) { Pentry_d_colonia_dx = Regex.Match(Pentry_d_colonia_dx.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_d_calle_dx.Groups[1].Value)) { Pentry_d_calle_dx = Regex.Match(Pentry_d_calle_dx.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_placa.Groups[1].Value)) { Pentry_placa = Regex.Match(Pentry_placa.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_autoriza.Groups[1].Value)) { Pentry_autoriza = Regex.Match(Pentry_autoriza.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} if (!string.IsNullOrEmpty(Pentry_d_destino.Groups[1].Value)) { Pentry_d_destino = Regex.Match(Pentry_d_destino.Groups[1].Value,$@"(\w.+)\s+{dtr["string_next"].ToString()}");} } if (!string.IsNullOrEmpty(Pentry_expediente.Groups[1].Value)) { valsData.Add(new List { Pentry_expediente.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_titular.Groups[1].Value)) { valsData.Add(new List { Pentry_titular.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_modelo.Groups[1].Value)) { valsData.Add(new List { Pentry_modelo.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_color.Groups[1].Value)) { valsData.Add(new List { Pentry_color.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_municipio_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_municipio_dx.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_calle_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_calle_dx.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_colonia_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_colonia_dx.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_ubicacion.Groups[1].Value)) { valsData.Add(new List { Pentry_ubicacion.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_QuienRecibe.Groups[1].Value)) { valsData.Add(new List { Pentry_QuienRecibe.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_vehiculo.Groups[1].Value)) { valsData.Add(new List { Pentry_vehiculo.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_brand_id.Groups[1].Value)) { valsData.Add(new List { Pentry_brand_id.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_destino.Groups[1].Value)) { valsData.Add(new List { Pentry_destino.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_placas.Groups[1].Value)) { valsData.Add(new List { Pentry_placas.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_vin.Groups[1].Value)) { valsData.Add(new List { Pentry_vin.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_falla.Groups[1].Value)) { valsData.Add(new List { Pentry_falla.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_marca.Groups[1].Value)) { valsData.Add(new List { Pentry_marca.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(sSubClient.Groups[1].Value)) { valsData.Add(new List { sSubClient.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_contacto.Groups[1].Value)) { valsData.Add(new List { Pentry_contacto.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(sExpediente.Groups[1].Value)) { valsData.Add(new List { sExpediente.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_d_municipio_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_d_municipio_dx.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_d_colonia_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_d_colonia_dx.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_d_calle_dx.Groups[1].Value)) { valsData.Add(new List { Pentry_d_calle_dx.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_placa.Groups[1].Value)) { valsData.Add(new List { Pentry_placa.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_autoriza.Groups[1].Value)) { valsData.Add(new List { Pentry_autoriza.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } if (!string.IsNullOrEmpty(Pentry_d_destino.Groups[1].Value)) { valsData.Add(new List { Pentry_d_destino.Groups[1].Value.Replace("\n"," "), dtr["field"].ToString() }); } } } } }