public IHttpActionResult EditRestoration(int restorationPK, string userID, string comment, List <Client_RestoredItemPK_RestoredQuantity> list) { if (new ValidationBeforeCommandDAO().IsValidUser(userID, "Receiver")) { IssuingDAO issuingDAO = new IssuingDAO(); Restoration restoration = null; try { restoration = db.Restorations.Find(restorationPK); if (restoration == null) { return(Content(HttpStatusCode.Conflict, "MÃ PHIẾU TRẢ HÀNG KHÔNG HỢP LỆ!")); } if (restoration.IsReceived) { return(Content(HttpStatusCode.Conflict, "PHIẾU TRẢ ĐÃ ĐƯỢC NHẬN, KHÔNG THỂ THAY ĐỔI!")); } if (restoration.UserID != userID) { return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY!")); } issuingDAO.UpdateRestoration(restorationPK, comment); issuingDAO.UpdateRestoredItems(list); } catch (Exception e) { return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage())); } return(Content(HttpStatusCode.OK, "CHỈNH SỬA HÀNG TRẢ THÀNH CÔNG!")); } else { return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY!")); } }
public IHttpActionResult ReceiveRestoredItem(int restorationPK, List <Client_Box_List> list, string userID) { if (new ValidationBeforeCommandDAO().IsValidUser(userID, "Receiver")) { IssuingDAO issuingDAO = new IssuingDAO(); ReceivingSession receivingSession; Restoration restoration = null; try { restoration = db.Restorations.Find(restorationPK); if (restoration == null) { return(Content(HttpStatusCode.Conflict, "MÃ PHIẾU TRẢ HÀNG KHÔNG HỢP LỆ!")); } if (restoration.IsReceived) { return(Content(HttpStatusCode.Conflict, "PHIẾU TRẢ ĐÃ ĐƯỢC NHẬN, KHÔNG THỂ THAY ĐỔI!")); } receivingSession = issuingDAO.CreateReceivingSession(restorationPK, userID); issuingDAO.UpdateRestoration(restorationPK, true); issuingDAO.CreateEntryReceiving(list, receivingSession); } catch (Exception e) { return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage())); } return(Content(HttpStatusCode.OK, "NHẬN HÀNG ĐƯỢC TRẢ THÀNH CÔNG!")); } else { return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY!")); } }
public IHttpActionResult RestoreItems(string userID, string comment, List <Client_AccessoryPK_RestoredQuantity> list) { if (new ValidationBeforeCommandDAO().IsValidUser(userID, "Receiver")) { IssuingDAO issuingDAO = new IssuingDAO(); Restoration restoration = null; try { restoration = issuingDAO.CreateRestoration(userID, comment); issuingDAO.CreateRestoredItems(restoration, list); } catch (Exception e) { if (restoration != null) { issuingDAO.DeleteRestoration(restoration.RestorationPK); } return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage())); } return(Content(HttpStatusCode.OK, "TRẢ HÀNG THÀNH CÔNG!")); } else { return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY!")); } }
public bool setRestoration(DataSetMuseum dataSet) { bool result = false; Connection connection = new Connection(); connection.Open(); try { Transaction transaction = connection.BeginTransaction(); try { restoration = new Restoration(); restoration.Save(dataSet, connection, transaction); transaction.Commit(); result = true; } catch (Exception ex) { ShowError(ex.ToString()); transaction.Rollback(); result = false; } } finally { connection.Close(); } return(result); }
public DataSetMuseum getRestoration() { DataSetMuseum result = new DataSetMuseum(); Connection connection = new Connection(); connection.Open(); try { Transaction transaction = connection.BeginTransaction(); try { restoration = new Restoration(); restoration.Read(result, connection, transaction); transaction.Commit(); } catch (Exception ex) { ShowError(ex.ToString()); transaction.Rollback(); result = null; } } finally { connection.Close(); } return(result); }
public OdontogramEntryPresenter(IDataRepository dataRepository, IOdontogramEntryPage page) { this.page = page; this.dataRepository = dataRepository; odontogramImagesCache = new Dictionary <string, Image>(); page.AddCavityClicked += (s, e) => { editMode = OdontogramEditMode.AddCavity; page.SetEditMode(editMode); }; page.AddRestorationClicked += (s, e) => { editMode = OdontogramEditMode.AddRestoration; page.SetEditMode(editMode); }; page.EraserClicked += (s, e) => { editMode = OdontogramEditMode.Eraser; page.SetEditMode(editMode); }; page.CanvasMouseUp += (s, e) => { var id = 0; switch (editMode) { case OdontogramEditMode.None: break; case OdontogramEditMode.AddCavity: id = dataRepository.Odontograms.GetNextIssueId(); var cavity = new Cavity(id, e); odontogramEntry.DentalIssues.Add(cavity); page.AddShapeToCanvas(cavity.Shape); dataRepository.Odontograms.AddOdontogramEntryIssue(odontogramEntry.Id, cavity); break; case OdontogramEditMode.AddRestoration: id = dataRepository.Odontograms.GetNextIssueId(); var restoration = new Restoration(id, e); odontogramEntry.DentalIssues.Add(restoration); page.AddShapeToCanvas(restoration.Shape); dataRepository.Odontograms.AddOdontogramEntryIssue(odontogramEntry.Id, restoration); break; case OdontogramEditMode.Eraser: break; default: break; } }; editMode = OdontogramEditMode.AddCavity; page.SetEditMode(editMode); }
public Restoration CreateRestoration(string userID, string comment) { try { // Add restoration DateTime now = DateTime.Now; // Generate Restoration //string restorationID = KhoiNKTType(now.Second) + KhoiNKTType(now.Minute) + KhoiNKTType(now.Hour) + KhoiNKTType(now.Day) + KhoiNKTType(now.Month) + now.Year; Restoration temp = db.Restorations.OrderByDescending(unit => unit.RestorationPK).FirstOrDefault(); string restorationID; if (temp != null) { string tempStr; Int32 tempInt; tempStr = temp.RestorationID.Substring(temp.RestorationID.Length - 5); tempInt = Int32.Parse(tempStr) + 1; tempStr = tempInt + ""; if (tempStr.Length == 1) { tempStr = "0000" + tempStr; } if (tempStr.Length == 2) { tempStr = "000" + tempStr; } if (tempStr.Length == 3) { tempStr = "00" + tempStr; } if (tempStr.Length == 4) { tempStr = "0" + tempStr; } restorationID = "AST-PT" + tempStr; } else { restorationID = "AST-PT-00001"; } Restoration restoration = new Restoration(restorationID, userID, comment); db.Restorations.Add(restoration); db.SaveChanges(); // restoration = (from res in db.Restorations.OrderByDescending(unit => unit.RestorationPK) select res).FirstOrDefault(); return(restoration); } catch (Exception e) { throw e; } }
public static TreatmentReturn getAvailibleTreatment(string type) { Console.WriteLine("Type " + type); Restoration restoration = new Restoration(); string[] treatmentItems = restoration.getTreatmentItems(type); TreatmentReturn returnVal = new TreatmentReturn(); if (treatmentItems == null) { returnVal.available = false; return(returnVal); } string sql = "SELECT * FROM `inventory` WHERE name IN ("; foreach (string item in treatmentItems) { if (treatmentItems[0] != item) { sql += ','; } sql += "'" + item + "'"; } ; sql += ')'; Inventory[] availableItems = inventorySqlRunner(sql); foreach (string item in treatmentItems) { bool contained = false; foreach (Inventory invItem in availableItems) { if (invItem.ItemName.Equals(item)) { contained = true; } } if (!contained) { // Code to copy the old array of needed items and add another item -> should become a list string[] newItems = new string[returnVal.items.Length + 1]; Array.Copy(returnVal.items, newItems, returnVal.items.Length); newItems[returnVal.items.Length] = item; returnVal.items = newItems; } } if (returnVal.available) { returnVal.items = treatmentItems; } return(returnVal); }
public static RPGAction AddRestorationEffect(BaseCharacterMono target, Restoration restoration) { var parameters = new Dictionary <string, object>() { { "Target", target }, { "Restoration", restoration } }; return(new RPGAction(RPGActionType.AddEffect, parameters)); }
private static async Task UseManaRestorationItem(TkClient itemUser, Restoration manaRestorationItem, int minimumRestoration = 1) { var requiredUsages = (int)Math.Ceiling((float)minimumRestoration / manaRestorationItem.RestoreAmount); itemUser.IncrementManaRestorationItemUsageCount(requiredUsages); if (!await UseItem(itemUser, manaRestorationItem, requiredUsages)) { Log.Error($"{itemUser.Self.Name} does not have any mana restoration items."); } }
public void Restore(Restoration restoration) { if (restoration.type == Resource.HEALTH) { currentHealth += restoration.amount; if (currentHealth > stats.GetStat(StatType.MAXHEALTH)) { currentHealth = stats.GetStat(StatType.MAXHEALTH); } } events.LaunchOnHealthChange(); }
// ReSharper disable once UnusedMember.Local private static async Task RestoreManaIfEligible(TkClient itemUser, Restoration manaRestorationItem) { await itemUser.Activity.WaitForCommandCooldown(); var currentManaDeficit = itemUser.Self.Mana.Deficit; if (currentManaDeficit > manaRestorationItem.RestoreAmount) { var usages = (int)(currentManaDeficit / manaRestorationItem.RestoreAmount); await UseManaRestorationItem(itemUser, manaRestorationItem, usages); } }
// ReSharper disable once UnusedMember.Local private static async Task <bool> RestoreManaIfEligible(TkClient itemUser, Restoration manaRestorationItem) { await itemUser.Activity.WaitForCommandCooldown(); var currentManaDeficit = itemUser.Self.Mana.Deficit; if (currentManaDeficit > manaRestorationItem.RestoreAmount) { return(await UseManaRestorationItem(itemUser, manaRestorationItem)); } return(false); }
public void DeleteRestoration(int restorationPK) { try { // Remove restoration Restoration restoration = db.Restorations.Find(restorationPK); db.Restorations.Remove(restoration); db.SaveChanges(); } catch (Exception e) { throw e; } }
public void UpdateRestoration(int restorationPK, bool isReceived) { try { // update restoration Restoration restoration = db.Restorations.Find(restorationPK); restoration.IsReceived = isReceived; db.Entry(restoration).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { throw e; } }
public void UpdateRestoration(int restorationPK, string comment) { try { // update restoration Restoration restoration = db.Restorations.Find(restorationPK); restoration.DateCreated = DateTime.Now; restoration.Comment = comment; db.Entry(restoration).State = EntityState.Modified; db.SaveChanges(); } catch (Exception e) { throw e; } }
public void CreateRestoredItems(Restoration restoration, List <IssuingController.Client_AccessoryPK_RestoredQuantity> list) { try { // Add restoredItems foreach (var item in list) { RestoredItem restoredItem = new RestoredItem(item.AssessoryPK, item.RestoredQuantity, restoration.RestorationPK); db.RestoredItems.Add(restoredItem); } db.SaveChanges(); } catch (Exception e) { throw e; } }
private static async Task <bool> UseManaRestorationItem(TkClient itemUser, Restoration manaRestorationItem, int minimumRestoration = 1) { if (manaRestorationItem == null) { Log.Error($"{itemUser.Self.Name} attempted to use a null item reference to restore mana!"); return(false); } var requiredUsages = (int)Math.Ceiling((float)minimumRestoration / manaRestorationItem.RestoreAmount); if (requiredUsages > MaxNumberOfItemUsages) { if (!_hasWarnedOfExcessiveUsage) { Log.Warning($"{itemUser.Self.Name} is about to try to cast a spell with insufficient mana. Normally, I would rapidly use as much {manaRestorationItem.Name} as needed to provide enough mana, but in this case, that would require {requiredUsages} uses, and I have to draw the line somewhere. Automated mana restoration will not be attempted for spells that would require more than {MaxNumberOfItemUsages} uses."); } _hasWarnedOfExcessiveUsage = true; return(false); } itemUser.IncrementManaRestorationItemUsageCount(requiredUsages); if (await UseItem(itemUser, manaRestorationItem, requiredUsages)) { return(true); } if (!_hasWarnedOfDepletedItems) { Log.Error($"{itemUser.Self.Name} does not have any mana restoration items left."); } _hasWarnedOfDepletedItems = true; return(false); }
public Task <Restoration> AddRestoration(Restoration restoration) { return(_restorationsRepository.AddItemAsync(restoration)); }
public Effect BuildProc(EffectType type, string str) { Effect effect; switch (type) { case EffectType.PSpeed: effect = new PSpeed(); break; case EffectType.PPhysicalDefense: effect = new PPhysicalDefence(); break; case EffectType.IRestoration: effect = new Restoration(); break; case EffectType.IFatalBlow: effect = new FatalBlow(); break; case EffectType.IDeath: effect = new Death(); break; case EffectType.PBlockSkillPhysical: effect = new PBlockSkillPhysical(); break; case EffectType.PBlockSkillSpecial: effect = new PBlockSkillSpecial(); break; case EffectType.PBlockSpell: effect = new PBlockSpell(); break; case EffectType.ITargetCancel: effect = new TargetCancel(); break; case EffectType.PDefenceAttribute: effect = new PDefenceAttribute(); break; case EffectType.IPAttack: effect = new IpAttack(); break; case EffectType.IRemoveSoul: effect = new RemoveSoul(); break; case EffectType.IAgathionEnergy: effect = new AgathionEnergy(); break; case EffectType.ISummonCubic: effect = new SummonCubic(); break; case EffectType.CubHeal: effect = new CubHeal(); break; default: return(null); } effect.Build(str); return(effect); }
public List <Client_Box_Shelf_Row> StoredBox_ItemPK_IsRestoredOfEntries(Accessory accessory) { List <Client_Box_Shelf_Row> result = new List <Client_Box_Shelf_Row>(); StoringDAO storingDAO = new StoringDAO(); try { // cực phẩm IQ double inStoredQuantity = InStoredQuantity(accessory.AccessoryPK); if (inStoredQuantity == 0) { throw new Exception("HÀNG TRONG KHO ĐÃ HẾT!"); } List <Entry> entries = (from e in db.Entries where e.AccessoryPK == accessory.AccessoryPK select e).ToList(); Dictionary <StoredBox_ItemPK_IsRestored, InBoxQuantity_AvailableQuantity> tempDictionary = new Dictionary <StoredBox_ItemPK_IsRestored, InBoxQuantity_AvailableQuantity>(); foreach (var entry in entries) { double inBoxQuantity = 0; StoredBox storedBox = db.StoredBoxes.Find(entry.StoredBoxPK); if (entry.KindRoleName == "AdjustingMinus" || entry.KindRoleName == "AdjustingPlus") { AdjustingSession adjustingSession = db.AdjustingSessions.Find(entry.SessionPK); Verification verification = db.Verifications.Where(unit => unit.SessionPK == adjustingSession.AdjustingSessionPK && unit.IsDiscard == false).FirstOrDefault(); if (verification != null && verification.IsApproved) { inBoxQuantity = storingDAO.EntryQuantity(entry); } } else if (entry.KindRoleName == "Discarding") { DiscardingSession discardingSession = db.DiscardingSessions.Find(entry.SessionPK); Verification verification = db.Verifications.Where(unit => unit.SessionPK == discardingSession.DiscardingSessionPK && unit.IsDiscard == true).FirstOrDefault(); if (verification != null && verification.IsApproved) { inBoxQuantity = storingDAO.EntryQuantity(entry); } } else { inBoxQuantity = storingDAO.EntryQuantity(entry); } Box box = db.Boxes.Find(storedBox.BoxPK); PassedItem passedItem; RestoredItem restoredItem; StoredBox_ItemPK_IsRestored key; if (entry.IsRestored) { restoredItem = db.RestoredItems.Find(entry.ItemPK); key = new StoredBox_ItemPK_IsRestored(storedBox.StoredBoxPK, restoredItem.RestoredItemPK, entry.IsRestored); } else { passedItem = db.PassedItems.Find(entry.ItemPK); key = new StoredBox_ItemPK_IsRestored(storedBox.StoredBoxPK, passedItem.PassedItemPK, entry.IsRestored); } if (box.IsActive) { InBoxQuantity_AvailableQuantity tmp = new InBoxQuantity_AvailableQuantity(inBoxQuantity, storingDAO.EntryQuantity(entry)); if (!tempDictionary.ContainsKey(key)) { tempDictionary.Add(key, tmp); } else { tempDictionary[key].InBoxQuantity += tmp.InBoxQuantity; tempDictionary[key].AvailableQuantity += tmp.AvailableQuantity; } } } foreach (var item in tempDictionary) { if (item.Value.AvailableQuantity > 0) { StoredBox storedBox = db.StoredBoxes.Find(item.Key.StoredBoxPK); Box box = db.Boxes.Find(storedBox.BoxPK); Shelf shelf = db.Shelves.Find(storedBox.ShelfPK); Row row = db.Rows.Find(shelf.RowPK); if (item.Key.IsRestored) { RestoredItem restoredItem = db.RestoredItems.Find(item.Key.ItemPK); Restoration restoration = db.Restorations.Find(restoredItem.RestorationPK); result.Add(new Client_Box_Shelf_Row(box.BoxID, storedBox.StoredBoxPK, shelf.ShelfID, row.RowID, item.Key.ItemPK, item.Key.IsRestored, item.Value.InBoxQuantity, restoration.RestorationID, item.Value.AvailableQuantity)); } else { PassedItem passedItem = db.PassedItems.Find(item.Key.ItemPK); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); result.Add(new Client_Box_Shelf_Row(box.BoxID, storedBox.StoredBoxPK, shelf.ShelfID, row.RowID, item.Key.ItemPK, item.Key.IsRestored, item.Value.InBoxQuantity, pack.PackID, item.Value.AvailableQuantity)); } } } } catch (Exception e) { throw e; } return(result); }
// ReSharper disable once UnusedMember.Local private static async Task RestoreManaIfBelowPercent(TkClient itemUser, double minimumManaPercent, Restoration manaRestorationItem) { await itemUser.Activity.WaitForCommandCooldown(); var currentManaPercent = itemUser.Self.Mana.Percent; if (currentManaPercent < minimumManaPercent) { await UseManaRestorationItem(itemUser, manaRestorationItem); } }
public List <Client_Session_Activity_Angular> GetSessions(int sessionNum) { List <Client_Session_Activity_Angular> result = new List <Client_Session_Activity_Angular>(); switch (sessionNum) { case 1: List <IdentifyingSession> identifyingSessions = (from ss in db.IdentifyingSessions select ss).ToList(); foreach (var ss in identifyingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); // query pack IdentifiedItem identifiedItem = (from iI in db.IdentifiedItems where iI.IdentifyingSessionPK == ss.IdentifyingSessionPK select iI).FirstOrDefault(); PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Ghi nhận " + "cụm phụ liệu thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 2: List <CountingSession> countingSessions = (from ss in db.CountingSessions select ss).ToList(); foreach (var ss in countingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); // query pack IdentifiedItem identifiedItem = db.IdentifiedItems.Find(ss.IdentifiedItemPK); PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Kiểm số lượng " + "cụm phụ liệu thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 3: List <CheckingSession> checkingSessions = (from ss in db.CheckingSessions select ss).ToList(); foreach (var ss in checkingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); IdentifiedItem identifiedItem = db.IdentifiedItems.Find(ss.IdentifiedItemPK); PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Kiểm chất lượng " + "cụm phụ liệu thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 4: List <ClassifyingSession> classifyingSessions = (from ss in db.ClassifyingSessions select ss).ToList(); foreach (var ss in classifyingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(ss.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Đánh giá " + "phụ liệu thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 5: List <ArrangingSession> arrangingSessions = (from ss in db.ArrangingSessions select ss).ToList(); foreach (var ss in arrangingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); UnstoredBox uBox1 = db.UnstoredBoxes.Find(ss.StartBoxPK); Box box1 = db.Boxes.Find(uBox1.BoxPK); UnstoredBox uBox2 = db.UnstoredBoxes.Find(ss.DestinationBoxPK); Box box2 = db.Boxes.Find(uBox2.BoxPK); string content = "Sắp xếp " + "cụm phụ liệu từ thùng mã số " + box1.BoxID.Substring(0, box1.BoxID.Length - 3) + "sang thùng mã số " + box2.BoxID.Substring(0, box2.BoxID.Length - 3); result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 6: List <ReturningSession> returningSessions = (from ss in db.ReturningSessions select ss).ToList(); foreach (var ss in returningSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); FailedItem failedItem = db.FailedItems.Find(ss.FailedItemPK); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(failedItem.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); Pack pack = db.Packs.Find(packedItem.PackPK); string content = "Trả hàng lỗi " + "thuộc Phiếu nhập mã số " + pack.PackID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 7: List <StoringSession> storingSessions = (from ss in db.StoringSessions select ss).ToList(); foreach (var ss in storingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); Box box = db.Boxes.Find(ss.BoxPK); string content = "Lưu kho " + "thùng mã số " + box.BoxID.Substring(0, box.BoxID.Length - 3); result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 8: List <MovingSession> movingSessions = (from ss in db.MovingSessions select ss).ToList(); foreach (var ss in movingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); StoredBox sBox = db.StoredBoxes.Find(ss.StoredBoxPK); Box box = db.Boxes.Find(sBox.BoxPK); Shelf shelf1 = db.Shelves.Find(ss.StartShelfPK); Shelf shelf2 = db.Shelves.Find(ss.DestinationShelfPK); string content = "Di chuyển thùng " + "mã số " + box.BoxID.Substring(0, box.BoxID.Length - 3) + "từ kệ " + shelf1.ShelfID + "sang kệ " + shelf2.ShelfID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 9: List <TransferringSession> tranferringSessions = (from ss in db.TransferringSessions select ss).ToList(); foreach (var ss in tranferringSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); StoredBox sBox1 = db.StoredBoxes.Find(ss.StartBoxPK); Box box1 = db.Boxes.Find(sBox1.BoxPK); StoredBox sBox2 = db.StoredBoxes.Find(ss.StartBoxPK); Box box2 = db.Boxes.Find(sBox2.BoxPK); string content = "Chuyển phụ liệu " + "tồn kho từ thùng mã số " + box1.BoxID.Substring(0, box1.BoxID.Length - 3) + "sang thùng mã số " + box2.BoxID.Substring(0, box2.BoxID.Length - 3); result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 10: List <IssuingSession> issuingSessions = (from ss in db.IssuingSessions select ss).ToList(); foreach (var ss in issuingSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); Request request = db.Requests.Find(ss.RequestPK); string content = "Xuất kho " + "phụ liệu cho Yêu cầu nhận mã số " + request.RequestID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; case 11: List <ReceivingSession> restoringSessions = (from ss in db.ReceivingSessions select ss).ToList(); foreach (var ss in restoringSessions) { SystemUser systemUser = db.SystemUsers.Find(ss.UserID); Restoration restoration = db.Restorations.Find(ss.RestorationPK); string content = "Nhận tồn " + "phụ liệu thuộc Phiếu trả mã số " + restoration.RestorationID; result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content)); } break; default: break; } return(result); }
public IHttpActionResult GetInBoxItemByBoxID(string boxID) { Client_InBoxItems_Shelf <Client_Shelf> result; Client_Shelf client_Shelf; List <Client_InBoxItem> client_InBoxItems = new List <Client_InBoxItem>(); BoxDAO boxDAO = new BoxDAO(); StoringDAO storingDAO = new StoringDAO(); try { // Get client Shelf Box box = boxDAO.GetBoxByBoxID(boxID); StoredBox sBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK); if (sBox == null) { return(Content(HttpStatusCode.Conflict, "BOX KHÔNG HỢP LỆ!")); } Shelf shelf = db.Shelves.Find(sBox.ShelfPK); Row row = db.Rows.Find(shelf.RowPK); client_Shelf = new Client_Shelf(shelf.ShelfID, row.RowID); // Get list inBoxItem List <Entry> entries = (from e in db.Entries where e.StoredBoxPK == sBox.StoredBoxPK select e).ToList(); // Hiện thực cặp value ko được trùng 2 key là itemPK và isRestored HashSet <KeyValuePair <int, bool> > listItemPK = new HashSet <KeyValuePair <int, bool> >(); foreach (var entry in entries) { listItemPK.Add(new KeyValuePair <int, bool>(entry.ItemPK, entry.IsRestored)); } foreach (var itemPK in listItemPK) { List <Entry> tempEntries = new List <Entry>(); foreach (var entry in entries) { if (entry.ItemPK == itemPK.Key && entry.IsRestored == itemPK.Value) { tempEntries.Add(entry); } } if (tempEntries.Count > 0) { Entry entry = tempEntries[0]; PassedItem passedItem; RestoredItem restoredItem; if (entry.IsRestored) { restoredItem = db.RestoredItems.Find(entry.ItemPK); Restoration restoration = db.Restorations.Find(restoredItem.RestorationPK); Accessory accessory = db.Accessories.Find(restoredItem.AccessoryPK); client_InBoxItems.Add(new Client_InBoxItem(accessory, restoration.RestorationID, storingDAO.EntriesQuantity(tempEntries), restoredItem.RestoredItemPK, true)); } else { passedItem = db.PassedItems.Find(entry.ItemPK); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); // lấy pack ID Pack pack = (from p in db.Packs where p.PackPK == packedItem.PackPK select p).FirstOrDefault(); // lấy phụ liệu tương ứng OrderedItem orderedItem = (from oI in db.OrderedItems where oI.OrderedItemPK == packedItem.OrderedItemPK select oI).FirstOrDefault(); Accessory accessory = (from a in db.Accessories where a.AccessoryPK == orderedItem.AccessoryPK select a).FirstOrDefault(); client_InBoxItems.Add(new Client_InBoxItem(accessory, pack.PackID, storingDAO.EntriesQuantity(tempEntries), passedItem.PassedItemPK, false)); } } } result = new Client_InBoxItems_Shelf <Client_Shelf>(client_Shelf, client_InBoxItems); } catch (Exception e) { return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage())); } return(Content(HttpStatusCode.OK, result)); }
public IHttpActionResult GetItemByBoxID(string boxID) { BoxDAO boxDAO = new BoxDAO(); StoringDAO storingDAO = new StoringDAO(); try { Box box = boxDAO.GetBoxByBoxID(boxID); if (box != null) { StoredBox sBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK); UnstoredBox uBox = boxDAO.GetUnstoredBoxbyBoxPK(box.BoxPK); // Nếu box chưa identify if (uBox.IsIdentified) { // nếu box chưa được store if (!(boxDAO.IsStored(box.BoxPK))) { List <Client_IdentifiedItemRead> client_IdentifiedItems = new List <Client_IdentifiedItemRead>(); List <IdentifiedItem> identifiedItems; identifiedItems = (from iI in db.IdentifiedItems.OrderByDescending(unit => unit.PackedItemPK) where iI.UnstoredBoxPK == uBox.UnstoredBoxPK select iI).ToList(); foreach (var identifiedItem in identifiedItems) { PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK); // lấy pack ID Pack pack = db.Packs.Find(packedItem.PackPK); // lấy phụ liệu tương ứng OrderedItem orderedItem = db.OrderedItems.Find(packedItem.OrderedItemPK); Accessory accessory = db.Accessories.Find(orderedItem.AccessoryPK); // lấy qualityState ClassifiedItem classifiedItem = (from cI in db.ClassifiedItems where cI.PackedItemPK == packedItem.PackedItemPK select cI).FirstOrDefault(); int?qualityState = null; if (classifiedItem != null) { qualityState = classifiedItem.QualityState; } client_IdentifiedItems.Add(new Client_IdentifiedItemRead(identifiedItem, accessory, pack.PackID, qualityState)); } return(Content(HttpStatusCode.OK, client_IdentifiedItems)); } else { Client_InBoxItems_Shelf <Client_Shelf> result; Client_Shelf client_Shelf; List <Client_InBoxItem> client_InBoxItems = new List <Client_InBoxItem>(); Shelf shelf = db.Shelves.Find(sBox.ShelfPK); Row row = db.Rows.Find(shelf.RowPK); client_Shelf = new Client_Shelf(shelf.ShelfID, row.RowID); // Get list inBoxItem List <Entry> entries = (from e in db.Entries where e.StoredBoxPK == sBox.StoredBoxPK select e).ToList(); HashSet <KeyValuePair <int, bool> > listItemPK = new HashSet <KeyValuePair <int, bool> >(); foreach (var entry in entries) { listItemPK.Add(new KeyValuePair <int, bool>(entry.ItemPK, entry.IsRestored)); } foreach (var itemPK in listItemPK) { List <Entry> tempEntries = new List <Entry>(); foreach (var entry in entries) { if (entry.ItemPK == itemPK.Key && entry.IsRestored == itemPK.Value) { tempEntries.Add(entry); } } if (tempEntries.Count > 0 && storingDAO.EntriesQuantity(tempEntries) > 0) { Entry entry = tempEntries[0]; PassedItem passedItem; RestoredItem restoredItem; if (entry.IsRestored) { restoredItem = db.RestoredItems.Find(entry.ItemPK); Restoration restoration = db.Restorations.Find(restoredItem.RestorationPK); Accessory accessory = db.Accessories.Find(restoredItem.AccessoryPK); client_InBoxItems.Add(new Client_InBoxItem(accessory, restoration.RestorationID, storingDAO.EntriesQuantity(tempEntries), restoredItem.RestoredItemPK, true)); } else { passedItem = db.PassedItems.Find(entry.ItemPK); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); // lấy pack ID Pack pack = (from p in db.Packs where p.PackPK == packedItem.PackPK select p).FirstOrDefault(); // lấy phụ liệu tương ứng OrderedItem orderedItem = (from oI in db.OrderedItems where oI.OrderedItemPK == packedItem.OrderedItemPK select oI).FirstOrDefault(); Accessory accessory = (from a in db.Accessories where a.AccessoryPK == orderedItem.AccessoryPK select a).FirstOrDefault(); client_InBoxItems.Add(new Client_InBoxItem(accessory, pack.PackID, storingDAO.EntriesQuantity(tempEntries), passedItem.PassedItemPK, false)); } } } result = new Client_InBoxItems_Shelf <Client_Shelf>(client_Shelf, client_InBoxItems); return(Content(HttpStatusCode.OK, result)); } } else { return(Content(HttpStatusCode.Conflict, "THÙNG NÀY CHƯA ĐƯỢC GHI NHẬN")); } } else { return(Content(HttpStatusCode.Conflict, "ĐỐI TƯỢNG KHÔNG TỒN TẠI")); } } catch (Exception e) { return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage())); } }
public Task <Restoration> UpdateRestoration(Restoration restoration) { return(_restorationsRepository.UpdateItemAsync(restoration)); }
public IHttpActionResult GetItemByRowID(string rowID) { BoxDAO boxDAO = new BoxDAO(); StoringDAO storingDAO = new StoringDAO(); try { Client_InBoxItems_Shelf <List <string> > result; List <string> shelfIDs = new List <string>(); List <Shelf> shelves; Row row = (from r in db.Rows where r.RowID == rowID select r).FirstOrDefault(); if (row != null || rowID == "TẠM THỜI") { if (rowID == "TẠM THỜI") { shelves = (from sh in db.Shelves where sh.RowPK == null && sh.ShelfID != "InvisibleShelf" select sh).ToList(); } else { shelves = (from sh in db.Shelves where sh.RowPK == row.RowPK && sh.ShelfID != "InvisibleShelf" select sh).ToList(); } Dictionary <KeyValuePair <int, bool>, Client_InBoxItem> client_InBoxItems = new Dictionary <KeyValuePair <int, bool>, Client_InBoxItem>(); foreach (var shelf in shelves) { List <StoredBox> sBoxes = (from sB in db.StoredBoxes where sB.ShelfPK == shelf.ShelfPK select sB).ToList(); shelfIDs.Add(shelf.ShelfID); foreach (var sBox in sBoxes) { // Get list inBoxItem List <Entry> entries = (from e in db.Entries where e.StoredBoxPK == sBox.StoredBoxPK select e).ToList(); // Hiện thực cặp value ko được trùng 2 key là itemPK và isRestored HashSet <KeyValuePair <int, bool> > listItem = new HashSet <KeyValuePair <int, bool> >(); foreach (var entry in entries) { listItem.Add(new KeyValuePair <int, bool>(entry.ItemPK, entry.IsRestored)); } foreach (var item in listItem) { List <Entry> tempEntries = new List <Entry>(); foreach (var entry in entries) { if (entry.ItemPK == item.Key && entry.IsRestored == item.Value) { tempEntries.Add(entry); } } if (tempEntries.Count > 0 && storingDAO.EntriesQuantity(tempEntries) > 0) { Entry entry = tempEntries[0]; PassedItem passedItem; RestoredItem restoredItem; if (item.Value) { restoredItem = db.RestoredItems.Find(item.Key); Restoration restoration = db.Restorations.Find(restoredItem.RestorationPK); Accessory accessory = db.Accessories.Find(restoredItem.AccessoryPK); if (!client_InBoxItems.ContainsKey(item)) { client_InBoxItems.Add(item, new Client_InBoxItem(accessory, restoration.RestorationID, storingDAO.EntriesQuantity(tempEntries), restoredItem.RestoredItemPK, item.Value)); } else { client_InBoxItems[item].InBoxQuantity += storingDAO.EntriesQuantity(tempEntries); } } else { passedItem = db.PassedItems.Find(item.Key); ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK); PackedItem packedItem = db.PackedItems.Find(classifiedItem.PackedItemPK); // lấy pack ID Pack pack = db.Packs.Find(packedItem.PackPK); // lấy phụ liệu tương ứng OrderedItem orderedItem = db.OrderedItems.Find(packedItem.OrderedItemPK); Accessory accessory = db.Accessories.Find(orderedItem.AccessoryPK); if (!client_InBoxItems.ContainsKey(item)) { client_InBoxItems.Add(item, new Client_InBoxItem(accessory, pack.PackID, storingDAO.EntriesQuantity(tempEntries), passedItem.PassedItemPK, item.Value)); } else { client_InBoxItems[item].InBoxQuantity += storingDAO.EntriesQuantity(tempEntries); } } } } } } result = new Client_InBoxItems_Shelf <List <string> >(shelfIDs, client_InBoxItems.Values.ToList()); return(Content(HttpStatusCode.OK, result)); } else { return(Content(HttpStatusCode.Conflict, "ĐỐI TƯỢNG KHÔNG TỒN TẠI")); } } catch (Exception e) { return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage())); } }
private static async Task RestoreManaForSpell(TkClient itemUser, KeySpell spell, Restoration manaRestorationItem) { await itemUser.Activity.WaitForCommandCooldown(); var currentMana = (int)itemUser.Self.Mana.Current; if (currentMana < spell.Cost) { await UseManaRestorationItem(itemUser, manaRestorationItem, spell.Cost - currentMana); } }
public void RunEffects() { GameObject effects = GameObject.Find("Effects"); GameObject Map = GameObject.Find("Map"); TileMap map = Map.GetComponent <TileMap> (); map.selecterPlayer = this.name; if (Restoration) { // map.selectedEnemy = this.name; // Restoration restoration = effects.GetComponent <Restoration> (); restoration.RunRestoration(); } if (Burned) { // map.selectedEnemy = this.name; // Burn burn = effects.GetComponent <Burn> (); burn.RunBurn(); } if (Slowed) { // map.selectedEnemy = this.name; // GameObject Slow = GameObject.Find ("_Scripts"); Slow slow = effects.GetComponent <Slow> (); slow.RunSlow(); } if (Poisoned) { // map.selectedEnemy = this.name; // GameObject Poison = GameObject.Find ("_Scripts"); Poison poison = effects.GetComponent <Poison> (); poison.RunPoison(); } if (Bleeding) { // map.selectedEnemy = this.name; // GameObject Bleed = GameObject.Find ("_Scripts"); Bleed bleed = effects.GetComponent <Bleed> (); bleed.RunBleed(); } if (Stunned) { // map.selectedEnemy = this.name; // GameObject Stun = GameObject.Find ("_Scripts"); Stun stun = effects.GetComponent <Stun> (); stun.RunStun(); } if (Chilled) { Chill chill = effects.GetComponent <Chill> (); chill.RunChill(); } if (Frozen) { Frozen frozen = effects.GetComponent <Frozen> (); frozen.RunFrozen(); } if (Blinded) { Blind blind = effects.GetComponent <Blind> (); blind.RunBlind(); } }
public void RunEffect() { GameObject effects = GameObject.Find("Effects"); switch (effect) { case Effects.ArmorUp: // less inc physical dmg break; case Effects.Burn: Burn burn = effects.GetComponent <Burn> (); damage = burn.Damage(damage, 3); //= damage / 3; burn.ApplyBurn(3, damage); break; case Effects.Bleed: // GameObject Bleed = GameObject.Find ("_Scripts"); Bleed bleed = effects.GetComponent <Bleed> (); bleed.ApplyBleed(); break; case Effects.Chill: // same as slow, but second proc will apply "frozen". Also apply frozen if speed = 0 Chill chill = effects.GetComponent <Chill> (); chill.ApplyChill(); break; case Effects.Slow: // GameObject Slow = GameObject.Find ("_Scripts"); Slow slow = effects.GetComponent <Slow> (); slow.ApplySlow(); break; case Effects.Freeze: // enemy will turns as long as frozen. Burn will neutralize effect. 50% less physical dmg Frozen frozen = effects.GetComponent <Frozen> (); frozen.ApplyFrozen(); break; case Effects.Poison: // GameObject Poison = GameObject.Find ("_Scripts"); Poison poison = effects.GetComponent <Poison> (); poison.damage = damage / 5; poison.ApplyPoison(); break; case Effects.ShieldUp: // block next melee or ranged attack break; case Effects.SpeedUp: // 20% more MS break; case Effects.Stun: // GameObject Stun = GameObject.Find ("_Scripts"); Stun stun = effects.GetComponent <Stun> (); stun.ApplyStun(); break; case Effects.Blind: // GameObject Stun = GameObject.Find ("_Scripts"); Blind blind = effects.GetComponent <Blind> (); blind.Applyblind(); break; case Effects.RemoveBleed: // Remove bleed stacks from target break; case Effects.MagicResUp: // less inc magic dmg break; case Effects.Restoration: // GameObject Restoration = GameObject.Find ("_Scripts"); Restoration restoration = effects.GetComponent <Restoration> (); restoration.heal = healDot; restoration.ApplyRestoration(); break; case Effects.Fly: // walk through objects break; case Effects.FullVision: // see full map break; case Effects.SharedVision: // all players see shared vision break; case Effects.VisionTotem: // tetem taht grands only vision break; case Effects.SpellTotem: // "playable" totem break; case Effects.Cure: // remove all negative effect break; case Effects.AiAlly: // summon AI ally break; case Effects.Empty: break; default: break; } }