示例#1
0
        private List <CalcSiteDto> MakeCalcSiteDtos([NotNull][ItemNotNull] List <Site> householdSites,
                                                    [NotNull][ItemNotNull] List <CalcLocationDto> calcLocations,
                                                    [NotNull] Dictionary <TransportationDeviceCategory,
                                                                          CalcTransportationDeviceCategoryDto> categoriesDict,
                                                    [NotNull] HouseholdKey householdKey,
                                                    [CanBeNull] ChargingStationSet chargingStationSet)
        {
            List <CalcSiteDto> calcSites = new List <CalcSiteDto>();

            //create the calcsites
            foreach (Site site in householdSites)
            {
                CalcSiteDto calcSite = new CalcSiteDto(site.Name, site.IntID, Guid.NewGuid().ToStrGuid(), householdKey);
                if (chargingStationSet != null)
                {
                    var chargingStationsAtSite =
                        chargingStationSet.ChargingStations.Where(x => x.Site == site).ToList();
                    foreach (var chargingStationSetEntry in chargingStationsAtSite)
                    {
                        if (chargingStationSetEntry.CarChargingLoadType == null)
                        {
                            throw new LPGException("Car charging load type was null");
                        }
                        if (chargingStationSetEntry.GridChargingLoadType == null)
                        {
                            throw new LPGException("Grid charging load type was null");
                        }

                        CalcLoadTypeDto carlt  = _loadTypeDict.Ltdtodict[chargingStationSetEntry.CarChargingLoadType];
                        CalcLoadTypeDto gridlt = _loadTypeDict.Ltdtodict[chargingStationSetEntry.GridChargingLoadType];
                        if (chargingStationSetEntry.TransportationDeviceCategory == null)
                        {
                            throw new LPGException("charging device category was null");
                        }

                        CalcTransportationDeviceCategoryDto cat =
                            categoriesDict[chargingStationSetEntry.TransportationDeviceCategory];
                        calcSite.AddChargingStation(gridlt, cat, chargingStationSetEntry.MaxChargingPower, carlt);
                    }
                }

                foreach (var calcloc in calcLocations)
                {
                    foreach (SiteLocation location in site.Locations)
                    {
                        if (calcloc.ID == location.Location.IntID)
                        {
                            calcSite.AddLocation(calcloc);
                        }
                    }
                }
                calcSites.Add(calcSite);
            }
            return(calcSites);
        }
示例#2
0
        private static List <CalcTravelRouteDto> MakeTravelRoutes([NotNull] TravelRouteSet travelRouteSet, [NotNull][ItemNotNull] List <Site> householdSites,
                                                                  [NotNull] Dictionary <TransportationDeviceCategory, CalcTransportationDeviceCategoryDto> categoriesDict,
                                                                  [NotNull][ItemNotNull] List <CalcSiteDto> calcSites, [NotNull] HouseholdKey key)
        {
            List <CalcTravelRouteDto> routes = new List <CalcTravelRouteDto>();
            //make travel routes
            var neededRoutes = travelRouteSet.TravelRoutes.Where(x =>
                                                                 householdSites.Contains(x.TravelRoute.SiteA) && householdSites.Contains(x.TravelRoute.SiteB));

            foreach (TravelRouteSetEntry entry in neededRoutes)
            {
                if (entry.TravelRoute.SiteA == null)
                {
                    throw new LPGException("site A was null");
                }
                if (entry.TravelRoute.SiteB == null)
                {
                    throw new LPGException("site B was null");
                }
                CalcSiteDto        siteA = calcSites.Single(x => x.ID == entry.TravelRoute.SiteA.IntID);
                CalcSiteDto        siteB = calcSites.Single(x => x.ID == entry.TravelRoute.SiteB.IntID);
                CalcTravelRouteDto ctr   = new CalcTravelRouteDto(entry.TravelRoute.Name, entry.TravelRoute.IntID, key,
                                                                  Guid.NewGuid().ToStrGuid(), siteA.Name, siteA.Guid, siteB.Name, siteB.Guid);
                foreach (TravelRouteStep step in entry.TravelRoute.Steps)
                {
                    CalcTransportationDeviceCategoryDto cat = categoriesDict[step.TransportationDeviceCategory];
                    ctr.AddTravelRouteStep(step.Name, step.IntID, cat, step.StepNumber, step.Distance,
                                           Guid.NewGuid().ToStrGuid());
                }
                routes.Add(ctr);
            }

            foreach (var site in calcSites)
            {
                CalcTravelRouteDto ctr = new CalcTravelRouteDto("Travel Route inside the site " + site.Name,
                                                                -1, key, Guid.NewGuid().ToStrGuid(), site.Name, site.Guid, site.Name, site.Guid);
                routes.Add(ctr);
            }
            return(routes);
        }