Ejemplo n.º 1
0
        public ActionResult SetBatchInterval(BatchMonitoringViewModel batchMonitoringVM)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("SetBatchInterval").Add("intervalTime", batchMonitoringVM.IntervalTime).ToInputLogString());
            try
            {
                if (ModelState.IsValid)
                {
                    _auditlogFacade = new AuditLogFacade();
                    if (_auditlogFacade.SaveBatchInterval(batchMonitoringVM.IntervalTimeInput.ToNullable <int>().Value))
                    {
                        return(RedirectToAction("BatchMonitoring", "AuditLog"));
                    }
                }

                TempData["BatchMonitoringVM"] = batchMonitoringVM;
                return(BatchMonitoring());
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("SetBatchInterval").Add("Error Message", ex.Message).ToFailLogString());
                return(Json(new
                {
                    Valid = false,
                    Error = Resource.Error_System,
                    Errors = string.Empty
                }));
            }
        }
Ejemplo n.º 2
0
        public ActionResult BatchMonitoring()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("BatchMonitoring").ToInputLogString());
            try
            {
                _auditlogFacade = new AuditLogFacade();
                BatchMonitoringViewModel batchMonitorVM = null;

                if (TempData["BatchMonitoringVM"] != null)
                {
                    batchMonitorVM = (BatchMonitoringViewModel)TempData["BatchMonitoringVM"];
                }
                else
                {
                    batchMonitorVM = new BatchMonitoringViewModel();
                    int intervalTime = _auditlogFacade.GetBatchInterval();
                    batchMonitorVM.IntervalTime      = intervalTime;
                    batchMonitorVM.IntervalTimeInput = intervalTime.ToString(CultureInfo.InvariantCulture);
                }

                batchMonitorVM.BatchProcessList = _auditlogFacade.GetBatchProcess();
                batchMonitorVM.MonitorDateTime  = DateTime.Now.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);

                return(View("~/Views/AuditLog/BatchMonitoring.cshtml", batchMonitorVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("BatchMonitoring").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Ejemplo n.º 3
0
        public JsonResult LoadActionByModule(string module)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("LoadActionByModule").Add("module", module).ToInputLogString());
            try
            {
                _auditlogFacade = new AuditLogFacade();

                var actionList = _auditlogFacade.GetActionByModule(module, Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                var lstAction  = new SelectList((IEnumerable)actionList, "Key", "Value", string.Empty);

                return(Json(new
                {
                    Valid = true,
                    lstAction = lstAction
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("LoadActionByModule").Add("Error Message", ex.Message).ToFailLogString());
                return(Json(new
                {
                    Valid = false,
                    Error = Resource.Error_System,
                    Errors = string.Empty
                }));
            }
        }
Ejemplo n.º 4
0
        public static bool BatchProcessEnd(string processCode, int batchStatus, DateTime endTime, TimeSpan processTime, string detail)
        {
            IAuditLogFacade auditLogFacade = null;

            try
            {
                auditLogFacade = new AuditLogFacade();
                var proc = auditLogFacade.GetBatchProcessByCode(processCode);
                if (proc != null)
                {
                    proc.Status      = batchStatus;
                    proc.EndTime     = endTime;
                    proc.ProcessTime = processTime;
                    proc.Detail      = detail;

                    return(auditLogFacade.UpdateBatchProcess(proc));
                }

                return(false);
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
            }
            finally
            {
                if (auditLogFacade != null)
                {
                    auditLogFacade.Dispose();
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        public static bool BatchProcessStart(string processCode, DateTime startTime)
        {
            IAuditLogFacade auditLogFacade = null;

            try
            {
                auditLogFacade = new AuditLogFacade();
                var proc = auditLogFacade.GetBatchProcessByCode(processCode);
                if (proc != null && proc.Status != Constants.BatchProcessStatus.Processing)
                {
                    proc.Status      = Constants.BatchProcessStatus.Processing;
                    proc.StartTime   = startTime;
                    proc.EndTime     = null;
                    proc.ProcessTime = null;
                    proc.Detail      = null;

                    return(auditLogFacade.UpdateBatchProcess(proc));
                }

                return(false);
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
            }
            finally
            {
                if (auditLogFacade != null)
                {
                    auditLogFacade.Dispose();
                }
            }

            return(false);
        }
Ejemplo n.º 6
0
        public ActionResult Search()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch AuditLog").ToInputLogString());
            try
            {
                _commonFacade   = new CommonFacade();
                _auditlogFacade = new AuditLogFacade();
                AuditLogViewModel auditlogVM = new AuditLogViewModel();

                auditlogVM.SearchFilter = new AuditLogSearchFilter
                {
                    FirstName = string.Empty,
                    LastName  = string.Empty,
                    DateFrom  = string.Empty,
                    DateTo    = string.Empty,
                    Module    = string.Empty,
                    Action    = string.Empty,
                    Status    = null,
                    PageNo    = 1,
                    PageSize  = _commonFacade.GetPageSizeStart(),
                    SortField = "AuditLogId",
                    SortOrder = "DESC"
                };

                var moduleList = _auditlogFacade.GetModule(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.Module = new SelectList((IEnumerable)moduleList, "Key", "Value", string.Empty);

                var actionList = _auditlogFacade.GetAction(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.Action = new SelectList((IEnumerable)actionList, "Key", "Value", string.Empty);

                var statusList = _auditlogFacade.GetStatusSelectList(Resource.Ddl_Status_All, Constants.ApplicationStatus.All);
                ViewBag.Status = new SelectList((IEnumerable)statusList, "Key", "Value", string.Empty);

                ViewBag.PageSize     = auditlogVM.SearchFilter.PageSize;
                ViewBag.PageSizeList = _commonFacade.GetPageSizeList();
                ViewBag.Message      = string.Empty;

                return(View(auditlogVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("InitSearch AuditLog").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Ejemplo n.º 7
0
        public ActionResult BatchProcessList()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("BatchProcessList").ToInputLogString());
            try
            {
                _auditlogFacade = new AuditLogFacade();
                var batchMonitorVM = new BatchMonitoringViewModel();
                batchMonitorVM.BatchProcessList = _auditlogFacade.GetBatchProcess();
                batchMonitorVM.MonitorDateTime  = DateTime.Now.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);

                return(PartialView("~/Views/AuditLog/_BatchProcessList.cshtml", batchMonitorVM));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("BatchProcessList").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
Ejemplo n.º 8
0
        public static void AuditLog(AuditLogEntity auditLog)
        {
            IAuditLogFacade auditLogFacade = null;

            try
            {
                auditLogFacade = new AuditLogFacade();
                auditLogFacade.AddLog(auditLog);
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
            }
            finally
            {
                if (auditLogFacade != null)
                {
                    auditLogFacade.Dispose();
                }
            }
        }
Ejemplo n.º 9
0
        public static void AuditLog(AuditLogEntity auditLog, LogStatus status, string detail)
        {
            IAuditLogFacade auditLogFacade = null;

            try
            {
                auditLogFacade  = new AuditLogFacade();
                auditLog.Status = status;
                auditLog.Detail = detail;
                auditLogFacade.AddLog(auditLog);
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
            }
            finally
            {
                if (auditLogFacade != null)
                {
                    auditLogFacade.Dispose();
                }
            }
        }
Ejemplo n.º 10
0
        public ActionResult AuditLogList(AuditLogSearchFilter searchFilter)
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Search AuditLog").Add("Name", searchFilter.FirstName)
                        .Add("DateFrom", searchFilter.DateFrom).Add("DateTo", searchFilter.DateTo).Add("Module", searchFilter.Module)
                        .Add("Action", searchFilter.Action).Add("Status", searchFilter.Status));
            try
            {
                #region "Validation"

                bool isValid = TryUpdateModel(searchFilter);
                if (!string.IsNullOrEmpty(searchFilter.DateFrom) && !searchFilter.DateFromValue.HasValue)
                {
                    isValid = false;
                    ModelState.AddModelError("txtFromDate", Resource.ValErr_InvalidDate);
                }
                else if (searchFilter.DateFromValue.HasValue)
                {
                    if (searchFilter.DateFromValue.Value > DateTime.Now.Date)
                    {
                        isValid = false;
                        ModelState.AddModelError("txtFromDate", Resource.ValErr_InvalidDate_MustLessThanToday);
                    }
                }

                if (!string.IsNullOrEmpty(searchFilter.DateTo) && !searchFilter.DateToValue.HasValue)
                {
                    isValid = false;
                    ModelState.AddModelError("txtToDate", Resource.ValErr_InvalidDate);
                }
                else if (searchFilter.DateToValue.HasValue)
                {
                    if (searchFilter.DateToValue.Value > DateTime.Now.Date)
                    {
                        isValid = false;
                        ModelState.AddModelError("txtToDate", Resource.ValErr_InvalidDate_MustLessThanToday);
                    }
                }

                if (searchFilter.DateFromValue.HasValue && searchFilter.DateToValue.HasValue &&
                    searchFilter.DateFromValue.Value > searchFilter.DateToValue.Value)
                {
                    isValid = false;
                    ModelState.AddModelError("dvDateRange", Resource.ValErr_InvalidDateRange);
                }

                #endregion

                if (isValid)
                {
                    _commonFacade   = new CommonFacade();
                    _auditlogFacade = new AuditLogFacade();
                    AuditLogViewModel auditlogVM = new AuditLogViewModel();
                    auditlogVM.SearchFilter = searchFilter;
                    auditlogVM.AuditLogList = _auditlogFacade.SearchAuditLogs(searchFilter);

                    ViewBag.PageSize     = auditlogVM.SearchFilter.PageSize;
                    ViewBag.PageSizeList = _commonFacade.GetPageSizeList();

                    return(PartialView("~/Views/AuditLog/_AuditLogList.cshtml", auditlogVM));
                }

                return(Json(new
                {
                    Valid = false,
                    Error = string.Empty,
                    Errors = GetModelValidationErrors()
                }));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Search AuditLog").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }