private void ExecuteTask(Data.User user, Item item, int quantity) { int qtyToGive = GetActualQuantity(user, item, quantity); if (qtyToGive == 0) { return; } Manager.Server.Whisper(user, string.Format("Giving you {0} {1}", qtyToGive, item.Name)); int remainingQuantity = qtyToGive; while (remainingQuantity > 0) { int give = Math.Min(qtyToGive, MAX_GIVE_STEP); Manager.Server.Execute(string.Format("give {0} {1} {2}", user.Username, item.Block_Decimal_ID, give)); remainingQuantity = remainingQuantity - give; } ItemHistory history = new ItemHistory(); history.Item = item; history.User = user; history.Quantity = qtyToGive; history.CreateDate = DateTime.Now; using (EMMDataContext db = Manager.GetContext) { db.ItemHistories.InsertOnSubmit(history); db.SubmitChanges(); } }
public void InOutGoodItems(ReturnInOutParam inOutParam) { Item ItemAfterInOrOut = _itemService.Find(inOutParam.ItemId); double oldQty = ItemAfterInOrOut.GetAppropriateQuantity; if (inOutParam.InOrOut == InOrOut.In) { InOutHelper.AddToAppopriateMeasurement(ItemAfterInOrOut, inOutParam.ReturnedItem.Qty); } else { InOutHelper.SubtractToAppopriateMeasurement(ItemAfterInOrOut, inOutParam.ReturnedItem.Qty); } double newQty = ItemAfterInOrOut.GetAppropriateQuantity; _itemService.Edit(ItemAfterInOrOut); if (inOutParam.InOrOut == InOrOut.In) { var p = CreateHistoryParameterForReturnedItems(inOutParam, oldQty, newQty); ItemHistory h = InOutHelper.MakeHistory(p); _historyService.Add(h); _returnedHistoryService.AddReturnedGoodItem(inOutParam.ReturnedItem.ReturnedHistory.Id, inOutParam.ReturnedItem); } else { _returnedHistoryService.DeleteGoodItem(inOutParam.ReturnedItem.Id); _historyService.DeleteReturnedHistoryByDRAndItem(inOutParam.DrId , inOutParam.ItemId); } }
public void InOutWithDR(InOutDRParam inParam) { Item itemAfterInOut = _itemService.Find(inParam.DRItem.Item.Id); double oldQty = itemAfterInOut.GetAppropriateQuantity; if (inParam.InOrOut == InOrOut.In) { InOutHelper.AddToAppopriateMeasurement(itemAfterInOut, inParam.DRItem.Qty); } else if (inParam.InOrOut == InOrOut.Out) { InOutHelper.SubtractToAppopriateMeasurement(itemAfterInOut, inParam.DRItem.Qty); } double newQty = itemAfterInOut.GetAppropriateQuantity; inParam.DRItem.Item = itemAfterInOut; var p = CreateHistoryParameterWithDr(inParam, oldQty, newQty); ItemHistory h = InOutHelper.MakeHistory(p); _historyService.Add(h); _itemService.Edit(itemAfterInOut); _drService.AddToDR(inParam.DRItem.DR.Id, inParam.DRItem); }
public ItemHistory BuildFromRow(DataRow row) { var returnRecord = ItemHistory.BuildItemHistoryFromRow(row); returnRecord = this.BuildExtraFromRow <ItemHistory>(returnRecord, row); return(returnRecord); }
public async Task <ValidationResult> Handle(UpdatePriceCommand request, CancellationToken cancellationToken) { if (!request.IsValid()) { return(request.ValidationResult); } var existingItem = await _itemRepository.FindById(request.ItemId); if (existingItem == null) { AddError("Item not found."); return(ValidationResult); } existingItem.UpdateValues(request.InCashValue, request.NormalValue, request.FullValue); existingItem.SetAvailability(request.IsAvailable); var history = new ItemHistory(request.ItemId, request.InCashValue, request.NormalValue, request.FullValue, request.IsAvailable); _itemRepository.AddHistory(history); existingItem.AddEvent(new PriceUpdatedEvent(request.ItemId, request.InCashValue, request.NormalValue, request.FullValue, request.IsAvailable)); return(await Persist(_itemRepository.UnitOfWork)); }
public async Task <HttpResponseMessage> Post(ItemHistory history) { IItemHistory createdHistory = await _itemHistoryBusinessLogic.Save(history); createdHistory = await _itemHistoryBusinessLogic.Get(createdHistory._id); return(CreateResponse(HttpStatusCode.Created, history)); }
/// <summary> /// Reads the JSON representation of the object. /// </summary> /// <param name="reader">The <see cref="T:Newtonsoft.Json.JsonReader" /> to read from.</param> /// <param name="objectType">Type of the object.</param> /// <param name="existingValue">The existing value of object being read.</param> /// <param name="serializer">The calling serializer.</param> /// <returns>The object value.</returns> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var result = new ItemHistory(); serializer.Converters.Add(new EmdRowCollectionJsonConverter <ItemHistory.ItemHistoryEntry>()); result.History = serializer.Deserialize <EmdRowCollection <ItemHistory.ItemHistoryEntry> >(reader); return(result); }
private void UpdateItemHistory(ItemHistory itemHistory, int quantity, AdjustmentType adjustmentType, string remarks) { itemHistory.Date = DateTime.Now; itemHistory.Quantity = adjustmentType == AdjustmentType.Add ? quantity : quantity * -1; itemHistory.Remarks = remarks; context.Entry(itemHistory).State = EntityState.Modified; }
public void DeleteHistoryByDRAndItem(long drId, long itemId) { ItemHistory hToDelete = _context.ItemHistories.FirstOrDefault(i => i.DR.Id == drId && i.Item_Id == itemId); if (hToDelete != null) { _context.ItemHistories.Remove(hToDelete); SaveChanges("DeleteHistoryByDRAndItem"); } }
public ItemHistory Insert(ItemHistory record) { DataRow row = this.dataSet.ttblitem_history.Newttblitem_historyRow(); this.UpdateToRow(ref row, record); this.ExtraUpdateToRow(ref row, record); this.dataSet.ttblitem_history.Addttblitem_historyRow((pdsitem_historyDataSet.ttblitem_historyRow)row); this.SaveChanges(); return(this.dataSet.ttblitem_history.Rows.Count > 0 ? this.BuildFromRow(this.dataSet.ttblitem_history.Rows[0]) : null); }
public ItemHistory GetByRowId(string rowId, string fldList) { var row = this.GetRowByRowId(rowId, fldList); ItemHistory itemHistory = null; if (row != null) { itemHistory = this.BuildFromRow(row); } return(itemHistory); }
//Insert workout history Item to database public Task <int> SaveItemHistoryAsync(ItemHistory item) { if (item.ID != 0) // When inserting Item into database, keep the ID = 0 { return(database.UpdateAsync(item)); } else { return(database.InsertAsync(item)); } }
protected ItemHistory Fetch(string where, int batchsize, string fldList) { this.FetchWhere(where, batchsize, fldList); var row = this.dataSet.ttblitem_history.AsEnumerable().SingleOrDefault(); ItemHistory itemHistory = null; if (row != null) { itemHistory = this.BuildFromRow(row); } return(itemHistory); }
public void HistorizeChange(UpdatedItemDataMessage itemUpdateInfo) { var historyItem = new ItemHistory(); historyItem.DateOfChange = DateTime.Now; historyItem.ItemId = itemUpdateInfo.Old.Id; historyItem.Name = itemUpdateInfo.Old.Name; historyItem.Note = itemUpdateInfo.Old.Note; historyItem.PricePerUnit = itemUpdateInfo.Old.PricePerUnit; _ItemHistoryManager.Add(historyItem); }
public void Delete(ItemHistory record) { var row = this.GetRowByRowId(record.rowID, string.Empty); if (row == null) { row = this.dataSet.ttblitem_history.Newttblitem_historyRow(); ItemHistory.BuildMinimalRow(ref row, record); this.dataSet.ttblitem_history.Addttblitem_historyRow((pdsitem_historyDataSet.ttblitem_historyRow)row); } row.Delete(); this.SaveChanges(); }
public ItemHistory Update(ItemHistory record) { var row = this.GetRowByRowId(record.rowID, string.Empty); if (row != null) { this.UpdateToRow(ref row, record); this.ExtraUpdateToRow(ref row, record); this.SaveChanges(); return(this.dataSet.ttblitem_history.Rows.Count > 0 ? this.BuildFromRow(this.dataSet.ttblitem_history.Rows[0]) : null); } ErrorReportingHelper.ReportErrors("global.update.doesnotexist", 421); return(null); }
private void DisplayItem(ItemHistory h) { var id = _sheet.Cell(_rowIndex, 1); id.Value = h.Id; if (h.Type != ReceiptType.Nothing) { var receiptType = _sheet.Cell(_rowIndex, 2); receiptType.Value = h.Type.ToString(); } var inOut = _sheet.Cell(_rowIndex, 3); inOut.Value = h.InOrOut.ToString(); inOut.Style.Fill.BackgroundColor = GetColor(h); if (h.DR != null) { var sdr = _sheet.Cell(_rowIndex, 4); sdr.Value = h.DR.DRNumberToDisplay; } var beginning = _sheet.Cell(_rowIndex, 5); beginning.Value = h.AppopriateBeginningQty; var qty = _sheet.Cell(_rowIndex, 6); qty.Value = h.AppopriateQty; var endingQty = _sheet.Cell(_rowIndex, 7); endingQty.Value = h.AppopriateEndingQty; var date = _sheet.Cell(_rowIndex, 8); date.Style.DateFormat.Format = @"[$-409]m/d/yy (h:mm AM/PM);@"; date.Value = h.DateAdded; date.DataType = XLCellValues.DateTime; var note = _sheet.Cell(_rowIndex, 9); note.Value = h.Note; var createdBy = _sheet.Cell(_rowIndex, 10); createdBy.Value = h.CreatedBy; }
public void In(InOutParam inParam) { Item itemAfterIn = _itemService.Find(inParam.Item.Id); double oldQty = itemAfterIn.GetAppropriateQuantity; InOutHelper.AddToAppopriateMeasurement(itemAfterIn, inParam.Qty); double newQty = itemAfterIn.GetAppropriateQuantity; var p = CreateHistoryParameter(inParam, oldQty, newQty); ItemHistory h = InOutHelper.MakeHistory(p); _historyService.Add(h); _itemService.Edit(itemAfterIn); }
public void GetItemHistoryTest() { foreach (AppId.AppName appId in Enum.GetValues(typeof(AppId.AppName))) { int page = 1; List <ItemHistoryRecord> itemHistoryRecords = ItemHistory.GetItemHistory(appId, page, new List <string>(), ItemHistory.ResultsPerPage.R480); while (itemHistoryRecords.Count != 0) { page++; itemHistoryRecords = ItemHistory.GetItemHistory(appId, page, new List <string>(), ItemHistory.ResultsPerPage.R480); } } Assert.IsTrue(true); }
private void UpdateAdjustmentItemHistory(Adjustment adjustment) { var itemHistory = new ItemHistory { ItemId = adjustment.ItemId, Date = DateTime.Now, Quantity = adjustment.AdjustmentType == AdjustmentType.Add.ToString() ? adjustment.Quantity : adjustment.Quantity * -1, Remarks = adjustment.Remarks, Adjustment = adjustment }; context.Entry(itemHistory).State = EntityState.Added; }
public void Out(InOutParam outParam) { Item itemAfterOut = _itemService.Find(outParam.Item.Id); double oldQty = itemAfterOut.GetAppropriateQuantity; InOutHelper.SubtractToAppopriateMeasurement(itemAfterOut, outParam.Qty); double newQty = itemAfterOut.GetAppropriateQuantity; var p = CreateHistoryParameter(outParam, oldQty, newQty); ItemHistory h = InOutHelper.MakeHistory(p); _historyService.Add(h); _itemService.Edit(itemAfterOut); }
public void Delete(int id) { bool elementExistsInDatabase = ItemHistories.FirstOrDefault(t => t.Id == id) != default; if (!elementExistsInDatabase) { throw new DataMissingException($"Gegenstandshistorie mit Id {id} kann nicht gelöscht werden, da er nicht in der Datenbank existiert"); } ItemHistory historyToDelete = ItemHistories.First(t => t.Id == id); ItemHistories.Remove(historyToDelete); SaveChanges(); RaiseMessageIfEventBrokerIsAttached(new DeletedItemHistoryDataMessage(historyToDelete)); }
public void UpdateItemType(int itemid, int oldtypeid, int newtypeid) { if (oldtypeid != newtypeid) { ItemHistory _item = new ItemHistory(); _item.ItemId = itemid; _item.OldItemTypeId = oldtypeid; _item.NewItemTypeId = newtypeid; _item.CompanyId = Sessions.CompanyId.Value; _item.Date = DateTime.Now; context.ItemHistories.Add(_item); context.SaveChanges(); } }
public static int GetBugCount(ItemHistory itemHistory) { //TODO: making many api calls return(Convert.ToInt32(itemHistory.Count)); int bugCount = 0; try { Parallel.ForEach(itemHistory.Value, changeset => { { Changeset cs = GetChangesetWithLinks(changeset); var url = cs._Links.WorkItems.href; using (var httpClient = new HttpClient(new HttpClientHandler { UseDefaultCredentials = true })) { try { var result = httpClient.GetStringAsync(url).Result; var associatedWorkItems = JsonConvert.DeserializeObject <AssociatedWorkItems>(result); foreach (WorkItem workitem in associatedWorkItems.Value) { if (workitem.WorkItemtype == "Bug") { bugCount += 1; } } } catch (AggregateException) { } } } }); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(bugCount); }
private double GetBeginningQty(Item item) { double qty = 0; ItemHistory h = _histories.Where(d => d.Item_Id == item.Id) .OrderBy(d => d.DateAdded) .FirstOrDefault(); if (h != null) { qty = h.AppopriateBeginningQty; } else { qty = TryGettingQtyFromOtherPastHistories(item.Id); } return(qty); }
private double GetEndingQty(Item item) { double qty = 0; ItemHistory h = _histories.Where(d => d.Item_Id == item.Id) .OrderByDescending(d => d.DateAdded) .FirstOrDefault(); if (h != null) { qty = h.AppopriateEndingQty; } else { qty = TryGettingQtyFromLatestDays(item); } return(qty); }
//public methods public void Add(ItemHistory history) { if (history == null) { throw new ArgumentException(nameof(history)); } bool elementExistsInDatabase = ItemHistories.FirstOrDefault(t => t.Id == history.Id) != default; if (elementExistsInDatabase) { throw new DataDuplicationException($"Gegenstandshistorie kann nicht angelegt werden, da sie bereits existiert"); } ItemHistories.Add(history); SaveChanges(); RaiseMessageIfEventBrokerIsAttached(new AddedItemHistoryDataMessage(history)); }
private XLColor GetColor(ItemHistory h) { XLColor c = XLColor.White; if (h.InOrOut == InOrOut.In) { c = XLColor.LightGreen; } if (h.InOrOut == InOrOut.Out) { c = XLColor.LightCoral; } if (h.IsMistaken) { c = XLColor.Orange; } return(c); }
public void EmitItemHistory(UserAccount createdBy, Guid jobItemId, int workTime, int overTime, string report, ListItemType workStatus, ListItemType workType) { var jobItem = CurrentSession.Get <JobItem>(jobItemId); var status = CurrentSession.Query <ListItem>().Where(li => li.Type == workStatus).Single(); var workTypeItem = CurrentSession.Query <ListItem>().Where(li => li.Type == workType).Single(); var itemHistory = new ItemHistory { Id = Guid.NewGuid(), DateCreated = AppDateTime.GetUtcNow(), JobItem = jobItem, User = createdBy, WorkTime = workTime, OverTime = overTime, Report = report, Status = status, WorkType = workTypeItem }; CurrentSession.Save(itemHistory); }
private void Approval() { if (Program.MsgBox_Show("Are you sure want to approve this transaction ? ", "Confirmation", "YesNo")) { var oMutationhd = new MutationHd(); oMutationhd.InventoryTxnID = Convert.ToString(cboTxnType.SelectedValue); oMutationhd.TxnNo = txtTxnNo.Text.Trim(); if (oMutationhd.SelectOne().Rows.Count > 0) { if (oMutationhd.IsApproval) { Program.MsgBox_Show("Transaction no. is already approved, please refresh your screen."); } else { var oItemHistory = new ItemHistory(); oItemHistory.TxnNo = txtTxnNo.Text.Trim(); oItemHistory.UserInsert = _loginInfo.UserID.Trim(); if (Convert.ToString(cboTxnType.SelectedValue).Trim() == "111") { oItemHistory.DoApproval(TxnType.AdjustmentMinus); } else { oItemHistory.DoApproval(TxnType.AdjustmentPlus); } oItemHistory.Dispose(); oItemHistory = null; openTxnNo(); } } else { Program.MsgBox_Show("Transaction no. not found."); } oMutationhd.Dispose(); oMutationhd = null; } }
private void FormatAddress(ItemHistory item) { var address = new JavaScriptSerializer().Deserialize<GlobalAddress>(item.Val); var sb = new StringBuilder(); if (!string.IsNullOrEmpty(address.Premise)) { sb.AppendFormat("{0} ", address.Premise); } if (!string.IsNullOrEmpty(address.SubBuilding)) { sb.AppendFormat("{0} ", address.SubBuilding); } if (!string.IsNullOrEmpty(address.Building)) { sb.AppendFormat("{0} ", address.Building); } if (!string.IsNullOrEmpty(address.Street)) { sb.AppendFormat("{0} ", address.Street); } if (!string.IsNullOrEmpty(address.City)) { sb.AppendFormat("{0} ", address.City); } if (!string.IsNullOrEmpty(address.ZipPostcode)) { sb.AppendFormat("{0} ", address.ZipPostcode); } item.Val = sb.ToString(); }
protected void Save_Next_Button_Click(object sender, EventArgs e) { try { if(currentItem == null) { currentItem = db.Items.SingleOrDefault(p=> p.isUntradeable == false && p.Name.Equals(ItemNameLabel.Text)); } ItemHistory ih = new ItemHistory(); ih.User_FK = currentUser.UserID; ih.nqPrice = Convert.ToInt32(NQ_Price_TextBox.Text.Trim()); if ((bool)currentItem.canHQ) { ih.hqPrice = Convert.ToInt32(HQ_Price_TextBox.Text.Trim()); } ih.recordDate = DateTime.UtcNow; currentItem.ItemHistories.Add(ih); db.SubmitChanges(); this.Skip_Next_Button_Click(null, null); } catch { } }