Ejemplo n.º 1
0
        public void TradeCountInventory()
        {
            Bot.main.Invoke((Action)(() =>
            {
                ShowTrade = new ShowTrade(Bot, Bot.SteamFriends.GetFriendPersonaName(OtherSID));
                ShowTrade.Show();
                ShowTrade.Activate();
            }));
            // Let's count our inventory
            Thread loadInventory = new Thread(() =>
            {
                Console.WriteLine("Trade window opened.");
                Console.WriteLine("Loading all inventory items.");
                try
                {
                    if (Bot.CurrentTrade == null)
                    {
                        return;
                    }
                    if (Trade.MyInventory == null)
                    {
                        Bot.log.Error("Trade inventory is null!");
                        return;
                    }
                    if (Trade.MyInventory.Items == null)
                    {
                        Bot.log.Error("Trade inventory item list is null!");
                        return;
                    }
                    Inventory.Item[] inventory = Trade.MyInventory.Items;
                    Bot.log.Debug("Adding items to trade inventory list.");
                    if (Trade.CurrentItemsGame == null)
                    {
                        Bot.log.Error("ItemsGame is null!");
                        return;
                    }
                    if (Trade.CurrentSchema == null)
                    {
                        Bot.log.Error("Schema is null!");
                        return;
                    }
                    foreach (Inventory.Item item in inventory)
                    {
                        if (!item.IsNotTradeable)
                        {
                            var currentItem  = Trade.CurrentSchema.GetItem(item.Defindex);
                            string name      = "";
                            string itemValue = "";
                            var type         = Convert.ToInt32(item.Quality.ToString());
                            if (Util.QualityToName(type) != "Unique")
                            {
                                name += Util.QualityToName(type) + " ";
                            }
                            name += currentItem.ItemName;
                            name += " (" + SteamTrade.Trade.CurrentItemsGame.GetItemRarity(item.Defindex.ToString()) +
                                    ")";
                            if (Util.QualityToName(type) == "Unusual")
                            {
                                try
                                {
                                    for (int count = 0; count < item.Attributes.Length; count++)
                                    {
                                        if (item.Attributes[count].Defindex == 134)
                                        {
                                            name += " (Effect: " +
                                                    Trade.CurrentSchema.GetEffectName(item.Attributes[count].FloatValue) +
                                                    ")";
                                        }
                                    }
                                }
                                catch (Exception)
                                {
                                }
                            }
                            try
                            {
                                int size = item.Attributes.Length;
                                for (int count = 0; count < size; count++)
                                {
                                    if (item.Attributes[count].Defindex == 261)
                                    {
                                        string paint = ShowBackpack.PaintToName(item.Attributes[count].FloatValue);
                                        name        += " (Painted: " + paint + ")";
                                    }
                                    if (item.Attributes[count].Defindex == 186)
                                    {
                                        name += " (Gifted)";
                                    }
                                }
                            }
                            catch
                            {
                                // Item has no attributes... or something.
                            }
                            ListInventory.Add(name, item.Id, currentItem.ImageURL);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Bot.log.Error(ex.ToString());
                    return;
                }
                try
                {
                    ShowTrade.loading = false;
                    Bot.main.Invoke((Action)(() => ShowTrade.list_inventory.SetObjects(ListInventory.Get())));
                }
                catch (Exception ex)
                {
                    Bot.log.Error(ex.ToString());
                }
            });

            loadInventory.Start();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Function to get inventory details for a vin number/customerid
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>NA</returns>
        /// <createdBy></createdBy>
        /// <createdOn>June-28,2016</createdOn>
        public void Search_Click(object obj)
        {
            try
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                Count = 0;
                if (CustomerID > 0)
                {
                    if (obj == null)
                    {
                        CurrentPageIndex = 0;
                    }
                    if (CurrentPageIndex == 0)
                    {
                        Application.Current.Properties["FindUserGridLastScrollOffset"] = 0;
                        Application.Current.Properties["FindUserGridCurrentPageIndex"] = 0;
                    }

                    PortStorageVehicleProp objVehicleProp = new PortStorageVehicleProp();
                    objVehicleProp.CustomerID       = CustomerID;
                    objVehicleProp.VIN              = VINNumber;
                    objVehicleProp.CurrentPageIndex = CurrentPageIndex;
                    objVehicleProp.PageSize         = CurrentPageIndex > 0 ? _GridPageSizeOnScroll : _GridPageSize;;
                    objVehicleProp.DefaultPageSize  = _GridPageSize;

                    var lstInventory = _serviceInstance.GetPortStorageInventoryDetails(objVehicleProp).Select(x => new PortStorageVehicleProp
                    {
                        VIN                   = x.VIN != null ? x.VIN : string.Empty,
                        VehicleYear           = x.VehicleYear != null ? x.VehicleYear : string.Empty,
                        Make                  = x.Make != null ? x.Make : string.Empty,
                        Model                 = x.Model != null ? x.Model : string.Empty,
                        Color                 = x.Color != null ? x.Color : string.Empty,
                        BayLocation           = x.BayLocation != null ? x.BayLocation : string.Empty,
                        DateIn                = x.DateIn,
                        DateRequested         = x.DateRequested,
                        VehicleStatus         = x.VehicleStatus != null ? x.VehicleStatus : string.Empty,
                        RequestedBy           = x.RequestedBy != null ? x.RequestedBy : string.Empty,
                        DateOut               = x.DateOut,
                        PortStorageVehiclesID = x.PortStorageVehiclesID,
                        IsSelected            = x.IsSelected,
                        Days                  = x.DateOut != null ? Convert.ToInt32(Convert.ToDateTime(x.DateOut).Subtract((DateTime)x.DateIn).TotalDays) : (x.DateIn != null ? Convert.ToInt32(DateTime.Now.Subtract((DateTime)x.DateIn).TotalDays) : 0), //(int)x.DateOut.Value.Subtract((DateTime)x.DateIn).TotalDays : 0//(Convert.ToDateTime(x.DateIn) != null ? (int)DateTime.Now.Subtract((DateTime)x.DateIn).TotalDays : 0)
                        TotalPageCount        = x.TotalPageCount
                    });

                    foreach (var item in lstInventory)
                    {
                        IsSelected = item.IsSelected;
                    }

                    if (CurrentPageIndex == 0)
                    {
                        ListInventory = null;
                        ListInventory = new ObservableCollection <PortStorageVehicleProp>(lstInventory);
                    }
                    else
                    {
                        if (ListInventory != null && ListInventory.Count > 0)
                        {
                            foreach (PortStorageVehicleProp ud in new ObservableCollection <PortStorageVehicleProp>(lstInventory))
                            {
                                ListInventory.Add(ud);
                            }
                        }
                    }
                    VehicleSummary = "Vehicles currently in storage: " + ListInventory.Where(x => x.VehicleStatus != Enums.VehicleStatusType.OutGated.ToString()).Count().ToString() + "(Requested: " + ListInventory.Where(x => x.VehicleStatus == Enums.VehicleStatusType.Requested.ToString()).Count().ToString() + ")";
                }
                else
                {
                    MessageBox.Show(Resources.MsgSelectUser);
                }

                Count = ListInventory.ToList().Where(x => x.TotalPageCount > 0).FirstOrDefault().TotalPageCount;
            }
            catch (Exception ex)
            {
                CommonSettings.logger.LogError(this.GetType(), ex);
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }