示例#1
0
        public Dictionary <DateTime, decimal> RevenueDataFrom(GraphTimePeriod graphTimePeriod, IEnumerable <Item> itemsPool)
        {
            List <DateTime> XAxis = GetXAxis(graphTimePeriod);
            List <decimal>  YAxis = GetYAxis(XAxis, itemsPool);
            Dictionary <DateTime, decimal> XYAxis = XAxis.Zip(YAxis, (k, v) => new { k, v })
                                                    .ToDictionary(row => row.k, row => row.v);

            return(XYAxis);
        }
示例#2
0
        public static void PrintGraphTimePeriodUsingExtensionMethods()
        {
            GraphTimePeriod pastDay  = GraphTimePeriod.PastDay;
            GraphTimePeriod pastHour = GraphTimePeriod.PastHour;
            GraphTimePeriod pastWeek = GraphTimePeriod.PastWeek;
            GraphTimePeriod pastYear = GraphTimePeriod.PastYear;

            Console.WriteLine(pastDay.StringRepresentation());
            Console.WriteLine(pastHour.StringRepresentation());
            Console.WriteLine(pastWeek.StringRepresentation());
            Console.WriteLine(pastYear.StringRepresentation());
        }
示例#3
0
        /// <summary>
        /// Takes in a time period and
        /// return a list of DateTimes's
        /// between DateTime.Now and DateTime.Now - graphTimePeriod
        /// with regular intervals declared in the function
        /// </summary>
        /// <param name="graphTimePeriod"></param>
        /// <returns></returns>
        List <DateTime> GetXAxis(GraphTimePeriod graphTimePeriod)
        {
            int xIntervalSetting = 0;
            int xStartSetting    = 0;

            //interval in for loop
            switch (graphTimePeriod)
            {
            //Unit for x axis is minutes
            case GraphTimePeriod.PastHour:
                xIntervalSetting = 5;
                xStartSetting    = -60;
                break;

            case GraphTimePeriod.PastDay:
                xIntervalSetting = 2 * 60;
                xStartSetting    = -24 * 60;
                break;

            case GraphTimePeriod.PastWeek:
                xIntervalSetting = 24 * 60;
                xStartSetting    = -7 * 24 * 60;
                break;

            case GraphTimePeriod.PastYear:
                xIntervalSetting = 30 * 24 * 60;
                xStartSetting    = -365 * 24 * 60;
                break;

            default:
                //some error found with graphTimePeriod
                return(null);
            }

            //creating the xAxis

            //unit = minutes
            DateTime now       = DateTime.Now;
            DateTime xStart    = now.Add(new TimeSpan(0, xStartSetting, 0));
            TimeSpan xInterval = new TimeSpan(0, xIntervalSetting, 0);

            List <DateTime> xAxis = new List <DateTime>();

            for (DateTime currTime = xStart; currTime <= now; currTime = currTime.Add(xInterval))
            {
                xAxis.Add(currTime);
            }

            xAxis.ForEach(dt => System.Console.WriteLine(dt));
            return(null);
        }
示例#4
0
        public Dictionary <DateTime, int> QuantityDataFrom(GraphTimePeriod graphTimePeriod, IEnumerable <Item> itemsPool)
        {
            List <DateTime> XAxis        = GetXAxis(graphTimePeriod);
            List <decimal>  DecimalYAxis = GetYAxis(XAxis, itemsPool);

            //converting decimals to integers
            List <int> YAxis = new List <int>();

            DecimalYAxis.ForEach(dec => YAxis.Add(Convert.ToInt32(dec)));

            Dictionary <DateTime, int> XYAxis = XAxis.Zip(YAxis, (k, v) => new { k, v })
                                                .ToDictionary(row => row.k, row => row.v);

            return(XYAxis);
        }
示例#5
0
文件: UIUtility.cs 项目: yagnab/IMS
        public static Dictionary <DateTime, int> GetQuantityData(GraphTimePeriod timePeriod)
        {
            switch (timePeriod)
            {
            case GraphTimePeriod.PastHour:
                return(GetQuantityDataPastHour());

            case GraphTimePeriod.PastDay:
                return(GetQuantityDataPastDay());

            case GraphTimePeriod.PastWeek:
                return(GetQuantityDataPastWeek());

            case GraphTimePeriod.PastYear:
                return(GetQuantityDataPastYear());

            default:
                return(null);
            }
        }
示例#6
0
文件: UIUtility.cs 项目: yagnab/IMS
        public static Dictionary <DateTime, decimal> GetRevenueData(GraphTimePeriod timePeriod, Item item)
        {
            switch (timePeriod)
            {
            case GraphTimePeriod.PastHour:
                return(GetRevenueDataPastHour(item));

            case GraphTimePeriod.PastDay:
                return(GetRevenueDataPastDay(item));

            case GraphTimePeriod.PastWeek:
                return(GetRevenueDataPastWeek(item));

            case GraphTimePeriod.PastYear:
                return(GetRevenueDataPastYear(item));

            default:
                return(null);
            }
        }
示例#7
0
        public static string StringRepresentation(this GraphTimePeriod timePeriod)
        {
            switch (timePeriod)
            {
            case GraphTimePeriod.PastDay:
                return("Past Day");

            case GraphTimePeriod.PastHour:
                return("Past Hour");

            case GraphTimePeriod.PastWeek:
                return("Past Week");

            case GraphTimePeriod.PastYear:
                return("Past Year");

            //some error occurs
            default:
                return(null);
            }
        }
示例#8
0
        public void SetPlotModel(GraphTimePeriod timePeriod)
        {
            Dictionary <DateTime, int>     _QuantityData;
            Dictionary <DateTime, decimal> _RevenueData;

            switch (timePeriod)
            {
            case GraphTimePeriod.PastHour:
                _QuantityData = UIUtility.GetQuantityData(timePeriod);
                _RevenueData  = UIUtility.GetRevenueData(timePeriod);
                plotModel     = new PastHour(_QuantityData, _RevenueData);
                break;

            case GraphTimePeriod.PastDay:
                _QuantityData = UIUtility.GetQuantityData(timePeriod);
                _RevenueData  = UIUtility.GetRevenueData(timePeriod);
                plotModel     = new PastDay(_QuantityData, _RevenueData);
                break;

            case GraphTimePeriod.PastWeek:
                _QuantityData = UIUtility.GetQuantityData(timePeriod);
                _RevenueData  = UIUtility.GetRevenueData(timePeriod);
                plotModel     = new PastWeek(_QuantityData, _RevenueData);
                break;

            case GraphTimePeriod.PastYear:
                _QuantityData = UIUtility.GetQuantityData(timePeriod);
                _RevenueData  = UIUtility.GetRevenueData(timePeriod);
                plotModel     = new PastYear(_QuantityData, _RevenueData);
                break;

            default:
                plotModel = null;
                break;
            }
        }