Ejemplo n.º 1
0
        private EtlSession[] GetEtlSessions(EtlSessionListModel model)
        {
            var dateTo   = DateTime.ParseExact(model.DateTo, SharedStrings.DateFormat, null);
            var dateFrom = DateTime.ParseExact(model.DateFrom, SharedStrings.DateFormat, null);
            var oneDay   = dateTo == dateFrom;

            dateTo = dateTo.AddDays(1);

            var query = new EtlSessionQuery
            {
                FromDateTime    = dateFrom,
                ToDateTime      = dateTo,
                MaxSessionCount = model.DefaultMaxSessionCount,
            };

            if (model.Status > 0)
            {
                query.EtlStatuses.Add(model.Status);
            }

            var agent     = SiteConfiguration.GetEtlAgent();
            var logParser = agent.GetEtlLogParser();
            var sessions  = logParser.GetEtlSessions(query);

            return(sessions);
        }
Ejemplo n.º 2
0
        private static EtlSessionListModel SetDefaultModel(EtlSessionListModel model)
        {
            if (model == null)
            {
                model = new EtlSessionListModel();
            }

            var dateFrom = StringToDateTime(model.DateFrom);
            var dateTo   = StringToDateTime(model.DateTo);

            if (!dateTo.HasValue)
            {
                dateTo = DateTime.Now;
            }

            if (!dateFrom.HasValue)
            {
                dateFrom = dateTo.Value.Subtract(new TimeSpan(model.DefaultTimespanDays, 0, 0, 0));
            }

            model.DateFrom = dateFrom.Value.ToString(SharedStrings.DateFormat);
            model.DateTo   = dateTo.Value.ToString(SharedStrings.DateFormat);
            model.Sessions = new List <EtlSession>();

            return(model);
        }
Ejemplo n.º 3
0
        private bool ValidateModelExt(EtlSessionListModel model)
        {
            var wasErrors = false;

            var dateFrom = StringToDateTime(model.DateFrom);
            var dateTo   = StringToDateTime(model.DateTo);

            if (!dateTo.HasValue)
            {
                dateTo = DateTime.Now;
            }

            if (!dateFrom.HasValue)
            {
                dateFrom = dateTo.Value.Subtract(new TimeSpan(model.DefaultTimespanDays, 0, 0, 0));
            }

            if (dateFrom.Value > dateTo.Value)
            {
                this.AddErrorMessageFor <EtlSessionListModel, string>(m => m.DateFrom, "Ќачальна¤ дата должна быть меньше конечной");
                wasErrors = true;
            }

            return(!wasErrors);
        }
        private static EtlSessionListModel SetDefaultModel(EtlSessionListModel model)
        {
            if (model == null)
            {
                model = new EtlSessionListModel();
            }

            var dateFrom = StringToDateTime(model.DateFrom);
            var dateTo = StringToDateTime(model.DateTo);

            if (!dateTo.HasValue)
            {
                dateTo = DateTime.Now;
            }

            if (!dateFrom.HasValue)
            {
                dateFrom = dateTo.Value.Subtract(new TimeSpan(model.DefaultTimespanDays, 0, 0, 0));
            }

            model.DateFrom = dateFrom.Value.ToString(SharedStrings.DateFormat);
            model.DateTo = dateTo.Value.ToString(SharedStrings.DateFormat);
            model.Sessions = new List<EtlSession>();

            return model;
        }
Ejemplo n.º 5
0
        public ActionResult EtlSessionList(EtlSessionListModel model)
        {
            model = SetDefaultModel(model);

            if (ValidateModelExt(model))
            {
                model.Sessions.AddRange(GetEtlSessions(model));
            }

            return(View(model));
        }
        public ActionResult EtlSessionList(EtlSessionListModel model)
        {
            model = SetDefaultModel(model);

            if (ValidateModelExt(model))
            {
                model.Sessions.AddRange(GetEtlSessions(model));
            }

            return View(model);
        }
        private EtlSession[] GetEtlSessions(EtlSessionListModel model)
        {
            var dateTo = DateTime.ParseExact(model.DateTo, SharedStrings.DateFormat, null);
            var dateFrom = DateTime.ParseExact(model.DateFrom, SharedStrings.DateFormat, null);
            var oneDay = dateTo == dateFrom;
            dateTo = dateTo.AddDays(1);

            var query = new EtlSessionQuery
            {
                FromDateTime = dateFrom,
                ToDateTime = dateTo,
                MaxSessionCount = model.DefaultMaxSessionCount,
            };

            if (model.Status > 0)
            {
                query.EtlStatuses.Add(model.Status);
            }

            var agent = SiteConfiguration.GetEtlAgent();
            var logParser = agent.GetEtlLogParser();
            var sessions = logParser.GetEtlSessions(query);

            return sessions;
        }
        private bool ValidateModelExt(EtlSessionListModel model)
        {
            var wasErrors = false;

            var dateFrom = StringToDateTime(model.DateFrom);
            var dateTo = StringToDateTime(model.DateTo);

            if (!dateTo.HasValue)
            {
                dateTo = DateTime.Now;
            }

            if (!dateFrom.HasValue)
            {
                dateFrom = dateTo.Value.Subtract(new TimeSpan(model.DefaultTimespanDays, 0, 0, 0));
            }

            if (dateFrom.Value > dateTo.Value)
            {
                this.AddErrorMessageFor<EtlSessionListModel, string>(m => m.DateFrom, "Ќачальна¤ дата должна быть меньше конечной");
                wasErrors = true;
            }

            return !wasErrors;
        }