예제 #1
0
        private void ParserForm(Dictionary <string, object> context)
        {
            ComboBox Combobox = context["Facility"] as ComboBox;
            string   selected = Combobox.SelectedItem as string;

            Type = 設施[selected];
        }
예제 #2
0
        public void LoadTransactionHistoryForAllClients(DateRange dateRange, FacilityType facilityType, bool isSalvageIncluded)
        {
            ArgumentChecker.ThrowIfNull(dateRange, "dateRange");
            ArgumentChecker.ThrowIfNull(facilityType, "facilityType");

            view.ShowTransactionHistory(repository.LoadTransactionHistoryForAllClients(dateRange, facilityType, isSalvageIncluded));
        }
예제 #3
0
        public async Task <ActionResult> ManageContactDetails(Guid id, FacilityType facilityType)
        {
            using (var client = apiClient())
            {
                var contact = await client.SendAsync(User.GetAccessToken(), new GetAatfContact(id));

                var aatf = await client.SendAsync(User.GetAccessToken(), new GetAatfById(id));

                var currentDate = await client.SendAsync(User.GetAccessToken(), new GetApiUtcDate());

                var countries = await client.SendAsync(this.User.GetAccessToken(), new GetCountries(false));

                if (!contact.CanEditContactDetails || !IsValidRecordToEdit(currentDate, aatf.ComplianceYear))
                {
                    return(new HttpForbiddenResult());
                }

                var model = this.mapper.Map <AatfEditContactAddressViewModel>(new AatfEditContactTransfer()
                {
                    AatfData = aatf, Countries = countries, CurrentDate = currentDate
                });

                SetBreadcrumb(facilityType, aatf.Name);
                return(View(model));
            }
        }
예제 #4
0
 public Facility(FacilityType facType)
 {
     FacType      = facType;
     FcCode       = "";
     MeasureItems = new List <MeasureItem>();
     Length       = 0;
 }
예제 #5
0
 public FacilityTypeSummaryDto(FacilityType facilityType)
 {
     Id          = facilityType.Id;
     Active      = facilityType.Active;
     Name        = facilityType.Name;
     Description = facilityType.Description;
 }
예제 #6
0
        private async Task <Aatf> CreateAatf(DatabaseWrapper database, FacilityType facilityType, DateTime date, short year, string approvalNumber = null, string name = null)
        {
            var country = database.WeeeContext.Countries.First();
            var competentAuthorityDataAccess = new CommonDataAccess(database.WeeeContext);
            var competentAuthority           = await competentAuthorityDataAccess.FetchCompetentAuthority(CompetentAuthority.England);

            var organisation = Organisation.CreatePartnership("Dummy");
            var contact      = new AatfContact("First Name", "Last Name", "Manager", "1 Address Lane", "Address Ward", "Town", "County", "Postcode", country, "01234 567890", "*****@*****.**");

            if (approvalNumber == null)
            {
                approvalNumber = "12345678";
            }

            if (name == null)
            {
                name = "name";
            }

            return(new Aatf(name,
                            competentAuthority,
                            approvalNumber,
                            AatfStatus.Approved,
                            organisation,
                            AddressHelper.GetAatfAddress(database),
                            A.Fake <AatfSize>(),
                            date,
                            contact,
                            facilityType,
                            year,
                            database.WeeeContext.LocalAreas.First(),
                            database.WeeeContext.PanAreas.First()));
        }
    public static FacilityM[] GetFacilityShopGoods(FacilityType type)
    {
        List <FacilityM> list = new List <FacilityM>();
        int typeInt           = (int)type;

        if (type == FacilityType.FACILITY)
        {
            list = FarmDataManager.facilityMaster.Where(delegate(FacilityM x)
            {
                int fid = int.Parse(x.facilityId);
                return(int.Parse(x.type) == typeInt && !FarmDataManager.FacilityInfo.initBuild.Any((FarmFacilityData.FacilityID id) => id == (FarmFacilityData.FacilityID)fid));
            }).ToList <FacilityM>();
        }
        else
        {
            list = FarmDataManager.facilityMaster.Where(delegate(FacilityM x)
            {
                int fid = int.Parse(x.facilityId);
                return(int.Parse(x.type) == typeInt && !FarmDataManager.FacilityInfo.initBuild.Any((FarmFacilityData.FacilityID id) => id == (FarmFacilityData.FacilityID)fid));
            }).ToList <FacilityM>();
        }
        List <FacilityM> list2 = list;

        if (FarmDataManager.< > f__mg$cache0 == null)
        {
            FarmDataManager.< > f__mg$cache0 = new Comparison <FacilityM>(FarmDataManager.CompareFacility);
        }
        list2.Sort(FarmDataManager.< > f__mg$cache0);
        return(list.ToArray());
    }
예제 #8
0
        public TransactionReportBase LoadInvoicesReportForAllClients(Date endDate, FacilityType facilityType, bool isSalvageIncluded, int ClientFacilityType, string TransactionFilter)
        {
            ArgumentChecker.ThrowIfNull(endDate, "endDate");
            ArgumentChecker.ThrowIfNull(facilityType, "facilityType");

            return(repository.LoadInvoicesReportForAllClients(endDate, facilityType, isSalvageIncluded, ClientFacilityType, SessionWrapper.Instance.Get.SelectedTransactionFilter));
        }
예제 #9
0
        public static void ConvertDpowToCobie(Stream input, CloudBlockBlob outputCobieBlob)
        {
            var temp = Path.GetTempFileName();

            try
            {
                var dpow      = PlanOfWork.Open(input);
                var facility  = new FacilityType();
                var exchanger = new XbimExchanger.DPoWToCOBieLite.DpoWtoCoBieLiteExchanger(dpow, facility);
                exchanger.Convert();

                using (var tw = File.CreateText(temp))
                {
                    CoBieLiteHelper.WriteJson(tw, facility);
                    tw.Close();
                }
                outputCobieBlob.UploadFromFile(temp, FileMode.Open);
            }
            finally
            {
                //tidy up
                if (File.Exists(temp))
                {
                    File.Delete(temp);
                }
            }
        }
예제 #10
0
 public Facility(FacilityType t)
 {
     type        = t;
     name        = t.ToString(); //TODO
     status      = Status.Ok;
     assignedBot = null;
 }
예제 #11
0
        private int ConvertProject(IPlanOfWork dpowPlanOfWork, FacilityType facility)
        {
            var warnings    = ConvertProjectUnits(dpowPlanOfWork, facility);//this never generates an error
            var projectType = new ProjectType();

            if (string.IsNullOrWhiteSpace(dpowPlanOfWork.Project.ProjectURI))
            {
                Logger.Warn("The Project URI is not a valid identifier. It is required");
                warnings += 1;
            }
            projectType.externalID         = dpowPlanOfWork.Project.ProjectURI;
            projectType.externalEntityName = "IPlanOfWork.Project";
            projectType.externalSystemName = DpowSystemName;
            if (string.IsNullOrWhiteSpace(dpowPlanOfWork.Project.ProjectName))
            {
                Logger.Warn("The Project Name is not a valid identifier. It is required");
                warnings += 1;
            }
            projectType.ProjectName = dpowPlanOfWork.Project.ProjectName;
            if (string.IsNullOrWhiteSpace(dpowPlanOfWork.Project.ProjectDescription))
            {
                Logger.Info("The Project Description has not been specified");
                warnings += 1;
            }
            projectType.ProjectDescription = dpowPlanOfWork.Project.ProjectDescription;
            facility.ProjectAssignment     = projectType;
            return(warnings);
        }
예제 #12
0
    public static Texture GetTextureForFacility(Tile tile, FacilityType facility)
    {
        if (facility == FacilityType.Tunnel)
        {
            return(LoadTunnelTexture(tile));
        }

        if (facility == FacilityType.TerraformingFacility && tile.TileType == TileType.Soil)
        {
            return(Resources.Load <Texture>($"Tiles/{facility}_0"));
        }
        if (facility == FacilityType.TerraformingFacility && tile.TileType == TileType.Surface)
        {
            return(Resources.Load <Texture>($"Tiles/{facility}_1"));
        }

        if (facility == FacilityType.BFCoreExtractor)
        {
            return(Resources.Load <Texture>($"Tiles/{facility}"));
        }

        //todo: other facilities.
        var result = Resources.Load <Texture>($"Tiles/{facility}_{tile.Layer}_0");

        return(result);
    }
예제 #13
0
        private static int ConvertProjectUnits(IPlanOfWork dpowPlanOfWork, FacilityType facility)
        {
            int warnings = 0;
            AreaUnitSimpleType areaUnitType;

            if (Enum.TryParse(dpowPlanOfWork.Project.AreaUnits.ToString(), true, out areaUnitType))
            {
                facility.FacilityDefaultAreaUnit          = areaUnitType;
                facility.FacilityDefaultAreaUnitSpecified = true;
            }
            else
            {
                Logger.WarnFormat("Default Area Unit of [{0}] is not a valid type.",
                                  dpowPlanOfWork.Project.AreaUnits.ToString());
                warnings++;
            }

            LinearUnitSimpleType linearUnitType;

            if (Enum.TryParse(dpowPlanOfWork.Project.LinearUnits.ToString(), true, out linearUnitType))
            {
                facility.FacilityDefaultLinearUnit          = linearUnitType;
                facility.FacilityDefaultLinearUnitSpecified = true;
            }
            else
            {
                Logger.WarnFormat("Default Linear Unit of [{0}] is not a valid type.",
                                  dpowPlanOfWork.Project.LinearUnits.ToString());
                warnings++;
            }

            VolumeUnitSimpleType volumeUnitType;

            if (Enum.TryParse(dpowPlanOfWork.Project.VolumeUnits.ToString(), true, out volumeUnitType))
            {
                facility.FacilityDefaultVolumeUnit          = volumeUnitType;
                facility.FacilityDefaultVolumeUnitSpecified = true;
            }
            else
            {
                Logger.WarnFormat("Default Volume Unit of [{0}] is not a valid type.",
                                  dpowPlanOfWork.Project.VolumeUnits.ToString());
                warnings++;
            }

            CurrencyUnitSimpleType currencyUnitType;

            if (Enum.TryParse(dpowPlanOfWork.Project.CurrencyUnits.ToString(), true, out currencyUnitType))
            {
                facility.FacilityDefaultCurrencyUnit          = currencyUnitType;
                facility.FacilityDefaultCurrencyUnitSpecified = true;
            }
            else
            {
                Logger.WarnFormat("Default Currency Unit of [{0}] is not a valid type.",
                                  dpowPlanOfWork.Project.CurrencyUnits.ToString());
                warnings++;
            }
            return(warnings);
        }
예제 #14
0
        public void ConvertCobieLiteToIfc()
        {
            var facility = FacilityType.ReadJson("COBieLite.json");

            var credentials = new XbimEditorCredentials()
            {
                ApplicationDevelopersName = "XbimTeam",
                ApplicationFullName       = "Xbim.Exchanger",
                EditorsOrganisationName   = "Xbim Development Team",
                EditorsFamilyName         = "Xbim Tester",
                ApplicationVersion        = "3.0"
            };

            using (var model = IfcStore.Create(credentials, XbimSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel))
            {
                using (var txn = model.BeginTransaction("Convert from COBieLite"))
                {
                    var exchanger = new CoBieLiteToIfcExchanger(facility, model);
                    exchanger.Convert();
                    txn.Commit();
                    //var err = model.Validate(model.Instances, Console.Out);
                }
                model.SaveAs(@"ConvertedFromCOBieLite.ifc", StorageType.Ifc);
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Type")] FacilityType facilityType)
        {
            if (id != facilityType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(facilityType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacilityTypeExists(facilityType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(facilityType));
        }
예제 #16
0
        public void ConvertDPoWToCOBieLite()
        {
            var          pow = PlanOfWork.OpenJson("NewtownHighSchool.new.dpow");
            const string dir = "Export";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            var outputs = new List <string>();

            foreach (var stage in pow.ProjectStages)
            {
                var facility  = new FacilityType();
                var exchanger = new DPoWToCOBieLiteExchanger(pow, facility, stage);
                exchanger.Convert();
                var output = Path.Combine(dir, stage.Name + ".json");
                outputs.Add(output);
                facility.WriteJson(output);
            }

            //check all result files exist
            foreach (var output in outputs)
            {
                Assert.IsTrue(File.Exists(output));
            }

            //try to reload to make sure serialization and deserilization works in both directions
            foreach (var output in outputs)
            {
                var facility = FacilityType.ReadJson(output);
            }
        }
예제 #17
0
        public void MapFromDomainEntity_NullContent_ReturnNull()
        {
            //Act
            var response = FacilityType.MapFromDomainEntity(null);

            //Assert
            Assert.IsNull(response);
        }
 public void LoadAllPromptReportForAllClients(int promptDays, FacilityType facilityType, bool isSalvageIncluded)
 {
     ArgumentChecker.ThrowIfNull(facilityType, "facilityType");
     if (CanViewReport())
     {
         view.ShowReport(repository.LoadPromptReportForAllInvoicesForAllClients(promptDays, facilityType, isSalvageIncluded));
     }
 }
예제 #19
0
        public void DetailViewModel_FacilityTypeSet_AddressLabelSetCorrectly(FacilityType type, string expected)
        {
            AatfDetailsViewModel model = new AatfDetailsViewModel();

            model.FacilityType = type;

            Assert.Equal(expected, model.AddressHeadingName);
        }
예제 #20
0
        public async Task AddGet_Always_SetsInternalBreadcrumb(FacilityType facilityType, string expectedBreadcrumb)
        {
            A.CallTo(() => weeeClient.SendAsync(A <string> ._, A <GetApiUtcDate> ._)).Returns(new DateTime(2019, 1, 1));

            await controller.Add(Guid.NewGuid(), facilityType);

            Assert.Equal(expectedBreadcrumb, breadcrumbService.InternalActivity);
        }
예제 #21
0
        public void ConvertDPoWToCOBieLite()
        {
            var dpow      = PlanOfWork.Open("NewtownHighSchool.dpow");
            var facility  = new FacilityType();
            var exchanger = new DPoWToCOBieLiteExchanger(dpow, facility);

            exchanger.Convert();
        }
예제 #22
0
        /// <summary>
        /// Constructs a new Facility object of the specified Type and Configuration, located within
        /// the specified Catchment
        /// </summary>
        /// <param name="type">The type of facility</param>
        /// <param name="configuration">The plumbed facility configuration</param>
        /// <param name="catchment">The Catchment containing the facility</param>
        public Facility(FacilityType type, FacilityConfiguration configuration, Catchment catchment)
        {
            _type          = type;
            _configuration = configuration;
            _catchment     = catchment;

            ConfigureFacility();
        }
예제 #23
0
        /// <summary>
        /// Returns a SelectList for populating dropdown lists containing either Practices only or all Practices/Facilities
        /// </summary>
        /// <param name="facilityType">Practice to retrieve all Practices only; Legal to retrieve all types</param>
        /// <param name="refresh">Pass True to force a refresh of the SelectList</param>
        /// <returns></returns>
        internal SelectList GetSelectList(FacilityType facilityType, bool refresh = false)
        {
            ObjectCache cache = MemoryCache.Default;

            SelectList list;

            if (facilityType == FacilityType.Practice)
            {
                list = (SelectList)cache["PracticeSelectList"];
                if (refresh || list == null)
                {
                    // Store just the Practices for use on the Doctor screen
                    var items = Search("", true)
                                .Select(s => new
                    {
                        Text  = s.PracticeName + (s.City != null ? " - " : "") + s.City + " " + s.State,
                        Value = s.Id
                    })
                                .ToList();
                    list = new SelectList(items, "Value", "Text");

                    if (refresh)
                    {
                        cache.Remove("PracticeSelectList");
                    }
                    cache.Add("PracticeSelectList", list,
                              new CacheItemPolicy {
                        Priority = CacheItemPriority.NotRemovable
                    });
                }
            }
            else
            {
                list = (SelectList)cache["FacilitySelectList"];
                if (refresh || list == null)
                {
                    // Store all Practices/Facilities for use on Presentation screen
                    var itemsAll = Search("")
                                   .Select(s => new
                    {
                        Text  = s.PracticeName + (s.City != null ? " - " : "") + s.City + " " + s.State,
                        Value = s.Id
                    })
                                   .ToList();
                    list = new SelectList(itemsAll, "Value", "Text");

                    if (refresh)
                    {
                        cache.Remove("FacilitySelectList");
                    }
                    cache.Add("FacilitySelectList", list, new CacheItemPolicy {
                        Priority = CacheItemPriority.NotRemovable
                    });
                }
            }

            return(list);
        }
예제 #24
0
 public void Initialize(UpgradeInfo upgradeInfo, FacilityType facilityType)
 {
     facility                = facilityType;
     _upgradeInfo            = upgradeInfo;
     asteroidCost.text       = upgradeInfo.asteroidCost.ToString();
     mineralCost.text        = upgradeInfo.mineralCost.ToString();
     upgradeName.text        = upgradeInfo.name;
     upgradeDescription.text = upgradeInfo.description;
 }
예제 #25
0
        private async Task <List <AatfDataList> > GetAatfs(FacilityType facilityType, FilteringViewModel filter = null)
        {
            using (var client = apiClient())
            {
                var mappedFilter = filter != null?mapper.Map <AatfFilter>(filter) : null;

                return(await client.SendAsync(User.GetAccessToken(), new GetAatfs(facilityType, mappedFilter)));
            }
        }
예제 #26
0
        public void ViewModel_GetFacilityTypeString(FacilityType type, string expected)
        {
            AatfDetailsViewModel model = new AatfDetailsViewModel()
            {
                FacilityType = type
            };

            Assert.Equal(expected, model.FacilityType.ToDisplayString());
        }
예제 #27
0
        private void advPropertyGrid1_PropertyValueChanging(object sender, PropertyValueChangingEventArgs e)
        {
            //var item = GetObjAndField(e.PropertyPath);
            //var obj= item.Item1;
            //var propertyName = item.Item2;
            if (e.PropertyName.EqualIgnoreCase("ModularDevices"))
            {
                var ModularDeviceID = ModularDevice.FindAllByName(e.NewValue.ToString())[0].ID;
                selectObj.Item1.SetItem("ModularDeviceID", ModularDeviceID);
            }
            else if (e.PropertyName.EqualIgnoreCase("Sensors"))
            {
                var SensorId = Sensor.FindAllByName("name", e.NewValue, null, 0, 0)[0].ID;
                selectObj.Item1.SetItem("SensorId", SensorId);
            }
            else if (e.PropertyName.EqualIgnoreCase("ControlJobTypes"))
            {
                var ControlJobTypeId = ControlJobType.FindAllByName("name", e.NewValue, null, 0, 0)[0].Id;
                selectObj.Item1.SetItem("ControlJobTypeId", ControlJobTypeId);
            }
            else if (e.PropertyName.EqualIgnoreCase("RelayTypes"))
            {
                var RelayTypeId = RelayType.FindAllByName("name", e.NewValue, null, 0, 0)[0].Id;
                selectObj.Item1.SetItem("RelayTypeId", RelayTypeId);
            }
            else if (e.PropertyName.EqualIgnoreCase("DeviceTypes"))
            {
                var DeviceTypeSerialnum = DeviceType.FindAllByName("name", e.NewValue, null, 0, 0)[0].Serialnum;
                selectObj.Item1.SetItem("DeviceTypeSerialnum", DeviceTypeSerialnum);
            }

            else if (e.PropertyName.EqualIgnoreCase("ShowDeviceTypes"))
            {
                var ShowDeviceTypeID = ShowDeviceType.FindAllByName("name", e.NewValue, null, 0, 0)[0].ID;
                selectObj.Item1.SetItem("ShowDeviceTypeID", ShowDeviceTypeID);
            }
            else if (e.PropertyName.EqualIgnoreCase("CommunicateDevices"))
            {
                var CommunicateDeviceID = CommunicateDevice.FindAllByName("name", e.NewValue, null, 0, 0)[0].ID;
                selectObj.Item1.SetItem("CommunicateDeviceID", CommunicateDeviceID);
            }
            else if (e.PropertyName.EqualIgnoreCase("Farms"))
            {
                var FarmID = Farm.FindAllByName("name", e.NewValue, null, 0, 0)[0].ID;
                selectObj.Item1.SetItem("FarmID", FarmID);
            }
            else if (e.PropertyName.EqualIgnoreCase("FacilityTypes"))
            {
                var FacilityTypeSerialnum = FacilityType.FindAllByName("name", e.NewValue, null, 0, 0)[0].Serialnum;
                selectObj.Item1.SetItem("FacilityTypeSerialnum", FacilityTypeSerialnum);
            }
            else
            {
                selectObj.Item1.SetItem(e.PropertyName, e.NewValue);
            }
        }
예제 #28
0
        public async Task <ActionResult> ManageAatfs(FacilityType facilityType)
        {
            SetBreadcrumb(facilityType, null);

            return(View(nameof(ManageAatfs), new ManageAatfsViewModel {
                FacilityType = facilityType, AatfDataList = await GetAatfs(facilityType), CanAddAatf = IsUserInternalAdmin(), Filter = new FilteringViewModel {
                    FacilityType = facilityType, CompetentAuthorityOptions = await GetCompetentAuthoritiesList()
                }
            }));
        }
예제 #29
0
        public FacilityType MapEFToModel(EF.Models.FacilityType data)
        {
            var facilityType = new FacilityType()
            {
                FacilityTypeId = data.FacilityTypeId,
                Name           = data.Name,
            };

            return(facilityType);
        }
예제 #30
0
        public async Task <List <MobileFoodFacility> > GetClosestMobileFoodFacility(FacilityType facilityType, double latitide, double longitude)
        {
            var mobileFoodFascilities = await EnsureFacilitiesAreCachedAsync();

            return((from ff in mobileFoodFascilities
                    let distance = (3959 * Math.Acos(Math.Cos(DegreeToRadian(latitide)) * Math.Cos(DegreeToRadian(ff.Latitude)) * Math.Cos(DegreeToRadian(ff.Longitude) - DegreeToRadian(longitude)) + Math.Sin(DegreeToRadian(latitide)) * Math.Sin(DegreeToRadian(ff.Latitude))))
                                   where ff.Status == ValidStatus && distance < 5
                                   orderby distance
                                   select ff).ToList());
        }
예제 #31
0
 public static Facility CreateConstructed(int row, int column, FacilityType facilityType)
 {
     return new Facility
     {
         FacilityType = facilityType,
         Row = row,
         Column = column,
         DaysUntilConstructionComplete = 0
     };
 }
 public AirlinerFacility(string section, string uid, FacilityType type, int fromYear, int serviceLevel, double percentOfSeats, double pricePerSeat, double seatUses)
 {
     AirlinerFacility.Section = section;
     this.Uid = uid;
     this.FromYear = fromYear;
     this.PricePerSeat = pricePerSeat;
     this.PercentOfSeats = percentOfSeats;
     this.Type = type;
     this.ServiceLevel = serviceLevel;
     this.SeatUses = seatUses;
 }
예제 #33
0
 public RouteFacility(string uid, FacilityType type, string name, int serviceLevel, ExpenseType eType, double expense, FeeType feeType,AirlineFacility requires)
 {
     this.Type = type;
     this.Name = name;
     this.Uid = uid;
     this.ServiceLevel = serviceLevel;
     this.EType = eType;
     this.ExpensePerPassenger = expense;
     this.FeeType = feeType;
     this.Requires = requires;
 }
예제 #34
0
 public RouteFacility(
     string uid,
     FacilityType type,
     string name,
     int serviceLevel,
     ExpenseType eType,
     double expense,
     FeeType feeType)
     : this(uid, type, name, serviceLevel, eType, expense, feeType, null)
 {
 }
예제 #35
0
 public AirportFacility(string section, string uid, string shortname,FacilityType type,int buildingDays, int typeLevel, double price, int serviceLevel, int luxuryLevel)
 {
     AirportFacility.Section = section;
     this.Uid = uid;
     this.Shortname = shortname;
     this.Price = price;
     this.LuxuryLevel = luxuryLevel;
     this.ServiceLevel = serviceLevel;
     this.BuildingDays = buildingDays;
     this.TypeLevel = typeLevel;
     this.Type = type;
 }
예제 #36
0
        public BuildFacility(FacilityType facilityType)
        {
            this.facilityType = facilityType;
            var metadata = facilityType.Metadata();

            AddControl(new Border(40, 192, 128, 160, ColorScheme.Blue, Backgrounds.Title, 12));
            AddControl(new Label(50, 202, metadata.Name, Font.Normal, ColorScheme.Blue));
            AddControl(new Label(62, 202, "COST>", Font.Normal, ColorScheme.Blue));
            AddControl(new Label(70, 202, metadata.Cost.FormatNumber(), Font.Large, ColorScheme.White));
            AddControl(new Label(90, 202, "CONSTRUCTION TIME>", Font.Normal, ColorScheme.Blue));
            AddControl(new Label(98, 202, metadata.DaysToConstruct.FormatNumber() + " days", Font.Large, ColorScheme.White));
            AddControl(new Label(118, 202, "MAINTENANCE>", Font.Normal, ColorScheme.Blue));
            AddControl(new Label(126, 202, metadata.Maintenance.FormatNumber(), Font.Large, ColorScheme.White));
            AddControl(new Button(176, 200, 112, 16, "Cancel", ColorScheme.Blue, Font.Normal, OnCancel));
            AddControl(new BaseFacilities(facilityType, OnClickFacility));
        }
예제 #37
0
		private void AddTopicControls(FacilityType facility)
		{
			var metadata = facility.Metadata();
			if (metadata.Shape == FacilityShape.Hangar)
			{
				AddControl(new Picture(18, 233, metadata.Image));
			}
			else
			{
				AddControl(new Picture(31, 249, metadata.Shape.BuildingImage()));
				AddControl(new Picture(30 + metadata.RowOffset, 248 + metadata.ColumnOffset, metadata.Image));
			}
			AddControl(new Label(24, 10, metadata.Name, Font.Large, ColorScheme.Blue));

			var nextTop = 40;
			var stats = new[]
			{
				Tuple.Create("Construction Time", $"{metadata.DaysToConstruct} days"),
				Tuple.Create("Construction Cost", $"${metadata.Cost.FormatNumber()}"),
				Tuple.Create("Maintenance Cost", $"${metadata.Maintenance.FormatNumber()}"),
				Tuple.Create("Defense Value", metadata.DefenseValue == 0 ? null : metadata.DefenseValue.FormatNumber()),
				Tuple.Create("Hit Ratio", metadata.HitRatio == 0 ? null : $"{metadata.HitRatio}\t%")
			};
			foreach (var stat in stats.Where(stat => stat.Item2 != null))
			{
				var top = nextTop;
				nextTop += 10;
				AddControl(new ExtendedLabel(top, 10, 140, stat.Item1, Font.Normal, ColorScheme.Blue));
				AddControl(new Label(top, 150, stat.Item2, Font.Normal, ColorScheme.White));
			}

			nextTop = 104;
			foreach (var descriptionLine in metadata.DescriptionLines)
			{
				var top = nextTop;
				nextTop += 8;
				AddControl(new Label(top, 10, descriptionLine, Font.Normal, ColorScheme.Blue));
			}
		}
예제 #38
0
 private static TopicMetadata Facility(FacilityType facility)
 {
     return new TopicMetadata
     {
         Name = facility.Metadata().Name,
         Category = TopicCategory.BaseFacilities,
         Background = Backgrounds.InfoFacility,
         BackgroundPalette = 1,
         Scheme = ColorScheme.LightWhite,
         RequiredResearch = new[] { facility.Metadata().RequiredResearch }
             .Where(research => research != null)
             .Cast<ResearchType>()
             .ToArray(),
         Subject = facility
     };
 }
예제 #39
0
 /// <summary>
 /// Constructor for a sloped facility
 /// </summary>
 /// <param name="type">The FacilityType; should be Swale or SlopedPlanter</param>
 /// <param name="configuration">The Configuration of the facility</param>
 /// <param name="catchment">The catchment for the facility</param>
 /// <param name="segments">A list of Segments to load the facility with</param>
 public SlopedFacility(FacilityType type, FacilityConfiguration configuration, Catchment catchment, List<SlopedFacilitySegment> segments)
     : base(type, configuration, catchment)
 {
     _segments = segments;
       SlopedFacility._this = this;
 }
 public AirlinerFacility(
     string section,
     string uid,
     FacilityType type,
     int fromYear,
     int serviceLevel,
     double percentOfSeats,
     double pricePerSeat,
     double seatUses)
 {
     Section = section;
     Uid = uid;
     FromYear = fromYear;
     PricePerSeat = pricePerSeat;
     PercentOfSeats = percentOfSeats;
     Type = type;
     ServiceLevel = serviceLevel;
     SeatUses = seatUses;
 }
예제 #41
0
        /// <summary>
        /// Constructs a new Facility object of the specified Type and Configuration, located within
        /// the specified Catchment
        /// </summary>
        /// <param name="type">The type of facility</param>
        /// <param name="configuration">The plumbed facility configuration</param>
        /// <param name="catchment">The Catchment containing the facility</param>
        public Facility(FacilityType type, FacilityConfiguration configuration, Catchment catchment)
        {
            _type = type;
              _configuration = configuration;
              _catchment = catchment;

              ConfigureFacility();
        }
예제 #42
0
 public RouteFacility(
     string uid,
     FacilityType type,
     string name,
     int serviceLevel,
     ExpenseType eType,
     double expense,
     FeeType feeType,
     AirlineFacility requires)
 {
     Type = type;
     Name = name;
     Uid = uid;
     ServiceLevel = serviceLevel;
     EType = eType;
     ExpensePerPassenger = expense;
     FeeType = feeType;
     Requires = requires;
 }
        public FacilitySearchResult Get(string latitude, string longitude, string gender, bool isChild, FacilityType type)
        {
            FacilitySearchResult result = new FacilitySearchResult();

            result.Origin = new Location { Latitude = latitude, Longitude = longitude };

            // Get the suburb and postcode for the origin location
            var google = new HealthBuddy.Api.Directions.DirectionsService();
            google.Lookup(result.Origin);
            double lat = double.Parse(result.Origin.Latitude);
            double lng = double.Parse(result.Origin.Longitude);

            if (type == FacilityType.Hospital)
            {
                // Use GovHack data sets - my hospitals contact list, length of stay data, etc.

                var hospitals = db.myhospitals_contact_data
                    .Where(
                        a => (!a.Emergency.HasValue || a.Emergency.Value)
                        && (!a.Child.HasValue || a.Child == isChild)
                        && (a.Gender == null || a.Gender == gender))
                    .OrderBy(
                        a => (a.Latitude - lat) * (a.Latitude - lat)
                        + (a.Longitude - lng) * (a.Longitude - lng))
                    .Take(5).ToList();

                var ids = hospitals.Select(a => a.Id).ToArray();
                var codes = hospitals.Select(a => a.HospitalCode).ToArray();
                var lengthsOfStay = db.emergencydept4hourlengthofstaymetadata.Where(a => ids.Contains(a.MyHospitalsId.Value)).OrderBy(a => a.ID).ToList();
                var emergencyStats = db.ED001_HospitalStatus.Where(a => codes.Contains(a.HospitalCode)).OrderBy(a => a.Id).ToList();

                result.Facilities.AddRange(hospitals.Select(hosp => new Facility
                    {
                        Name = hosp.Hospital_name,
                        LessThan4HrsPct = GetLengthOfStay(hosp, lengthsOfStay),
                        EmergencyDepartmentStatus = GetEDStatus(hosp, emergencyStats),
                        Location = GetLocation(hosp),
                        TwitterSentiment = EventHub.EventService.GetTwitterSentiment(hosp.HospitalCode),
                        OpenNow = "true",
                    }));
            }
            else if (type == FacilityType.Community)
            {
                // Use ACHC20150617_DataDotGov

                var charities = db.ACHC20150617_DataDotGov
                    .Where(
                        a => (a.Advancing_Health == "Y")
                        && (!isChild || a.Children == "Y")
                        && (a.Latitude.HasValue && a.Longitude.HasValue))
                    .OrderBy(
                        a => (a.Latitude - lat) * (a.Latitude - lat)
                        + (a.Longitude - lng) * (a.Longitude - lng))
                    .Take(5).ToList();

                result.Facilities.AddRange(charities.Select(hosp => new Facility
                {
                    Name = hosp.Charity_Legal_Name,
                    Location = GetLocation(hosp)
                }));
            }
            else
            {
                // Use NHSD lookup.
                var nhsd = new HealthBuddy.Api.Nhsd.NhsdService();
                result.Facilities.AddRange(nhsd.Search(result.Origin, type));
            }

            // Get the travel times by driving and transit to each facility.
            foreach (var facility in result.Facilities)
            {
                facility.TravelTimes = google.GetTravelTimes(result.Origin, facility.Location);
            }
            return result;
        }
예제 #44
0
 public BaseFacilities(FacilityType facilityType, Action<int, int> action)
 {
     mode = Mode.BuildFacility;
     this.action = action;
     this.facilityType  = facilityType;
 }
예제 #45
0
 private void OnSelectFacilityType(FacilityType facilityType)
 {
     new BuildFacility(facilityType).DoModal(this);
 }
        public List<Facility> Search(Location loc, FacilityType type)
        {

            string serviceCategory = null;
            string servicetype = null;
            switch (type)
            {
                case FacilityType.GP:
                    serviceCategory = "General Practice/GP (doctor)";
                    break;
                case FacilityType.Pharmacy:
                    servicetype = "Pharmacy";
                    break;
            }

            var requestDic = new Dictionary<string, string>
            {
                {"usepostcoderadialsearch", "true"},
                {"suburbpostcodedata", JsonConvert.SerializeObject(new { SiteSearchSuburbPostcodeParams = new { SuburbPostcode = loc.Suburb + " " + loc.Postcode, SearchSurroundingSuburbs = true } })},
                {"startpos", "1"},
                {"servicetype", servicetype},
                {"ServiceCategory", serviceCategory},
                {"SearchSiteAddress", "true"},
                {"SearchServiceCoverageArea", "false"},
                {"SearchServiceAddress", "false"},
                {"orderby", "Distance"},
                {"endpos", "5"},
                {"deliverymethod", "{\"string\":\"Site Visit\"}"},
                {"callback", "angular.callbacks._4"},
                {"apikey", "nhccn-9vSRwUZooHY2BebTOvAhA93n"},
                {"alwaysreturn", "5"}
            };

            string url = "https://api.nhsd.com.au/nhsd/v2.8/rest/sitesearch?";
            foreach (var entry in requestDic)
            {
                if (entry.Value != null)
                {
                    url += entry.Key + "=" + Uri.EscapeDataString(entry.Value) + "&";
                }
            }

            WebRequest req = WebRequest.Create(url);

            StreamReader sr = new StreamReader(req.GetResponse().GetResponseStream());
            WebResponse response = req.GetResponse();
            string responseString = sr.ReadToEnd();
            string json = responseString.Substring(requestDic["callback"].Length + 1, responseString.Length - requestDic["callback"].Length - 2);
            RootObject result = JsonConvert.DeserializeObject<RootObject>(json);
            FacilitySearchResult searchResult = new FacilitySearchResult();
            var firstSite = result.SiteSearchResponse.SiteSearchResult.ResultList.SiteData[0];
            
            var facilities = result.SiteSearchResponse.SiteSearchResult.ResultList.SiteData.Select(a => new Facility
                {
                    Location = new Location
                    {
                        Address = a.SiteAddress.Address_Line_1 + " " + a.SiteAddress.Address_Line_2 + " " + a.SiteAddress.Address_Line_3,
                        Suburb = a.SiteAddress.Suburb,
                        Postcode = a.SiteAddress.Postcode,
                        Latitude = a.SiteAddress.Latitude,
                        Longitude = a.SiteAddress.Longitude,
                    },
                    OpenNow = a.ServiceCollection.ServiceData.OpenNow,
                    ClosingTime = GetClosingTime(a.ServiceCollection.ServiceData),
                    Name = a.OrganisationName,
                }).ToList();
            return facilities;
        }
예제 #47
0
		public int CountFacilities(FacilityType facilityType)
		{
			return Facilities.Count(facility =>
				facility.DaysUntilConstructionComplete == 0 &&
				facility.FacilityType == facilityType);
		}