//需要调用窗体名称 System.Windows.Forms.Control INetUserControl.CreateControl(UFSoft.U8.Framework.Login.UI.clsLogin login, string MenuID, string Paramters) { UFSoft.U8.Framework.LoginContext.UserData LoginInfo = new UFSoft.U8.Framework.LoginContext.UserData(); LoginInfo = login.GetLoginInfo(); string conn = LoginInfo.ConnString; conn = Utils.ConvertConn(conn); DbHelperSQL.connectionString = conn; string sLogUserid = LoginInfo.UserId; string sLogUserName = LoginInfo.UserName; string sLogDate = LoginInfo.operDate; string sAccID = LoginInfo.AccID; ClsUserRight clsUser = new ClsUserRight(); if (clsUser.chkRight(login, "TH_24")) { PurchaseSet fm = new PurchaseSet(); fm.Conn = conn; fm.sUserID = sLogUserid; fm.sUserName = sLogUserName; fm.sLogDate = sLogDate; fm.sAccID = sAccID; this._Title = "Purchase Set"; return(fm); } else { return(null); } }
private static PurchaseSet getPurchaseSet(string name, List <ItemStatic> items, bool includePrice = true) { var purchaseSet = new PurchaseSet() { Name = name, RecMath = false }; foreach (var item in items) { purchaseSet.Items.Add(item); if (includePrice) { purchaseSet.TotalCost += item.Gold.TotalPrice; } } return(purchaseSet); }
private static PurchaseSet getStartingItems(Timeline timeline, int participantId) { PurchaseSet set = new PurchaseSet() { Name = "Starting Items", RecMath = false }; bool foundAny = false; foreach (var frame in timeline.Frames) { var purchasesThisFrame = new List <Event>(); var sellbacksThisFrame = new List <Event>(); if (frame.Events != null) { purchasesThisFrame = frame.Events.Where(x => x.ParticipantId == participantId && x.EventType == EventType.ItemPurchased).ToList(); sellbacksThisFrame = frame.Events.Where(x => x.ParticipantId == participantId && (x.EventType == EventType.ItemSold || x.EventType == EventType.ItemUndo)).ToList(); } foreach (var purchase in purchasesThisFrame) { set.Items.Add(getItem(purchase.ItemId)); } foreach (var sellback in sellbacksThisFrame) { if (set.Items.Any(x => x.Id == sellback.ItemId)) { set.Items.Remove(set.Items.First(x => x.Id == sellback.ItemId)); } } if (foundAny) { break; } if (purchasesThisFrame.Any()) { foundAny = true; } } foreach (var item in set.Items) { set.TotalCost += item.Gold.TotalPrice; } set.Name = set.Name + " (" + set.TotalCost + " gold)"; return(set); }
public void Load() { var data = new PurchaseSet(Environment.GlobalConfig.DB.FromType.Read).GetKeyAndValueGuids(); // 移除db中没有的key if (_localCache.Count > 0) { List <Guid> removedVal = null; foreach (var keyToRemove in _localCache.Keys.Except(data.Keys).ToList()) { _localCache.TryRemove(keyToRemove, out removedVal); } } // 添加或更新 foreach (var keyValuePair in data) { _localCache.AddOrUpdate(keyValuePair.Key, keyValuePair.Value, (key, oldVal) => keyValuePair.Value); } }
private static PurchaseSet getRushItem(List <ItemStatic> items, List <ItemStatic> alreadyOwnedItems) { ItemStatic RushItem = items.FirstOrDefault(x => x.From != null && (x.Into == null || x.Into.Count == 1 && getItem(x.Into.First()).SpecialRecipe != 0) && x.Gold.TotalPrice > 300); if (RushItem == null) { return(null); } var possibleComponents = items.GetRange(0, items.IndexOf(RushItem)); var buildOrder = possibleComponents.Where(x => RushItem.From.Contains(x.Id.ToString())).ToList(); PurchaseSet set = new PurchaseSet() { Name = "Rush " + RushItem.Name, RecMath = true }; foreach (var item in buildOrder) { set.Items.Add(item); set.TotalCost += item.Gold.TotalPrice; } foreach (var from in RushItem.From.ToList()) { if (!set.Items.Any(x => x.Id.ToString() == from)) { var item = getItem(from); set.Items.Add(item); set.TotalCost += item.Gold.TotalPrice; } } var componentTree = RushItem.From.ToList(); while (componentTree.Any()) { var item = getItem(componentTree[0]); componentTree.RemoveAt(0); var dupe = alreadyOwnedItems.FirstOrDefault(x => x.Id == item.Id); if (dupe is ItemStatic) { alreadyOwnedItems.Remove(alreadyOwnedItems.First(x => x.Id == dupe.Id)); if (set.Items.Any(x => x.Id == dupe.Id)) { set.Items.Remove(set.Items.First(x => x.Id == dupe.Id)); } set.TotalCost -= dupe.Gold.TotalPrice; } else { if (item.From != null) { foreach (var key in item.From) { componentTree.Add(key); } } } } set.Items.Add(RushItem); if (RushItem.Into != null && RushItem.Into.Count == 1 && getItem(RushItem.Into.First()).SpecialRecipe != 0) { set.Items.Add(getItem(RushItem.Into.First())); } set.TotalCost += RushItem.Gold.BasePrice; set.Name = set.Name + " (" + set.TotalCost + " gold)"; return(set); }
private void button_confirm_end_rent_Click(object sender, EventArgs e) { try { var rent = (from x in db.RentSets where x.rent_id == rent_id select x).Single(); if (!string.IsNullOrEmpty(textBox_mileage.Text)) { if (rent.mileage_start < Convert.ToInt32(textBox_mileage.Text)) { rent.mileage_end = Convert.ToInt32(textBox_mileage.Text); try { VehicleSet veh = (from x in db.VehicleSets where x.vehicle_id == car_id select x).Single(); veh.mileage = Convert.ToInt32(textBox_mileage.Text); db.SubmitChanges(); MessageBox.Show("Zakończenie rezerwacji zakończyło się powodzeniem", "Ending Rent", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { MessageBox.Show("Nie udało się nadpisać przebiegu pojazdu", "Error Ending Rent", MessageBoxButtons.OK, MessageBoxIcon.Error); } mileage1 = Convert.ToInt32(textBox_mileage.Text) - Convert.ToInt32(dataGridView_my_rents.Rows[row].Cells[6].Value.ToString()); if (comboBox_type_cost.SelectedIndex == -1) { db.SubmitChanges(); } else if (comboBox_type_cost.Text == "Tankowanie") { litres = Convert.ToDouble(textBox_litres.Text); PurchaseSet car = new PurchaseSet() { Rent_rent_id = rent_id, price = Convert.ToDouble(textBox_all_cost.Text), type = "Paliwo", purchase_date = rent.date_to, litres = Convert.ToDouble(textBox_litres.Text), mileage = mileage1 }; db.PurchaseSets.InsertOnSubmit(car); db.SubmitChanges(); } else if (comboBox_type_cost.Text == "Tankowanie oraz inne") { litres = Convert.ToDouble(textBox_litres.Text); PurchaseSet car = new PurchaseSet() { Rent_rent_id = rent_id, price = Convert.ToDouble(textBox_all_cost.Text), type = textBox_other.Text, purchase_date = rent.date_to, litres = litres, mileage = mileage1 }; db.PurchaseSets.InsertOnSubmit(car); db.SubmitChanges(); } else if (comboBox_type_cost.Text == "Inne") { PurchaseSet car = new PurchaseSet() { Rent_rent_id = rent_id, price = Convert.ToDouble(textBox_all_cost.Text), type = textBox_other.Text, purchase_date = rent.date_to, litres = 0, mileage = mileage1 }; db.PurchaseSets.InsertOnSubmit(car); db.SubmitChanges(); } fillDataGridView(); litres_and_other_hide(); } else { MessageBox.Show("Przebieg po jest mniejszy niż przed", "Error Ending Rent", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Wpisz przebieg po zakończeniu jazd", "Error Ending Rent", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show("Zaznacz wypożyczenie", "Error Ending Rent", MessageBoxButtons.OK, MessageBoxIcon.Error); } // czyszczenie textBox_mileage.Clear(); textBox_other.Clear(); textBox_litres.Clear(); textBox_all_cost.Clear(); }
public ChampionPurchaseCalculator(PurchaseSet set) { Key = set.Key; MatchCount = set.MatchCount; // Create stats var stats = PurchaseStats.Create(set.AllItemPurchases, set.MatchCount); // Compute initial determinations based on game stage and settings percentages var statsList = stats.SelectMany(kvp => kvp.Value.Select(nkvp => nkvp.Value)); var purchaseDeterminations = statsList.Select(purchaseStats => new IncludeDetermination() { Stats = purchaseStats, GameStage = SetBuilderSettings.GetGameStage(purchaseStats), Include = false }).ToDictionary( determination => new ItemPurchaseTrackerData.ItemPurchaseKey(determination.Stats) ); // Filter initial include list by percentage purchaseDeterminations.Values .Where(determination => determination.Stats.Percentage >= SetBuilderSettings.ItemMinimumPurchasePercentage[determination.GameStage]) .ToList() .ForEach(determination => determination.Include = true); // Compute build path includes DetermineBuildPathIncludes(purchaseDeterminations); // Generate stage-based include list Purchases = purchaseDeterminations.Values .Where(determination => determination.Include) .GroupBy(determination => determination.GameStage) .ToDictionary( g => g.Key, g => g.Select(d => d.Stats).OrderBy(s => s.AveragePurchaseTimeSeconds).ToList() ); // If early items contain items that build into a mid-game item, migrate the mid-game item to early game if (Purchases.ContainsKey(GameStage.Early) && Purchases.ContainsKey(GameStage.Mid)) { // Check if a full build path exists in the early stage already bool hasFullEarlyPath = Purchases[GameStage.Early].Any(p => p.FinalBuildItemPercentage.Any(finalItem => Purchases[GameStage.Early].Any(i => finalItem.Key.ItemId == i.ItemId))); if (!hasFullEarlyPath) { // Find the first early game item that builds into something in mid-game var earlyItem = Purchases[GameStage.Early].FirstOrDefault(p => p.FinalBuildItemPercentage.Any(finalItem => Purchases[GameStage.Mid].Any(i => finalItem.Key.ItemId == i.ItemId))); if (earlyItem != null) { // Find the mid-game item to move var midItemIndex = Purchases[GameStage.Mid].FindIndex(i => earlyItem.FinalBuildItemPercentage.Any(kvp => kvp.Key.ItemId == i.ItemId)); var midItem = Purchases[GameStage.Mid][midItemIndex]; // Move the mid-game item Purchases[GameStage.Early].Add(midItem); Purchases[GameStage.Mid].RemoveAt(midItemIndex); } } } // If start items add up to less than 475, try to absorb first early item if (Purchases.ContainsKey(GameStage.Start) && Purchases.ContainsKey(GameStage.Early)) { int startCost = Purchases[GameStage.Start].Sum(d => StaticDataStore.Items.Items[d.ItemId].Gold.TotalPrice); if (startCost < 475) { ItemPurchaseStats d = Purchases[GameStage.Early].FirstOrDefault(); if (StaticDataStore.Items.Items[d.ItemId].Gold.TotalPrice + startCost <= 475) { // Move item Purchases[GameStage.Start].Add(d); Purchases[GameStage.Early].RemoveAt(0); } } } // Move consumables to end of each section foreach (GameStage stage in Purchases.Keys) { // Remove all consumables, sort by cost, then add to end of list var purchaseList = Purchases[stage]; var consumables = purchaseList.Where(d => StaticDataStore.Items.Items[d.ItemId].Consumed).ToList(); purchaseList.RemoveAll(d => consumables.Contains(d)); consumables.Sort((a, b) => { int cmp = StaticDataStore.Items.Items[a.ItemId].Gold.TotalPrice.CompareTo( StaticDataStore.Items.Items[b.ItemId].Gold.TotalPrice); if (cmp != 0) return cmp; return a.ItemId.CompareTo(b.ItemId); } ); purchaseList.AddRange(consumables); } // Remove components in mid/late game var removeComponentsStages = new[] { GameStage.Late, GameStage.Mid }; IEnumerable<ItemStatic> componentItems = Enumerable.Empty<ItemStatic>(); foreach (GameStage stage in removeComponentsStages) { if (!Purchases.ContainsKey(stage)) continue; var allComponents = Purchases[stage] .Select(p => StaticDataStore.Items.Items[p.ItemId]) .Where(i => i.Into == null || i.Into.Count == 0) .SelectMany(i => i.AllComponents()) .Where(i => i.Tags == null || (!i.Tags.Contains("Boots") && !i.Tags.Contains("Trinket"))) .Distinct(); componentItems = componentItems.Concat(allComponents).Distinct().ToList(); // Remove any component items Purchases[stage].RemoveAll(i => componentItems.Any(c => c.Id == i.ItemId)); } }