Esempio n. 1
0
        public JsonResult MantemHoraProjeto(int id, int projetoId, int subFaseProjetoId, DateTime dataInicio, DateTime dataFim, string obs, string atalho)
        {
            try
            {
                int usuarioId = Convert.ToInt32(Session["IDUSUARIO"]);

                var retorno = "";

                var obj = new Indigo_HorasProjeto
                {
                    hpo_Id             = id,
                    hpo_prjId          = projetoId,
                    hpo_sfpId          = subFaseProjetoId,
                    hpo_usrId          = usuarioId,
                    hpo_DataHoraInicio = dataInicio,
                    hpo_DataHoraFim    = dataFim,
                    hpo_Observacao     = obs
                };

                retorno = this.dataInterface.IniciaHoras(obj);

                return(base.Json(new { Result = retorno }, 0));
            }
            catch (Exception ex)
            {
                log(ex.Message + " -- " + ex.StackTrace);
                return(base.Json(new { Result = ex.Message + " -- " + ex.StackTrace }, 0));
            }
        }
Esempio n. 2
0
 public JsonResult IniciaHorasProjetosUsuarioAtalho(string atalho)
 {
     try
     {
         int usuarioId = Convert.ToInt32(Session["IDUSUARIO"]);
         var list      = this.dataInterface.BuscaHorasProjetoAtalho().FirstOrDefault(x => x.hpoa_usrId != null && x.hpoa_usrId == usuarioId && x.hpoa_Atalho.TrimEnd() == atalho);
         var retorno   = "";
         var obj       = new Indigo_HorasProjeto
         {
             hpo_Id             = 0,
             hpo_prjId          = list.hpoa_prjId,
             hpo_sfpId          = list.hpoa_sfpId,
             hpo_usrId          = usuarioId,
             hpo_DataHoraInicio = DateTime.Now,
             hpo_DataHoraFim    = DateTime.Now,
             hpo_Observacao     = list.hpoa_Observacao
         };
         retorno = this.dataInterface.IniciaHoras(obj);
         return(base.Json(new { Result = retorno }, 0));
     }
     catch (Exception ex)
     {
         log(ex.Message + " -- " + ex.StackTrace);
         return(base.Json(new { Result = ex.Message + "\r\n" + ex.StackTrace }, 0));
     }
 }
Esempio n. 3
0
 public List <RetornoEstruturaJustifica> IniciaHorasJust(Indigo_HorasProjeto horasProjeto, int justifica)
 {
     try
     {
         var context = new Indigo_Controle_Licenca();
         return(context.STP_INICIO_TAREFA_JUST(horasProjeto.hpo_prjId, horasProjeto.hpo_sfpId, horasProjeto.hpo_usrId, horasProjeto.hpo_DataHoraInicio, horasProjeto.hpo_DataHoraFim, horasProjeto.hpo_Observacao, horasProjeto.hpo_jtfAprovado, justifica).ToList());
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 4
0
        public string IniciaHoras(Indigo_HorasProjeto horasProjeto)
        {
            try
            {
                var context = new Indigo_Controle_Licenca();
                context.STP_INICIO_TAREFA(horasProjeto.hpo_prjId, horasProjeto.hpo_sfpId, horasProjeto.hpo_usrId, horasProjeto.hpo_DataHoraInicio, horasProjeto.hpo_DataHoraFim, horasProjeto.hpo_Observacao);

                return("Horas registradas com sucesso");
            }
            catch (Exception ex)
            {
                return(String.Format(ex.Message + "\r\n" + ex.StackTrace));
            }
        }
Esempio n. 5
0
        public string MantemHorasProjeto(Indigo_HorasProjeto horasProjeto)
        {
            try
            {
                var context = new Indigo_Controle_Licenca();
                context.Indigo_HorasProjeto.AddOrUpdate(horasProjeto);
                context.SaveChanges();

                return("Horas em projeto iniciada com sucesso!");
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 6
0
        public ActionResult ProcessaJustificativa(int id, int jtfid, DateTime dao, DateTime daf, int justid)
        {
            try
            {
                Indigo_JustificaHorasUsuario objJust     = dataInterface.BuscaJustificaHorasUsuario().FirstOrDefault(x => x.usr_id == id && x.jtf_data == null && x.usrjtf_id == justid && x.jft_dataReg != null);
                Indigo_JustificaHorasProjeto objJustDesc = dataInterface.BuscaTipoJustificativa().FirstOrDefault(x => x.jtf_Id == justid);
                Indigo_Usuario      objUsuario           = dataInterface.BuscaUsuario().FirstOrDefault(x => x.usr_Id == id);
                Indigo_HorasProjeto HorasProjeto         = new Indigo_HorasProjeto();
                Indigo_HorasNTrab   HorasNtrab           = new Indigo_HorasNTrab();
                var retorno = "";
                if (objJust != null)
                {
                    objJust.jtf_Aprova = jtfid;
                    objJust.jtf_data   = DateTime.Now;
                    dataInterface.JustificativaUsuario(objJust);
                    if (objJust.jft_Tipo == "HNormal")
                    {
                        Indigo_HorasProjeto objHorasProj = dataInterface.BuscaHorasProjeto().FirstOrDefault(x => x.hpo_Id == objJust.hpo_id);
                        objHorasProj.hpo_jtfAprovado = jtfid;
                        retorno = dataInterface.MantemHorasProjeto(objHorasProj);
                    }
                    else if (objJust.jft_Tipo == "HNTrab")
                    {
                        Indigo_HorasNTrab objHorasProj = dataInterface.BuscaHorasNtrab().FirstOrDefault(x => x.hnt_Id == objJust.hpo_id);
                        objHorasProj.hnt_jtfAprovado = jtfid;
                        retorno = dataInterface.MantemHorasNTrab(objHorasProj);
                    }
                    if (retorno != "")
                    {
                        string trataHora = "", strAprova = "";
                        if (jtfid == 1)
                        {
                            strAprova      = "aprovada";
                            ViewBag.status = "Justificativa aprovada com sucesso !";
                        }
                        else if (jtfid == 0)
                        {
                            strAprova      = "negada";
                            ViewBag.status = "Justificativa negada com sucesso !";
                        }

                        if (DateTime.Now.Hour < 12)
                        {
                            trataHora = "Bom dia";
                        }
                        else if (DateTime.Now.Hour > 12 && DateTime.Now.Hour < 18)
                        {
                            trataHora = "Boa tarde";
                        }
                        else if (DateTime.Now.Hour > 18)
                        {
                            trataHora = "Boa noite";
                        }

                        StringBuilder pagina = new StringBuilder();

                        pagina.Append(@"<!DOCTYPE html>
                                        <html>
                                        <head>
                                            <title>Ferramenta Check-in / Check-out</title>
                                        </head>
                                        <body>
                                        <style>
                                        body
                                        {
                                        background-color:aliceblue;
                                        }
                                        @font-face
                                     {font-family:Calibri;
                                     panose-1:2 15 5 2 2 2 4 3 2 4;}
                                        @font-face
                                     {font-family:Verdana;
                                     panose-1:2 11 6 4 3 5 4 4 2 4;}
                                        table, td {s
                                        border:1px solid black;
                                        border-collapse: collapse;
                                        }
                                        </style>
                                        <p>" + objUsuario.usr_Nome + @", " + trataHora + @" !</p>
                                        <p>Sua justificativa <b>" + objJustDesc.jtf_Nome + @"</b>, foi " + strAprova + @" pelo seu gestor.</p>
                                        </div>
                                        <p>Segue o link da página.</ p>
                                        </br>
                                        </br>
                                        <a href = ""http://admin.indigosoft.biz/"">http://admin.indigosoft.biz/</a>
                                        </body>
                                        </html>");

                        var email = EnviaEmail("*****@*****.**", "indigo.2017", objUsuario.usr_Email, "Ferramenta Check-in/out - Aprovação de justificativa", pagina.ToString());

                        return(View());
                    }
                    else
                    {
                        ViewBag.status = "Ocorreu algum erro, tente novamente !";
                        return(View());
                    }
                }
                else
                {
                    ViewBag.status = "Justificativa já processada !";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                log(ex.Message + " -- " + ex.StackTrace);
                return(View());
            }
        }
Esempio n. 7
0
        public JsonResult JustificaPonto(int justificativa, int id, int projetoId, int subFaseProjetoId, DateTime dataInicio, DateTime dataFim, string obs)
        {
            try
            {
                int usuarioId = Convert.ToInt32(Session["IDUSUARIO"]);

                List <Indigo_HorasProjeto> objn = dataInterface.BuscaHorasProjeto().Where(x => x.hpo_usrId == usuarioId && x.hpo_jtfAprovado == 1 && x.hpo_DataHoraInicio.Value.Month == DateTime.Now.Month).ToList();

                var    numero    = objn.GroupBy(x => x.hpo_jtfSequencia).ToList();
                string respEmail = "";

                if (numero.Count <= 12)
                {
                    List <RetornoEstruturaJustifica> retorno = new List <RetornoEstruturaJustifica>();

                    var obj = new Indigo_HorasProjeto
                    {
                        // hpo_Id = id,
                        hpo_prjId          = projetoId,
                        hpo_sfpId          = subFaseProjetoId,
                        hpo_usrId          = usuarioId,
                        hpo_DataHoraInicio = dataInicio,
                        hpo_DataHoraFim    = dataFim,
                        hpo_Observacao     = obs,
                        hpo_jtfAprovado    = 0
                    };

                    retorno = this.dataInterface.IniciaHorasJust(obj, justificativa);

                    string trataHora = "";

                    if (DateTime.Now.Hour < 12)
                    {
                        trataHora = "Bom dia";
                    }
                    else if (DateTime.Now.Hour > 12 && DateTime.Now.Hour < 18)
                    {
                        trataHora = "Boa tarde";
                    }
                    else if (DateTime.Now.Hour > 18)
                    {
                        trataHora = "Boa noite";
                    }


                    foreach (var just in retorno)
                    {
                        if (just.DataInicio != just.DataFim)
                        {
                            int diferenca = (Time.WorkDays(just.DataInicio, just.DataFim) - 2) * 8;
                            var tempos    = Time.TimeSpaces(just.HoraInicio, just.HoraFim);
                            var res       = Time.SumTimes(tempos[0], tempos[1]);
                            just.Tempo = Time.AddHours(res, diferenca);
                        }
                        else
                        {
                            just.Tempo = (just.Tempo == null) ? "" : just.Tempo;
                        }

                        StringBuilder pagina = new StringBuilder();

                        pagina.Append(@"<!DOCTYPE html>
                            <html>
                            <head>
                                <title> Ponto justificado</title>
                            </head>
                            <body>
                            <style>
                                .Aprova {
                                    background: #1886cf;
                                }
                                .Negar {
                                    background: #e52525;
                                }
                                table {
                                    font-family: 'Helvetica Neue', sans-serif;
                                    border-bottom: 1px solid #555;
                                    border-top: 1px solid black;
                                }
                                table td {
                                    color: #555;
                                    padding: 1em;
                                }
                                .btn-container {
                                    text-align: center;
                                    margin-top: 1em;
                                }
                                .btn-container a {
                                    padding: 1em;
                                    border-radius: 3px;
                                    margin-top: 1em;
                                    color: white;
                                    font - size: 16px;
                                    text - transform: uppercase;
                                }
                                table th {
                                    font-weight: bolder;
                                }
                            </style>
                            <p>" + just.NomeEstrutura + ", " + trataHora + @" </p>
                               <p> Você tem uma justificativa de horas de projetos registrada por " + just.Nome + @", abaixo detalhes:</p>
                                  <table align = ""center"">
                                            <th> Nome </th>
                                            <th> Justificativa </th>
                                            <th> Data Início </th>
                                            <th> Hora Início </th>
                                            <th> Data Fim </th>
                                            <th> Hora Fim </th>
                                            <th> Tempo </th>
                                            <th> Cliente </th>
                                            <th> Produto </th>
                                            <th> Projeto </th>
                                            <th> Fase Projeto </th>
                                            <th> Atividade </th>
                                            <th> Observação </th>
                                            <tr>
                                            <td>" + just.Nome + @"</td>
                                            <td>" + just.Justificativa + @"</td>
                                            <td>" + just.DataInicio + @"</td>
                                            <td>" + just.HoraInicio + @"</td>
                                            <td>" + just.DataFim + @"</td>
                                            <td>" + just.HoraFim + @"</td>
                                            <td>" + just.Tempo + @"</td>
                                            <td>" + just.Cliente + @"</td>
                                            <td>" + just.Produto + @"</td>
                                            <td>" + just.Projeto + @"</td>
                                            <td>" + just.Fase_Projeto + @"</td>
                                            <td>" + just.Atividade + @"</td>
                                            <td>" + just.Observacao + @"</td>
                                            </tr>
                                            </table>
                                            <div class=""btn-container"">
                                            <a class=""Aprova"" href =""http://admin.indigosoft.biz/HorasProjeto/ProcessaJustificativa?id=" + usuarioId + "&jtfid=1&dao=" + dataInicio.ToString("yyyy-MM-dd") + "&daf=" + dataFim.ToString("yyyy-MM-dd") + "&justid=" + justificativa + @""" style=""text-decoration:none;"">APROVAR</a>
                                             <a class=""Negar"" href =""http://admin.indigosoft.biz/HorasProjeto/ProcessaJustificativa?id=" + usuarioId + "&jtfid=0&dao=" + dataInicio.ToString("yyyy-MM-dd") + "&daf=" + dataFim.ToString("yyyy-MM-dd") + @"&justid=" + justificativa + @""" style=""text-decoration:none;"">RECUSAR</a>
                                            </div>
                                            </body>
                                            </html>");


                        respEmail = EnviaEmail("*****@*****.**", "indigo.2017", just.EmailEstrutura.ToString(), "Ferramenta Check in/out", pagina.ToString());
                    }

                    return(base.Json(new { Result = respEmail }, 0));
                }
                else
                {
                    return(base.Json(new { Result = "Você não pode justificar mais ausência esse mês !" }, 0));
                }
            }
            catch (Exception ex)
            {
                log(ex.Message + " -- " + ex.StackTrace);
                return(base.Json(new { Result = ex.Message + " -- " + ex.StackTrace }, 0));
            }
        }