Exemplo 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));
        }
Exemplo n.º 2
0
        public ActionResult GenerateData(XmlLogIndexViewModel model)
        {
            try
            {
                //string folderPath = @"D:\Temp\EMS\zipFolder\";
                string folderPath = ConfigurationManager.AppSettings["XmlLogPath"];
                string zipName    = "XmlLogZip" + "_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + "_" + CurrentUser.USER_ID + ".zip";

                var input = new BackupXmlLogInput();
                input.FolderPath  = folderPath;
                input.FileZipName = folderPath + zipName;

                input.FileName = model.FileName;
                input.Month    = model.Month;

                _nLogBll.BackupXmlLog(input);

                return(Json(new { success = true, zipName }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                return(Json(new { success = false, message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        private XmlLogIndexViewModel SetListIndex(XmlLogIndexViewModel model)
        {
            //var listData = _nLogBll.GetAllData();
            //result = listData.DistinctBy(c=>c.FileName).ToList();

            var listData = _nLogBll.GetAllDataFileName();

            //model.FileNameList = new SelectList(listData, "FileName", "FileName");
            model.FileNameList = new SelectList(listData);
            model.MonthList    = GetListMont();

            //if (listData.Any())
            //    model.FileName = listData.First();

            return(model);
        }
Exemplo n.º 5
0
        public ActionResult BackupXml(XmlLogIndexViewModel model)
        {
            //var input = new NlogGetByParamInput()
            //{
            //    FileName = model.FileName,
            //    Month = model.Month
            //};

            //_nLogBll.DeleteDataByParam(input);

            //AddMessageInfo("Success backup data", Enums.MessageInfoType.Success);

            //return RedirectToAction("Index");

            try
            {
                //string folderPath = @"D:\Temp\EMS\zipFolder\";
                string folderPath = ConfigurationManager.AppSettings["XmlLogPath"];
                string zipName    = "XmlLogZip" + "_" + DateTime.Now.ToString("ddMMyyyyHHmmss") + "_" + CurrentUser.USER_ID + ".zip";

                var input = new BackupXmlLogInput();
                input.FolderPath  = folderPath;
                input.FileZipName = folderPath + zipName;

                input.FileName = model.FileName;
                input.Month    = model.Month;

                _nLogBll.BackupXmlLog(input);

                // Read bytes from disk
                //byte[] fileBytes = System.IO.File.ReadAllBytes(Server.MapPath("~/Directories/hello/sample.zip"));
                byte[] fileBytes = System.IO.File.ReadAllBytes(folderPath + zipName);

                // Return bytes as stream for download
                return(File(fileBytes, "application/zip", zipName));
            }
            catch (Exception ex)
            {
                AddMessageInfo(ex.Message, Enums.MessageInfoType.Error);

                return(RedirectToAction("Index"));
            }
        }