Exemplo n.º 1
0
        /// <summary>
        /// Recupera uma lista de eventos
        /// </summary>
        /// <param name="count">Quantidade maxima de mensagens que devem ser retornadas</param>
        /// <returns></returns>
        public Dictionary <long, string> GetList(int count = 100)
        {
            Dictionary <long, string> ret = new Dictionary <long, string>();

            List <Entities.Log> evs = new List <Entities.Log>();

            using (IDbConnection db = base.GetConnection())
                using (IDbCommand cmd = db.CreateCommand())
                {
                    cmd.CommandText = "SELECT IdLog, Message from Log order by IdLog asc LIMIT " + count;
                    cmd.CommandType = CommandType.Text;
                    db.Open();
                    cmd.Prepare();

                    IDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Entities.Log log = new Entities.Log();

                        log.IdLog   = reader.GetInt64(reader.GetOrdinal("IdLog"));
                        log.Message = reader.IsDBNull(reader.GetOrdinal("Message")) ? null : reader.GetString(reader.GetOrdinal("Message"));

                        evs.Add(log);
                    }
                }

            foreach (Entities.Log item in evs)
            {
                ret.Add(item.IdLog, item.Message);
            }

            return(ret);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Recupera um evento do banco de dados
        /// </summary>
        /// <param name="id">Codigo do evento</param>
        /// <returns></returns>
        public NetStashEvent Get(out long id)
        {
            Entities.Log getLog = null;
            using (IDbConnection db = GetConnection())
                using (IDbCommand cmd = db.CreateCommand())
                {
                    cmd.CommandText = "SELECT IdLog, Message from Log order by IdLog asc LIMIT 1";
                    cmd.CommandType = CommandType.Text;
                    db.Open();
                    cmd.Prepare();

                    IDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        getLog = new Entities.Log
                        {
                            IdLog   = reader.GetInt64(reader.GetOrdinal("IdLog")),
                            Message = reader.IsDBNull(reader.GetOrdinal("Message"))
                            ? null
                            : reader.GetString(reader.GetOrdinal("Message"))
                        };
                    }
                }

            if (getLog == null)
            {
                id = -1;
                return(null);
            }

            id = getLog.IdLog;

            return(JsonConvert.DeserializeObject <NetStashEvent>(getLog.Message));
        }
Exemplo n.º 3
0
        public void Add(NetStashEvent log)
        {
            Entities.Log addLog = new Entities.Log();
            //addLog.Message = Newtonsoft.Json.JsonConvert.SerializeObject(log);

            //Microsoft.AspNetCore.Formatter.Json
            string JsonString = log.GetJson();

            addLog.Message = JsonString;

            using (IDbConnection db = NetStashStandard.Log.NetStashLog.TypeNet == Log.TypeNet.NetCore ? baseProxy.GetConnectionSqlite() : baseProxy.GetConnection())

                using (IDbCommand cmd = db.CreateCommand())
                {
                    cmd.CommandText = "INSERT INTO Log (Message) VALUES (@Message)";
                    cmd.CommandType = CommandType.Text;
                    IDbDataParameter pMessage = cmd.CreateParameter();
                    pMessage.ParameterName = "@Message";
                    pMessage.Value         = addLog.Message;
                    cmd.Parameters.Add(pMessage);
                    cmd.Prepare();
                    db.Open();
                    cmd.ExecuteNonQuery();
                }
        }
Exemplo n.º 4
0
        public void AddLog(string message, LogDetails details)
        {
            var existingClass  = GetExistingOrNewClass(details);
            var existingMethod = GetExistingOrNewMethod(details, existingClass);

            var newLogEnt = new Entities.Log
            {
                MethodId    = existingMethod.Id,
                Message     = message,
                DateCreated = details.TimeLogged,
                LogType     = (short)details.LogType
            };

            _logEntryData.Save(newLogEnt);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adiciona uma nova mensagem no banco de dados
        /// </summary>
        /// <param name="log">Evento que sera adicionado</param>
        public void Add(NetStashEvent log)
        {
            Entities.Log addLog = new Entities.Log();
            addLog.Message = Newtonsoft.Json.JsonConvert.SerializeObject(log.ToDictionary());

            using (IDbConnection db = base.GetConnection())
                using (IDbCommand cmd = db.CreateCommand())
                {
                    cmd.CommandText = "INSERT INTO Log (Message) VALUES (@Message)";
                    cmd.CommandType = CommandType.Text;
                    IDbDataParameter pMessage = cmd.CreateParameter();
                    pMessage.ParameterName = "@Message";
                    pMessage.Value         = addLog.Message;
                    cmd.Parameters.Add(pMessage);
                    db.Open();
                    cmd.Prepare();
                    cmd.ExecuteNonQuery();
                }
        }
Exemplo n.º 6
0
        public static List <Entities.Log> ListarLog(string ticketid)
        {
            var lista = new List <Entities.Log>();

            using (var cn = new SqlConnection(conexion.Cadena))
            {
                using (var cmd = new SqlCommand("select ld.Id,ld.RobotVirtualMachineId,ro.Description as robot,ld.StateId,st.Name as state, " +
                                                "ld.TicketId,ld.Description,ld.Exception, ld.StackTrace, ld.Method, ld.CreationDate from[EES.BBVA.2018v1].dbo.LogDatas ld " +
                                                "left join[EES.BBVA.2018v1].dbo.RobotVirtualMachines rvm on rvm.Id = ld.RobotVirtualMachineId " +
                                                "left join[EES.BBVA.2018v1].dbo.Robots ro on ro.Id = rvm.RobotId " +
                                                "left join[EES.BBVA.2018v1].dbo.States st on st.Id = ld.StateId " +
                                                "where ld.TicketId = " + ticketid + " order by ld.id desc", cn))
                {
                    cn.Open();
                    using (var dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            var oLog = new Entities.Log();
                            oLog.id = Convert.ToString(dr[dr.GetOrdinal("Id")]);
                            oLog.robotvirtualmachineId = Convert.ToString(dr[dr.GetOrdinal("RobotVirtualMachineId")]);
                            oLog.robot        = Convert.ToString(dr[dr.GetOrdinal("robot")]);
                            oLog.stateid      = Convert.ToString(dr[dr.GetOrdinal("StateId")]);
                            oLog.state        = Convert.ToString(dr[dr.GetOrdinal("state")]);
                            oLog.ticketid     = Convert.ToString(dr[dr.GetOrdinal("TicketId")]);
                            oLog.description  = Convert.ToString(dr[dr.GetOrdinal("Description")]);
                            oLog.exception    = Convert.ToString(dr[dr.GetOrdinal("Exception")]);
                            oLog.method       = Convert.ToString(dr[dr.GetOrdinal("Method")]);
                            oLog.creationdate = Convert.ToString(dr[dr.GetOrdinal("CreationDate")]);
                            lista.Add(oLog);
                        }
                    }
                    return(lista);
                }
            }
        }