public int IdAgente(string codigoAgente, string rutaEmpresa) { int dbResponse, agentId = 0, fqResult; StringBuilder sbDBAgente = new StringBuilder(31); int connection = AdminPaqLib.dbLogIn("", rutaEmpresa); if (connection == 0) { ErrLogger.Log("Connection not allowed in adminpaq for concepts"); return(0); } dbResponse = AdminPaqLib.dbGetTopNoLock(connection, "MGW10001", "PRIMARYKEY"); if (dbResponse == 4) { ErrLogger.Log("La ruta de la empresa es incorrecta."); return(0); } while (dbResponse == 0) { fqResult = AdminPaqLib.dbFieldChar(connection, "MGW10001", 2, sbDBAgente, 31); if (sbDBAgente.ToString().Substring(0, 30).Trim().ToUpper().Equals(codigoAgente.Trim().ToUpper())) { fqResult = AdminPaqLib.dbFieldLong(connection, "MGW10001", 1, ref agentId); break; } dbResponse = AdminPaqLib.dbSkip(connection, "MGW10001", "PRIMARYKEY", 1); } AdminPaqLib.dbLogOut(connection); return(agentId); }
public bool CodigoDocoValido(string codigoDoco, string rutaEmpresa) { Dictionary <string, int> connections = new Dictionary <string, int>(); connections.Add("concepts", AdminPaqLib.dbLogIn("", rutaEmpresa)); long conceptId = ConceptId(int.Parse(codigoDoco), connections); ReleaseConnections(connections); return(conceptId != 0); }
public void RetrieveSales(Empresa empresa) { //DateTime today = DateTime.Today; DateTime today = new DateTime(2014, 4, 12); int weekStartDelta = 1 - (int)today.DayOfWeek; DateTime weekStart = today.AddDays(weekStartDelta); DateTime weeksAgo = weekStart.AddDays(-21); DateTime saleDate = weeksAgo; Dictionary <string, int> connections = new Dictionary <string, int>(); connections.Add("documents", AdminPaqLib.dbLogIn("", empresa.Ruta)); connections.Add("concepts", AdminPaqLib.dbLogIn("", empresa.Ruta)); while (saleDate <= today) { RetrieveSales(saleDate, empresa, connections); saleDate = saleDate.AddDays(1); } ReleaseConnections(connections); }
public void InitializeSDK() { int connEmpresas, dbResponse, fieldResponse; connEmpresas = AdminPaqLib.dbLogIn("", lib.DataDirectory); if (connEmpresas == 0) { ErrLogger.Log("No se pudo crear conexión a la tabla de Empresas de AdminPAQ."); return; } dbResponse = AdminPaqLib.dbGetTopNoLock(connEmpresas, TableNames.EMPRESAS, IndexNames.EMPRESAS_PK); while (dbResponse == 0) { Empresa empresa = new Empresa(); int idEmpresa = 0; fieldResponse = AdminPaqLib.dbFieldLong(connEmpresas, TableNames.EMPRESAS, Empresa.ID_EMPRESA, ref idEmpresa); empresa.Id = idEmpresa; StringBuilder nombreEmpresa = new StringBuilder(151); fieldResponse = AdminPaqLib.dbFieldChar(connEmpresas, TableNames.EMPRESAS, Empresa.NOMBRE_EMPRESA, nombreEmpresa, 151); string sNombreEmpresa = nombreEmpresa.ToString(0, 150).Trim(); empresa.Nombre = sNombreEmpresa; StringBuilder rutaEmpresa = new StringBuilder(254); fieldResponse = AdminPaqLib.dbFieldChar(connEmpresas, TableNames.EMPRESAS, Empresa.RUTA_EMPRESA, rutaEmpresa, 254); string sRutaEmpresa = rutaEmpresa.ToString(0, 253).Trim(); empresa.Ruta = sRutaEmpresa; empresas.Add(empresa); dbResponse = AdminPaqLib.dbSkip(connEmpresas, TableNames.EMPRESAS, IndexNames.EMPRESAS_PK, 1); } AdminPaqLib.dbLogOut(connEmpresas); }