private void Thread_Load_Market_Data(string filename) { StreamReader sr = new StreamReader(filename); List<String> itemNotFound = new List<string>(); string[] data = null; int rowCount = 0; statusStrip1.Invoke(new UpdateUI(UpdateUIStatusText), " Loading Market Data"); User u = db.Users.First(); while (!sr.EndOfStream) { string raw = sr.ReadLine().Trim(); data = raw.Split(','); if (rowCount != 0) { try { if (data.Count() != 3) { throw new Exception("Item not found"); } else { int vendorPrice = -1; string itemName = data[0]; int marketPrice = Convert.ToInt32(data[1]); if (!data[2].Equals("")) { vendorPrice = Convert.ToInt32(data[2]); } Item i = db.Items.SingleOrDefault(p => p.Name.Equals(itemName)); if (i == null) { throw new Exception("Item not found"); } ItemHistory ih = new ItemHistory(); ih.Item = i; ih.User = u; ih.recordDate = DateTime.UtcNow; ih.nqPrice = marketPrice; ih.hqPrice = 0; i.buyFromVendor = vendorPrice; i.ItemHistories.Add(ih); db.SubmitChanges(); } } catch (Exception ex) { itemNotFound.Add("Bad Row " + rowCount + " ( " + raw + " )"); } } rowCount++; } sr.Close(); File.WriteAllLines("Market_Import_Errors.txt", itemNotFound); statusStrip1.Invoke(new UpdateUI(UpdateUIStatusText), "All Market Data Loaded"); statusStrip1.Invoke(new UpdateUIFinish(UpdateUIFinished)); }
private void detach_ItemHistories(ItemHistory entity) { this.SendPropertyChanging(); entity.User = null; }
partial void DeleteItemHistory(ItemHistory instance);
partial void UpdateItemHistory(ItemHistory instance);
partial void InsertItemHistory(ItemHistory instance);
private void attach_ItemHistories(ItemHistory entity) { this.SendPropertyChanging(); entity.Item = this; }