public async Task <IFacility> Update(IFacility entity) { TFacility tEntity = entity as TFacility; var errors = await this.ValidateEntityToCheckExistsAtUpdate(tEntity); if (errors.Count() > 0) { await this.ThrowEntityException(errors); } try { this.StartTransaction(); await base.Update(tEntity, x => new { x.Name, x.Description, x.Enabled, x.ModifiedBy, x.ModifiedDate }); this.CommitTransaction(); return(tEntity); } catch (PostgresException ex) { throw new EntityUpdateException(ex); } catch { throw; } }
static private List <string> GetOptions(IFacility fac) { var output = new List <string>(); if (fac is ChickenHouse) { output.Add("Chicken"); } if (fac is DuckHouse) { output.Add("Duck"); } if (fac is GrazingField) { output.Add("Cow"); output.Add("Goat"); output.Add("Ostrich"); output.Add("Pig"); output.Add("Sheep"); } if (fac is NaturalField) { output.Add("Sunflower"); output.Add("Wildflower"); } if (fac is PlowedField) { output.Add("Sesame"); output.Add("Wildflower"); } return(output); }
public async Task <IFacility> AddNew(IFacility entity) { TFacility tEntity = entity as TFacility; var errors = await this.ValidateEntityToCheckExists(tEntity); if (errors.Count() > 0) { await this.ThrowEntityException(errors); } try { this.StartTransaction(); var savedEntity = await base.AddNew(entity as TFacility); this.CommitTransaction(); return(savedEntity); } catch (PostgresException ex) { throw new EntityUpdateException(ex); } catch { throw; } }
public Facility(string name, IFacility facilityInstance, params IFacilityExtension[] extensions) { _key = name; _facilityInstance = facilityInstance; _configuration = ConfigurationHelper.CreateConfiguration(null, "facility", null); _extensions = extensions; }
public virtual IKernel AddFacility(IFacility facility) { #pragma warning disable 612,618 return(AddFacility(facility?.GetType().FullName, facility)); #pragma warning restore 612,618 }
public void Creation() { IFacility facility = _kernel.GetFacilities()[0]; Assert.IsNotNull(facility); Assert.AreSame(_facility, facility); }
public static void CollectInput(Farm farm) { IFacility selectedFacility = SelectFacility(farm); if (selectedFacility == null) { return; // Back to main menu... } List <string> options = GetOptions(selectedFacility); int choice; if (options.Count > 1) { choice = StandardMessages.ShowMenu(options, "What type of resource are you buying today?"); } else { choice = 1; // Auto selects chickens or ducks. } if (choice == 0) { return; // Go back... } IResource newResource = GetResourceType(options[choice - 1]); StandardMessages.ShowMessage($"Adding a {newResource.Type} to the {selectedFacility.Type}: {selectedFacility.Name}"); // TODO: Add multiple resources at the same time... selectedFacility.AddResource(newResource); }
public override void AddFacility(string key, IFacility facility) { if (facility is DeferredServiceResolutionFacility) { _facility = facility as DeferredServiceResolutionFacility; } base.AddFacility(key, facility); }
public ReservationsController( IFacility facilityService, IDog dogService, IReservation reservationService) { _facilityService = facilityService; _dogService = dogService; _reservationService = reservationService; }
/// <summary> /// Initializes a new instance of the <see cref="FacilityData" /> class. /// </summary> /// <param name="facility">The facility.</param> /// <param name="owner">The owner.</param> /// <param name="passiveCMs">The passive countermeasures.</param> /// <param name="hullEquipment">The hull equipment.</param> /// <param name="activeCMs">The active countermeasures.</param> /// <param name="sensors">The sensors.</param> /// <param name="shieldGenerators">The shield generators.</param> /// <param name="hqPriority">The HQ priority.</param> /// <param name="topography">The topography.</param> public FacilityData(IFacility facility, Player owner, IEnumerable<PassiveCountermeasure> passiveCMs, FacilityHullEquipment hullEquipment, IEnumerable<ActiveCountermeasure> activeCMs, IEnumerable<Sensor> sensors, IEnumerable<ShieldGenerator> shieldGenerators, Priority hqPriority, Topography topography) : base(facility, owner, passiveCMs, hullEquipment, activeCMs, sensors, shieldGenerators, hqPriority) { Topography = topography; Science = hullEquipment.Science; Culture = hullEquipment.Culture; Income = hullEquipment.Income; }
private void NotifyPositivePay(IFacility facility) { var email = new MailMessage("*****@*****.**", "*****@*****.**"); var Smtp = new SmtpClient("192.168.254.220"); email.Bcc.Add("*****@*****.**"); email.Subject = "New Pay Positive File"; email.Body = "There is a new Positive Pay file \n" + facility.OutputFileName + "\nwith " + facility.Checks + " checks, that can be uploaded."; Smtp.Send(email); }
/// <summary> /// Init_s the form. /// </summary> private void Init_Form() { IFacility mgr = (IFacility)ObjectFactory.CreateInstance("BusinessProcess.Security.BFacility, BusinessProcess.Security"); theDS = mgr.GetFacilityStats(Convert.ToInt32(ddFacility.SelectedValue)); panelPMTCT.Visible = false; //tblPMTCTCare.Visible = panelHEI.Visible = false; //tblExpInfant.Visible = panelHIV.Visible = false; //tblHIVCare.Visible = ViewState["theDS"] = theDS; mgr = null; DataTable dttecareas = new DataTable(); dttecareas = theDS.Tables[10]; lblTotalActivePatients.Text = theDS.Tables[0].Rows.Count.ToString(); lblActiveNonARTPatients.Text = theDS.Tables[1].Rows.Count.ToString(); lblActiveARTPatients.Text = theDS.Tables[2].Rows.Count.ToString(); lblCurrentMotherPMTCT.Text = theDS.Tables[3].Rows.Count.ToString(); lblANC.Text = theDS.Tables[4].Rows.Count.ToString(); lblLD.Text = theDS.Tables[5].Rows.Count.ToString(); lblPostnatal.Text = theDS.Tables[6].Rows.Count.ToString(); lblCurrentTotalExposedInfants.Text = theDS.Tables[7].Rows.Count.ToString(); lblCurrentPMTCTInfants.Text = theDS.Tables[8].Rows.Count.ToString(); lblCurrentHIVCareInfants.Text = theDS.Tables[9].Rows.Count.ToString(); Session["Facility"] = ddFacility.SelectedValue.ToString(); string FacName = ddFacility.SelectedItem.Text; string[] theFacility = FacName.Split(new char[] { '-' }); if (theFacility[0] == "All") { Session["FacilityName"] = "All Facilities"; } else { Session["FacilityName"] = Convert.ToString(theDS.Tables[12].Rows[0]["FacilityName"]); } DataView theDV = new DataView(theDS.Tables[13]); theDV.RowFilter = "ModuleID=1"; if (theDV.Count > 0) { panelPMTCT.Visible = true; //= tblPMTCTCare.Visible panelHEI.Visible = true; //= tblExpInfant.Visible } theDV.RowFilter = "ModuleID=2 or ModuleID=203"; if (theDV.Count > 0) { panelHIV.Visible = true;//= tblHIVCare.Visible } }
public String BuildFacilityInfo(IFacility facility) { String returnValue=String.Format("<tr class=\"tableHeaderRow\"><th nowrap class=\"tableHeaderCell\" colspan=\"3\">{0}</th></tr>\n", facility.ToString()); if (typeof(AbstractFacility).IsAssignableFrom(facility.GetType())) { String indentation = " "; IConfiguration conf = ((AbstractFacility)facility).FacilityConfig; returnValue=WriteAttributes(conf, returnValue,indentation); } return returnValue; }
public String BuildFacilityInfo(IFacility facility) { String returnValue = String.Format("<tr class=\"tableHeaderRow\"><th nowrap class=\"tableHeaderCell\" colspan=\"3\">{0}</th></tr>\n", facility.ToString()); if (typeof(AbstractFacility).IsAssignableFrom(facility.GetType())) { String indentation = " "; IConfiguration conf = ((AbstractFacility)facility).FacilityConfig; returnValue = WriteAttributes(conf, returnValue, indentation); } return(returnValue); }
public void LifeCycle() { Assert.IsFalse(_facility.Terminated); IFacility facility = _kernel.GetFacilities()[0]; Assert.IsTrue(_facility.Initialized); Assert.IsFalse(_facility.Terminated); _kernel.Dispose(); Assert.IsTrue(_facility.Initialized); Assert.IsTrue(_facility.Terminated); }
public virtual void AddFacility(String key, IFacility facility) { if (key == null) { throw new ArgumentNullException("key"); } if (facility == null) { throw new ArgumentNullException("facility"); } facility.Init(this, ConfigurationStore.GetFacilityConfiguration(key)); facilities.Add(facility); }
public static void CollectInput(Farm farm, IPlantable seed) { Console.Clear(); for (int i = 0; i < farm.PlowFields.Count; i++) { IFacility <IPlantable> field = farm.PlowFields[i]; if (field.Capacity > 0) { Console.WriteLine($"{i + 1}. Plow Field"); Console.WriteLine($"Current Plant Seeds: {field.GetList().Count}"); var plantsGroupedByType = field.GetList().GroupBy(n => n.plant); foreach (var group in plantsGroupedByType) { Console.WriteLine($"{group.Key}: {group.Count()}"); } Console.WriteLine(); } } if (farm.PlowFields.Count >= 1) { Console.WriteLine(); // How can I output the type of animal chosen here? Console.WriteLine($"Place the seeds where?"); Console.Write("> "); int choice = Int32.Parse(Console.ReadLine()); int index = choice - 1; farm.PlowFields[index].AddResource(seed); } else { Console.WriteLine("No Field to select from, Please purchase an appropriate facility. "); Console.ReadLine(); } /* * Couldn't get this to work. Can you? * Stretch goal. Only if the app is fully functional. */ // farm.PurchaseResource<IGrazing>(animal, choice); }
public Farm() { FileHandler = new FileHandler(); SeedHarvester = new SeedHarvester(FileHandler); Composter = new Composter(FileHandler); MeatProcessor = new MeatProcessor(FileHandler); FeatherGatherer = new FeatherGatherer(FileHandler); EggGatherer = new EggGatherer(FileHandler); FileHandler.Facilities.ForEach(fac => { IFacility newFacility = null; string[] facilityData = fac.Split(":"); string type = facilityData[0]; string name = facilityData[1]; string data = facilityData[2]; switch (type) { case "Chicken House": newFacility = new ChickenHouse(name, data); break; case "Duck House": newFacility = new DuckHouse(name, data); break; case "Grazing Field": newFacility = new GrazingField(name, data); break; case "Plowed Field": newFacility = new PlowedField(name, data); break; case "Natural Field": newFacility = new NaturalField(name, data); break; default: throw new Exception("Invalid data"); } Facilities.Add(newFacility); }); }
public virtual IKernel AddFacility(string key, IFacility facility) { if (facility == null) { throw new ArgumentNullException(nameof(facility)); } var facilityType = facility.GetType(); if (facilities.Any(f => f.GetType() == facilityType)) { throw new ArgumentException( $"Facility of type '{facilityType.FullName}' has already been registered with the container. Only one facility of a given type can exist in the container."); } facilities.Add(facility); facility.Init(this, ConfigurationStore.GetFacilityConfiguration(key)); return(this); }
/// <summary> /// Registers a facility within the kernel. /// </summary> /// <param name="key"></param> /// <param name="facility"></param> public override void AddFacility(String key, IFacility facility) { if (!IsInstallerThread) { mrEvent.WaitOne(); } lock (this) { if (initialized && savedException == null) { base.AddFacility(key, facility); } else { throw savedException == null ? new InitializationException() : new InitializationException(savedException); } } }
public async Task <IFacility> AddNew(IFacility entity) { try { this.StartTransaction(); var savedEntity = await base.AddNew(entity as TFacility); this.CommitTransaction(); return(savedEntity); } catch (PostgresException ex) { throw new EntityUpdateException(ex); } catch { throw; } }
static public void CollectInput(Farm farm) { int response = StandardMessages.ShowMenu(_options, "Choose what facility to create..."); if (response == 0) { return; // Going back... } else { IFacility newFacility = GetNewFacility(response); string facilityType = _options[response - 1]; newFacility.Name = GetName(facilityType); farm.AddFacility(newFacility); Console.WriteLine($"Successfully added new {facilityType}: {newFacility.Name}"); } }
public Facility Register() { if (_extensions != null) { foreach (IFacilityExtension extension in _extensions) { extension.Apply(this); } } IFacility instance = ObtainFacilityInstance(); if (_configuration != null) { kernel.ConfigurationStore.AddFacilityConfiguration(_key, _configuration); } kernel.AddFacility(_key, instance); return(this); }
protected virtual void SetUpFacilities(IConfiguration[] configurations, IWindsorContainer container) { foreach (IConfiguration facility in configurations) { String id = facility.Attributes["id"]; String typeName = facility.Attributes["type"]; if (typeName == null || typeName.Length == 0) { continue; } Type type = ObtainType(typeName); IFacility facilityInstance = InstantiateFacility(type); System.Diagnostics.Debug.Assert(id != null); System.Diagnostics.Debug.Assert(facilityInstance != null); container.AddFacility(id, facilityInstance); } }
/// <summary> /// Registers a facility within the container. /// </summary> /// <param name = "facility"></param> public IWindsorContainer AddFacility(IFacility facility) { kernel.AddFacility(facility); return(this); }
/// <summary> /// Registers a facility within the kernel. /// </summary> /// <param name="key"></param> /// <param name="facility"></param> public virtual void AddFacility(String key, IFacility facility) { _kernel.AddFacility(key, facility); }
/// <summary> /// Returns the facilities registered on the kernel. /// </summary> /// <returns></returns> public virtual IFacility[] GetFacilities() { IFacility[] list = new IFacility[facilities.Count]; facilities.CopyTo(list, 0); return(list); }
public virtual IWindsorContainer AddFacility(String idInConfiguration, IFacility facility) { kernel.AddFacility(idInConfiguration, facility); return(this); }
//public List<IAnimalFacility> AnimalFacilities //{ // get // { // return Facilities.Where(fac => { // return fac is IAnimalFacility; // }).Cast<IAnimalFacility>().ToList(); // } //} //public int NumberOfAnimalFacilities { // get // { // return ChickenHouses.Count + DuckHouses.Count + GrazingFields.Count; // } } //public List<IAnimalFacility> AnimalFacilities { get // { // List<IAnimalFacility> output = new List<IAnimalFacility>(); // output.AddRange(); // } //} //public int NumberOfPlantFacilities //{ // get // { // return NaturalFields.Count + PlowedFields.Count; // } //} /* * This method must specify the correct product interface of the * resource being purchased. */ //public void PurchaseResource<T>(IResource resource, int index) //{ // Console.WriteLine(typeof(T).ToString()); // switch (typeof(T).ToString()) // { // case "Cow": // GrazingFields[index].AddResource(resource); // break; // default: // break; // } //} public void AddFacility(IFacility facility) { Facilities.Add(facility); }
internal static void RegisterFacility(IFacility facility) { Instance.AddFacility(facility); }
public void Apply(IFacility obj) { }
public Facility(IFacility facility, params IFacilityExtension[] extensions) : this(facility.GetType().FullName, facility, extensions) { }
public IKernel AddFacility(IFacility facility) { throw new NotImplementedException(); }