protected void Page_Load(object sender, EventArgs e) { try { ucCambiarEstatusTicket.OnAceptarModal += UcCambiarEstatusTicket_OnAceptarModal; ucCambiarEstatusTicket.OnCancelarModal += UcCambiarEstatusTicketOnCancelarModal; if (!IsPostBack) { ParametrosGenerales parametros = _serviciosParametros.ObtenerParametrosGenerales(); if (parametros != null) { foreach (ArchivosPermitidos alowedFile in _serviciosParametros.ObtenerArchivosPermitidos()) { ArchivosPermitidos += string.Format("{0}|", alowedFile.Extensiones); } TamañoArchivo = double.Parse(parametros.TamanoDeArchivo); } if (Request.QueryString["IdTicket"] != null) { IdTicket = int.Parse(Request.QueryString["IdTicket"]); } } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
protected void Page_Load(object sender, EventArgs e) { try { Alerta = new List <string>(); if (!IsPostBack) { Session["registrosCatalogos"] = Session["registrosCatalogos"] ?? new List <CatalogoGenerico>(); ParametrosGenerales parametros = _serviciosParametros.ObtenerParametrosGenerales(); if (parametros != null) { foreach (ArchivosPermitidos alowedFile in _serviciosParametros.ObtenerArchivosPermitidos()) { ArchivosPermitidos += string.Format("{0}|", alowedFile.Extensiones); } TamañoArchivo = double.Parse(parametros.TamanoDeArchivo); } //ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "disableUpload", "var elms = document.getElementById('ContentPlaceHolder1_ucConsultaCatalogos_ucAltaCatalogos_afuArchivo').getElementsByTagName(\"*\");" + "for (var i = 0; i < elms.length; i++) " + "{" + "elms[i].disabled = " + true.ToString().ToLower() + "" + "};", true); } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { ParametrosGenerales parametros = _serviciosParametros.ObtenerParametrosGenerales(); if (parametros != null) { foreach (ArchivosPermitidos alowedFile in _serviciosParametros.ObtenerArchivosPermitidos()) { ArchivosPermitidos += string.Format("{0}|", alowedFile.Extensiones); } TamañoArchivo = double.Parse(parametros.TamanoDeArchivo); } if (Request.QueryString["id"] != null && Request.QueryString["asigna"] != null) { LlenaTicket(int.Parse(Request.QueryString["id"]), bool.Parse(Request.QueryString["asigna"])); } } else { UcDetalleMascaraCaptura.IdTicket = IdTicket; } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
public List <ParametrosGenerales> ParametrosGeneralesGetAll() { List <ParametrosGenerales> lstParametrosGenerales = new List <ParametrosGenerales>(); try { ds = new DataSet(); Conexion oConexion = new Conexion(); OracleConnection cn = oConexion.getConexion(); cn.Open(); string sqlSelect = "select * from Parametros_Generales "; cmd = new OracleCommand(sqlSelect, cn); adapter = new OracleDataAdapter(cmd); cmd.ExecuteNonQuery(); adapter.Fill(ds); DataTable dt = new DataTable(); dt = ds.Tables[0]; if (dt.Rows.Count > 0) { for (int i = 0; dt.Rows.Count > i; i++) { DataRow dr = dt.Rows[i]; ParametrosGenerales NewEnt = new ParametrosGenerales(); NewEnt = CargarParametrosGenerales(dr); lstParametrosGenerales.Add(NewEnt); } } return(lstParametrosGenerales); } catch (Exception ex) { throw ex; } }
protected override void OnInit(EventArgs e) { base.OnInit(e); _lstControles = new List <Control>(); Mascara mascara = null; if (Request.Params["Id"] != null) { mascara = _servicioMascaras.ObtenerMascaraCaptura(int.Parse(Request.Params["Id"])); } else { mascara = (Mascara)Session["PreviewDataFormulario"]; } if (mascara != null) { hfComandoInsertar.Value = mascara.ComandoInsertar; hfComandoActualizar.Value = mascara.ComandoInsertar; hfRandom.Value = mascara.Random.ToString(); lblTitle.Text = mascara.Descripcion; ParametrosGenerales parametros = _serviciosParametros.ObtenerParametrosGenerales(); if (parametros != null) { foreach (ArchivosPermitidos alowedFile in _serviciosParametros.ObtenerArchivosPermitidos()) { ArchivosPermitidos += string.Format("{0}|", alowedFile.Extensiones); } TamañoArchivo = double.Parse(parametros.TamanoDeArchivo); } PintaControles(mascara.CampoMascara); } }
private void CondicioinPassword() { try { ParametrosGenerales parametrosGenerales = _servicioParametros.ObtenerParametrosGenerales(); if (parametrosGenerales != null) { ParametroPassword parametrosPassword = _servicioParametros.ObtenerParemtrosPassword(); if (parametrosPassword != null) { lblCaracteristicas.Visible = parametrosGenerales.StrongPassword; listParamtros.Visible = parametrosGenerales.StrongPassword; lblLongitud.Text = string.Format("Longitud minima de {0} caracteres", parametrosPassword.Min); lblLongitudMayus.Text = string.Format("{0} Mayuscula", parametrosPassword.Mayusculas); paramMayuscula.Visible = parametrosPassword.Mayusculas > 0; paramNumero.Visible = parametrosPassword.Numeros; paramEspecial.Visible = parametrosPassword.Especiales; } } } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { Alerta = new List <string>(); _mp = (UsuariosMaster)Page.Master; if (!IsPostBack) { ParametrosGenerales parametros = _serviciosParametros.ObtenerParametrosGenerales(); if (parametros != null) { foreach (ArchivosPermitidos alowedFile in _serviciosParametros.ObtenerArchivosPermitidos()) { ArchivosPermitidos += string.Format("{0}|", alowedFile.Extensiones); } TamañoArchivo = double.Parse(parametros.TamanoDeArchivo); } } } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); Alerta = _lstError; } }
protected override void OnStart(string[] args) { try { BusinessParametros bparams = new BusinessParametros(); ParametrosGenerales parametros = bparams.ObtenerParametrosGenerales(); double intervalo = 60000; if (parametros != null) { intervalo = parametros.FrecuenciaDemonioSegundos * 1000; _intervaloEjecucion = new Timer(intervalo); } else { _intervaloEjecucion = new Timer(intervalo); } _intervaloEjecucion.Elapsed += intervaloEjecucion_Elapsed; _intervaloEjecucion.Start(); LogCorrect("Timer Start"); } catch (Exception ex) { LogError(ex.Message); } }
protected override void OnStart(string[] args) { //System.Diagnostics.Debugger.Launch(); try { File.Create(AppDomain.CurrentDomain.BaseDirectory + "OnStart.txt"); BusinessParametros bparams = new BusinessParametros(); ParametrosGenerales parametros = bparams.ObtenerParametrosGenerales(); double intervalo = 60000; if (parametros != null) { intervalo = parametros.FrecuenciaDemonioSegundos * 1000; _intervaloEjecucion = new Timer(intervalo); } else { _intervaloEjecucion = new Timer(intervalo); } _intervaloEjecucion.Elapsed += intervaloEjecucion_Elapsed; LogCorrect("KiiniNet", "Service Send Notication", "Iniciando Servicio"); _intervaloEjecucion.Start(); LogCorrect("KiiniNet", "Service Send Notication", "Servicio Iniciado"); } catch (Exception ex) { MessageBox.Show(ex.Message); LogError("KiiniNet", "Service Send Notication", ex.Message); } }
public ParametrosGenerales ParametrosGeneralesGetById(string Codigo, string Tipo) { try { DataSet ds = new DataSet(); Conexion oConexion = new Conexion(); OracleConnection cn = oConexion.getConexion(); cn.Open(); string sqlSelect = "select * from Parametros_Generales " + "WHERE PAG_CODIGO='" + Codigo + "' and PAG_TIPO='" + Tipo + "'"; cmd = new OracleCommand(sqlSelect, cn); adapter = new OracleDataAdapter(cmd); cmd.ExecuteNonQuery(); adapter.Fill(ds); DataTable dt; dt = ds.Tables[0]; ParametrosGenerales NewEnt = new ParametrosGenerales(); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; NewEnt = CargarParametrosGenerales(dr); } return(NewEnt); } catch (Exception ex) { throw ex; } }
public ActionResult Edit(ParametrosGenerales parametrosgenerales) { if (ModelState.IsValid) { db.Entry(parametrosgenerales).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.zafraAct = new SelectList(db.Zafras, "id", "descripcionZafra", parametrosgenerales.zafraAct); return(View(parametrosgenerales)); }
public async Task <Response> PostParametrosGenerales([FromBody] ParametrosGenerales parametrosGenerales) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var respuesta = Existe(parametrosGenerales); if (!respuesta.IsSuccess) { db.ParametrosGenerales.Add(parametrosGenerales); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio }); } return(new Response { IsSuccess = false, Message = Mensaje.Satisfactorio }); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.SwTH), ExceptionTrace = ex.Message, Message = Mensaje.Excepcion, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "", }); return(new Response { IsSuccess = false, Message = Mensaje.Error, }); } }
public async Task <IActionResult> Create(ParametrosGenerales parametrosGenerales) { if (!ModelState.IsValid) { InicializarMensaje(null); return(View(parametrosGenerales)); } Response response = new Response(); try { response = await apiServicio.InsertarAsync(parametrosGenerales, new Uri(WebApp.BaseAddress), "api/ParametrosGenerales/InsertarParametrosGenerales"); if (response.IsSuccess) { var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), ExceptionTrace = null, Message = "Se ha creado un Parametro General", UserName = "******", LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), EntityID = string.Format("{0} {1}", "ParametrosGenerales:", parametrosGenerales.IdParametrosGenerales), }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(parametrosGenerales)); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Creando Parametro General", ExceptionTrace = ex.Message, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
public ActionResult Parametros(ParametrosGenerales parametrosgenerales) { if (db.ParametrosGenerales.Any()) { ModelState.AddModelError("", "Ya su aplicacion esta configurada"); return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { db.ParametrosGenerales.Add(parametrosgenerales); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } ViewBag.zafraAct = new SelectList(db.Zafras, "id", "descripcionZafra", parametrosgenerales.zafraAct); return(View(parametrosgenerales)); }
public async Task <IActionResult> Edit(string id, ParametrosGenerales parametrosGenerales) { Response response = new Response(); try { if (!string.IsNullOrEmpty(id)) { response = await apiServicio.EditarAsync(id, parametrosGenerales, new Uri(WebApp.BaseAddress), "/api/ParametrosGenerales"); if (response.IsSuccess) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), EntityID = string.Format("{0} : {1}", "Sistema", id), LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ADV), Message = "Se ha actualizado un registro sistema", UserName = "******" }); return(RedirectToAction("Index")); } ViewData["Error"] = response.Message; return(View(parametrosGenerales)); } return(BadRequest()); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.WebAppTh), Message = "Editando un Parametro General", ExceptionTrace = ex, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "******" }); return(BadRequest()); } }
private void registrarCajaInicial() { try { ParametrosGenerales pg = new ParametrosGenerales(); DateTime fecha = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); pg.modificarFechaSistema(fecha); registrarMovimientosInicialesCaja(); modificarCajaInicial(); pg.modificarEstadoGlobalSistema(1); this.Hide(); } catch (Exception e) { MessageBox.Show(e.Message.ToString(), "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private ParametrosGenerales CargarParametrosGenerales(DataRow dr) { try { ParametrosGenerales oObjeto = new ParametrosGenerales(); oObjeto.PagCodigo = dr["PAG_CODIGO"].ToString(); oObjeto.PagDescripcion = dr["PAG_DESCRIPCION"].ToString(); oObjeto.PagValor = dr["PAG_VALOR"].ToString(); oObjeto.PagTipo = dr["PAG_TIPO"].ToString(); oObjeto.PagVisible = dr["PAG_VISIBLE"].ToString(); oObjeto.PagModificableUsr = dr["PAG_MODIFICABLE_USR"].ToString(); return(oObjeto); } catch (Exception ex) { throw ex; } }
private void btnCerrarCaja_Click(object sender, EventArgs e) { try { Boolean deseaModificarUnMovimiento = (MessageBox.Show("¿Desea modificar algún movimiento antes de realizar el Cierre de Caja correspondiente?", "Cierre de Caja.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes); if (deseaModificarUnMovimiento) { frmCaja caja = new frmCaja(); caja.ShowDialog(); } else { Entidades.Caja caja = new Entidades.Caja(); Boolean deseaContinuarConElCierreDeLaCaja = (MessageBox.Show("A continuación se realizará el Cierre de Caja correspondiente al día " + caja.obtenerFechaCajaAbierta() + ". ¿Desea Continuar?", "Cierre de Caja.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes); if (deseaContinuarConElCierreDeLaCaja) { MovimientoCaja movCaja = new MovimientoCaja(); DateTime fecSisActual = fg.appFechaSistema(); String Hora = System.DateTime.Now.TimeOfDay.ToString().Substring(0, 8); String Descripcion = "Cierre de caja del día " + fg.appFechaSistema().ToString(); DataSet Ds = new DataSet(); Ds.Reset(); Ds = caja.obtenerCierreParcialCaja(fg.appFechaSistema()); double valor = double.Parse(Ds.Tables[0].Rows[0]["Cierre_Parcial"].ToString()); movCaja.registrarMovimientoCaja(0, Descripcion, valor, fecSisActual, Hora); ParametrosGenerales pg = new ParametrosGenerales(); pg.modificarEstadoGlobalSistema(0); //CIERRO LA CAJA - ESTADO "0" MessageBox.Show("Se realizó el Cierre de Caja Correctamente.", "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } catch (Exception r) { MessageBox.Show(r.Message.ToString(), "Atención.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Response Existe(ParametrosGenerales parametrosGenerales) { var bdd = parametrosGenerales.Nombre.ToUpper().TrimEnd().TrimStart(); var loglevelrespuesta = db.ParametrosGenerales.Where(p => p.Nombre.ToUpper().TrimStart().TrimEnd() == bdd).FirstOrDefault(); if (loglevelrespuesta != null) { return(new Response { IsSuccess = true, Message = Mensaje.ExisteRegistro, Resultado = null, }); } return(new Response { IsSuccess = false, Resultado = loglevelrespuesta, }); }
protected void Page_Load(object sender, EventArgs e) { try { AlertaGeneral = new List <string>(); if (!IsPostBack) { ParametrosGenerales parametros = _servicioParametros.ObtenerParametrosGenerales(); if (parametros != null) { foreach (ArchivosPermitidos alowedFile in _servicioParametros.ObtenerArchivosPermitidos()) { ArchivosPermitidos += string.Format("{0}|", alowedFile.Extensiones); } TamañoArchivo = double.Parse(parametros.TamanoDeArchivo); } LlenaCombos(); Session["FileSize"] = 0; Session["selectedFiles"] = new List <HelperFiles>(); if (Request.QueryString["IdInformacionConsulta"] != null) { EsAlta = false; IdInformacionConsulta = int.Parse(Request.QueryString["IdInformacionConsulta"]); } } //ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Scripttagsbusqueda", "$('#txtBusqueda').tagsInput({ width: 'auto', defaultText: 'Agregar', delimiter: '|' });", true); //ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Scripttags", "$('#txtTags').tagsInput({ width: 'auto', defaultText: 'Agregar', delimiter: '|' });", true); } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); AlertaGeneral = _lstError; } }
private void LlenaCombos() { try { ParametrosGenerales generales = _servicioParametros.ObtenerParametrosGenerales(); List <int> uploads = new List <int>(); for (int i = 1; i <= int.Parse(generales.NumeroArchivo); i++) { uploads.Add(i); } //rptDonloads.DataSource = uploads; //rptDonloads.DataBind(); } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); AlertaGeneral = _lstError; } }
public int ParametrosGeneralesAdd(ParametrosGenerales OPaG) { try { Conexion oConexion = new Conexion(); OracleConnection cn = oConexion.getConexion(); cn.Open(); //Clave PAG_CODIGO, PAG_TIPO ds = new DataSet(); cmd = new OracleCommand("insert into Parametros_Generales(PAG_CODIGO, " + "PAG_DESCRIPCION, PAG_VALOR, PAG_TIPO, PAG_VISIBLE, PAG_MODIFICABLE_USR) " + "values('" + OPaG.PagCodigo + "','" + OPaG.PagDescripcion + "','" + OPaG.PagValor + "','" + OPaG.PagTipo + "','" + OPaG.PagVisible + "','" + OPaG.PagModificableUsr + "')", cn); adapter = new OracleDataAdapter(cmd); response = cmd.ExecuteNonQuery(); cn.Close(); return(response); } catch (Exception ex) { throw ex; } }
protected void Page_Load(object sender, EventArgs e) { try { AlertaGeneral = new List <string>(); ParametrosGenerales generales = (ParametrosGenerales)Session["ParametrosGenerales"]; if (!IsPostBack) { if (!generales.LevantaTickets) { Response.Redirect("~/Users/DashBoard.aspx"); } if (generales.LevantaTickets && (!((Usuario)Session["UserData"]).LevantaTickets && !((Usuario)Session["UserData"]).LevantaRecado)) { Response.Redirect("~/Users/DashBoard.aspx"); } } if (generales.ValidaUsuario) { ucMensajeValidacion.Mensaje = generales.MensajeValidacion; ucMensajeValidacion.OnCancelarModal += ucMensajeValidacion_OnCancelarModal; } ucAltaPreticket.OnAceptarModal += UcAltaPreticketOnOnAceptarModal; ucAltaPreticket.OnCancelarModal += UcAltaPreticketOnOnCancelarModal; } catch (Exception ex) { if (_lstError == null) { _lstError = new List <string>(); } _lstError.Add(ex.Message); AlertaGeneral = _lstError; } }
public bool ParametrosGeneralesUpdate(ParametrosGenerales OPaG) { try { Conexion oConexion = new Conexion(); OracleConnection cn = oConexion.getConexion(); cn.Open(); ds = new DataSet(); cmd = new OracleCommand("update Parametros_Generales " + "SET PAG_DESCRIPCION='" + OPaG.PagDescripcion + "', '" + "PAG_VALOR='" + OPaG.PagValor + "', '" + "PAG_VISIBLE='" + OPaG.PagVisible + "', '" + "PAG_MODIFICABLE_USR='******' " + "WHERE PAG_CODIGO='" + OPaG.PagCodigo + "' and PAG_TIPO='" + OPaG.PagTipo + "'", cn); adapter = new OracleDataAdapter(cmd); response = cmd.ExecuteNonQuery(); cn.Close(); return(response > 0); } catch (Exception ex) { throw ex; } }
private string EnviaNotificacion(List <Ticket> lstInforme, int idTipoGrupo, bool antesVencimiento, BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion tipoNotificacion, ParametrosGenerales parametros) { StringBuilder result = new StringBuilder(); DataBaseModelContext db = new DataBaseModelContext(); try { db.ContextOptions.ProxyCreationEnabled = _proxy; foreach (Ticket ticket in lstInforme.Distinct()) { //db.LoadProperty(ticket, "UsuarioLevanto"); foreach (TicketGrupoUsuario tgu in db.TicketGrupoUsuario.Where(w => w.IdTicket == ticket.Id && w.GrupoUsuario.IdTipoGrupo == idTipoGrupo).Distinct()) { db.LoadProperty(tgu, "GrupoUsuario"); db.LoadProperty(tgu.GrupoUsuario, "UsuarioGrupo"); foreach (UsuarioGrupo ug in tgu.GrupoUsuario.UsuarioGrupo.Distinct()) { string mensaje; switch (tipoNotificacion) { case BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Correo: db.LoadProperty(ug, "Usuario"); db.LoadProperty(ug.Usuario, "CorreoUsuario"); foreach (CorreoUsuario correoUsuario in ug.Usuario.CorreoUsuario.Distinct()) { mensaje = string.Format("Ticket No.: <b>{0}</b> Clave <b>{1}</b>" + "<br>Grupo Notificado <b>{2}</b> " + "<br>Usuario que pertenece al grupo <b>{3}</b> " + "<br>Persona Levanto <b>{4}</b>" + "<br>Fecha levanto <b>{5}</b> " + "<br>Fecha termino estimada <b>{6}</b> ", ticket.Id, ticket.Random ? ticket.ClaveRegistro : "N/A", tgu.GrupoUsuario.Descripcion, correoUsuario.Usuario.NombreCompleto, ticket.UsuarioLevanto.NombreCompleto, ticket.FechaHoraAlta, ticket.FechaHoraFinProceso); GeneraCorreo(ticket.Id, ug.IdGrupoUsuario, correoUsuario.IdUsuario, correoUsuario.Correo, antesVencimiento, mensaje, parametros); result.AppendLine(string.Format("Se envio notificación de ticket {0} a correo: {1}", ticket.Id, correoUsuario.Correo)); } break; case BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Sms: db.LoadProperty(ug, "Usuario"); db.LoadProperty(ug.Usuario, "TelefonoUsuario"); foreach (TelefonoUsuario telefono in ug.Usuario.TelefonoUsuario.Where(w => w.IdTipoTelefono == (int)BusinessVariables.EnumTipoTelefono.Celular).Distinct()) { mensaje = string.Format("Ticket No.: <b>{0}</b> Clave <b>{1}</b>" + "<br>Grupo Notificado <b>{2}</b> " + "<br>Usuario que pertenece al grupo <b>{3}</b> " + "<br>Persona Levanto <b>{4}</b>" + "<br>Fecha levanto <b>{5}</b> " + "<br>Fecha termino estimada <b>{6}</b> ", ticket.Id, ticket.Random ? ticket.ClaveRegistro : "N/A", tgu.GrupoUsuario.Descripcion, telefono.Usuario.NombreCompleto, ticket.UsuarioLevanto.NombreCompleto, ticket.FechaHoraAlta, ticket.FechaHoraFinProceso); GeneraSms(ticket.Id, ug.IdGrupoUsuario, telefono.IdUsuario, telefono.Numero, mensaje, parametros); result.AppendLine(string.Format("Se envio notificación de ticket {0} a numero: {1}", ticket.Id, telefono.Numero)); } break; } } } } } catch { } finally { db.Dispose(); } return(result.ToString().Trim()); }
public async Task <Response> PutParametrosGenerales([FromRoute] int id, [FromBody] ParametrosGenerales parametrosGenerales) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var parametrosGeneralesActualizar = await db.ParametrosGenerales.Where(x => x.IdParametrosGenerales == id).FirstOrDefaultAsync(); if (parametrosGeneralesActualizar != null) { try { parametrosGeneralesActualizar.Nombre = parametrosGenerales.Nombre; parametrosGeneralesActualizar.Valor = parametrosGenerales.Valor; db.ParametrosGenerales.Update(parametrosGeneralesActualizar); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio, }); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.SwTH), ExceptionTrace = ex.Message, Message = Mensaje.Excepcion, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "", }); return(new Response { IsSuccess = false, Message = Mensaje.Error, }); } } return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro }); } catch (Exception) { return(new Response { IsSuccess = false, Message = Mensaje.Excepcion }); } }
public int ParametrosGeneralesAdd(ParametrosGenerales oParametrosGenerales) { ParametrosGeneralesImpl oParametrosGeneralesImpl = new ParametrosGeneralesImpl(); return(oParametrosGeneralesImpl.ParametrosGeneralesAdd(oParametrosGenerales)); }
private void GeneraCorreo(int idTicket, int idGrupoUsuario, int idUsuario, string correoUsuario, bool antesVencimiento, string mensaje, ParametrosGenerales parametros) { DataBaseModelContext db = new DataBaseModelContext(); try { if (db.TicketNotificacion.Count(c => c.IdTicket == idTicket && c.IdGrupoUsuario == idGrupoUsuario && c.CorreoUsuario == correoUsuario) < parametros.MensajesNotificacion) { TicketNotificacion lastNotificacion = db.TicketNotificacion.Where(w => w.IdTicket == idTicket && w.IdGrupoUsuario == idGrupoUsuario && w.CorreoUsuario == correoUsuario).ToList().LastOrDefault(); if (lastNotificacion != null) { if (DateTime.Now >= lastNotificacion.FechaNotificacion.AddMinutes(parametros.FrecuenciaNotificacionMinutos)) { TicketNotificacion tn = new TicketNotificacion { IdTicket = idTicket, IdGrupoUsuario = idGrupoUsuario, IdUsuario = idUsuario, CorreoUsuario = correoUsuario, IdTipoNotificacion = (int)BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Correo, FechaNotificacion = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), "yyyy-MM-dd HH:mm:ss:fff", CultureInfo.InvariantCulture) }; db.TicketNotificacion.AddObject(tn); db.SaveChanges(); BusinessCorreo.SendMail(correoUsuario, string.Format("{0}", antesVencimiento ? "Ticket apunto de vencer" : "Ticket ha vencido"), mensaje); } } else { TicketNotificacion tn = new TicketNotificacion { IdTicket = idTicket, IdGrupoUsuario = idGrupoUsuario, IdUsuario = idUsuario, CorreoUsuario = correoUsuario, IdTipoNotificacion = (int)BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Correo, FechaNotificacion = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), "yyyy-MM-dd HH:mm:ss:fff", CultureInfo.InvariantCulture) }; db.TicketNotificacion.AddObject(tn); db.SaveChanges(); BusinessCorreo.SendMail(correoUsuario, string.Format("{0}", antesVencimiento ? "Ticket apunto de vencer" : "Ticket ha vencido"), mensaje); } } } catch { } finally { db.Dispose(); } }
private string NotificacionesVencimiento(bool antesVencimiento) { StringBuilder result = new StringBuilder(); DataBaseModelContext db = new DataBaseModelContext(); try { result.AppendLine(string.Format("Procesando notificaciones {0} de vencimiento", antesVencimiento ? "antes" : "despues")); db.ContextOptions.ProxyCreationEnabled = _proxy; //Listas Notificacion Correo List <Ticket> informeNotificacionCorreo = new List <Ticket>(); ////Listas Notificacion SMS List <Ticket> informeNotificacionSms = new List <Ticket>(); List <int> enumEstatusExcluidos = new List <int>(); enumEstatusExcluidos.Add((int)BusinessVariables.EnumeradoresKiiniNet.EnumEstatusTicket.Cerrado); enumEstatusExcluidos.Add((int)BusinessVariables.EnumeradoresKiiniNet.EnumEstatusTicket.Cancelado); enumEstatusExcluidos.Add((int)BusinessVariables.EnumeradoresKiiniNet.EnumEstatusTicket.EnEspera); enumEstatusExcluidos.Add((int)BusinessVariables.EnumeradoresKiiniNet.EnumEstatusTicket.ReTipificado); ParametrosGenerales parametros = db.ParametrosGenerales.SingleOrDefault(); if (parametros != null) { List <int> tiposGposNotificar = new List <int>(); tiposGposNotificar.Add((int)BusinessVariables.EnumTiposGrupos.Notificaciones); //DateTime fechaConsulta = antesVencimiento ? DateTime.Now : DateTime.Now.AddMinutes(parametros.MensajesNotificacion * 10); DateTime fechaConsulta = DateTime.Now; DateTime fechaInicioConsulta = fechaConsulta.AddMinutes((parametros.MensajesNotificacion * 10) * -1); DateTime fechaFinConsulta = fechaConsulta.AddMinutes(parametros.MensajesNotificacion * 10); List <TiempoInformeArbol> lstTiempoInforme = (from tia in db.TiempoInformeArbol join t in db.Ticket on tia.IdArbol equals t.IdArbolAcceso where tia.AntesVencimiento == antesVencimiento && t.DentroSla == antesVencimiento && t.FechaHoraFinProceso != null && !enumEstatusExcluidos.Contains(t.IdEstatusTicket) select tia).Distinct().ToList(); foreach (TiempoInformeArbol tiempoInforme in lstTiempoInforme) { int tiemponotificacionHoras; var qry = from t in db.Ticket where t.IdEstatusTicket < (int)BusinessVariables.EnumeradoresKiiniNet.EnumEstatusTicket.Resuelto && t.IdArbolAcceso == tiempoInforme.IdArbol select t; if (antesVencimiento) { if (tiempoInforme.Dias > 0) { tiemponotificacionHoras = decimal.ToInt32(tiempoInforme.Dias); qry = from q in qry where System.Data.Objects.EntityFunctions.AddDays((DateTime?)q.FechaHoraFinProceso, -tiemponotificacionHoras) <= fechaConsulta select q; //where System.Data.Objects.EntityFunctions.AddDays((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) >= fechaInicioConsulta //&& System.Data.Objects.EntityFunctions.AddMinutes((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) <= fechaFinConsulta } if (tiempoInforme.Horas > 0) { tiemponotificacionHoras = decimal.ToInt32(tiempoInforme.Horas); qry = from q in qry where System.Data.Objects.EntityFunctions.AddHours((DateTime?)q.FechaHoraFinProceso, -tiemponotificacionHoras) <= fechaConsulta select q; } if (tiempoInforme.Minutos > 0) { tiemponotificacionHoras = decimal.ToInt32(tiempoInforme.Minutos); qry = from q in qry where System.Data.Objects.EntityFunctions.AddMinutes((DateTime?)q.FechaHoraFinProceso, -tiemponotificacionHoras) <= fechaConsulta select q; } if (tiempoInforme.Segundos > 0) { tiemponotificacionHoras = decimal.ToInt32(tiempoInforme.Segundos); qry = from q in qry where System.Data.Objects.EntityFunctions.AddSeconds((DateTime?)q.FechaHoraFinProceso, -tiemponotificacionHoras) <= fechaConsulta select q; } } else { if (tiempoInforme.Dias > 0) { tiemponotificacionHoras = decimal.ToInt32(tiempoInforme.Dias); qry = from q in qry where System.Data.Objects.EntityFunctions.AddDays((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) >= fechaInicioConsulta && System.Data.Objects.EntityFunctions.AddMinutes((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) <= fechaFinConsulta select q; } if (tiempoInforme.Horas > 0) { tiemponotificacionHoras = decimal.ToInt32(tiempoInforme.Horas); qry = from q in qry where System.Data.Objects.EntityFunctions.AddHours((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) >= fechaInicioConsulta && System.Data.Objects.EntityFunctions.AddMinutes((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) <= fechaFinConsulta select q; } if (tiempoInforme.Minutos > 0) { tiemponotificacionHoras = decimal.ToInt32(tiempoInforme.Minutos); qry = from q in qry where System.Data.Objects.EntityFunctions.AddMinutes((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) >= fechaInicioConsulta && System.Data.Objects.EntityFunctions.AddMinutes((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) <= fechaFinConsulta select q; } if (tiempoInforme.Segundos > 0) { tiemponotificacionHoras = decimal.ToInt32(tiempoInforme.Segundos); qry = from q in qry where System.Data.Objects.EntityFunctions.AddSeconds((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) >= fechaInicioConsulta && System.Data.Objects.EntityFunctions.AddMinutes((DateTime?)q.FechaHoraFinProceso, tiemponotificacionHoras) <= fechaFinConsulta select q; } } List <Ticket> tickets = qry.Distinct().ToList(); result.AppendLine(string.Format("Se encontraron {0} para procesar", tickets.Count)); foreach (Ticket t in tickets) { db.LoadProperty(t, "UsuarioLevanto"); } switch (tiempoInforme.IdTipoNotificacion) { case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Correo: switch (tiempoInforme.IdTipoGrupo) { case (int)BusinessVariables.EnumTiposGrupos.Notificaciones: informeNotificacionCorreo.AddRange(tickets.ToList().Distinct()); break; } break; case (int)BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Sms: switch (tiempoInforme.IdTipoGrupo) { case (int)BusinessVariables.EnumTiposGrupos.Notificaciones: informeNotificacionSms.AddRange(tickets.ToList().Distinct()); break; } break; } } // Envia notificacion Correo if (informeNotificacionCorreo.Any()) { result.AppendLine(EnviaNotificacion(informeNotificacionCorreo, (int)BusinessVariables.EnumTiposGrupos.Notificaciones, antesVencimiento, BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Correo, parametros)); } //Envia Notificacion SMS if (informeNotificacionSms.Any()) { result.AppendLine(EnviaNotificacion(informeNotificacionSms, (int)BusinessVariables.EnumTiposGrupos.Notificaciones, antesVencimiento, BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Sms, parametros)); } } } catch (Exception e) { throw new Exception(e.Message); } finally { db.Dispose(); } return(result.ToString().Trim()); }
private void GeneraSms(int idTicket, int idGrupoUsuario, int idUsuario, string numero, string mensaje, ParametrosGenerales parametros) { DataBaseModelContext db = new DataBaseModelContext(); try { if (db.TicketNotificacion.Count(c => c.IdTicket == idTicket && c.IdGrupoUsuario == idGrupoUsuario && c.TelefonoUsuario == numero && c.SmsService.Numero == numero) < parametros.MensajesNotificacion) { TicketNotificacion lastNotificacion = db.TicketNotificacion.Where(w => w.IdTicket == idTicket && w.IdGrupoUsuario == idGrupoUsuario && w.TelefonoUsuario == numero && w.SmsService.Numero == numero).ToList().LastOrDefault(); if (lastNotificacion != null) { if (lastNotificacion.FechaNotificacion.AddMinutes(parametros.FrecuenciaNotificacionMinutos) >= DateTime.Now) { TicketNotificacion tn = new TicketNotificacion { IdTicket = idTicket, IdGrupoUsuario = idGrupoUsuario, IdUsuario = idUsuario, TelefonoUsuario = numero, IdTipoNotificacion = (int)BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Sms, FechaNotificacion = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), "yyyy-MM-dd HH:mm:ss:fff", CultureInfo.InvariantCulture), SmsService = new SmsService { IdUsuario = idUsuario, IdTipoLink = (int)BusinessVariables.EnumTipoLink.Notificacion, Numero = numero, Mensaje = mensaje, Enviado = false, Habilitado = true } }; db.TicketNotificacion.AddObject(tn); db.SaveChanges(); } } else { TicketNotificacion tn = new TicketNotificacion { IdTicket = idTicket, IdGrupoUsuario = idGrupoUsuario, IdUsuario = idUsuario, TelefonoUsuario = numero, IdTipoNotificacion = (int)BusinessVariables.EnumeradoresKiiniNet.EnumTipoNotificacion.Sms, FechaNotificacion = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), "yyyy-MM-dd HH:mm:ss:fff", CultureInfo.InvariantCulture), SmsService = new SmsService { IdUsuario = idUsuario, IdTipoLink = (int)BusinessVariables.EnumTipoLink.Notificacion, Numero = numero, Mensaje = mensaje, Enviado = false, Habilitado = true } }; db.TicketNotificacion.AddObject(tn); db.SaveChanges(); } } } catch (Exception) { ; } finally { db.Dispose(); } }