Ejemplo n.º 1
0
        public static LogVM GetLog(Guid requestId)
        {
            using (NGADbContext context = new NGADbContext())
            {
                UnitOfWork       unitOfWork = new UnitOfWork(context);
                DbSet <Log>      _log       = context.Set <Log>();
                DbSet <LogError> _logError  = context.Set <LogError>();

                Log request = _log.FirstOrDefault(a => a.Id == requestId);
                if (request != null)
                {
                    LogVM result = new LogVM();

                    result.ActionName     = request.ActionName;
                    result.ControllerName = request.ControllerName;
                    result.CreateDate     = request.CreateDate;
                    result.Id             = request.Id;
                    result.MethodType     = request.MethodType;
                    result.Path           = request.Path;
                    result.RequestBody    = request.RequestBody;
                    result.ResponseTime   = request.ResponseTime;
                    result.ReturnTypeName = request.ReturnTypeName;
                    result.Errors         = _logError.Where(a => a.RequestId == request.Id).ToList();

                    return(result);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 2
0
        public static void LoadStaticValues()
        {
            using (NGADbContext context = new NGADbContext())
            {
                UnitOfWork unitOfWork = new UnitOfWork(context);

                DbSet <Parameter> _param = context.Set <Parameter>();

                List <Parameter> parameters = _param.Where(a => !a.IsDeleted).ToList();

                Type myType = typeof(ParameterValue);
                foreach (var item in parameters)
                {
                    PropertyInfo myPropInfo = myType.GetProperty(item.Code);
                    if (myPropInfo == null)
                    {
                        continue;
                    }

                    var value = parameters.Where(a => a.Code == item.Code).Select(a => a.Value).FirstOrDefault();
                    if (value == null || Validation.IsNullOrEmpty(value))
                    {
                        continue;
                    }

                    if (myPropInfo.PropertyType == typeof(string))
                    {
                        myPropInfo.SetValue(null, value);
                    }
                    else if (myPropInfo.PropertyType == typeof(Guid) || myPropInfo.PropertyType == typeof(Guid?))
                    {
                        Guid?guidVal = Guid.Parse(value);

                        if (guidVal != null && guidVal != Guid.Empty)
                        {
                            myPropInfo.SetValue(null, guidVal.Value);
                        }
                    }
                    else if (myPropInfo.PropertyType == typeof(bool))
                    {
                        myPropInfo.SetValue(null, NGA.Core.Convert.ToBoolean(value));
                    }
                    else if (myPropInfo.PropertyType == typeof(int))
                    {
                        int num = Convert.ToInt32(value);
                        myPropInfo.SetValue(null, num);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void Save()
        {
            try
            {
                if (!ParameterValue.SYS01001)
                {
                    return;
                }

                if ((Errors != null && Errors.Count > 0) || (Logs != null && Logs.Count > 0))
                {
                    using (NGADbContext context = new NGADbContext())
                    {
                        UnitOfWork       unitOfWork = new UnitOfWork(context);
                        DbSet <Log>      _log       = context.Set <Log>();
                        DbSet <LogError> _logError  = context.Set <LogError>();

                        if (Logs != null)
                        {
                            foreach (var item in Logs)
                            {
                                _log.Add(item);
                            }
                        }

                        if (Errors != null)
                        {
                            foreach (var error in Errors)
                            {
                                _logError.Add(error);
                            }
                        }

                        context.SaveChanges();
                        Clean();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 4
0
        public static List <LogVM> GetLogs()
        {
            List <Log>      _logs   = new List <Log>();
            List <LogError> _errors = new List <LogError>();

            using (NGADbContext context = new NGADbContext())
            {
                UnitOfWork       unitOfWork = new UnitOfWork(context);
                DbSet <Log>      _log       = context.Set <Log>();
                DbSet <LogError> _logError  = context.Set <LogError>();

                _logs   = _log.ToList();
                _errors = _logError.ToList();
            }

            List <LogVM> result = new List <LogVM>();

            foreach (var item in _logs)
            {
                result.Add(new LogVM()
                {
                    ActionName     = item.ActionName,
                    ControllerName = item.ControllerName,
                    CreateDate     = item.CreateDate,
                    Id             = item.Id,
                    MethodType     = item.MethodType,
                    Path           = item.Path,
                    RequestBody    = item.RequestBody,
                    ResponseTime   = item.ResponseTime,
                    ReturnTypeName = item.ReturnTypeName,
                    Errors         = _errors.Where(a => a.RequestId == item.Id).ToList()
                });
            }

            return(result);
        }
Ejemplo n.º 5
0
 public LoggerFilter(NGADbContext _con)
 {
     con = _con;
 }
Ejemplo n.º 6
0
 public UserService(NGADbContext _con, IMapper _mapper)
 {
     con    = _con;
     mapper = _mapper;
 }
Ejemplo n.º 7
0
 public ChatHub(IMessageService service, IMapper mapper, NGADbContext con)
 {
     _service = service;
     _mapper  = mapper;
     _con     = con;
 }
Ejemplo n.º 8
0
 public Repository(NGADbContext context)
 {
     con = context;
 }
Ejemplo n.º 9
0
 public UnitOfWork(NGADbContext _con)
 {
     con = _con;
 }