Esempio n. 1
0
        public DrivenVehicleStatistics FromStartStatistics(int userid)
        {
            var statistics = new DrivenVehicleStatistics();

            statistics.Reports = new List <ReportModel>();
            foreach (var report in DBContext.Report)
            {
                if (report.Employee_Id == userid)
                {
                    var newReport = new ReportModel()
                    {
                        Distance             = report.Distance.Value,
                        Employee_ID          = report.Employee_Id,
                        ReportDate           = report.ReportDate,
                        TotalPrice           = report.TotalPrice.Value,
                        Vehicle_ID           = report.Vehicle_Id,
                        PrimaryFuel_ID       = report.PrimaryFuel_ID,
                        PrimaryFuelAmount    = report.PrimaryFuelAmount.Value,
                        PrimaryFuelUnitPrice = report.PrimaryFuelUnitPrice.Value
                    };
                    if (report.SecondaryFuel_ID != null)
                    {
                        newReport.SecondaryFuel_ID       = report.SecondaryFuel_ID;
                        newReport.SecondaryFuelAmount    = report.SecondaryFuelAmount;
                        newReport.SecondaryFuelUnitPrice = report.SecondaryFuelUnitPrice;
                    }
                    statistics.Reports.Add(newReport);
                }
            }
            return(CountStatistics.FixStatistics(statistics));
        }
Esempio n. 2
0
 public ChatStatistics()
 {
     Words    = new CountStatistics();
     Letters  = new CountStatistics();
     Users    = new CountStatistics();
     Messages = new CountStatistics();
 }
Esempio n. 3
0
        public DrivenVehicleStatistics DrivenVehicleStatistic(string regnr, int userid)
        {
            var statistics = new DrivenVehicleStatistics();

            statistics.Reports = new List <ReportModel>();

            foreach (var information in DBContext.Report)
            {
                if (information.Employee_Id == userid && regnr == information.Vehicle_Id)
                {
                    var yearReport = new ReportModel()
                    {
                        Distance             = information.Distance.Value,
                        Employee_ID          = information.Employee_Id,
                        ReportDate           = information.ReportDate,
                        TotalPrice           = information.TotalPrice.Value,
                        Vehicle_ID           = information.Vehicle_Id,
                        PrimaryFuel_ID       = information.PrimaryFuel_ID,
                        PrimaryFuelAmount    = information.PrimaryFuelAmount.Value,
                        PrimaryFuelUnitPrice = information.PrimaryFuelUnitPrice.Value
                    };


                    if (information.SecondaryFuel_ID != null)
                    {
                        yearReport.SecondaryFuel_ID       = information.SecondaryFuel_ID;
                        yearReport.SecondaryFuelAmount    = information.SecondaryFuelAmount;
                        yearReport.SecondaryFuelUnitPrice = information.SecondaryFuelUnitPrice;
                    }
                    statistics.Reports.Add(yearReport);
                }
            }
            return(CountStatistics.FixStatistics(statistics));
        }
Esempio n. 4
0
        public void GetReports()
        {
            Months value = _selectedMonth;
            int    month = (int)value;

            try
            {
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Helpers.CredentialHelper.Credential);
                string getReports = $"http://moggeapi.azurewebsites.net/api/report/getuserreports/{_selectedEmployee.Id}/{month}/{_selectedYear}";

                var jsonUsers = client.GetAsync(getReports).Result.Content.ReadAsStringAsync().Result;
                var reports   = JsonConvert.DeserializeObject <List <ReportModel> >(jsonUsers);
                if (reports.Count > 0)
                {
                    var fixedStatistics = CountStatistics.Count(reports);

                    AvarageCost      = Math.Round(fixedStatistics.AvarageCost, 2);
                    AvarageDistance  = Math.Round(fixedStatistics.AvarageDistance, 2);
                    Distance         = fixedStatistics.Distance;
                    TotalCost        = Math.Round(fixedStatistics.TotalCost, 2);
                    AvarageCostTenKm = Math.Round(fixedStatistics.AvarageFuelTenKm, 2);

                    if (_selectedMonth == Months.Alltime)
                    {
                        EmployeeStatisticsLabel = _fullName + "\t" + _selectedMonth;
                    }
                    if (_selectedMonth == Months.Year)
                    {
                        if (SelectedYear != 0)
                        {
                            EmployeeStatisticsLabel = _fullName + "\t" + SelectedYear;
                        }
                        else
                        {
                            EmployeeStatisticsLabel = _fullName;
                        }
                    }
                    if (_selectedMonth > 0 && month < 13)
                    {
                        EmployeeStatisticsLabel = _fullName + "\t" + _selectedMonth + " " + SelectedYear;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                throw;
            }
        }
Esempio n. 5
0
        private static List <SalientObject> GroupSalientTiles(LabTiledImage saliencyMap, ref float threshold, int minimumGroupSize = 8)
        {
            if (threshold <= 0f || threshold > 1f)
            {
                CountStatistics countStatistics = saliencyMap.CreateStats((LabTile tile) => (double)tile.Saliency);
                threshold = (1f - (float)countStatistics.Average) * 0.6f;
            }
            SaliencyGrouper saliencyGrouper = new SaliencyGrouper(saliencyMap, threshold);
            List <RegionInfo <ArgbPixel, byte, LabTile> > list = saliencyGrouper.Process(minimumGroupSize);

            list.Sort((RegionInfo <ArgbPixel, byte, LabTile> first, RegionInfo <ArgbPixel, byte, LabTile> second) => second.TileCount.CompareTo(first.TileCount));
            return((from region in list
                    select new SalientObject
            {
                Region = region
            }).ToList <SalientObject>());
        }
Esempio n. 6
0
        public void GetVehicleStatistics()
        {
            var value = _selectedMonth;
            var month = (int)value;

            try
            {
                var getVehiclereports = $"http://moggeapi.azurewebsites.net/api/report/getvehiclereports/{RegNr}/{month}/{SelectedYear}";

                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Helpers.CredentialHelper.Credential);
                var jsonString = client.GetAsync(getVehiclereports).Result.Content.ReadAsStringAsync().Result;
                var reportList = JsonConvert.DeserializeObject <List <ReportModel> >(jsonString);

                var statistics = CountStatistics.VehicleStatistics(reportList);

                SelectedVehicleAvarageCost              = statistics.AvarageCost;
                SelectedVehicleAvarageDistance          = statistics.AvarageDistance;
                SelectedVehicleAvarageFuelTenKm         = statistics.AvaragePrimaryFuelCostTenKm;
                SelectedVehicleAvaragePrimaryFuelAmount = statistics.AvaragePrimaryFuelAmount;
                SelectedVehicleAvaragePrimaryFuelCost   = statistics.AvaragePrimaryFuelCost;
                SelectedVehicleTotalCost = statistics.TotalCost;
                SelectedVehicleDistance  = statistics.Distance;

                if (statistics.AvarageSecondaryFuelAmount > 0)
                {
                    SelectedVehicleAvarageSecondaryFuelAmount = statistics.AvarageSecondaryFuelAmount;
                    SelectedVehicleAvarageSecondaryFuelCost   = statistics.AvarageSecondaryFuelCost;
                }
                else
                {
                    SelectedVehicleAvarageSecondaryFuelAmount = 0;
                    SelectedVehicleAvarageSecondaryFuelCost   = 0;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                throw;
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Creates a copy of the original <see cref="CountStatistics"/>
 /// </summary>
 /// <param name="copy"></param>
 public CountStatistics(CountStatistics copy)
     : base(copy)
 {
 }
Esempio n. 8
0
        public DrivenVehicleStatistics DriverYearMonthStatisics(string regnr, int userid, int year, int month)
        {
            var statistics = new DrivenVehicleStatistics();

            statistics.Reports = new List <ReportModel>();

            try
            {
                if (month == 13)
                {
                    foreach (var report in DBContext.Report)
                    {
                        if (report.Employee_Id == userid && report.Vehicle_Id == regnr)
                        {
                            var newReport = new ReportModel()
                            {
                                Distance             = report.Distance.Value,
                                Employee_ID          = report.Employee_Id,
                                ReportDate           = report.ReportDate,
                                TotalPrice           = report.TotalPrice.Value,
                                Vehicle_ID           = report.Vehicle_Id,
                                PrimaryFuel_ID       = report.PrimaryFuel_ID,
                                PrimaryFuelAmount    = report.PrimaryFuelAmount.Value,
                                PrimaryFuelUnitPrice = report.PrimaryFuelUnitPrice.Value
                            };
                            if (report.SecondaryFuel_ID != null)
                            {
                                newReport.SecondaryFuel_ID       = report.SecondaryFuel_ID;
                                newReport.SecondaryFuelAmount    = report.SecondaryFuelAmount;
                                newReport.SecondaryFuelUnitPrice = report.SecondaryFuelUnitPrice;
                            }
                            statistics.Reports.Add(newReport);
                        }
                    }
                    if (statistics.Reports.Count > 0)
                    {
                        return(CountStatistics.FixStatistics(statistics));
                    }
                }

                if (month == 0)
                {
                    foreach (var report in DBContext.Report)
                    {
                        if (report.Employee_Id == userid && report.ReportDate.Year == year && report.Vehicle_Id == regnr)
                        {
                            var newReport = new ReportModel()
                            {
                                Distance             = report.Distance.Value,
                                Employee_ID          = report.Employee_Id,
                                ReportDate           = report.ReportDate,
                                TotalPrice           = report.TotalPrice.Value,
                                Vehicle_ID           = report.Vehicle_Id,
                                PrimaryFuel_ID       = report.PrimaryFuel_ID,
                                PrimaryFuelAmount    = report.PrimaryFuelAmount.Value,
                                PrimaryFuelUnitPrice = report.PrimaryFuelUnitPrice.Value
                            };
                            if (report.SecondaryFuel_ID != null)
                            {
                                newReport.SecondaryFuel_ID       = report.SecondaryFuel_ID;
                                newReport.SecondaryFuelAmount    = report.SecondaryFuelAmount;
                                newReport.SecondaryFuelUnitPrice = report.SecondaryFuelUnitPrice;
                            }
                            statistics.Reports.Add(newReport);
                        }
                    }
                    if (statistics.Reports.Count > 0)
                    {
                        return(CountStatistics.FixStatistics(statistics));
                    }
                }
                if (month > 0)
                {
                    foreach (var report in DBContext.Report)
                    {
                        if (report.Vehicle_Id == regnr && report.Employee_Id == userid && report.ReportDate.Year == year && report.ReportDate.Month == month)
                        {
                            var newReport = new ReportModel()
                            {
                                Distance             = report.Distance.Value,
                                Employee_ID          = report.Employee_Id,
                                ReportDate           = report.ReportDate,
                                TotalPrice           = report.TotalPrice.Value,
                                Vehicle_ID           = report.Vehicle_Id,
                                PrimaryFuel_ID       = report.PrimaryFuel_ID,
                                PrimaryFuelAmount    = report.PrimaryFuelAmount.Value,
                                PrimaryFuelUnitPrice = report.PrimaryFuelUnitPrice.Value
                            };
                            if (report.SecondaryFuel_ID != null)
                            {
                                newReport.SecondaryFuel_ID       = report.SecondaryFuel_ID;
                                newReport.SecondaryFuelAmount    = report.SecondaryFuelAmount;
                                newReport.SecondaryFuelUnitPrice = report.SecondaryFuelUnitPrice;
                            }
                            statistics.Reports.Add(newReport);
                        }
                    }

                    if (statistics.Reports.Count > 0)
                    {
                        return(CountStatistics.FixStatistics(statistics));
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(new DrivenVehicleStatistics());
        }