Ejemplo n.º 1
0
        //
        // GET: /XmlLog/
        public ActionResult Index()
        {
            var model = new XmlLogIndexViewModel();

            model.MainMenu    = Enums.MenuList.Settings;
            model.CurrentMenu = PageInfo;
            model.LogDate     = DateTime.Now.ToString("dd MMM yyyy");
            model             = SetListIndex(model);

            var input = new NlogGetByParamInput();

            input.FileName = model.FileName;
            input.LogDate  = model.LogDate;

            var dataXml = _nLogBll.GetNlogByParam(input);

            model.ListXmlLogs = Mapper.Map <List <XmlLogFormViewModel> >(dataXml);
            foreach (var xmlLogFormViewModel in model.ListXmlLogs)
            {
                if (xmlLogFormViewModel.Logger.Length > 30)
                {
                    xmlLogFormViewModel.Logger = xmlLogFormViewModel.Logger.Substring(0, 30) + "...";
                }

                if (xmlLogFormViewModel.Message.Length > 30)
                {
                    xmlLogFormViewModel.Message = xmlLogFormViewModel.Message.Substring(0, 30) + "...";
                }
            }



            return(View(model));
        }
Ejemplo n.º 2
0
        public PartialViewResult Filter(XmlLogIndexViewModel model)
        {
            var input = new NlogGetByParamInput()
            {
                FileName = model.FileName,
                Month    = model.Month,
                LogDate  = model.LogDate
            };

            var dataXml = _nLogBll.GetNlogByParam(input);

            model.ListXmlLogs = Mapper.Map <List <XmlLogFormViewModel> >(dataXml);

            foreach (var xmlLogFormViewModel in model.ListXmlLogs)
            {
                if (xmlLogFormViewModel.Logger.Length > 30)
                {
                    xmlLogFormViewModel.Logger = xmlLogFormViewModel.Logger.Substring(0, 30) + "...";
                }

                if (xmlLogFormViewModel.Message.Length > 30)
                {
                    xmlLogFormViewModel.Message = xmlLogFormViewModel.Message.Substring(0, 30) + "...";
                }
            }

            return(PartialView("_XmlLogViewIndex", model));
        }
Ejemplo n.º 3
0
        public List <NlogDto> GetNlogByParam(NlogGetByParamInput input)
        {
            Expression <Func <NlogLogs, bool> > queryFilter = PredicateHelper.True <NlogLogs>();

            if (!string.IsNullOrEmpty(input.FileName))
            {
                queryFilter = queryFilter.And(c => c.FileName == input.FileName);
            }

            if (input.Month.HasValue)
            {
                queryFilter = queryFilter.And(c => c.Timestamp.Value.Month == input.Month);
            }

            if (!string.IsNullOrEmpty(input.LogDate))
            {
                var dt = Convert.ToDateTime(input.LogDate);
                queryFilter = queryFilter.And(c => c.Timestamp.Value.Day == dt.Day && c.Timestamp.Value.Month == dt.Month && c.Timestamp.Value.Year == dt.Year);
            }

            Func <IQueryable <NlogLogs>, IOrderedQueryable <NlogLogs> > orderByFilter = n => n.OrderByDescending(z => z.Timestamp);


            var result = _repository.Get(queryFilter, orderByFilter, "").ToList();

            return(Mapper.Map <List <NlogDto> >(result.ToList()));
        }
Ejemplo n.º 4
0
        public void DeleteDataByParam(NlogGetByParamInput input)
        {
            var listData = GetNlogByParam(input);

            foreach (var nlogDto in listData)
            {
                //get data
                var data = _repository.GetByID(nlogDto.Nlog_Id);
                if (data != null)
                {
                    _repository.Delete(data);
                }
            }


            _uow.SaveChanges();
        }
Ejemplo n.º 5
0
        public void BackupXmlLog(BackupXmlLogInput input)
        {
            var inputParam = new NlogGetByParamInput();

            inputParam.FileName = input.FileName;
            inputParam.Month    = input.Month;

            var listData = GetNlogByParam(inputParam);

            var listFile = listData.DistinctBy(c => c.FileName).Select(x => x.FileName).ToList();

            //check file
            foreach (var file in listFile)
            {
                if (!System.IO.File.Exists(input.FolderPath + file))
                {
                    throw new BLLException(ExceptionCodes.BLLExceptions.LogXmlNotFound);
                }
            }

            foreach (var nlogDto in listData)
            {
                //get data
                var data = _repository.GetByID(nlogDto.Nlog_Id);
                if (data != null)
                {
                    _repository.Delete(data);
                }
            }

            //ZipHelper.CreateZip();
            //backup to zip file


            ZipHelper.CreateZip(listFile, input.FolderPath, input.FileZipName);

            _uow.SaveChanges();
        }