public override async Task ExecuteAsync(CBListPacket packet, ClientSession clientSession) { var itemssearch = packet.ItemVNumFilter.FirstOrDefault() == 0 ? new List <short>() : packet.ItemVNumFilter; var bzlist = await _bazaarHttpClient.GetBazaarLinksAsync(-1, packet.Index, 50, packet.TypeFilter, packet.SubTypeFilter, packet.LevelFilter, packet.RareFilter, packet.UpgradeFilter, null).ConfigureAwait(false); var bzlistsearched = bzlist.Where(s => itemssearch !.Contains(s.ItemInstance !.ItemVNum)).ToList(); //price up price down quantity up quantity down var definitivelist = itemssearch.Any() ? bzlistsearched : bzlist; definitivelist = packet.OrderFilter switch { 0 => definitivelist .OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language]) .ThenBy(s => s.BazaarItem !.Price) .ToList(), 1 => definitivelist .OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language]) .ThenByDescending(s => s.BazaarItem !.Price) .ToList(), 2 => definitivelist .OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language]) .ThenBy(s => s.BazaarItem !.Amount) .ToList(), 3 => definitivelist .OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language]) .ThenByDescending(s => s.BazaarItem !.Amount) .ToList(), _ => definitivelist.OrderBy(s => _items.First(o => o.VNum == s.ItemInstance !.ItemVNum).Name[clientSession.Account.Language]) .ToList() }; await clientSession.SendPacketAsync(new RcbListPacket { PageIndex = packet.Index, Items = definitivelist .Where(s => ((s.BazaarItem !.DateStart.AddHours(s.BazaarItem.Duration) - SystemTime.Now()) .TotalMinutes > 0) && (s.ItemInstance !.Amount > 0)) .Select(bzlink => new RcbListElementPacket { AuctionId = bzlink.BazaarItem !.BazaarItemId, OwnerId = bzlink.BazaarItem.SellerId, OwnerName = bzlink.SellerName, ItemId = bzlink.ItemInstance !.ItemVNum, Amount = bzlink.ItemInstance.Amount, IsPackage = bzlink.BazaarItem.IsPackage, Price = bzlink.BazaarItem.Price, MinutesLeft = (long)(bzlink.BazaarItem.DateStart.AddHours(bzlink.BazaarItem.Duration) - SystemTime.Now()) .TotalMinutes, Unknown1 = false, Unknown = 2, Rarity = bzlink.ItemInstance.Rare, Upgrade = bzlink.ItemInstance.Upgrade, EInfo = new EInfoPacket() }).ToList() as List <RcbListElementPacket?>
public AISClass(String source, DateTime dateStart) { Source = new SourceInfo(source); DateStart = dateStart.Date; DateEnd = DateStart.AddHours(24); Dates = new List<DateTime>(); DateTime date = DateStart.AddMinutes(30); while (date <= DateEnd) { Dates.Add(date); date = date.AddMinutes(30); } }
public AISClass(String source, DateTime dateStart) { //Source = new SourceInfo(source); Objs = new List <int>(); string[] arr = source.Split(','); foreach (string s in arr) { Objs.Add(Convert.ToInt32(s)); } ObjType = Objs.Count > 1 ? 0 : 2; DateStart = dateStart.Date; DateEnd = DateStart.AddHours(24); Dates = new List <DateTime>(); DateTime date = DateStart.AddMinutes(30); while (date <= DateEnd) { Dates.Add(date); date = date.AddMinutes(30); } }
public async Task <bool> ReadData() { ResultData = new Dictionary <DateTime, Dictionary <string, double> >(); DateTime date = DateStart.AddHours(0); while (date < DateEnd) { DateTime de = date.AddHours(0); switch (Period) { case EDSReportPeriod.sec: de = date.AddSeconds(1); break; case EDSReportPeriod.minute: de = date.AddMinutes(1); break; case EDSReportPeriod.hour: de = date.AddHours(1); break; case EDSReportPeriod.day: de = date.AddDays(1); break; case EDSReportPeriod.month: de = date.AddMonths(1); break; } ResultData.Add(date, new Dictionary <string, double>()); foreach (string id in RequestData.Keys) { ResultData[date].Add(id, 0); } date = de.AddHours(0); } List <TabularRequestItem> list = new List <TabularRequestItem>(); foreach (EDSReportRequestRecord rec in RequestData.Values) { list.Add(new TabularRequestItem() { function = EDSClass.getReportFunctionName(rec.Function), pointId = new PointId() { iess = rec.Point.IESS }, shadePriority = rec.Point.IsShade ? ShadePriority.SHADEOVERREGULAR : ShadePriority.REGULAROVERSHADE }); } if (!EDSClass.Connected) { EDSClass.Connect(); } if (EDSClass.Connected) { if (Period != EDSReportPeriod.month) { List <DateTime> dates = ResultData.Keys.ToList(); DateTime ds = DateStart.AddHours(0); DateTime de = DateStart.AddHours(1); while (ds < DateEnd) { if (Period == EDSReportPeriod.minute || Period == EDSReportPeriod.sec) { int i0 = dates.IndexOf(ds); int i1 = i0 + 1000; de = i1 < dates.Count ? dates[i1] : DateEnd; } else { de = de.AddDays(5); try { de = dates.First(d => d >= de); } catch { de = DateEnd; } } EDSClass.Single.GlobalInfo = String.Format("{0}-{1}", ds.ToString("dd.MM.yyyy HH:mm:ss"), de.ToString("dd.MM.yyyy HH:mm:ss")); TabularRequest req = new TabularRequest(); req.period = new TimePeriod() { from = new Timestamp() { second = EDSClass.toTS(ds) }, till = new Timestamp() { second = EDSClass.toTS(de) } }; req.step = new TimeDuration() { seconds = EDSClass.getPeriodSeconds(Period) }; req.items = list.ToArray(); uint id = EDSClass.Client.requestTabular(EDSClass.AuthStr, req); TabularRow[] rows; bool ok = await EDSClass.ProcessQueryAsync(id); if (!ok) { break; } PointId[] points = EDSClass.Client.getTabular(EDSClass.AuthStr, id, out rows); List <string> keys = RequestData.Keys.ToList(); foreach (TabularRow row in rows) { DateTime dt = EDSClass.fromTS(row.ts.second); for (int i = 0; i < row.values.Count(); i++) { double val = EDSClass.getVal(row.values[i].value); PointId point = points[i]; string resId = keys[i]; EDSReportRequestRecord request = RequestData[resId]; if (request.Function == EDSReportFunction.vyrab && Period == EDSReportPeriod.day) { val *= 24; } ResultData[dt][resId] = val; } } ds = de.AddHours(0); } } else { DateTime ds = DateStart.AddHours(0); while (ds < DateEnd) { EDSClass.Single.GlobalInfo = String.Format("{0}-{1}", ds.ToString("dd.MM.yyyy"), ds.AddMonths(1).ToString("dd.MM.yyyy")); DateTime de = ds.AddMonths(1); TabularRequest req = new TabularRequest(); req.period = new TimePeriod() { from = new Timestamp() { second = EDSClass.toTS(ds) }, till = new Timestamp() { second = EDSClass.toTS(de) } }; int seconds = (int)(EDSClass.toTS(de) - EDSClass.toTS(ds)); req.step = new TimeDuration() { seconds = seconds }; req.items = list.ToArray(); uint id = EDSClass.Client.requestTabular(EDSClass.AuthStr, req); TabularRow[] rows; bool ok = await EDSClass.ProcessQueryAsync(id); if (!ok) { break; } PointId[] points = EDSClass.Client.getTabular(EDSClass.AuthStr, id, out rows); List <string> keys = RequestData.Keys.ToList(); TabularRow row = rows.First(); DateTime dt = EDSClass.fromTS(row.ts.second); for (int i = 0; i < row.values.Count(); i++) { double val = EDSClass.getVal(row.values[i].value); PointId point = points[i]; string resId = keys[i]; EDSReportRequestRecord request = RequestData[resId]; if (request.Function == EDSReportFunction.vyrab) { val *= seconds / 3600.0; } ResultData[dt][resId] = val; } ds = de.AddHours(0); } } } return(true); }