Esempio n. 1
0
        private static List <Logs> Get_Logs_Defeitos(Projeto projeto, Defeito defeito, alm.Database database)
        {
            Connection SGQConn          = new Connection();
            string     Esquema          = SGQConn.Get_String($"select Esquema from ALM_Projetos where subprojeto = '{projeto.Subprojeto}' and entrega = '{projeto.Entrega}'");
            string     Encaminhado_Para = "bg_user_template_09".ToUpper();

            SGQConn.Dispose();

            if (defeito.Ultima_Data == null)
            {
                defeito.Ultima_Data = "1901-01-01 01:01:01";
            }

            string sql_Logs = $@"
            select 
                to_char(au_time,'yyyy-mm-dd hh24:mi:ss') as Data,
                ap_field_name as Campo,
                ap_new_value as Valor,
                au_user as Operador
            from  
                {Esquema}.audit_properties
                inner join {Esquema}.audit_log
                    on ap_action_id = au_action_id 
                inner join {Esquema}.bug
                    on au_entity_id = bg_bug_id 
            where 
                (au_entity_type = 'BUG') and 
                (ap_field_name = 'BG_STATUS' or ap_field_name = '{Encaminhado_Para}') and
                (au_entity_id = {defeito.Id}) 
            order by au_time"; //.Replace("{Ultima_Data}", defeito.Ultima_Data);

            ALMConnection ALMConn = new ALMConnection(database);
            //List<Logs> List_Logs = new List<Logs>();
            //List_Logs = ALMConn.Executar<Logs>(sql_Logs);
            List <Logs> List_Logs = ALMConn.Executar <Logs>(sql_Logs);

            ALMConn.Dispose();

            return(List_Logs);
        }
Esempio n. 2
0
        private static List <Evento> Get_Eventos(Defeito defeito, List <Logs> List_Logs)
        {
            string Ultimo_Data             = "";
            string Ultimo_Status           = "";
            string Ultimo_Encaminhado_Para = "";
            var    List_Eventos            = new List <Evento>();
            var    evento = new Evento();

            evento.Dt_De = "";

            foreach (Logs oLogs in List_Logs)
            {
                if (evento.Dt_De == "")
                {
                    evento.Dt_De = oLogs.Data;
                }

                if (oLogs.Data != evento.Dt_De)
                {
                    evento.Dt_Ate = oLogs.Data;

                    if (evento.Status == null && Ultimo_Status != "")
                    {
                        evento.Status = Ultimo_Status;
                    }

                    if (evento.Encaminhado_Para == null && Ultimo_Encaminhado_Para != "")
                    {
                        evento.Encaminhado_Para = Ultimo_Encaminhado_Para;
                    }

                    Ultimo_Data             = evento.Dt_Ate;
                    Ultimo_Status           = evento.Status;
                    Ultimo_Encaminhado_Para = evento.Encaminhado_Para;

                    evento.Tempo_Util_Min = (long)DataEHora.BusinessTimeDelta(
                        DateTime.ParseExact(evento.Dt_De, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
                        DateTime.ParseExact(evento.Dt_Ate, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
                        ).TotalMinutes;

                    evento.Tempo_Decorrido_Min = DataEHora.DateDiff(
                        DataEHora.DateInterval.Minute,
                        DateTime.ParseExact(evento.Dt_De, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
                        DateTime.ParseExact(evento.Dt_Ate, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
                        );

                    List_Eventos.Add(evento);
                    evento       = new Evento();
                    evento.Dt_De = oLogs.Data;
                }

                evento.Operador = oLogs.Operador.ToUpper();

                if (oLogs.Valor != null)
                {
                    if (oLogs.Campo == "BG_STATUS")
                    {
                        evento.Status = oLogs.Valor.ToUpper();
                    }
                    else
                    {
                        evento.Encaminhado_Para = oLogs.Valor.ToUpper();
                    }
                }
            }

            if (evento.Dt_De != null && evento.Dt_De != "")
            {
                if (evento.Status == null && Ultimo_Status != "")
                {
                    evento.Status = Ultimo_Status;
                }

                if (evento.Encaminhado_Para == null && Ultimo_Encaminhado_Para != "")
                {
                    evento.Encaminhado_Para = Ultimo_Encaminhado_Para;
                }

                if (evento.Status == "CLOSED" || evento.Status == "CANCELLED")
                {
                    evento.Dt_Ate = evento.Dt_De;
                }
                else
                {
                    evento.Dt_Ate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }

                evento.Tempo_Util_Min = (long)DataEHora.BusinessTimeDelta(
                    DateTime.ParseExact(evento.Dt_De, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
                    DateTime.ParseExact(evento.Dt_Ate, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
                    ).TotalMinutes;

                evento.Tempo_Decorrido_Min = DataEHora.DateDiff(
                    DataEHora.DateInterval.Minute,
                    DateTime.ParseExact(evento.Dt_De, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture),
                    DateTime.ParseExact(evento.Dt_Ate, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
                    );

                List_Eventos.Add(evento);
            }

            return(List_Eventos);
        }