/// <summary> /// copies am Article and his Childs to ProductionOrder /// Creates Demand Provider for Production oder and DemandRequests for childs /// </summary> /// <returns></returns> public ProductionOrder CopyArticleToProductionOrder(int articleId, decimal quantity, int demandRequesterId) { var article = Articles.Include(a => a.ArticleBoms).ThenInclude(c => c.ArticleChild).Single(a => a.Id == articleId); var mainProductionOrder = new ProductionOrder { ArticleId = article.Id, Name = "Prod. Auftrag: " + article.Name, Quantity = quantity, }; ProductionOrders.Add(mainProductionOrder); CreateProductionOrderWorkSchedules(mainProductionOrder); var demandProvider = new DemandProviderProductionOrder() { ProductionOrderId = mainProductionOrder.Id, Quantity = quantity, ArticleId = article.Id, DemandRequesterId = demandRequesterId, }; Demands.Add(demandProvider); SaveChanges(); return(mainProductionOrder); }
/// <summary> /// Consume up to requested amount /// </summary> /// <param name="demandCell">The Cell making the request</param> /// <param name="requested">Th requested amount</param> /// <returns>The amount consumed</returns> public float Consume(Cell demandCell, float requested) { int i = Demands.IndexOf(demandCell); float consumed = 0.0f; if (i >= 0) { for (int j = 0; j < Stocks.Count; j++) { float conso = AllocationTable[i, j]; if (consumed + conso > requested) { conso = requested - consumed; // Do not consume more than requested } if (conso > Stocks[j][ResourceId]) { conso = Stocks[j][ResourceId]; // Do not consume more than available } Stocks[j][ResourceId] -= conso; consumed += conso; } } return(consumed); }
public IActionResult Add(MedicineDemand meds) { // string s = meds.Medicine + meds.Demand.ToString(); try { if (meds == null) { return(RedirectToAction("Index", "DemandSupply")); } Demands newdemand = new Demands() { Medicine = meds.Medicine, Demand = meds.Demand }; int res = repo.AddDemand(newdemand); if (res > 0) { return(RedirectToAction("AddSupply", newdemand)); } return(RedirectToAction("Index", "DemandSupply")); } catch (Exception e) { ViewBag.Message = "Exception Encountered : " + e.Message; return(View("~/Views/Shared/ExceptionAndError.cshtml")); } }
//Todo: check logic public void CreatePurchaseDemand(IDemandToProvider demand, decimal amount, int time) { if (NeedToRefill(demand, amount)) { var providerPurchasePart = new DemandProviderPurchasePart() { Quantity = amount, ArticleId = demand.ArticleId, DemandRequesterId = demand.Id, State = State.Created, }; Demands.Add(providerPurchasePart); CreatePurchase(demand, amount, providerPurchasePart, time); Demands.Update(providerPurchasePart); } else { var providerStock = new DemandProviderStock() { Quantity = amount, ArticleId = demand.ArticleId, DemandRequesterId = demand.Id, State = State.Created, StockId = Stocks.Single(a => a.ArticleForeignKey == demand.ArticleId).Id }; Demands.Add(providerStock); } SaveChanges(); }
public List <ProductionOrderWorkSchedule> GetBomParents(ProductionOrderWorkSchedule plannedSchedule) { var provider = plannedSchedule.ProductionOrder.DemandProviderProductionOrders; if (provider == null || provider.ToList().Any(dppo => dppo.DemandRequester == null)) { return(new List <ProductionOrderWorkSchedule>()); } var requester = (from demandProviderProductionOrder in provider select demandProviderProductionOrder.DemandRequester into req select req).ToList(); var pows = new List <ProductionOrderWorkSchedule>(); foreach (var singleRequester in requester) { if (singleRequester.GetType() == typeof(DemandOrderPart) || singleRequester.GetType() == typeof(DemandStock)) { return(null); } var demand = Demands.OfType <DemandProductionOrderBom>().Include(a => a.ProductionOrderBom) .ThenInclude(b => b.ProductionOrderParent).ThenInclude(c => c.ProductionOrderWorkSchedule) .Single(a => a.Id == singleRequester.Id); var schedules = demand.ProductionOrderBom.ProductionOrderParent.ProductionOrderWorkSchedule; pows.Add(schedules.Single(a => a.HierarchyNumber == schedules.Min(b => b.HierarchyNumber))); } return(pows); /*return (from demandProviderProductionOrder in provider * select demandProviderProductionOrder.DemandRequester into requester * where requester.GetType() == typeof(DemandProductionOrderBom) * select ((DemandProductionOrderBom)requester).ProductionOrderBom.ProductionOrderParent.ProductionOrderWorkSchedule into schedules * select schedules.Single(a => a.HierarchyNumber == schedules.Min(b => b.HierarchyNumber))).ToList();*/ }
public void DemandsAddAll(Demands demands) { foreach (var demand in demands) { DemandsAdd(demand); } // T_ProductionOrderOperation IStackSet <ProductionOrderOperation> tProductionOrderOperations = new StackSet <ProductionOrderOperation>(); foreach (var productionOrderBom in _productionOrderBoms) { T_ProductionOrderBom tProductionOrderBom = (T_ProductionOrderBom)productionOrderBom.ToIDemand(); if (tProductionOrderBom != null) { ((ProductionOrderBom)productionOrderBom).EnsureOperationIsLoadedIfExists(); if (tProductionOrderBom.ProductionOrderOperation == null) { throw new MrpRunException( "Every tProductionOrderBom must have an operation."); } tProductionOrderOperations.Push(new ProductionOrderOperation( tProductionOrderBom.ProductionOrderOperation)); } } _productionOrderOperations.AddAll(tProductionOrderOperations); }
public decimal GetReserved(int articleId) { var demands = Demands.OfType <DemandProviderStock>() .Where(a => a.State != State.Finished && a.ArticleId == articleId).Sum(a => a.Quantity); return(demands); }
/// <summary> /// Detail /// </summary> /// <param name="id"></param> /// <returns></returns> public Demands Detail(int id) { try { this.sqlConnection.Open(); Demands result = this.Demands.Where(x => x.Id == id).Select(x => new Demands { Id = x.Id, DemandType = x.DemandType, Date = x.Date, Expiration = x.Expiration, SeekerUsers = x.SeekerUsers, SeekerUsersId = x.SeekerUsersId, VolunteerUsersId = x.VolunteerUsersId, VolunteerUsers = x.VolunteerUsers, Description = x.Description, DemandTypeId = x.DemandTypeId }).FirstOrDefault(); this.sqlConnection.Close(); return(result); } catch (Exception) { throw; } }
internal LandUse(PFSSection Section) { _pfsHandle = Section; for (int i = 1; i <= Section.GetSectionsNo(); i++) { PFSSection sub = Section.GetSection(i); switch (sub.Name) { case "VEGETATION": _vEGETATION = new VEGETATION(sub); break; case "CommandAreas": _commandAreas = new CommandAreas(sub); break; case "Demands": _demands = new Demands(sub); break; case "Priorities": _priorities = new Priorities(sub); break; case "PavedRunoffCoefficient": _pavedRunoffCoefficient = new Topography(sub); break; default: _unMappedSections.Add(sub.Name); break; } } }
public async Task <IActionResult> AddSupply(Demands med) { var distributionOfStock = new List <PharmacyMedicineSupply>(); using (var httpclient = new HttpClient()) { httpclient.BaseAddress = new Uri("https://localhost:44358/"); HttpResponseMessage res = await httpclient.GetAsync("api/MedicineSupply/GetSupplies/" + med.Medicine + "/" + med.Demand); if (res.IsSuccessStatusCode) { var result = res.Content.ReadAsStringAsync().Result; distributionOfStock = JsonConvert.DeserializeObject <List <PharmacyMedicineSupply> >(result); } } if (distributionOfStock.Count == 0) { return(RedirectToAction("Index", "Home")); } foreach (var supply in distributionOfStock) { supplyrepo.AddSupply(new Supplies { PharmacyName = supply.PharmacyName, MedicineName = supply.MedicineName, SupplyCount = supply.SupplyCount }); } return(View(distributionOfStock)); }
/// <summary> /// returns the OrderIds for the ProductionOrder /// </summary> /// <param name="po"></param> /// <returns></returns> public List <int> GetOrderIdsFromProductionOrder(ProductionOrder po) { po = ProductionOrders.Include(a => a.DemandProviderProductionOrders).ThenInclude(b => b.DemandRequester).Single(a => a.Id == po.Id); var ids = new List <int>(); var requester = (from provider in po.DemandProviderProductionOrders select provider.DemandRequester).ToList(); if (!requester.Any() || requester.First() == null) { return(ids); } foreach (var singleRequester in requester) { if (singleRequester.GetType() == typeof(DemandProductionOrderBom)) { ids.AddRange(GetOrderIdsFromProductionOrder( ((DemandProductionOrderBom)singleRequester).ProductionOrderBom.ProductionOrderParent)); } else if (singleRequester.GetType() == typeof(DemandOrderPart)) { var dop = Demands.OfType <DemandOrderPart>().Include(a => a.OrderPart).Single(a => a.Id == singleRequester.Id); ids.Add(dop.OrderPart.OrderId); } } return(ids); }
public void TestEveryOperationHasNeededMaterialAtStart(string testConfigurationFileName ) { InitTestScenario(testConfigurationFileName); IZppSimulator zppSimulator = new ZppSimulator.impl.ZppSimulator(); // TODO: set to true once dbPersist() has an acceptable time zppSimulator.StartTestCycle(false); // TODO: replace this by ReloadTransactionData() once shouldPersist is enabled IDbTransactionData dbTransactionData = ZppConfiguration.CacheManager.GetDbTransactionData(); IAggregator aggregator = ZppConfiguration.CacheManager.GetAggregator(); foreach (var operation in dbTransactionData.ProductionOrderOperationGetAll()) { Demands productionOrderBoms = aggregator.GetProductionOrderBomsBy(operation); foreach (var productionOrderBom in productionOrderBoms) { foreach (var stockExchangeProvider in aggregator.GetAllChildProvidersOf( productionOrderBom)) { Assert.True(operation.GetStartTime() >= stockExchangeProvider.GetEndTimeBackward().GetValue()); } } } }
private void ManufacturingResourcePlanning(Demands dbDemands) { if (dbDemands == null || dbDemands.Any() == false) { throw new MrpRunException( "How could it happen, that no dbDemands are given to plan ?"); } // MaterialRequirementsPlanning IMrp1 mrp1 = new Mrp1.impl.Mrp1(dbDemands); mrp1.StartMrp1(); // BackwardForwardBackwardScheduling OrderOperationGraph orderOperationGraph = new OrderOperationGraph(); ScheduleBackwardFirst(orderOperationGraph); AssertEveryDemandAndProviderIsScheduled(); ScheduleForward(orderOperationGraph, _simulationInterval); ScheduleBackwardSecond(orderOperationGraph); // job shop scheduling JobShopScheduling(orderOperationGraph); }
public void StartMrp2() { // execute mrp2 Demands unsatisfiedCustomerOrderParts = ZppConfiguration.CacheManager.GetAggregator() .GetUnsatisfiedCustomerOrderParts(); ManufacturingResourcePlanning(unsatisfiedCustomerOrderParts); }
public int ProductDemandInPeriod(int product_uid) { int pdp = 0; Demands.ToList().Where(d => d.Key.Product.UID == product_uid).ToList().ForEach(pd => pdp += pd.Value); return(pdp); }
/// <summary> /// HandleSecureDemand /// </summary> /// <param name="demand"></param> private static void HandleSecureDemand(Demands demand) { string message = $"User.FirstName & User.LastName Catégorie: Demand.DemandType User." + $"Ville Voici le lien afin de confirmer votre participation LINK Merci de participer au soutien collectif via Ping-Flood"; string phoneNumber = demand.SeekerUsers.Phone; SMSHelper.SendSMS(phoneNumber, $"+1{message}"); }
public void VerifyDrawDemand() { int deckCount = _allCards.Length; Card[] expectedHand = { _allCards[0] }; Card[] actualHand = Demands.Draw(ref _allCards, 1); CollectionAssert.AreEqual(expectedHand, actualHand); Assert.AreEqual(deckCount - 1, _allCards.Length, "Verify card removed from drawn pile."); }
public void AddItem(ItemType itemType, decimal amount) { Items [itemType] = (decimal)Items [itemType] + amount; if (Demands != null && Demands.GetDemandAmount(itemType) > 0) { Demands.RemoveDemand(itemType, amount); } }
public void VerifyDrawAllDemand() { Card[] expectedHand = XmlCardReader.GetCards(); int countAllCards = _allCards.Length; Card[] actualHand = Demands.Draw(ref _allCards, countAllCards); Assert.AreEqual(0, _allCards.Length, "Drawn pile should be empty."); CollectionAssert.AreEqual(expectedHand, actualHand); }
public DueTime GetEarliestPossibleStartTimeOf( ProductionOrderOperation productionOrderOperation) { DueTime maximumOfEarliestStartTimes = null; Providers providers = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildStockExchangeProvidersOf(productionOrderOperation); foreach (var stockExchangeProvider in providers) { DueTime earliestStartTime = productionOrderOperation.GetStartTimeBackward(); if (earliestStartTime.IsGreaterThanOrEqualTo(stockExchangeProvider .GetStartTimeBackward())) { earliestStartTime = stockExchangeProvider.GetStartTimeBackward(); } else { throw new MrpRunException( "A provider of a demand cannot have a later dueTime."); } Demands stockExchangeDemands = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildDemandsOf(stockExchangeProvider); if (stockExchangeDemands.Any() == false) // StockExchangeProvider has no childs (stockExchangeDemands), // take that from stockExchangeProvider { DueTime childDueTime = stockExchangeProvider.GetStartTimeBackward(); if (childDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = childDueTime; } } else // StockExchangeProvider has childs (stockExchangeDemands) { foreach (var stockExchangeDemand in stockExchangeDemands) { DueTime stockExchangeDemandDueTime = stockExchangeDemand.GetStartTimeBackward(); if (stockExchangeDemandDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = stockExchangeDemandDueTime; } } } if (maximumOfEarliestStartTimes == null || earliestStartTime.IsGreaterThan(maximumOfEarliestStartTimes)) { maximumOfEarliestStartTimes = earliestStartTime; } } return(maximumOfEarliestStartTimes); }
private void HandleLine(string sLine, int number) { if (sLine == "EOF") { return; } var collection = sLine.Trim().Split(); var rest = sLine.Substring(collection[0].Length).Trim(); if (SetFlags(sLine)) { return; } ; if (SetSingleValues(collection[0], rest)) { return; } if (depots_flag) { Depots.Add(int.Parse(collection[0])); } else if (demands_flag) { Demands.Add(int.Parse(collection[1])); } else if (locationCordSection_flag) { LocationCordSection.Add(new Tuple <int, int>(int.Parse(collection[1]), int.Parse(collection[2]))); } else if (depotLocationSection_flag) { DepotLocationSection.Add(new Tuple <int, int>(int.Parse(collection[0]), int.Parse(collection[1]))); } else if (durationSection_flag) { DurationSection.Add(int.Parse(collection[1])); } else if (visitLocationSection_flag) { VisitLocationSection.Add(new Tuple <int, int>(int.Parse(collection[0]), int.Parse(collection[1]))); } else if (depotTimeWindowSection_flag) { DepotTimeWindowSection.Add(new Tuple <int, int>(int.Parse(collection[1]), int.Parse(collection[2]))); } else if (timeAvailSection_flag) { TimeAvailSection.Add(int.Parse(collection[1])); } }
public List <ILinkDemandAndProvider> GetArrowsFrom(Demands demands) { List <ILinkDemandAndProvider> list = new List <ILinkDemandAndProvider>(); foreach (var demand in demands) { list.AddRange(GetArrowsFrom(demand)); } return(list); }
public Demands CustomerOrderPartGetAll() { Demands demands = new Demands(); foreach (var demand in _customerOrderParts) { demands.Add(new CustomerOrderPart(demand.ToIDemand())); } return(demands); }
public void ConsumerClient() { Provider provider = new Provider(); provider.Add(new Resource(ResourceType.Firmware, 10)); Demands demands = new Demands(); demands.Add(new Requirements(ResourceType.Firmware, 5)); int c = Create(provider, demands); }
public DueTime GetEarliestPossibleStartTimeOf(ProductionOrderBom productionOrderBom) { DueTime earliestStartTime = productionOrderBom.GetStartTimeBackward(); Providers providers = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildProvidersOf(productionOrderBom); if (providers.Count() > 1) { throw new MrpRunException("A productionOrderBom can only have one provider !"); } Provider stockExchangeProvider = providers.GetAny(); if (earliestStartTime.IsGreaterThanOrEqualTo( stockExchangeProvider.GetStartTimeBackward())) { earliestStartTime = stockExchangeProvider.GetStartTimeBackward(); } else { throw new MrpRunException("A provider of a demand cannot have a later dueTime."); } Demands stockExchangeDemands = ZppConfiguration.CacheManager.GetAggregator() .GetAllChildDemandsOf(stockExchangeProvider); if (stockExchangeDemands.Any() == false) // StockExchangeProvider has no childs (stockExchangeDemands), // take that from stockExchangeProvider { DueTime childDueTime = stockExchangeProvider.GetStartTimeBackward(); if (childDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = childDueTime; } } else // StockExchangeProvider has childs (stockExchangeDemands) { foreach (var stockExchangeDemand in stockExchangeDemands) { DueTime stockExchangeDemandDueTime = stockExchangeDemand.GetStartTimeBackward(); if (stockExchangeDemandDueTime.IsGreaterThan(earliestStartTime)) { earliestStartTime = stockExchangeDemandDueTime; } } } return(earliestStartTime); }
/** * ProviderToDemand */ public Demands GetAllChildDemandsOf(Provider provider) { Demands demands = new Demands(); Ids ids = _dbTransactionData.ProviderToDemandGetAll().GetByProviderId(provider.GetId()); foreach (var id in ids) { T_ProviderToDemand providerToDemand = _dbTransactionData.ProviderToDemandGetById(id); demands.Add(_dbTransactionData.DemandsGetById(providerToDemand.GetDemandId())); } return(demands); }
public void Should_Add_Requirements_To_Demands() { //Arrange Demands demands = new Demands(); demands.Add(new Requirements(eResourceType.Hardware, 5)); demands.Add(new Requirements(eResourceType.Firmware, 5)); demands.Add(new Requirements(eResourceType.Software, 5)); demands.Add(new Requirements(eResourceType.Other, 5)); //Act,Assert Assert.Equal(4, demands.Requirements.Count); }
public static int GetCount(Provider provider, Demands demands) { int count = 0; foreach (var requirement in demands.Requirements.Values) { //find relevant resource first var resource = provider.Resources.Keys.Contains(requirement.Type) ? provider.Resources[requirement.Type] : null; //find how many whole multiples of this requirement exists. count += resource != null ? (resource.NumberOfUnits / requirement.NumberOfUnits) : 0; } return(count); }
public void RemoveRequirement_ForExistingRequriement_Should_Work() { //Arrange Demands demands = new Demands(); demands.Add(new Requirements(eResourceType.Hardware, 5)); demands.Add(new Requirements(eResourceType.Firmware, 15)); demands.Add(new Requirements(eResourceType.Other, 25)); demands.Add(new Requirements(eResourceType.Software, 15)); demands.Remove(new Requirements(eResourceType.Other, 25)); Assert.Equal(3, demands.Requirements.Count); }
public void ValueEquals() { Provider provider = new Provider(); provider.Add(new Resource(ResourceType.Firmware, 10)); Demands demands = new Demands(); demands.Add(new Resource(ResourceType.Firmware, 10)); int c = Create(provider, demands); Assert.IsTrue(c == 1); }
protected override void OnParse(byte[] table) { if (ActualRegisterTable == null) { throw new InvalidOperationException("La propiedad ActualRegisterTable no puede ser nula."); } /*if (BitConverter.IsLittleEndian) * Array.Reverse(cant_arr); * short cant = BitConverter.(cant_arr, 0);*/ int offset = 0; for (int i = 0; i < ActualRegisterTable.NumberOfPresentDemands; i++) { int hours = (int)table[offset]; offset++; int minutes = (int)table[offset]; offset++; int seconds = (int)table[offset]; offset++; byte[] demandArray = new byte[5]; Array.Copy(table, offset, demandArray, 0, 5); Array.Reverse(demandArray); PresentDemand demand = new PresentDemand { TimeRemaining = new TimeSpan(hours, minutes, seconds), Value = new BillingRegister() { Value = Helper.GetLong(demandArray) } }; Demands.Add(demand); offset = offset + 5; } for (int i = 0; i < ActualRegisterTable.NumberOfPresentValues; i++) { byte[] valueArray = new byte[6]; Array.Copy(table, offset, valueArray, 0, 6); Array.Reverse(valueArray); long value = Helper.GetLong(valueArray); Values.Add(new BillingRegister() { Value = value }); offset = offset + 6; } }