Esempio n. 1
0
        List <PPDeviceSizes> getPPDeviceSizes()
        {
            var allClients = new PpxLookupProvider().Get();
            var allSizes   = new Dictionary <int, PPDeviceSizes>();

            foreach (var client in allClients)
            {
                if (client.PlacementDate.Year != 1900 &&
                    client.PlacementDate.Year < 2017)
                {
                    continue;
                }
                PPDeviceSizes current = null;
                var           dayId   = (client.PlacementDate.Year * 1000) + client.PlacementDate.DayOfYear;
                if (!allSizes.TryGetValue(dayId, out current))
                {
                    current         = new PPDeviceSizes(client.PlacementDate);
                    allSizes[dayId] = current;
                }
                current.Add(client.DeviceSize);
            }

            var toReturn = new List <PPDeviceSizes>();

            toReturn.AddRange(allSizes.Values);
            return(toReturn);
        }
Esempio n. 2
0
        private void getPrepexSuppliesReport()
        {
            //we get all clients
            var allSizes = getPPDeviceSizes();
            var resList  = new List <string>();

            resList.Add(Resources.GetString(Resource.String.ppx_sys_deviceusage));
            resList.Add(System.Environment.NewLine);
            resList.Add(PPDeviceSizes.getHeader());
            var ordered = allSizes.OrderByDescending(t => t.PlacementDate);

            var monthTotals = new Dictionary <int, PPDeviceSizes>();

            foreach (var dayUsage in ordered)
            {
                var           month        = dayUsage.PlacementDate.Month;
                var           year         = dayUsage.PlacementDate.Year;
                var           yyyyMM       = year * 100 + month;
                PPDeviceSizes sizeForMonth = null;
                if (!monthTotals.TryGetValue(yyyyMM, out sizeForMonth))
                {
                    sizeForMonth = new PPDeviceSizes(01, month, year)
                    {
                        isMonth = true
                    };
                    monthTotals[yyyyMM] = sizeForMonth;
                }
                sizeForMonth.Add(dayUsage.size);
            }
            //foreach (var dayUsage in ordered)
            //{
            //    resList.Add(dayUsage.toDisplay());
            //}
            foreach (var monthUsages in monthTotals)
            {
                resList.Add(monthUsages.Value.toDisplay());
            }

            var asString = string.Join(System.Environment.NewLine, resList);

            setTextResults(asString);
        }