public LedorVadorResponse SendPackages(LedorVadorRequest request) { LedorVadorResponse response = new LedorVadorResponse(); int aceptados = 0, omitidos = 0; string warningMsg = "", exceptionMsg = ""; // DbHandler db = new DbHandler(ConfigurationManager.ConnectionStrings["db"].ConnectionString); request.login = ConfigurationManager.AppSettings.Get("LOGIN"); request.password = ConfigurationManager.AppSettings.Get("PASS"); db.Using(request.login, request.password, (SqlConnection conn) => { // foreach (LedorVadorFlowPackage package in request.packages) { try { logger.write("Leyendo documento " + package.documento_externId + " cliente " + package.histClinica + " " + package.razonSocial); string localWarningMsg = ""; localWarningMsg = CheckPackage(package); if (localWarningMsg == "") //Si se genero un mensaje de warning se omite directamente el paquete. { localWarningMsg = savePackage(db, conn, package); if (localWarningMsg == "") { try { response.documentosAceptados.Add(Int32.Parse(package.documento_externId)); } catch (Exception e) { localWarningMsg = "[" + e.Message + "]"; } } } warningMsg += localWarningMsg; aceptados++; } catch (Exception e) { try { response.documentosOmitidos.Add(Int32.Parse(package.documento_externId)); } catch (Exception ex) { warningMsg += "[" + ex.Message + "]"; } logger.write(e.ToString()); exceptionMsg += Environment.NewLine + e.ToString().Substring(0, 300); omitidos++; } } // }, (string exMessage) => { exceptionMsg += Environment.NewLine + exMessage.Substring(0, 300); }); // response.responseMessage = " Aceptados [" + aceptados + "]"; response.responseMessage += " Omitidos [" + omitidos + "]"; if (warningMsg != "") { response.responseMessage += " Warning [" + warningMsg + "]"; } if (exceptionMsg != "") { response.responseMessage += Environment.NewLine + " ServerExceptions [" + exceptionMsg + "]"; } return(response); }
public LedorVadorResponse SendPackages(LedorVadorRequest request) { LedorVadorResponse response = new LedorVadorResponse(); int aceptados = 0, omitidos = 0; string warningMsg = "", exceptionMsg = ""; // DbHandler db = new DbHandler(ConfigurationManager.ConnectionStrings["db"].ConnectionString); request.login = ConfigurationManager.AppSettings.Get("LOGIN"); request.password = ConfigurationManager.AppSettings.Get("PASS"); db.Using(request.login, request.password, (SqlConnection conn) => { // foreach (LedorVadorFlowPackage package in request.packages) { try { logger.write("Leyendo documento " + package.documento_externId + " cliente " + package.histClinica + " " + package.razonSocial); string localWarningMsg = ""; localWarningMsg = CheckPackage(package); if (localWarningMsg == "") { //Si se genero un mensaje de warning se omite directamente el paquete. localWarningMsg = savePackage(db, conn, package); if (localWarningMsg == "") { try { response.documentosAceptados.Add(Int32.Parse(package.documento_externId)); } catch (Exception e) { localWarningMsg = "[" + e.Message + "]"; } } } warningMsg += localWarningMsg; aceptados++; } catch (Exception e) { try { response.documentosOmitidos.Add(Int32.Parse(package.documento_externId)); } catch (Exception ex) { warningMsg += "[" + ex.Message + "]"; } logger.write(e.ToString()); exceptionMsg += Environment.NewLine + e.ToString().Substring(0, 300); omitidos++; } } // }, (string exMessage) => { exceptionMsg += Environment.NewLine + exMessage.Substring(0, 300); }); // response.responseMessage = " Aceptados [" + aceptados + "]"; response.responseMessage += " Omitidos [" + omitidos + "]"; if (warningMsg != "") { response.responseMessage += " Warning [" + warningMsg + "]"; } if (exceptionMsg != "") { response.responseMessage += Environment.NewLine + " ServerExceptions [" + exceptionMsg + "]"; } return response; }
public static void LedorVadorServiceASMXTestUnit() { List <LedorVadorFlowPackage> packages = new List <LedorVadorFlowPackage>(); packages.Add(new LedorVadorFlowPackage() { histClinica = Convert.ToInt32(ConfigurationManager.AppSettings.Get("HistClinica")), razonSocial = ConfigurationManager.AppSettings.Get("RazonSocial"), empresaPropia = Convert.ToInt32(ConfigurationManager.AppSettings.Get("EmpresaID_Propia")), documento_externId = ConfigurationManager.AppSettings.Get("Documento_ExternID"), establecimiento_numero = ConfigurationManager.AppSettings.Get("Establecimiento_Numero"), documento_numero = ConfigurationManager.AppSettings.Get("Documento_Numero"), fecha = DateTime.Now, observacion = ConfigurationManager.AppSettings.Get("Observacion"), tipoServicioId = Convert.ToInt32(ConfigurationManager.AppSettings.Get("TipoServicioID")), tipoImpuestoId_Iva = Convert.ToInt32(ConfigurationManager.AppSettings.Get("TipoImpuestoID_IVA")), cantidad = Convert.ToDouble(ConfigurationManager.AppSettings.Get("Cantidad")), importeUnitario = Convert.ToDouble(ConfigurationManager.AppSettings.Get("ImporteUnitario")) }); LedorVadorRequest request = new LedorVadorRequest() { login = ConfigurationManager.AppSettings.Get("login"), password = ConfigurationManager.AppSettings.Get("pass"), packages = packages.ToArray() }; SendPackagesRequest req = new SendPackagesRequest() { Body = new SendPackagesRequestBody(request) }; try { LVASMX_SMG01.LVServiceSoapClient client = new LVServiceSoapClient(); SendPackagesResponse resp = client.SendPackages(req); LedorVadorResponse response = resp.Body.SendPackagesResult; Console.WriteLine(response.responseMessage); } catch (Exception e) { Console.WriteLine("[LedorVadorFlowService TestUnit Exception][Posible EnpointAdress nulo][" + e.ToString().Substring(0, 300) + "]"); } Console.ReadKey(); }