public TransactionDTO(DateTime timeStamp, InventoryAction inventoryAction, int quantity, bool isReturning, double unitCost, double totalCost, int partInstanceId, string partInstanceName, string locationName, int locationId, bool isBubbler = false, double measured = 0, double weight = 0, int referenceTransactionId = 0, int conditionId = 0) { this.TimeStamp = timeStamp; this.InventoryAction = inventoryAction; this.Quantity = quantity; this.Measured = measured; this.Weight = weight; this.IsReturning = isReturning; this.UnitCost = unitCost; this.TotalCost = totalCost; this.PartInstanceId = partInstanceId; this.PartInstanceName = partInstanceName; this.LocationName = locationName; this.LocationId = locationId; this.IsBubbler = isBubbler; if (referenceTransactionId != 0) { this.ReferenceTransactionId = referenceTransactionId; } this.ConditionId = conditionId; }
/// <summary> /// Handles an <see cref="InventoryActionPkt"/> to handle. Ran on server and client. /// </summary> /// <param name="action">The <see cref="InventoryAction"/> to run</param> /// <param name="relatedInt">The item related to the action.</param> /// <returns>Weather the action failed or not.</returns> public bool HandleAction(InventoryAction action, int[] intList) { switch (action) { case InventoryAction.Equip: Inventory.Drive.EquipItem(intList[0]); return(true); case InventoryAction.Unequip: EquipSlot Slot = (EquipSlot)intList[0]; Inventory.Drive.UnequipSlot(Slot); return(true); case InventoryAction.Use: EquipSlot UseSlot = (EquipSlot)intList[0]; Item UseItem = Inventory.Drive.GetSlot(UseSlot); if (UseItem != null && UseItem.Action != null && Character != null && (!Client.IsRunning() || Client.GetConnectedPlayer().Character != Character)) { // Item exists, it has an action, and the character // isn't controlled by the client (no double-actions). UseItem.Action(Character); return(true); } return(false); case InventoryAction.Switch: if (!Client.IsRunning() || Client.GetConnectedPlayer().Character != Character) { Inventory.Drive.SwitchSlots(intList[0], intList[1]); } return(true); } return(false); }
private static InventoryAction GetInventoryAction(ProductivityImportModel productivityImportModel) { var inventory = new InventoryAction { Id = productivityImportModel.DocumentNumber.Trim(), DocumentName = productivityImportModel.DocumentName, StartTime = productivityImportModel.StartTime, Duration = TimeSpan.FromSeconds(productivityImportModel.OperationDuration), Operation = new Operation { Name = productivityImportModel.Operation.Trim() }, Employee = GetEmployee(productivityImportModel), InventoryActionDetails = new List <InventoryActionDetail> { new InventoryActionDetail { ProductId = productivityImportModel.ProductId ?? 0, Product = GetProduct(productivityImportModel), ProductQuantity = productivityImportModel.ProductQuantity ?? 0, Address = GetAddress(productivityImportModel.SenderAddress), AccountingQuantity = productivityImportModel.AccountingQuantity ?? 0, } } }; return(inventory); }
void UpdateUI(Item item, InventoryAction action) { switch (action) { case InventoryAction.AddItem: for (int i = 0; i < inventorySlots.Length; i++) { if (inventorySlots[i].IsEmpty()) { inventorySlots[i].addItem(item); return; } } break; case InventoryAction.RemoveItem: for (int i = 0; i < inventorySlots.Length; i++) { if (inventorySlots[i].Contains(item)) { inventorySlots[i].removeItem(); return; } } break; default: break; } }
public ActionResult Edit(int id, IFormCollection collection) { try { // TODO: Add update logic here InventoryItem item = new InventoryItem(); item.id = int.Parse(collection["id"]); item.lottag_number = collection["lottag_number"]; item.lottag_description = collection["lottag_description"]; item.weight_net = collection["weight_net"]; item.on_hand_balance = collection["on_hand_balance"]; item.unit_of_measure = collection["unit_of_measure"]; item.active = Convert.ToBoolean(collection["active"].ToString().Split(',')[0]); string connString = Configuration["ConnectionStrings:DefaultConnection"]; bool IsUpdated = InventoryAction.UpdateInventoryItem(connString, item); if (IsUpdated) { return(RedirectToAction(nameof(Index))); } else { return(View("ErrorUpdating")); } } catch { return(View("ErrorUpdating")); } }
/// <summary> /// Creates an inventory packet containing only one int. /// </summary> /// <param name="action"></param> /// <param name="relatedInt"></param> public InventoryActionPkt(InventoryAction action, int relatedInt) { Action = action; IntList = new int[1] { relatedInt }; }
public bool MatchItems() { List <Item> haveItems = new List <Item>(); List <Item> needItems = new List <Item>(); for (int i = 0; i < this.Actions.Count; ++i) { InventoryAction action = this.Actions[i]; if (action.TargetItem.ID != BlockIDs.AIR && action.TargetItem.Count > 0) { needItems.Add(action.TargetItem.Clone()); } if (!action.IsValid(this.Player)) { return(false); } if (action.SourceItem.ID != BlockIDs.AIR && action.SourceItem.Count > 0) { haveItems.Add(action.SourceItem.Clone()); } } List <Item> have = new List <Item>(); for (int i = 0; i < haveItems.Count; ++i) { have.Add(haveItems[i]); } List <Item> need = new List <Item>(); for (int i = 0; i < needItems.Count; ++i) { need.Add(needItems[i]); } for (int i = 0; i < have.Count; ++i) { for (int j = 0; j < need.Count; ++j) { Item haveItem = have[i]; Item needItem = need[j]; if (haveItem.Equals(needItem, true, false)) { int amount = Math.Min(haveItem.Count, needItem.Count); haveItem.Count -= amount; needItem.Count -= amount; if (haveItem.Count == 0) { haveItems.Remove(haveItem); } if (needItem.Count == 0) { needItems.Remove(needItem); } } } } return(haveItems.Count == 0 && needItems.Count == 0); }
public TransactionAction(InventoryAction inventoryAction, ContainerType source, ushort srcSlot, ContainerType destination, ushort dstSlot) { InventoryAction = inventoryAction; Source = source; SrcSlot = srcSlot; Destination = destination; DstSlot = dstSlot; }
public void AddInventoryAction(InventoryAction inventoryAction) { using (AirShoppContext _context = new AirShoppContext()) { _context.InventoryAction.Add(inventoryAction); _context.SaveChanges(); } }
public virtual void AddAction(InventoryAction action) { if (this.Actions.Contains(action)) { return; } action.AddInventory(this); this.Actions.Add(action); }
// GET: Admin/Edit/5 public ActionResult Edit(int id) { string connString = Configuration["ConnectionStrings:DefaultConnection"]; InventoryItem item = new InventoryItem(); item = InventoryAction.GetInventoryItem(connString, id); return(View(item)); }
public void SetupCheckInStandard(PartInstance instance, InventoryAction inventoryAction, int locationId, DateTime timeStamp) { this.TimeStamp = timeStamp; this.PartInstance = instance; this.UnitCost = instance.UnitCost; this.TotalCost = instance.TotalCost; this.InventoryAction = inventoryAction; this.Quantity = instance.Quantity; this.LocationId = locationId; }
public void SetupCheckinBubbler(PartInstance instance, InventoryAction inventoryAction, int locationId, DateTime timeStamp) { this.TimeStamp = timeStamp; this.PartInstance = instance; this.Weight = instance.BubblerParameter.Weight; this.MeasuredWeight = instance.BubblerParameter.Measured; this.UnitCost = instance.UnitCost; this.TotalCost = instance.TotalCost; this.InventoryAction = inventoryAction; this.Quantity = instance.Quantity; this.LocationId = locationId; }
public Transaction(PartInstance instance, InventoryAction inventoryAction, double measured, double weight, Location location, DateTime timeStamp) { this.TimeStamp = timeStamp; this.Weight = weight; this.MeasuredWeight = measured; this.UnitCost = instance.UnitCost; this.Quantity = 1; //this.TotalCost = (instance.BubblerParameter.NetWeight * instance.UnitCost); this.TotalCost = (instance.IsBubbler) ? (instance.UnitCost * instance.BubblerParameter.NetWeight) : (this.Quantity * this.UnitCost); this.InventoryAction = inventoryAction; this.LocationId = location.Id; this.PartInstanceId = instance.Id; }
public async Task <string> CreateInventoryAction(InventoryAction invAction) { string result = string.Empty; var data = JsonConvert.SerializeObject(JsonConvert.SerializeObject(invAction)); _httpClient.DefaultRequestHeaders.Clear(); _httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", string.Format("Bearer {0}", Settings.UserToken)); StringContent content = new StringContent(data, Encoding.UTF8, "application/json"); var response = await _httpClient.PostAsync(string.Format(InventoryActionEndPoint, Settings.Server), content); string resultContent = response.Content.ReadAsStringAsync().Result; result = resultContent; return(result); }
public void CheckPause__CurrentPacking_PackingStartAndEndLessCurrentEnd__SetsCurrentEndEqualToPackingStart() { // curr: |_____________|.. - not paccking -> curr: |_______|..... - not paccking // next: ........|___|..... - packing -> next: ........|___|. - packing // Arrange: var builder = GetBuilder(); var momento = builder.BuildNew(); var gatheringOperation = new Operation { Name = "Current Operation", Group = OperationGroups.Gathering }; var packingOperation = new Operation { Name = "Packing Operation", Group = OperationGroups.Packing }; var currentAction = new InventoryAction { StartTime = DateTime.Parse("22.02.2019 8:00:00"), Duration = TimeSpan.FromSeconds(60), Operation = gatheringOperation, }; var packingAction = new DoubleAddressAction() { StartTime = DateTime.Parse("22.02.2019 8:00:15"), Duration = TimeSpan.FromSeconds(30), Operation = packingOperation, DoubleAddressDetails = new List <DoubleAddressActionDetail>(new [] { new DoubleAddressActionDetail { ProductQuantity = 1 }, }) }; var next = builder.CheckDuration(packingAction, momento); var current = builder.CheckDuration(currentAction, momento); // Action: builder.CheckPause(current, next, momento); // Assert: var res = momento.ProductivityMap[gatheringOperation][currentAction]; Assert.That(res.Duration.TotalSeconds, Is.EqualTo(15)); }
public JsonResult DeleteInventoryAction(int id) { if (!User.IsInRole("Officer")) { return(Json(new { Result = "ERROR", Message = "You do not have the authority delete this inventory action." })); } try { JourListDMContainer dm = new JourListDMContainer(); // Grab the item InventoryAction item = dm.InventoryActions.Single(z => z.Id == id); // Delete the object only if there are no references if (item.InventoryLogs.Count < 1) { dm.InventoryActions.DeleteObject(item); } // Otherwise just deactivate so we don't break any historical records else { return(Json(new { Result = "ERROR", Message = "Please eliminate references to delete." })); } // Save the changes dm.SaveChanges(); return(Json(new { Result = "OK" })); } catch (Exception e) { return(Json(new { Result = "ERROR", Message = e.Message })); } }
private async void OnSaveCommandExecuted() { await _pageDialogService.DisplayAlertAsync("Inventory List Count", _inventoryList.Count.ToString(), "OK"); foreach (InventoryThumbnail inventory in _inventoryList) { try { int quantity = (ActionNameCodeList[ActionNameCodeIndex].Code.Equals("DISCOUNT")) ? Math.Abs(Quantity) * -1 : Math.Abs(Quantity); InventoryAction ia = new InventoryAction { inventory_action_id = -1, inventory_id = inventory.inventory_id, action_name_code = ActionNameCodeList[ActionNameCodeIndex].Code, quantity = quantity, quantity_unit_code = QuantityUnitCode, action_date = ActionDate, method_id = MethodList[MethodIndex].value_member, cooperator_id = Settings.UserCooperatorId, note = Note }; await _restClient.CreateInventoryAction(ia); inventory.quantity_on_hand += quantity; await _restClient.UpdateInventory(inventory); } catch (Exception ex) { await _pageDialogService.DisplayAlertAsync("Error", ex.Message, "OK"); } } /*var answer = await _pageDialogService.DisplayAlertAsync("Changes saved", "Do you want to go back to Inventories List Page", "YES", "NO"); * if (answer) * {*/ var navigationParams = new NavigationParameters(); navigationParams.Add("inventoryList", _inventoryList); await NavigationService.GoBackAsync(navigationParams); //} }
public JsonResult CreateInventoryAction(InventoryActionModel model) { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = "Form is not valid! " + "Please correct it and try again." })); } if (!User.IsInRole("Officer")) { return(Json(new { Result = "ERROR", Message = "You do not have the authority to create a new inventory action." })); } try { JourListDMContainer dm = new JourListDMContainer(); InventoryAction item = new InventoryAction(); item.Description = model.Description; dm.AddToInventoryActions(item); dm.SaveChanges(); model.Id = item.Id; return(Json(new { Result = "OK", Record = model })); } catch (Exception e) { return(Json(new { Result = "ERROR", Message = e.Message })); } }
IEnumerator SendAction(ItemInfo source, ActionType type) { string host = @"https://dev3r02.elysium.today/inventory/status"; InventoryAction action = new InventoryAction() { action = type, source = source, target = info }; string json = JsonUtility.ToJson(action); UnityWebRequest request = UnityWebRequest.Post(host, json); request.SetRequestHeader("auth", "\"BMeHG5xqJeB4qCjpuJCTQLsqNGaqkfB6\""); yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debug.LogError(request.error); } else { Debug.Log(request.downloadHandler.text); } }
public ActionResult Delete(int id, IFormCollection collection) { try { // TODO: Add delete logic here string connString = Configuration["ConnectionStrings:DefaultConnection"]; bool IsDeleted = InventoryAction.DeleteInventoryItem(connString, id); if (IsDeleted) { return(RedirectToAction(nameof(Index))); } else { return(View("ErrorDeleting")); } } catch { return(View("ErrorDeleting")); } }
public JsonResult UpdateInventoryAction(InventoryActionModel model) { try { if (!ModelState.IsValid) { return(Json(new { Result = "ERROR", Message = "Form is not valid! " + "Please correct it and try again." })); } if (!User.IsInRole("Officer")) { return(Json(new { Result = "ERROR", Message = "You do not have the authority to update this inventory action." })); } JourListDMContainer dm = new JourListDMContainer(); InventoryAction item = dm.InventoryActions.Single(z => z.Id == model.Id); item.Description = model.Description; dm.SaveChanges(); return(Json(new { Result = "OK" })); } catch (Exception e) { return(Json(new { Result = "ERROR", Message = e.Message })); } }
public ItemUpdateInventoryAckMessage(InventoryAction action, ItemDto item) { Action = action; Item = item; }
public IActionResult Inventory() { string connString = Configuration["ConnectionStrings:DefaultConnection"]; return(View("Inventory", InventoryAction.GetAllInventoryItems(connString))); }
private void InventoryTransactionHandle(InventoryTransactionPacket pk) { List <InventoryAction> actions = new List <InventoryAction>(); for (int i = 0; i < pk.Actions.Length; ++i) { try { InventoryAction action = pk.Actions[i].GetInventoryAction(this); actions.Add(action); } catch (Exception e) { Logger.Log($"Unhandled inventory action from {this.Name}: {e.Message}"); this.SendAllInventories(); return; } } if (pk.TransactionType == InventoryTransactionPacket.TYPE_NORMAL) { InventoryTransaction transaction = new InventoryTransaction(this, actions); if (this.IsSpectator) { this.SendAllInventories(); return; } if (!transaction.Execute()) { Logger.Log($"Failed to execute inventory transaction from {this.Name} with actions"); } } else if (pk.TransactionType == InventoryTransactionPacket.TYPE_MISMATCH) { this.SendAllInventories(); return; } else if (pk.TransactionType == InventoryTransactionPacket.TYPE_USE_ITEM) { UseItemData data = (UseItemData)pk.TransactionData; Vector3 blockPos = data.BlockPos; BlockFace face = data.Face; if (data.ActionType == InventoryTransactionPacket.USE_ITEM_ACTION_CLICK_BLOCK) { this.SetFlag(Entity.DATA_FLAGS, Entity.DATA_FLAG_ACTION, false, true); if (this.CanInteract(blockPos + new Vector3(0.5f, 0.5f, 0.5f), this.IsCreative ? 13 : 7)) { Item item = this.Inventory.MainHandItem; this.World.UseItem(blockPos, item, face, data.ClickPos, this); } //Send MainHand } else if (data.ActionType == InventoryTransactionPacket.USE_ITEM_ACTION_BREAK_BLOCK) { Item item = this.Inventory.MainHandItem; if (this.CanInteract(blockPos + new Vector3(0.5f, 0.5f, 0.5f), this.IsCreative ? 13 : 7)) { this.World.UseBreak(data.BlockPos, item, this); if (this.IsSurvival) { //TODO : food this.Inventory.SendMainHand(); } } else { this.World.SendBlocks(new Player[] { this }, new Vector3[] { data.BlockPos }); } } } else if (pk.TransactionType == InventoryTransactionPacket.TYPE_USE_ITEM_ON_ENTITY) { } else if (pk.TransactionType == InventoryTransactionPacket.TYPE_RELEASE_ITEM) { ReleaseItemData data = (ReleaseItemData)pk.TransactionData; if (data.ActionType == InventoryTransactionPacket.RELEASE_ITEM_ACTION_RELEASE) { } else if (data.ActionType == InventoryTransactionPacket.RELEASE_ITEM_ACTION_CONSUME) { if (this.Inventory.MainHandItem != data.MainHandItem || this.Inventory.MainHandSlot != data.HotbarSlot) { this.Inventory.SendMainHand(this); return; } Item item = this.Inventory.MainHandItem; if (!(item is IConsumeable)) { this.Inventory.SendMainHand(this); return; } IConsumeable consume = (IConsumeable)item; PlayerItemConsumeableEventArgs playerItemConsumeableEvent = new PlayerItemConsumeableEventArgs(this, consume); PlayerEvents.OnPlayerItemConsumeable(playerItemConsumeableEvent); if (playerItemConsumeableEvent.IsCancel) { this.Inventory.SendMainHand(this); return; } consume.OnConsume(this); } } }
public SInventoryActionAckMessage(InventoryAction action, ItemDto item) { Action = action; Item = item; }
/// <summary> /// Queue a forced inventory action that will be performed on commit. /// </summary> public void Add(InventoryAction inventoryAction, ContainerType source, ushort srcSlot, ContainerType destination = ContainerType.None, ushort dstSlot = ushort.MaxValue) { actions.Enqueue(new TransactionAction(inventoryAction, source, srcSlot, destination, dstSlot)); }
public ActionResult AddNewProduct(ProductRequestModel product, HttpPostedFileBase image) { var path = Request.MapPath("~/Content/" + product.categoryId); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var filePath = Path.Combine(path, Path.GetFileName(image.FileName)); try { image.SaveAs(filePath); } catch { throw new Exception(); } string imgPath = filePath.Substring(path.IndexOf("\\Content")); string RealPath = imgPath.Replace("\\", "/"); Product p = new Product() { CategoryId = product.categoryId, IsOnSale = false, ProductionDate = product.productionTime, ProviderId = product.provider, Url = RealPath, KeepDate = product.keepTime, Price = product.price, ProductName = product.productName }; long productId = _productRepository.AddProduct(p); //Add to ProductInFactory table ProductInFactory productInFactory = new ProductInFactory() { Amount = product.productCount, InDate = DateTime.UtcNow, Price = Convert.ToString(p.Price), }; long productInFactoryId = _inventoryRepository.AddProductInFactory(productInFactory); //Add to Inventory table Inventory inventory = new Inventory() { Amount = product.productCount, ProductId = productId, WarehouseId = product.warehouse, }; long inventoryId = _inventoryRepository.AddInventory(inventory); //Add InventoryAction InventoryAction inventoryAction = new InventoryAction() { InventoryId = inventoryId, ProductInFactoryId = productInFactoryId }; _inventoryRepository.AddInventoryAction(inventoryAction); //Add to Discount table Discount discount = new Discount() { Discounts = Constants.DEFAULTDISCOUNT, IsUsed = false, ProductId = productId, StartTime = DateTime.UtcNow, EndTime = DateTime.UtcNow }; _discountRepository.AddProductDiscount(discount); //InventoryProductListViewModel productViewModel = GetInventoryProducts(null,null); return(RedirectToAction("GetAllInventoryProduct", "Inventory")); }
/// <summary> /// Creates an inventory action packet for sending. /// </summary> /// <param name="action">The action done.</param> /// <param name="relatedInt"></param> public InventoryActionPkt(InventoryAction action, int[] intList) { Action = action; IntList = intList; }
/// <summary> /// Deserializes the <see cref="InventoryActionPkt"/> /// </summary> /// <param name="reader"></param> public override void Deserialize(NetworkReader reader) { Action = (InventoryAction)reader.ReadByte(); IntList = reader.ReadMessage <IntListPkt>().IntList; SyncBaseID = reader.ReadInt32(); }