public static void ImportPartInstances() { var context = new ManufacturingContext(); var lines = File.ReadAllLines(@"C:\InventoryTransfer\PartInstances.txt"); foreach (var line in lines) { var rows = line.Split('\t'); PartInstance instance = new PartInstance(); var properties = typeof(PartInstance).GetProperties(); foreach (var keyValue in HeaderIndex) { if (keyValue.Key == 0 || keyValue.Key == 4) { instance.GetType().GetProperty(keyValue.Value).SetValue(instance, rows[keyValue.Key]); } else if ((keyValue.Key >= 1 && keyValue.Key <= 3) || (keyValue.Key >= 8 && keyValue.Key <= 11)) { instance.GetType().GetProperty(keyValue.Value).SetValue(instance, Convert.ToInt32(rows[keyValue.Key])); } else if (keyValue.Key >= 5 && keyValue.Key <= 7) { instance.GetType().GetProperty(keyValue.Value).SetValue(instance, false); } } context.Add(instance); } context.SaveChanges(); Console.WriteLine("Maybe???"); Console.ReadKey(); }
private async Task <CheckOutOutputData> ExecuteStandard(PartInstance partInstance, Location location, CheckOutInputData item) { partInstance.UpdateQuantity(0 - item.Quantity); if (item.ConditionId != 0) { var condition = await this._categoryRepository.GetEntityAsync(e => e.Id == item.ConditionId); if (condition != null) { partInstance.ConditionId = condition.Id; } } Transaction transaction = new Transaction(partInstance, InventoryAction.OUTGOING, 0, 0, location, item.TimeStamp); transaction.Quantity = item.Quantity; transaction.UnitCost = item.UnitCost; transaction.TotalCost = item.Quantity * item.UnitCost; if (!partInstance.StockType.IsDefault) { var stockType = (StockType)await this._categoryRepository.GetEntityAsync(e => e.Id == partInstance.StockType.Id); if (stockType != null) { stockType.Quantity -= item.Quantity; await this._categoryRepository.UpdateAsync(stockType); } else { return(new CheckOutOutputData(null, false, "Error: Could not adjust stock, Please contact administrator")); } } transaction.SessionId = this._userService.CurrentSessionId.Value; var instance = await this._partInstanceRepository.UpdateAsync(partInstance); var trans = await this._transactionRepository.AddAsync(transaction); StringBuilder builder = new StringBuilder(); if (instance != null && trans != null) { var val = await this._unitOfWork.Save(); builder.AppendFormat("Instance: {0} Quantity:{1} LinesUpdated: {2}", instance.Name, transaction.Quantity, val).AppendLine(); return(new CheckOutOutputData(trans, true, builder.ToString())); } else { await this._unitOfWork.Undo(); builder.AppendFormat("Instance: {0}", partInstance.Name).AppendLine(); return(new CheckOutOutputData(transaction, false, builder.ToString())); } }
public CheckInInput(PartInstance partInstance, PriceOption priceOption, DateTime timeStamp, int partId, bool isExisiting, int?quantity = null, Price price = null) { this.PartInstance = partInstance; this.TimeStamp = timeStamp; this.PricingOption = priceOption; this.Price = price; this.PartId = partId; this.Quantity = quantity; this.IsExisiting = isExisiting; }
public static void Postfix(PartInstance __instance, ref bool __result) { if (__result) { PartsDatabase pdb = Traverse.Create <PartsDatabase>().Field("s_instance").GetValue <PartsDatabase>(); if (!pdb.m_parts.ContainsKey(__instance.GetPartId())) { logger.LogInfo(__instance.GetPartId() + "在数据库中不存在,将进行移除"); __result = false; } } }
private async Task <TransactionUndoOutput> ExecuteUndoAddTo(PartInstance partInstance, Transaction transaction) { var stockType = (StockType)await this._categoryRepository.GetEntityAsync(e => e.Id == partInstance.StockTypeId); if (stockType != null) { partInstance.UpdateQuantity(0 - transaction.Quantity); if (!stockType.IsDefault) { stockType.Quantity -= transaction.Quantity; } var instance = await this._partInstanceRepository.UpdateAsync(partInstance); var trans = await this._transactionRepository.DeleteAsync(transaction); var updated = await this._categoryRepository.UpdateAsync(stockType); if (updated != null && instance != null && trans != null) { var count = await this._unitOfWork.Save(); if (count > 0) { return(new TransactionUndoOutput(null, true, "Success: Transaction Successfully Undone")); } else { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not save")); } } else { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not update Entities")); } } else { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not find Stock type")); } }
public InstanceDto(PartInstance partInstance) { if (partInstance != null) { this.Id = partInstance.Id; this.Name = partInstance.Name; this.PartCategory = partInstance.Part.Name; this.IsBubbler = partInstance.IsBubbler; this.Quantity = (this.IsBubbler && partInstance.BubblerParameter != null) ? partInstance.BubblerParameter.Weight : partInstance.Quantity; } else { this.Id = -1; this.Name = "Deleted PartInstance"; this.PartCategory = "PartInstance was deleted"; this.IsBubbler = false; this.Quantity = -1; } }
private static void Main(string[] args) { using (var context = new InventoryContext()) { Warehouse warehouse = new Warehouse(); warehouse.Name = "Epi System Parts"; warehouse.Description = "Storage room for replacement epi parts"; context.Locations.Add(warehouse); Distributor distributor = new Distributor(); distributor.Name = "Aixtron"; distributor.Description = "Original Aixtron Parts"; context.Distributors.Add(distributor); Contact contact = new Contact(); contact.FirstName = "Marcy"; contact.LastName = "Ripley"; contact.Comments = "Aixtron Customer Service Representative"; contact.Address = "1700 Wyatt Drive, Suite 15 Santa Clara, CA 95054"; contact.Website = "www.aixtron.com"; contact.Email = "*****@*****.**"; contact.Phone = "669-228-3870"; distributor.Contacts.Add(contact); context.Contacts.Add(contact); Part part = new Part("Diffusion Barrier", "Diffusion Barriers"); context.InventoryItems.Add(part); PartInstance barrierThin = new PartInstance(part, "2.22mm Barrier", "7-03-002-00-05R1", "", ""); barrierThin.Quantity = 6; barrierThin.MinQuantity = 4; barrierThin.SafeQuantity = 8; part.Instances.Add(barrierThin); PartInstance barrierThick = new PartInstance(part, "3.33mm Barrier", "", "", ""); barrierThick.Quantity = 2; barrierThick.MinQuantity = 0; barrierThick.SafeQuantity = 0; part.Instances.Add(barrierThick); Price price = new Price(); price.Distributor = distributor; price.DistributorName = distributor.Name; price.Amount = 362; price.MinOrder = 1; price.LeadTime = 28; price.TimeStamp = DateTime.Now; distributor.Rates.Add(price); context.Rates.Add(price); context.SaveChanges(); Console.WriteLine("Should be done"); Console.ReadKey(); } }
public CheckInOutput(PartInstance partInstance, bool success, string message) { this.PartInstance = partInstance; this.Success = success; this.Message = message; }
private async Task <ReturnItemOutput> ExecuteBubbler(PartInstance partInstance, Location location, Transaction refTransaction, ReturnItemInput item) { partInstance.UpdateWeight(item.MeasuredWeight); //partInstance.BubblerParameter.DateRemoved = item.TimeStamp; partInstance.UpdateQuantity(1); partInstance.CostReported = false; partInstance.LocationId = location.Id; partInstance.DateRemoved = item.TimeStamp; if (item.ConditionId != 0) { var condition = await this._categoryRepository.GetEntityAsync(e => e.Id == item.ConditionId); if (condition != null) { partInstance.ConditionId = condition.Id; } } if (!partInstance.StockType.IsDefault) { var stockType = (StockType)await this._categoryRepository.GetEntityAsync(e => e.Id == partInstance.StockTypeId); if (stockType != null) { stockType.Quantity += (int)partInstance.BubblerParameter.Weight; var updated = await this._categoryRepository.UpdateAsync(stockType); if (updated == null) { await this._unitOfWork.Undo(); return(new ReturnItemOutput(null, false, "Error: Could not adjust stock, Please contact administrator")); } } else { await this._unitOfWork.Undo(); return(new ReturnItemOutput(null, false, "Error: Could not adjust stock, Please contact administrator")); } } Transaction transaction = new Transaction(partInstance, InventoryAction.RETURNING, partInstance.BubblerParameter.Measured, partInstance.BubblerParameter.Weight, location, item.TimeStamp); transaction.UnitCost = 0; transaction.TotalCost = 0; transaction.ReferenceTransactionId = refTransaction.Id; transaction.SessionId = this._userService.CurrentSessionId.Value; var bubbler = await this._bubblerRepository.UpdateAsync(partInstance.BubblerParameter); var instance = await this._partInstanceRepository.UpdateAsync(partInstance); var trans = await this._transactionRepository.AddAsync(transaction); StringBuilder builder = new StringBuilder(); if (bubbler != null && instance != null && trans != null) { var val = await this._unitOfWork.Save(); builder.AppendFormat("Instance: {0} Weight: {1} LinesUpdated: {2}", instance.Name, bubbler.Weight, val).AppendLine(); return(new ReturnItemOutput(trans, true, builder.ToString())); } else { await this._unitOfWork.Undo(); builder.AppendFormat("Instance: {0}", partInstance.Name).AppendLine(); return(new ReturnItemOutput(transaction, false, builder.ToString())); } }
private async Task <CheckOutOutputData> ExecuteBubbler(PartInstance partInstance, Location location, CheckOutInputData item) { partInstance.UpdateWeight(item.MeasuredWeight); partInstance.DateInstalled = item.TimeStamp; partInstance.DateRemoved = null; partInstance.UpdateQuantity(-1); partInstance.CostReported = false; partInstance.LocationId = location.Id; if (item.ConditionId != 0) { var condition = await this._categoryRepository.GetEntityAsync(e => e.Id == item.ConditionId); if (condition != null) { partInstance.ConditionId = condition.Id; } } if (!partInstance.StockType.IsDefault) { var stockType = (StockType)await this._categoryRepository.GetEntityAsync(e => e.Id == partInstance.StockType.Id); if (stockType != null) { stockType.Quantity -= (int)partInstance.BubblerParameter.Weight; await this._categoryRepository.UpdateAsync(stockType); } else { return(new CheckOutOutputData(null, false, "Error: Could not adjust stock, Please contact administrator")); } } Transaction transaction = new Transaction(partInstance, InventoryAction.OUTGOING, partInstance.BubblerParameter.Measured, partInstance.BubblerParameter.Weight, location, item.TimeStamp); transaction.SessionId = this._userService.CurrentSessionId.Value; var bubbler = await this._bubblerRepository.UpdateAsync(partInstance.BubblerParameter); var instance = await this._partInstanceRepository.UpdateAsync(partInstance); var trans = await this._transactionRepository.AddAsync(transaction); StringBuilder builder = new StringBuilder(); if (bubbler != null && instance != null && trans != null) { var stockType = await this._context.Categories.OfType <StockType>().Include(e => e.PartInstances).FirstOrDefaultAsync(e => e.Id == instance.Id); var val = await this._unitOfWork.Save(); builder.AppendFormat("Instance: {0} Weight: {1} LinesUpdated: {2}", instance.Name, bubbler.Weight, val).AppendLine(); return(new CheckOutOutputData(trans, true, builder.ToString())); } else { await this._unitOfWork.Undo(); builder.AppendFormat("Instance: {0}", partInstance.Name).AppendLine(); return(new CheckOutOutputData(transaction, false, builder.ToString())); } }
public PartInstanceDetailsEditOutput(PartInstance partInstance, bool success, string message) { this.PartInstance = partInstance; this.Success = success; this.Message = message; }
private async Task <TransactionUndoOutput> ExecuteDelete(PartInstance partInstance, Transaction transaction) { var stockType = (StockType)await this._categoryRepository.GetEntityAsync(e => e.Id == partInstance.StockTypeId); if (stockType != null) { if (!stockType.IsDefault) { if (partInstance.IsBubbler) { stockType.Quantity -= (int)partInstance.BubblerParameter.Weight; } else { stockType.Quantity -= partInstance.Quantity; } } else { var userAlerts = this._context.UserAlerts.Where(e => e.AlertId == partInstance.IndividualAlertId); if (userAlerts.Count() > 0) { this._context.RemoveRange(userAlerts); } this._context.Alerts.Remove(partInstance.IndividualAlert); partInstance.IndividualAlert = null; } var instance = await this._partInstanceRepository.DeleteAsync(partInstance); var trans = await this._transactionRepository.DeleteAsync(transaction); var updated = await this._categoryRepository.UpdateAsync(stockType); if (updated != null && instance != null && trans != null) { var count = await this._unitOfWork.Save(); if (count > 0) { return(new TransactionUndoOutput(null, true, "Success: Transaction Successfully Undone")); } else { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not save")); } } else { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not update Entities")); } } else { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not find Stock type")); } }
private async Task <TransactionUndoOutput> ExecuteUndoReturn(PartInstance partInstance, Transaction transaction) { var referenceTransaction = await this._transactionRepository.GetEntityAsync(e => e.Id == transaction.ReferenceTransactionId); if (referenceTransaction != null) { var location = await this._locationRepository.GetEntityAsync(e => e.Id == referenceTransaction.LocationId); var stockType = (StockType)await this._categoryRepository.GetEntityAsync(e => e.Id == partInstance.StockTypeId); if (stockType != null) { if (location != null) { partInstance.LocationId = location.Id; } if (partInstance.IsBubbler) { partInstance.UpdateQuantity(-1); partInstance.UpdateWeight(referenceTransaction.MeasuredWeight); partInstance.DateRemoved = null; if (!stockType.IsDefault) { stockType.Quantity -= (int)partInstance.BubblerParameter.Weight; } var bubbler = await this._bubblerRepository.UpdateAsync(partInstance.BubblerParameter); if (bubbler == null) { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not update BubblerParameter")); } } else { partInstance.UpdateQuantity(0 - transaction.Quantity); if (!stockType.IsDefault) { stockType.Quantity -= transaction.Quantity; } } var instance = await this._partInstanceRepository.UpdateAsync(partInstance); var trans = await this._transactionRepository.DeleteAsync(transaction); var updated = await this._categoryRepository.UpdateAsync(stockType); if (updated != null && instance != null && trans != null) { var count = await this._unitOfWork.Save(); if (count > 0) { return(new TransactionUndoOutput(null, true, "Success: Transaction Successfully Undone")); } else { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not save")); } } else { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not update Entities")); } } else { await this._unitOfWork.Undo(); return(new TransactionUndoOutput(null, false, "Internal Error: Could not find Stock type")); } } else { return(new TransactionUndoOutput(null, false, "Internal Error: Could not find ReferenceTransaction")); } }
public PartInstanceDetailsEditInput(PartInstance partInstance) { this.PartInstance = partInstance; }
public InstanceParameter(PartInstance part, Parameter parameter) : this() { this.PartInstance = part; this.Parameter = parameter; }