public void SendSMS(Sms sms) { string urlRequest; if (sms.Message.Length > 150) { sms.Message = sms.Message.Substring(0, 150); } urlRequest = string.Format(REQUEST, API_URL, userName, password, sms.To, Uri.EscapeUriString(sms.Message)); WebRequest request = WebRequest.Create(urlRequest); Stream oStream = request.GetResponse().GetResponseStream(); StreamReader objReader = new StreamReader(oStream); string sLine = ""; int i = 0; while (sLine != null) { i++; sLine = objReader.ReadLine(); if (sLine != null && sLine.Contains("ERROR")) { ErrLogger.Log(sLine); } } }
private void textBoxClient_TextChanged(object sender, EventArgs e) { if (comboBoxClientName.Text.Trim().Equals(string.Empty) || inCustSelection) { return; } try { DataTable dtCustomers = dbCustomer.ReadCustomers(); foreach (DataRow dr in dtCustomers.Rows) { if (dr["nombre_cliente"].ToString().ToLower().Equals(comboBoxClientName.Text.Trim().ToLower())) { comboBoxClient.Text = dr["cd_cliente"].ToString(); } } comboBoxSerie.DataSource = dbCustomer.SeriesFromCustomer(comboBoxClient.Text); inCustNameTyping = false; }catch (Exception ex) { ErrLogger.Log(ex.StackTrace); MessageBox.Show("No fue posible consultar el código del cliente en la base de datos. Intente más tarde: \n" + ex.Message, "Error al obtener nombre del cliente", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private static DocumentConcept GetDocumentConcept(int docId, string filePath) { DocumentConcept response = null; int connDocos, dbResponse, fqResponse; StringBuilder sConceptCode = new StringBuilder(31); StringBuilder sConceptName = new StringBuilder(61); string key, conceptCode, conceptName; connDocos = AdminPaqLib.dbLogIn("", filePath); if (connDocos == 0) { ErrLogger.Log("Unable to open connection to concepts table from [" + filePath + "]"); return(response); } key = docId.ToString().PadLeft(11); dbResponse = AdminPaqLib.dbGetNoLock(connDocos, TableNames.CONCEPTOS_DOCUMENTOS, IndexNames.PRIMARY_KEY, key); if (dbResponse == 0) { fqResponse = AdminPaqLib.dbFieldChar(connDocos, TableNames.CONCEPTOS_DOCUMENTOS, 2, sConceptCode, 31); conceptCode = sConceptCode.ToString().Substring(0, 30).Trim(); fqResponse = AdminPaqLib.dbFieldChar(connDocos, TableNames.CONCEPTOS_DOCUMENTOS, 3, sConceptName, 61); conceptName = sConceptName.ToString().Substring(0, 60).Trim(); response = new DocumentConcept(); response.Id = docId; response.Code = conceptCode; response.Name = conceptName; } AdminPaqLib.dbLogOut(connDocos); return(response); }
private string GetPassWord(string companyCode, string userName) { string correctPassword = null; try { string sql = ""; sql = " SELECT PSWRD "; sql += "FROM TESTUSERS "; sql += "WHERE ECODE = '" + userName + "' "; dTable = new DataTable(); dTable = RetrieveInDataTable(sql); if (dTable.Rows.Count > 0 && dTable != null) { correctPassword = dTable.Rows[0]["PSWRD"].ToString().Trim(); } return(correctPassword); } catch (Exception ex) { //Log error if possible String clientIP = (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] == null) ? HttpContext.Current.Request.UserHostAddress : HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; ErrLogger.WriteError(ex.Message, clientIP + "/" + userName); return(correctPassword); } }
private void sendSMS() { string configFilePath = configuredFilePath(); ConfigValidator cv = new ConfigValidator(); cv.API = api; cv.Ruta = configFilePath; if ("".Equals(configFilePath.Trim()) || !File.Exists(configFilePath) || !cv.ValidateConfiguration()) { openConfigForm(configFilePath); } else { try { Settings set = Settings.Default; SalesPicker sp = new SalesPicker(); sp.WorkbookPath = configFilePath; sp.UserName = set.user; sp.Password = set.password; //sp.SendMethod = SMSSender.CommonConstants.SMS_LOCAL; sp.SendMethod = SMSSender.CommonConstants.SMS_MAS_MENSAJES; sp.RetrieveConfiguration(); sp.RetrieveSales(); sp.SendSMS(); sp.SendBossSMS(); }catch (Exception e) { ErrLogger.Log(e.Message); ErrLogger.Log(e.StackTrace); } } }
private bool ValidarAgentesDeVenta(Excel.Worksheet evalSheet) { Excel.Range salesRange = RangoDeColumna(evalSheet, 4, 7); foreach (Excel.Range rSales in salesRange) { int currentRow = rSales.Row - 6; Excel.Range currentRange = salesRange.Cells[currentRow, 1]; object oTemp = currentRange.Value; if (oTemp != null) { string sTemp = oTemp.ToString(); int sysId = api.IdAgente(sTemp, evalSheet.Range["B3"].Value); if (sysId == 0) { ErrLogger.Log("Sales Agent Code found to be invalid in database: [" + sTemp + "]"); return(false); } else { evalSheet.Range["H" + rSales.Row].Value = sysId; } } } return(true); }
private void FormMain_Load(object sender, EventArgs e) { api = new AdminPaqImp(); Enterprise dbEnterprise = new Enterprise(); foreach (Empresa enterprise in api.Empresas) { try { if (ValidateDBConfig()) { dbEnterprise.SaveEnterprise(enterprise); DtCustomer = CustomerInterface.ReadCustomers(); DtSeries = AccountInterface.ReadSeries(); DtFolios = AccountInterface.ReadFolios(); } else { OpenConfig(); return; } } catch (Exception ex) { ErrLogger.Log(ex.Message); } } }
private void DialogSearch_Load(object sender, EventArgs e) { try { comboBoxClient.DataSource = DtCustomer; comboBoxClient.DisplayMember = "cd_cliente"; comboBoxClient.ValueMember = "id_cliente"; comboBoxSerie.DataSource = DtSeries; DtSeries.DefaultView.Sort = "serie_doco ASC"; comboBoxSerie.DisplayMember = "serie_doco"; comboBoxSerie.ValueMember = "serie_doco"; comboBoxClientName.DataSource = DtCustomer; comboBoxClientName.DisplayMember = "nombre_cliente"; comboBoxClientName.ValueMember = "id_cliente"; comboBoxFolios.DataSource = DtFolios; comboBoxFolios.DisplayMember = "folio_doco"; comboBoxFolios.ValueMember = "folio_doco"; comboBoxClient.SelectedIndex = -1; comboBoxClient.Text = ""; comboBoxClientName.SelectedIndex = -1; comboBoxClientName.Text = ""; comboBoxFolios.SelectedIndex = -1; comboBoxFolios.Text = ""; }catch (Exception ex) { ErrLogger.Log(ex.StackTrace); MessageBox.Show("No fue posible consultar algunos datos en la base de datos. Intente más tarde: \n" + ex.Message, "Error al obtener datos para búsqueda", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void UpdateCollectable(Account account) { int connection, dbResponse; string key, command; connection = AdminPaqLib.dbLogIn("", account.Company.EnterprisePath); if (connection == 0) { ErrLogger.Log("Unable to open connection to documents table for company [" + account.Company.EnterprisePath + "]"); throw new Exception("No se pudo establecer conexión con adminPaq en la siguiente ruta: " + account.Company.EnterprisePath); } key = account.ApId.ToString().PadLeft(11); dbResponse = AdminPaqLib.dbGet(connection, TableNames.DOCUMENTOS, IndexNames.PRIMARY_KEY, key); if (dbResponse == 0) { if (account.CollectDate.Ticks > 0) { string sCollectDate = account.CollectDate.ToString("yyyyMMdd"); command = string.Format("UPDATE {0}(CFECHAEX01=\"{1}\",CTEXTOEX01=\"{2}\",CTEXTOEX02=\"{3}\");", TableNames.DOCUMENTOS, sCollectDate, account.CollectType, account.Note); } else { command = string.Format("UPDATE {0}(CFECHAEX01=\"{1}\",CTEXTOEX01=\"{2}\",CTEXTOEX02=\"{3}\");", TableNames.DOCUMENTOS, "18991230", account.CollectType, account.Note); } dbResponse = AdminPaqLib.dbCmdExec(connection, command); if (dbResponse != 0) { dbResponse = AdminPaqLib.dbCmdExec(connection, "ROLLBACK;"); AdminPaqLib.dbLogOut(connection); throw new Exception("No se pudo actualizar el registro"); } else { dbResponse = AdminPaqLib.dbCmdExec(connection, "COMMIT;"); if (dbResponse != 0) { dbResponse = AdminPaqLib.dbCmdExec(connection, "ROLLBACK;"); AdminPaqLib.dbLogOut(connection); throw new Exception("No se pudo confirmar la actualización del registro."); } } } else { AdminPaqLib.dbLogOut(connection); throw new Exception("El registro del documento se encuentra bloqueado por otro usuario. \n" + "folio: " + account.ApId.ToString() + "\n" + "ruta empresa: " + account.Company.EnterprisePath); } AdminPaqLib.dbLogOut(connection); }
public void SetCollectDate(int docId, DateTime collectDate, string rutaEmpresa) { int connection, dbResponse; string key, command; connection = AdminPaqLib.dbLogIn("", rutaEmpresa); if (connection == 0) { ErrLogger.Log("Unable to open connection to documents table for company [" + rutaEmpresa + "]"); throw new Exception("No se pudo establecer conexión con adminPaq en la siguiente ruta: " + rutaEmpresa); } key = docId.ToString().PadLeft(11); dbResponse = AdminPaqLib.dbGet(connection, TableNames.DOCUMENTOS, IndexNames.PRIMARY_KEY, key); if (dbResponse == 0) { string sCollectDate = collectDate.ToString("yyyyMMdd"); command = string.Format("UPDATE {0}(CFECHAEX01=\"{1}\");", TableNames.DOCUMENTOS, sCollectDate); dbResponse = AdminPaqLib.dbCmdExec(connection, command); if (dbResponse != 0) { dbResponse = AdminPaqLib.dbCmdExec(connection, "ROLLBACK;"); AdminPaqLib.dbLogOut(connection); throw new Exception("No se pudo actualizar el registro"); } else { dbResponse = AdminPaqLib.dbCmdExec(connection, "COMMIT;"); if (dbResponse != 0) { dbResponse = AdminPaqLib.dbCmdExec(connection, "ROLLBACK;"); AdminPaqLib.dbLogOut(connection); throw new Exception("No se pudo confirmar la actualización del registro."); } } } else { AdminPaqLib.dbLogOut(connection); throw new Exception("El registro del documento se encuentra bloqueado por otro usuario. \n" + "folio: " + docId + "\n" + "ruta empresa: " + rutaEmpresa); } AdminPaqLib.dbLogOut(connection); }
private void comboBoxClient_SelectionChangeCommitted(object sender, EventArgs e) { if (comboBoxClient.Text.Equals(string.Empty) || inCustNameTyping) { return; } try { comboBoxClientName.Text = dbCustomer.CustomerNameByCode(comboBoxClient.Text); inCustSelection = false; }catch (Exception ex) { ErrLogger.Log(ex.StackTrace); MessageBox.Show("No fue posible consultar el nombre del cliente en la base de datos. Intente más tarde: \n" + ex.Message, "Error al obtener nombre del cliente", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (Context.Session != null) { if (Session.IsNewSession) { string szCookieHeader = Request.Headers["Cookie"]; if ((szCookieHeader != null) && (szCookieHeader.IndexOf("ASP.NET_SessionId") >= 0)) { ErrLogger.WriteError("Session Expired", "0"); Response.Redirect("~/Web/Error.aspx", false); } } } }
private bool validateFile() { bool validated = false; int sheetIdx = 1; // Validate each worksheet Excel.Application xlApp = new Excel.Application(); xlApp.Visible = false; Excel.Workbook book = xlApp.Workbooks.Open(ruta); while (sheetIdx <= book.Worksheets.Count) { validated = validateWorkSheet(book.Worksheets[sheetIdx]); if (!validated) { validated = false; break; } sheetIdx++; } try { if (validated) { book.Save(); } } catch (Exception e) { ErrLogger.Log("Unable to save changes to phones workbook: " + e.Message.ToString()); } book.Close(SaveChanges: false); xlApp.Quit(); Marshal.FinalReleaseComObject(book); Marshal.FinalReleaseComObject(xlApp); return(validated); }
private bool ValidarCodigosDevolucion(Excel.Worksheet evalSheet) { Excel.Range salesRange = RangoDeColumna(evalSheet, 2, 7); foreach (Excel.Range rSales in salesRange) { int currentRow = rSales.Row - 6; Excel.Range currentRange = salesRange.Cells[currentRow, 1]; object oTemp = currentRange.Value; if (oTemp != null) { string sTemp = oTemp.ToString(); if (!api.CodigoDocoValido(sTemp, evalSheet.Range["B3"].Value)) { ErrLogger.Log("Refunds Document Code found to be invalid in database: [" + sTemp + "]"); return(false); } } } return(true); }
private void sendSMS(bool bUsePostgres) { try { //Postgresql mode SalesPickerPostgresql sp = new SalesPickerPostgresql(); Settings set = Settings.Default; sp.UserName = set.user; sp.Password = set.password; sp.SendMethod = SMSSender.CommonConstants.SMS_MAS_MENSAJES; sp.RetrieveData(); sp.SendSMS(); sp.SendBossSMS(); Console.WriteLine("*******************************************"); Console.ReadLine(); } catch (Exception e) { ErrLogger.Log(e.Message); ErrLogger.Log(e.StackTrace); } }
private void localFiles() { string configFilePath = configuredFilePath(); ConfigValidator cv = new ConfigValidator(); cv.API = api; cv.Ruta = configFilePath; if ("".Equals(configFilePath.Trim()) || !File.Exists(configFilePath) || !cv.ValidateConfiguration()) { openConfigForm(configFilePath); } else { try { Settings set = Settings.Default; SalesPicker sp = new SalesPicker(); sp.WorkbookPath = configFilePath; sp.UserName = set.user; sp.Password = set.password; sp.SendMethod = SMSSender.CommonConstants.SMS_LOCAL; //sp.SendMethod = SMSSender.CommonConstants.SMS_MAS_MENSAJES; sp.RetrieveConfiguration(); sp.RetrieveSales(); sp.SendSMS(); sp.SendBossSMS(); } catch (Exception e) { ErrLogger.Log(e.Message); ErrLogger.Log(e.StackTrace); } MessageBox.Show("Archivos locales de simulación de SMS generados exitosamente.", "Simulación de SMS Local", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private bool SaveAdminPaq() { if (dateTimePickerCollectDate.Checked) { account.CollectDate = dateTimePickerCollectDate.Value; } else { account.CollectDate = new DateTime(0); } account.CollectType = textBoxCollectType.Text; account.Note = textBoxNote.Text; try { api.UpdateCollectable(account); postgresAcct.UpdateAccountById(account); MessageBox.Show("Los datos han sido grabados exitosamente.", "Datos Guardados", MessageBoxButtons.OK, MessageBoxIcon.Information); FormMain fMain = (FormMain)this.MdiParent; if (fMain.IsProcessOpen) { fMain.RefreshProcessAccounts(); } adminPaqDirty = false; return(true); } catch (Exception ex) { ErrLogger.Log("Unable to save account data: " + ex.Message); MessageBox.Show("No fue posible agregar los datos: \n" + ex.Message, "Error al grabar datos", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
private bool ValidarEmpresa(Excel.Worksheet evalSheet) { string sEmpresa = evalSheet.Range["B2"].Value; bool empresaEnLista = false; foreach (Empresa empresa in api.Empresas) { if (sEmpresa.ToLower().Equals(empresa.Nombre.ToLower())) { empresaEnLista = true; evalSheet.Range["B1"].Value = empresa.Id; evalSheet.Range["B3"].Value = empresa.Ruta; break; } } if (!empresaEnLista) { ErrLogger.Log("Company not found in database: " + sEmpresa); } return(empresaEnLista); }
private 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.PRIMARY_KEY); 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.PRIMARY_KEY, 1); } AdminPaqLib.dbLogOut(connEmpresas); }
private static string CurrencyName(int currencyId, string filePath) { int connCurrency, dbResponse, fqResponse; StringBuilder sbCurrencyName = new StringBuilder(61); string key, sCurrencyName = String.Empty; connCurrency = AdminPaqLib.dbLogIn("", filePath); if (connCurrency == 0) { ErrLogger.Log("Unable to open connection for currency table from [" + filePath + "]"); return(null); } key = currencyId.ToString().PadLeft(11); dbResponse = AdminPaqLib.dbGetNoLock(connCurrency, TableNames.MONEDAS, IndexNames.PRIMARY_KEY, key); if (dbResponse == 0) { fqResponse = AdminPaqLib.dbFieldChar(connCurrency, TableNames.MONEDAS, 6, sbCurrencyName, 61); sCurrencyName = sbCurrencyName.ToString().Substring(0, 60).Trim(); } AdminPaqLib.dbLogOut(connCurrency); return(sCurrencyName); }
private void localFiles(bool bUsePostgresqlConfiguration) { try { Settings set = Settings.Default; SalesPickerPostgresql sp = new SalesPickerPostgresql(); sp.UserName = set.user; sp.Password = set.password; sp.SendMethod = SMSSender.CommonConstants.SMS_LOCAL; //sp.SendMethod = SMSSender.CommonConstants.SMS_MAS_MENSAJES; sp.RetrieveData(); sp.SendSMS(); sp.SendBossSMS(); } catch (Exception e) { ErrLogger.Log(e.Message); ErrLogger.Log(e.StackTrace); } MessageBox.Show("Archivos locales de simulación de SMS generados exitosamente.", "Simulación de SMS Local", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void FormMain_Load(object sender, EventArgs e) { api = new AdminPaqImp(); Enterprise dbEnterprise = new Enterprise(); foreach (Empresa enterprise in api.Empresas) { try { if (ValidateDBConfig()) { dbEnterprise.SaveEnterprise(enterprise); DtCustomer = CustomerInterface.ReadCustomers(); DtSeries = AccountInterface.ReadSeries(); DtFolios = AccountInterface.ReadFolios(); Settings set = Settings.Default; if (set.empresa == 1) { MessageBox.Show("Por favor seleccione la empresa en la cual desea trabajar."); OpenConfig(); return; } } else { OpenConfig(); return; } } catch (Exception ex) { ErrLogger.Log(ex.Message); } } }