Beispiel #1
0
        public Dictionary <string, double> GetRunningTimeReport(TrendAnalisysViewModel model)
        {
            var hotels = Repo <HotelRestaurantRepository>().GetAllModels()
                         .AddEqual(obj => obj.DistrictId == model.AreaGuid, model.AreaGuid)
                         .AddEqual(item => item.StreetId == model.StreetGuid, model.StreetGuid)
                         .AddEqual(hotel => hotel.AddressId == model.AddressGuid, model.AddressGuid)
                         .AddEqual(h => h.ProjectName == model.QueryName, model.QueryName)
                         .Select(t => t.Identity).ToList();

            model.StartDateTime = model.StartDateTime.GetCurrentMonth();
            model.DueDateTime   = model.DueDateTime.GetCurrentMonth();

            var dateList = GetProcessDateTimes(model);

            var linageList = new Dictionary <string, double>();

            using (var repo = Repo <RunningTimeRepository>())
            {
                var runTimes = repo.GetModels(obj => hotels.Contains(obj.ProjectIdentity));
                foreach (var date in dateList)
                {
                    linageList.Add(date.ToString("yyyy-MM"), GetLinkage(runTimes, date, model.ReportType));
                }
            }

            return(linageList);
        }
        public ActionResult GetTrendAnalysis(TrendAnalisysViewModel model)
        {
            if (model.ReportType != ReportType.Month)
            {
                model.StartDateTime = DateTime.Parse($"{Request["StartDateTime"]}-1-1");
                model.DueDateTime   = DateTime.Parse($"{Request["DueDateTime"]}-1-1");
            }
            var result = ProcessInvoke <RunningTimeProcess>().GetRunningTimeReport(model);

            return(Json(new JsonStruct()
            {
                Result = result.Select(obj => new { Date = obj.Key, Linkage = obj.Value })
            },
                        JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        private List <DateTime> GetMonthDateRange(TrendAnalisysViewModel model)
        {
            var months = model.DueDateTime.MonthDifference(model.StartDateTime);

            var monthDates = new List <DateTime>();
            var current    = 0;

            while (current <= months)
            {
                monthDates.Add(model.StartDateTime);
                model.StartDateTime = model.StartDateTime.AddMonths(1);
                current++;
            }

            return(monthDates);
        }
Beispiel #4
0
        private List <DateTime> GetSeasonDateRange(TrendAnalisysViewModel model)
        {
            var startDate = new DateTime(model.StartDateTime.Year, GetSeamonMonth(model.StartSeason), DateTime.DaysInMonth(model.StartDateTime.Year, GetSeamonMonth(model.StartSeason)));
            var endDate   = new DateTime(model.DueDateTime.Year, GetSeamonMonth(model.EndSeason), DateTime.DaysInMonth(model.DueDateTime.Year, GetSeamonMonth(model.EndSeason)));
            var rounds    = endDate.MonthDifference(startDate) / 3;

            var monthDates = new List <DateTime>();
            var current    = 0;

            while (current <= rounds)
            {
                monthDates.Add(startDate);
                startDate = startDate.AddMonths(3);
                current++;
            }

            return(monthDates);
        }
Beispiel #5
0
        private List <DateTime> GetYearDateRange(TrendAnalisysViewModel model)
        {
            var startDate = new DateTime(model.StartDateTime.Year, 12, 31);
            var endDate   = new DateTime(model.DueDateTime.Year, 12, 31);
            var rounds    = endDate.MonthDifference(startDate) / 12;

            var monthDates = new List <DateTime>();
            var current    = 0;

            while (current <= rounds)
            {
                monthDates.Add(startDate);
                startDate = startDate.AddMonths(12);
                current++;
            }

            return(monthDates);
        }
Beispiel #6
0
        private List <DateTime> GetHalfYearDateRange(TrendAnalisysViewModel model)
        {
            var startDate = new DateTime(model.StartDateTime.Year, ((int)model.StartHalfYear + 1) * 6, DateTime.DaysInMonth(model.StartDateTime.Year, ((int)model.StartHalfYear + 1) * 6));
            var endDate   = new DateTime(model.DueDateTime.Year, ((int)model.EndHalfYear + 1) * 6, DateTime.DaysInMonth(model.DueDateTime.Year, ((int)model.EndHalfYear + 1) * 6));
            var rounds    = endDate.MonthDifference(startDate) / 6;

            var monthDates = new List <DateTime>();
            var current    = 0;

            while (current <= rounds)
            {
                monthDates.Add(startDate);
                startDate = startDate.AddMonths(6);
                current++;
            }

            return(monthDates);
        }
Beispiel #7
0
        private List <DateTime> GetProcessDateTimes(TrendAnalisysViewModel model)
        {
            switch (model.ReportType)
            {
            case ReportType.Month:
                return(GetMonthDateRange(model));

            case ReportType.Season:
                return(GetSeasonDateRange(model));

            case ReportType.Halfyear:
                return(GetHalfYearDateRange(model));

            case ReportType.Year:
                return(GetYearDateRange(model));
            }

            return(null);
        }
        public ActionResult TrendAnalysis(TrendAnalisysViewModel model)
        {
            var areaList = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = "全部", Value = ""
                }
            };

            var streetList = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = "全部", Value = ""
                }
            };

            var addressList = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = "全部", Value = ""
                }
            };

            areaList.AddRange(ProcessInvoke <UserDictionaryProcess>()
                              .GetDistrictSelectList()
                              .Select(obj => new SelectListItem()
            {
                Text = obj.Value, Value = obj.Key.ToString()
            })
                              .ToList());

            model.AreaListItems    = areaList;
            model.StreetListItems  = streetList;
            model.AddressListItems = addressList;
            return(View(model));
        }