void Awake() { manifest = GetComponentInParent <ItemManifest>(); StartCoroutine(startSpawn()); }
/// <summary> /// Updates tokens with the latest structure data. /// </summary> public override void Update() { if (this.Structure == null) { this.tokens.Clear(); Log.Warn("Attempted to tokenize a null structure."); } else { this.tokens["StructureID"] = this.Structure.Id.ToString(); this.tokens["Damage"] = (this.Structure.DamageLevel * 100.0).ToString("F2"); this.tokens["Powered"] = this.Structure.IsPowered ? "Yes" : "No"; this.tokens["Pilot"] = this.Structure.Pilot?.Name ?? "None"; this.TokenizeTank(this.Structure.FuelTank, "Fuel"); this.TokenizeTank(this.Structure.OxygenTank, "Oxygen"); this.TokenizeTank(this.Structure.PentaxidTank, "Pentaxid"); List <IStructure> dockedVessels = this.Structure.GetDockedVessels(); this.tokens["DockedVesselCount"] = dockedVessels.Count.ToString(); this.TokenizeStructureList(dockedVessels, "DockedVesselList"); List <IPlayer> passengers = this.Structure.GetPassengers(); this.tokens["PassengerCount"] = passengers.Count.ToString(); this.TokenizePlayerList(passengers, "PassengerList"); List <SenderSignal> signals = this.Structure.GetBlockSignals(); signals = signals.Concat <SenderSignal>(this.Structure.GetControlPanelSignals()).ToList(); this.TokenizeSignalList(signals); // Get a manifest of all items in the structure. ItemManifest manifest = new ItemManifest(); manifest.Add(this.Structure); if (EmpyrionExtension.Configuration != null) { // Buckets of item totals, each will get their own tag. Dictionary <string, int> allItems = new Dictionary <string, int>(); // Key is the name of the category. Value is the item->count lookup. Dictionary <string, SortedDictionary <string, int> > categories = new Dictionary <string, SortedDictionary <string, int> >(); EmpyrionObject obj; string category, name; SortedDictionary <string, int> categoryList; foreach (KeyValuePair <int, int> count in manifest.Items) { if (EmpyrionExtension.Configuration.ObjectsByID.ContainsKey(count.Key)) { obj = EmpyrionExtension.Configuration.ObjectsByID[count.Key]; name = obj?.Name ?? count.Key.ToString(); allItems[name] = count.Value; category = obj?.ResolveProperty("Category")?.Value; if (category != null) { if (categories.ContainsKey(category)) { categoryList = categories[category]; } else { categoryList = new SortedDictionary <string, int>(); categories[category] = categoryList; } if (categoryList.ContainsKey(name)) { categoryList[name] += count.Value; } else { categoryList[name] = count.Value; } } } else { Log.Debug("Encountered block with unknown ID " + count.Key); allItems[count.Key.ToString()] = count.Value; } } this.tokens["InventoryAll"] = string.Join(Environment.NewLine, allItems.Select(kvp => $"{EmpyrionExtension.Localization?[kvp.Key] ?? kvp.Key}: {kvp.Value}")); foreach (KeyValuePair <string, SortedDictionary <string, int> > kvp in categories) { this.tokens["Inventory-" + kvp.Key] = string.Join(Environment.NewLine, kvp.Value.Select(item => $"{EmpyrionExtension.Localization?[item.Key] ?? item.Key}: {item.Value}")); } } else { Log.Debug("Configuration is null."); } } }
public async Task <PagedListResult <ShipmentManifestsDtos> > ListManifestDtoAsync(int pageIndex = 1, int pageSize = 2, string DestinationPort = null, string OriginPort = null, string Carrier = null, DateTime?ETDFrom = null, DateTime?ETDTo = null, string Status = null, string Vendor = null, string PONumber = null, string Item = null) { PagedListResult <ShipmentManifestsDtos> pageResult = new PagedListResult <ShipmentManifestsDtos>(); List <ShipmentManifestsDtos> shipmentManifestsDtos = new List <ShipmentManifestsDtos>(); List <ShipmentManifestsDtos> currentPage = new List <ShipmentManifestsDtos>(); List <ShipmentManifestsDtos> previousPage = new List <ShipmentManifestsDtos>(); Expression <Func <Container, bool> > All = x => x.Id > 0; Expression <Func <Booking, bool> > AllBooking = o => o.Id > 0; if (DestinationPort != null) { Expression <Func <Container, bool> > filterDestinationPort = x => x.Manifests.Where(p => p.Booking.PortOfDelivery == DestinationPort).Count() > 0; All = All.And(filterDestinationPort); } if (OriginPort != null) { Expression <Func <Container, bool> > filterOriginPort = x => x.Manifests.Where(p => p.Booking.PortOfLoading == OriginPort).Count() > 0; All = All.And(filterOriginPort); } if (Carrier != null) { Expression <Func <Container, bool> > filterCarrier = x => x.Manifests.Where(p => p.Booking.Carrier == Carrier).Count() > 0; All = All.And(filterCarrier); } if (ETDFrom != null) { Expression <Func <Container, bool> > filterETDFrom = x => x.Manifests.Where(p => p.Booking.ETD.CompareTo(ETDFrom) > 0).Count() > 0; Expression <Func <Booking, bool> > filter = x => x.ETD.CompareTo(ETDFrom) > 0; AllBooking = AllBooking.And(filter); All = All.And(filterETDFrom); } if (ETDTo != null) { Expression <Func <Container, bool> > filterETDTo = x => x.Manifests.Where(p => p.Booking.ETD.CompareTo(ETDTo) < 0).Count() > 0; Expression <Func <Booking, bool> > filter = x => x.ETD.CompareTo(ETDTo) > 0; AllBooking = AllBooking.And(filter); All = All.And(filterETDTo); } if (Status != null) { Expression <Func <Container, bool> > filterStatus = x => x.Manifests.Where(p => p.Booking.Status.GetDescription <OrderStatus>() == Status).Count() > 0; Expression <Func <Booking, bool> > filter = x => x.Status.GetDescription <OrderStatus>() == Status; AllBooking = AllBooking.And(filter); All = All.And(filterStatus); } if (Vendor != null) { Expression <Func <Container, bool> > filterVendor = x => x.Manifests.Where(p => p.Booking.Order.Vendor == Vendor).Count() > 0; Expression <Func <Booking, bool> > filter = x => x.ETD.CompareTo(ETDFrom) > 0; AllBooking = AllBooking.And(filter); All = All.And(filterVendor); } if (PONumber != null) { Expression <Func <Container, bool> > filterPONumber = x => x.Manifests.Where(p => p.Booking.PONumber.Contains(PONumber)).Count() > 0; Expression <Func <Booking, bool> > filter = x => x.PONumber.Contains(PONumber); AllBooking = AllBooking.And(filter); All = All.And(filterPONumber); } if (Item != null) { Expression <Func <Container, bool> > filterItem = x => x.Manifests.Where(p => p.Booking.ItemNumber == Item).Count() > 0; Expression <Func <Booking, bool> > filter = x => x.ItemNumber == Item; AllBooking = AllBooking.And(filter); All = All.And(filterItem); } Expression <Func <Booking, bool> > filterBooking = p => p.PortOfLoading == OriginPort && p.PortOfDelivery == DestinationPort && p.Carrier == Carrier; var containers = await _containerDataProvider.ListAsync(All, "Name", true, pageIndex, pageSize); AllBooking = AllBooking.And(filterBooking); var bookings = await _shipmentBookingDataProvider.ListAsync(AllBooking, null, true); var previous = await _containerDataProvider.ListAsync(All, null, true, pageIndex, pageSize); List <Booking> listBooking = bookings.Items; List <Booking> listBookingNoContainer = listBooking.Where(p => p.Status == OrderStatus.BookingMade || p.Status == OrderStatus.PartlyManifested).OrderBy(p => p.PortOfLoading).ToList(); bool checkEmptyContainer = false; if (listBookingNoContainer.Count() == 0) { checkEmptyContainer = true; } if (checkEmptyContainer == false && pageIndex != 1) { previous = await _containerDataProvider.ListAsync(All, null, true, pageIndex - 1, pageSize); } //currentDTO foreach (var container in containers.Items) { List <ItemManifest> itemManifests = new List <ItemManifest>(); ShipmentManifestsDtos shipmentManifestsDto = new ShipmentManifestsDtos(); foreach (var item in container.Manifests) { decimal temp = 0; foreach (var manifest in item.Booking.Manifests) { temp += manifest.Quantity; } var orderDeatail = await _orderDetailRepository.Query(p => p.ItemNumber == item.Booking.ItemNumber, true).SelectAsync(); ItemManifest itemManifest = new ItemManifest() { Id = item.Id, Vendor = orderDeatail[0].Order.Vendor, Carrier = item.Booking.Carrier, PONumber = item.Booking.PONumber, ItemNumber = item.Booking.ItemNumber, ETDDate = item.Booking.ETD, BookingQuantity = item.Booking.Quantity, OpenQuantity = item.Booking.Quantity - temp, ShipQuantity = item.Quantity, BookingCartons = item.Booking.Quantity * (decimal)item.Booking.Cartons, ShipCartons = item.Quantity * (decimal)item.Cartons, BookingCube = item.Booking.Quantity * (decimal)item.Booking.Cube, ShipCube = item.Quantity * (decimal)item.Cube, NetWeight = item.Quantity * (decimal)item.KGS, Manifested = item.Booking.Status.GetDescription <OrderStatus>(), }; itemManifests.Add(itemManifest); } shipmentManifestsDto.Id = container.Id; shipmentManifestsDto.Manifests = itemManifests; shipmentManifestsDto.Name = container.Name; shipmentManifestsDto.Size = container.Size; shipmentManifestsDto.Loading = container.Loading; shipmentManifestsDto.PackType = container.PackType; currentPage.Add(shipmentManifestsDto); } if (containers.TotalCount % 2 == 0 && checkEmptyContainer == false) { pageResult.PageCount = containers.PageCount + 1; } else { pageResult.PageCount = containers.PageCount; } if (checkEmptyContainer == true) { pageResult.Items = currentPage; pageResult.PageCount = containers.PageCount; } ShipmentManifestsDtos shipmentNoContainerDto = new ShipmentManifestsDtos(); // Define DTO No Container List <ItemManifest> itemNoContainer = new List <ItemManifest>(); // Define List Booking No Manifest Container Or Status is PartlyManifest if (checkEmptyContainer == false) { foreach (var bookingNoContainer in listBookingNoContainer) { var orderDeatail = await _orderDetailRepository.Query(p => p.ItemNumber == bookingNoContainer.ItemNumber, true).SelectAsync(); if (bookingNoContainer.Status == OrderStatus.BookingMade) { ItemManifest itemManifest = new ItemManifest() { Id = 0, Vendor = orderDeatail[0].Order.Vendor, Carrier = bookingNoContainer.Carrier, PONumber = bookingNoContainer.PONumber, ItemNumber = bookingNoContainer.ItemNumber, ETDDate = bookingNoContainer.ETD, BookingQuantity = bookingNoContainer.Quantity, BookingCartons = bookingNoContainer.Quantity * (decimal)bookingNoContainer.Cartons, OpenQuantity = bookingNoContainer.Quantity, BookingCube = bookingNoContainer.Quantity * (decimal)bookingNoContainer.Cube, Manifested = bookingNoContainer.Status.GetDescription <OrderStatus>(), BookingId = bookingNoContainer.Id, Cube = bookingNoContainer.Cube, Carton = bookingNoContainer.Cartons, KGS = orderDeatail[0].KGS, }; itemNoContainer.Add(itemManifest); } if (bookingNoContainer.Status == OrderStatus.PartlyManifested) { ItemManifest itemManifest = new ItemManifest() { Id = 0, Vendor = orderDeatail[0].Order.Vendor, Carrier = bookingNoContainer.Carrier, PONumber = bookingNoContainer.PONumber, ItemNumber = bookingNoContainer.ItemNumber, ETDDate = bookingNoContainer.ETD, BookingQuantity = bookingNoContainer.Quantity, BookingCartons = bookingNoContainer.Quantity * (decimal)bookingNoContainer.Cartons, BookingCube = bookingNoContainer.Quantity * (decimal)bookingNoContainer.Cube, Manifested = bookingNoContainer.Status.GetDescription <OrderStatus>(), BookingId = bookingNoContainer.Id, Cube = bookingNoContainer.Cube, Carton = bookingNoContainer.Cartons, KGS = orderDeatail[0].KGS, }; decimal temp = 0; foreach (var quantity in bookingNoContainer.Manifests) { temp += quantity.Quantity; } itemManifest.OpenQuantity = bookingNoContainer.Quantity - temp; itemNoContainer.Add(itemManifest); } } shipmentNoContainerDto.Id = 0; shipmentNoContainerDto.Manifests = itemNoContainer; //Dto no container foreach (var next in previous.Items) //get DTO previous page { List <ItemManifest> itemManifests = new List <ItemManifest>(); ShipmentManifestsDtos shipmentManifestsNextDto = new ShipmentManifestsDtos(); foreach (var item in next.Manifests) { decimal temp = 0; foreach (var manifest in item.Booking.Manifests) { temp += manifest.Quantity; } ItemManifest itemManifest = new ItemManifest() { Id = item.Id, Vendor = item.Booking.Factory, Carrier = item.Booking.Carrier, PONumber = item.Booking.PONumber, ItemNumber = item.Booking.ItemNumber, ETDDate = item.Booking.ETD, BookingQuantity = item.Booking.Quantity, OpenQuantity = item.Booking.Quantity - temp, ShipQuantity = item.Quantity, BookingCartons = item.Booking.Quantity * (decimal)item.Booking.Cartons, ShipCartons = item.Quantity * (decimal)item.Cartons, BookingCube = item.Booking.Quantity * (decimal)item.Booking.Cube, ShipCube = item.Quantity * (decimal)item.Cube, NetWeight = item.Quantity * (decimal)item.KGS, Manifested = item.Booking.Status.GetDescription <OrderStatus>(), }; itemManifests.Add(itemManifest); } shipmentManifestsNextDto.Id = next.Id; shipmentManifestsNextDto.Manifests = itemManifests; shipmentManifestsNextDto.Name = next.Name; shipmentManifestsNextDto.Size = next.Size; shipmentManifestsNextDto.Loading = next.Loading; shipmentManifestsNextDto.PackType = next.PackType; previousPage.Add(shipmentManifestsNextDto); } if (pageIndex == 1) { shipmentManifestsDtos.Add(shipmentNoContainerDto); if (currentPage.Count() > 0) { shipmentManifestsDtos.Add(currentPage[0]); } pageResult.Items = shipmentManifestsDtos; } if (pageIndex > 1) { shipmentManifestsDtos.Add(previousPage[1]); if (currentPage.Count > 0) { shipmentManifestsDtos.Add(currentPage[0]); } pageResult.Items = shipmentManifestsDtos; } } return(pageResult); }
// Use this for initialization void Awake() { collected = false; manifest = GameObject.Find("ItemManifest").GetComponent <ItemManifest>(); }