public DataSet TPVQueueResponse(string Id, bool Result, string Fecha, string Hora, string Msg) { if ((DBUser == null) || (DBUser.UserCode == "")) return MiddleWareTPVCentral.Utilidades.GenerarError("", "TPVResponse()", "ERROR: No se ha validado, debe abrir login"); try { NavisionDBTable dt = new NavisionDBTable(this.Connection, this.DBUser); NavisionDBAdapter da = new NavisionDBAdapter(); DataSet ds = new DataSet(); dt.TableName = "TPV Response"; da.AddTable(dt); ds = dt.GenerateStructure(); DataRow dr = ds.Tables[0].NewRow(); dr["Entry No."] = 0; dr["ID"] = Id; dr["Shop Code"] = DBUser.UserCode; if (!String.IsNullOrEmpty(Fecha)) { DateTime FechaDT = DateTime.Parse(Fecha); dr["Execution Date"] = FechaDT.ToString("dd/MM/yyyy"); } else { dr["Execution Date"] = DateTime.Now.ToString("dd/MM/yyyy"); } if (!String.IsNullOrEmpty(Hora)) { DateTime HoraDT = DateTime.Parse(Hora); dr["Execution Time"] = HoraDT.ToString("HH:mm:ss"); } else { dr["Execution Time"] = DateTime.Now.ToString("HH:mm:ss"); } int len = Msg.Length; if (len < 250) { dr["Message 1"] = Msg.Substring(0, len); } else { dr["Message 1"] = Msg.Substring(0, 250); } if (Msg.Length > 250) { len -= 250; if (len < 250) { dr["Message 2"] = Msg.Substring(250, len); } else { dr["Message 2"] = Msg.Substring(250, 250); } } if (Msg.Length > 500) { len -= 250; if (len < 250) { dr["Message 3"] = Msg.Substring(500, len); } else { dr["Message 3"] = Msg.Substring(500, 250); } } if (Msg.Length > 750) { len -= 250; if (len < 250) { dr["Message 4"] = Msg.Substring(750, len); } else { dr["Message 4"] = Msg.Substring(750, 250); } } if (Result) { dr["Status"] = "Success"; } else { dr["Status"] = "Error"; } ds.Tables[0].Rows.Add(dr); da.InsertItem = ds; try { this.Connection.BWT(); da.Update(); this.Connection.EWT(); } catch (Exception ex) { this.Connection.AWT(); return MiddleWareTPVCentral.Utilidades.GenerarError(this.DBUser.UserCode, "TPVResponse(): ", ex.Message); } return Utilidades.GenerarResultado("Ok"); } catch (Exception ex) { return MiddleWareTPVCentral.Utilidades.GenerarError(this.DBUser.UserCode, "TPVResponse(): ", ex.Message); } }
private void InsertTicketPendiente(string tipoDocumento, string documentNo, string codTienda, string codTPV, string fechaDocumento, int errorEnvio) { NavisionDBTable errorTable = new NavisionDBTable(this.Connection, this.DBUser); NavisionDBAdapter errorAdapter = new NavisionDBAdapter(); DataSet TicketPendiente = new DataSet(); errorTable.TableNo = 50074; //Ticket Pendiente errorAdapter.AddTable(errorTable); TicketPendiente = errorTable.GenerateStructure(); DataRow TicketPendienteRow = TicketPendiente.Tables[0].NewRow(); TicketPendienteRow["Tipo documento"] = tipoDocumento; TicketPendienteRow["Nº documento"] = documentNo; TicketPendienteRow["Cód. tienda"] = codTienda; TicketPendienteRow["Cód. TPV"] = codTPV; TicketPendienteRow["Fecha documento"] = fechaDocumento; TicketPendienteRow["Error envío"] = errorEnvio; TicketPendiente.Tables[0].Rows.Add(TicketPendienteRow); errorAdapter.InsertItem = TicketPendiente; try { errorTable.ConnectionDB.BWT(); errorAdapter.Update(); errorTable.ConnectionDB.EWT(); } catch (Exception) { errorTable.ConnectionDB.AWT(); } }
public DataSet TPVQueueRequest(string Fecha) { if ((DBUser == null) || (DBUser.UserCode == "")) return MiddleWareTPVCentral.Utilidades.GenerarError("", "TPVQueueRequest()", "ERROR: No se ha validado, debe abrir login"); try { NavisionDBTable dt = new NavisionDBTable(this.Connection, this.DBUser); NavisionDBAdapter da = new NavisionDBAdapter(); DataSet ds = new DataSet(); dt.TableName = "TPV Request"; dt.AddColumn("ID"); dt.AddColumn("Expiration Date/Time"); dt.AddColumn("Earliest Start Date/Time"); dt.AddColumn("Object Type to Run"); dt.AddColumn("Object ID to Run"); dt.AddColumn("Maximum No. of Attempts to Run"); dt.AddColumn("Status"); dt.AddColumn("Priority"); dt.AddColumn("Parameter String"); dt.AddColumn("Recurring Job"); dt.AddColumn("No. of Minutes between Runs"); dt.AddColumn("Run on Mondays"); dt.AddColumn("Run on Tuesdays"); dt.AddColumn("Run on Wednesdays"); dt.AddColumn("Run on Thursdays"); dt.AddColumn("Run on Fridays"); dt.AddColumn("Run on Saturdays"); dt.AddColumn("Run on Sundays"); dt.AddColumn("Starting Time"); dt.AddColumn("Ending Time"); dt.AddColumn("Synch Results"); dt.KeyInNavisionFormat = "Shop Code,Creation Date,Active"; dt.AddFilter("Shop Code", DBUser.UserCode + "|''"); if (!String.IsNullOrEmpty(Fecha)) { dt.AddFilter("Creation Date", DateTime.Parse(Fecha).ToString("dd/MM/yyyy") + ".."); } dt.AddFilter("Active", "true"); da.AddTable(dt); da.Fill(ref ds, false); Utilidades.CompletarDataSet(ref ds, false, false); //string guid = ds.Tables[0].Rows[0].ItemArray.GetValue(0).ToString(); da = new NavisionDBAdapter(); dt.Reset(); DataSet dsLog = new DataSet(); dt.TableName = "TPV Response"; da.AddTable(dt); dsLog = dt.GenerateStructure(); DataRow dr; int lItems = ds.Tables[0].Rows.Count; for (int i = 0; i < lItems; i++) { dr = dsLog.Tables[0].NewRow(); dr["Entry No."] = 0; dr["ID"] = "{" + ds.Tables[0].Rows[i].ItemArray.GetValue(0).ToString() + "}"; dr["Shop Code"] = DBUser.UserCode; dr["Status"] = "Downloaded"; dr["Execution Date"] = DateTime.Now.ToString("dd/MM/yyyy"); dr["Execution Time"] = DateTime.Now.ToString("HH:mm:ss"); dsLog.Tables[0].Rows.Add(dr); } da.InsertItem = dsLog; try { this.Connection.BWT(); da.Update(); this.Connection.EWT(); } catch (Exception excep) { this.Connection.AWT(); throw new Exception("TPVQueueRequest(): " + excep.Message); } return ds; } catch (Exception ex) { return MiddleWareTPVCentral.Utilidades.GenerarError(this.DBUser.UserCode, "TPVQueueRequest(): ", ex.Message); } }