/// <summary> /// Parâmetros para efetuar a alteração preservando a data de criação /// </summary> protected override void ParamAlterar(QueryStoredProcedure qs, CFG_Alerta entity) { base.ParamAlterar(qs, entity); qs.Parameters.RemoveAt("@cfa_dataCriacao"); qs.Parameters["@cfa_dataAlteracao"].Value = DateTime.Now; }
/// <summary> /// Processa o alerta de alunos com baixa frequência. /// </summary> public static void ExecJOB_AlertaAlunosBaixaFrequencia() { CFG_Alerta alerta = CFG_AlertaBO.GetEntity(new CFG_Alerta { cfa_id = (byte)CFG_AlertaBO.eChaveAlertas.AlertaAlunosBaixaFrequencia }); if (alerta.cfa_periodoAnalise > 0 && !string.IsNullOrEmpty(alerta.cfa_assunto)) { // Busca os usuários para envio da notificação DataTable dt = new GestaoEscolarServicoDAO().ExecJOB_AlertaAlunosBaixaFrequencia(); List <sAlertaAlunosBaixaFrequencia> lstUsuarios = (from DataRow dr in dt.Rows select(sAlertaAlunosBaixaFrequencia) GestaoEscolarUtilBO.DataRowToEntity(dr, new sAlertaAlunosBaixaFrequencia())).ToList(); List <int> lstEscolas = lstUsuarios.Select(p => p.esc_id).Distinct().ToList(); DateTime dataAtual = DateTime.UtcNow; lstEscolas.ForEach(e => { NotificacaoDTO notificacao = new NotificacaoDTO(); notificacao.SenderName = "SGP"; notificacao.Recipient = new DestinatarioNotificacao(); notificacao.Recipient.UserRecipient = new List <string>(); notificacao.MessageType = 3; notificacao.DateStartNotification = string.Format("{0:yyyy-MM-ddTHH:mm:ss.0000000-00:00}", dataAtual); notificacao.DateEndNotification = alerta.cfa_periodoValidade > 0 ? string.Format("{0:yyyy-MM-ddTHH:mm:ss.0000000-00:00}", dataAtual.AddHours(alerta.cfa_periodoValidade)) : null; notificacao.Title = alerta.cfa_nome; List <sAlertaAlunosBaixaFrequencia> lstUsuariosEscola = lstUsuarios.FindAll(u => u.esc_id == e); notificacao.Message = alerta.cfa_assunto .Replace("[NomeEscola]", lstUsuariosEscola.First().esc_nome.ToString()) .Replace("[PercentualMinimoFrequencia]", lstUsuariosEscola.First().percentualBaixaFrequencia.ToString()) .Replace("[Dias]", alerta.cfa_periodoAnalise.ToString()) .Replace("[PulaLinha]", "<br/>"); lstUsuariosEscola.ForEach(ue => notificacao.Recipient.UserRecipient.Add(ue.usu_id.ToString())); if (EnviarNotificacao(notificacao)) { List <LOG_AlertaAlunosBaixaFrequencia> lstLog = new List <LOG_AlertaAlunosBaixaFrequencia>(); notificacao.Recipient.UserRecipient.ForEach(ur => lstLog.Add(new LOG_AlertaAlunosBaixaFrequencia { usu_id = new Guid(ur), esc_id = e, lbf_dataEnvio = DateTime.Now })); LOG_AlertaAlunosBaixaFrequenciaBO.SalvarEmLote(lstLog); } } ); } }
private void Salvar() { bool sucessoSalvar = true; bool sucessoAgendar = true; CFG_Alerta alerta = CFG_AlertaBO.GetEntity(new CFG_Alerta { cfa_id = VS_cfa_id }); alerta.cfa_nome = txtNome.Text; alerta.cfa_periodoAnalise = string.IsNullOrEmpty(txtPeriodoAnalise.Text) ? 0 : Convert.ToInt32(txtPeriodoAnalise.Text); alerta.cfa_periodoValidade = string.IsNullOrEmpty(txtPeriodoValidade.Text) ? 0 : Convert.ToInt32(txtPeriodoValidade.Text); alerta.cfa_assunto = txtAssunto.Text; sucessoSalvar = CFG_AlertaBO.Salvar(alerta, CarregaGruposSelecionados()); if (sucessoSalvar) { try { SalvarTriggerQuartz(alerta.cfa_nomeProcedimento, chkDesativar.Checked ? (byte)GestaoEscolarServicosBO.eServicoAtivo.Desabilitado : (byte)GestaoEscolarServicosBO.eServicoAtivo.Ativo); } catch (Exception ex) { ApplicationWEB._GravaErro(ex); sucessoAgendar = false; } } if (sucessoSalvar && sucessoAgendar) { __SessionWEB.PostMessages = UtilBO.GetErroMessage(GetGlobalResourceObject("GestaoEscolar.Configuracao.Alertas.Cadastro", "mensagemSucessoSalvar").ToString(), UtilBO.TipoMensagem.Sucesso); Response.Redirect(__SessionWEB._AreaAtual._Diretorio + "Configuracao/Alertas/Busca.aspx", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } else { lblMessage.Text = UtilBO.GetErroMessage(sucessoSalvar ? "Erro ao tentar agendar o alerta." : "Erro ao tentar salvar alerta.", UtilBO.TipoMensagem.Erro); } }
/// <summary> /// Processa o alerta de preenchimento de frequência. /// </summary> public static void ExecJOB_AlertaPreenchimentoFrequencias() { CFG_Alerta alerta = CFG_AlertaBO.GetEntity(new CFG_Alerta { cfa_id = (byte)CFG_AlertaBO.eChaveAlertas.AlertaPreenchimentoFrequencia }); if (!string.IsNullOrEmpty(alerta.cfa_assunto)) { // Busca os usuários para envio da notificação DataTable dt = new GestaoEscolarServicoDAO().ExecJOB_AlertaPreenchimentoFrequencias(); List <sAlertaPreenchimentoFrequencia> lstUsuarios = (from DataRow dr in dt.Rows select(sAlertaPreenchimentoFrequencia) GestaoEscolarUtilBO.DataRowToEntity(dr, new sAlertaPreenchimentoFrequencia())).ToList(); if (lstUsuarios.Any()) { DateTime dataAtual = DateTime.UtcNow; NotificacaoDTO notificacao = new NotificacaoDTO(); notificacao.SenderName = "SGP"; notificacao.Recipient = new DestinatarioNotificacao(); notificacao.Recipient.UserRecipient = new List <string>(); notificacao.MessageType = 3; notificacao.DateStartNotification = string.Format("{0:yyyy-MM-ddTHH:mm:ss.0000000-00:00}", dataAtual); notificacao.DateEndNotification = alerta.cfa_periodoValidade > 0 ? string.Format("{0:yyyy-MM-ddTHH:mm:ss.0000000-00:00}", dataAtual.AddHours(alerta.cfa_periodoValidade)) : null; notificacao.Title = alerta.cfa_nome; notificacao.Message = alerta.cfa_assunto.Replace("[PulaLinha]", "<br/>"); lstUsuarios.ForEach(ue => notificacao.Recipient.UserRecipient.Add(ue.usu_id.ToString())); if (EnviarNotificacao(notificacao)) { List <LOG_AlertaPreenchimentoFrequencia> lstLog = new List <LOG_AlertaPreenchimentoFrequencia>(); notificacao.Recipient.UserRecipient.ForEach(ur => lstLog.Add(new LOG_AlertaPreenchimentoFrequencia { usu_id = new Guid(ur), lpf_dataEnvio = DateTime.Now })); LOG_AlertaPreenchimentoFrequenciaBO.SalvarEmLote(lstLog); } } } }
private void Carregar(short cfa_id) { UCFrequenciaServico1.LimparCampos(); VS_cfa_id = cfa_id; CFG_Alerta alerta = CFG_AlertaBO.GetEntity(new CFG_Alerta { cfa_id = VS_cfa_id }); txtNome.Text = alerta.cfa_nome; txtPeriodoAnalise.Text = alerta.cfa_periodoAnalise.ToString(); txtPeriodoValidade.Text = alerta.cfa_periodoValidade.ToString(); txtAssunto.Text = alerta.cfa_assunto; switch (alerta.cfa_nomeProcedimento) { case "MS_JOB_AlertaPreenchimentoFrequencia": { lblLegendaMensagem.Text = GetGlobalResourceObject("GestaoEscolar.Configuracao.Alertas.Cadastro", "lblLegendaMensagem.Text.MS_JOB_AlertaPreenchimentoFrequencia").ToString(); break; } case "MS_JOB_AlertaInicioFechamento": { lblLegendaMensagem.Text = GetGlobalResourceObject("GestaoEscolar.Configuracao.Alertas.Cadastro", "lblLegendaMensagem.Text.MS_JOB_AlertaInicioFechamento").ToString(); break; } case "MS_JOB_AlertaFimFechamento": { lblLegendaMensagem.Text = GetGlobalResourceObject("GestaoEscolar.Configuracao.Alertas.Cadastro", "lblLegendaMensagem.Text.MS_JOB_AlertaFimFechamento").ToString(); break; } case "MS_JOB_AlertaAlunosBaixaFrequencia": { lblLegendaMensagem.Text = GetGlobalResourceObject("GestaoEscolar.Configuracao.Alertas.Cadastro", "lblLegendaMensagem.Text.MS_JOB_AlertaAlunosBaixaFrequencia").ToString(); break; } case "MS_JOB_AlertaAlunosFaltasConsecutivas": { lblLegendaMensagem.Text = GetGlobalResourceObject("GestaoEscolar.Configuracao.Alertas.Cadastro", "lblLegendaMensagem.Text.MS_JOB_AlertaAlunosFaltasConsecutivas").ToString(); break; } default: { lblLegendaMensagem.Text = ""; break; } } // Carrega os grupos grvGrupos.DataSource = CFG_AlertaGrupoBO.SelecionarGruposPorAlerta(VS_cfa_id, __SessionWEB.__UsuarioWEB.Grupo.sis_id); grvGrupos.DataBind(); // Carrega configuração serviço string expressao; string trigger = string.Format("Trigger_{0}", alerta.cfa_nomeProcedimento); if (GestaoEscolarServicosBO.SelecionaExpressaoPorTrigger(trigger, out expressao)) { UCFrequenciaServico1.ConfigurarFrequencia(expressao); chkDesativar.Visible = true; } else { chkDesativar.Visible = false; } }
/// <summary>s /// Método alterado para que o update não faça a alteração da data de criação /// </summary> /// <param name="entity"> Entidade CFG_Alerta</param> /// <returns>true = sucesso | false = fracasso</returns> protected override bool Alterar(CFG_Alerta entity) { __STP_UPDATE = "NEW_CFG_Alerta_Update"; return(base.Alterar(entity)); }