Пример #1
0
        public override DateTime ReadJson(JsonReader reader, Type objectType, DateTime existingValue, bool hasExistingValue,
                                          JsonSerializer serializer)
        {
            long utime = (long)reader.Value;

            return(UnixTimeConverter.FromUnixTime(utime));
        }
Пример #2
0
        public static TradeExecutionUpdate Parse(string json)
        {
            if (JToken.Parse(json).Type != JTokenType.Array)
            {
                return(null);
            }

            var arr = JArray.Parse(json);

            if (!(arr[0].Type == JTokenType.Integer &&
                  arr[1].Type == JTokenType.String &&
                  arr[2].Type == JTokenType.Array))

            {
                return(null);
            }

            if (arr[1].Value <string>() != @"tu")
            {
                return(null);
            }

            var item = arr[2].Value <JArray>();

            return(new TradeExecutionUpdate
            {
                ChannelId = arr[0].Value <long>(),
                Seq = item[0].Value <string>(),
                Id = item[1].Value <long>(),
                AssetPair = item[2].Value <string>(),
                TimeStamp = UnixTimeConverter.FromUnixTime(item[3].Value <long>()),
                OrderId = item[4].Value <long>(),
                Volume = item[5].Value <decimal>(),
                Price = item[6].Value <decimal>(),
                OrderType = item[7].Value <string>(),
                OrderPrice = item[8].Value <decimal?>(),
                Fee = item[9].Value <decimal>(),
                FeeCurrency = item[10].Value <string>()
            });
        }
Пример #3
0
        public IEnumerable <ProductInShelf> GetProductsInShelf(Shelf shelf)
        {
            string rawJson           = webClient.DownloadString(String.Format("/azusa/products/inshelf/{0}", shelf.Id));
            JArray deserializeObject = (JArray)JsonConvert.DeserializeObject(rawJson);

            foreach (JToken jToken in deserializeObject)
            {
                ProductInShelf productInShelf = new ProductInShelf();
                productInShelf.CoverSize        = jToken.Value <long>("CoverSize");
                productInShelf.BoughtOn         = UnixTimeConverter.FromUnixTime(jToken.Value <long>("BoughtOn"));
                productInShelf.ContainsUndumped = jToken.Value <bool>("ContainsUndumped");
                productInShelf.IconId           = jToken.Value <int>("IconId");
                productInShelf.Id = jToken.Value <int>("Id");
                productInShelf.MissingGraphData = jToken.Value <int>("MissingGraphData");
                productInShelf.NSFW             = jToken.Value <bool>("NSFW");
                productInShelf.Name             = jToken.Value <string>("Name");
                productInShelf.NumberOfDiscs    = jToken.Value <int>("NumberOfDiscs");
                productInShelf.Price            = jToken.Value <double>("Price");
                productInShelf.relatedShelf     = shelf;
                yield return(productInShelf);
            }
            yield break;
        }
Пример #4
0
        public static SearchQuery GetSearchQuery(Folder folder)
        {
            bool         exists  = false;
            AzusaContext context = AzusaContext.GetInstance();
            int          count   = context.DatabaseDriver.MailArchive_CountItemsInFolder(folder);

            exists = count > 0;

            if (!exists)
            {
                return(SearchQuery.All);
            }

            long newestUtime = context.DatabaseDriver.MailArchive_GetHighestMessageUTimeInFolder(folder);

            if (newestUtime > 0)
            {
                return(SearchQuery.DeliveredAfter(UnixTimeConverter.FromUnixTime(newestUtime)));
            }
            else
            {
                return(SearchQuery.All);
            }
        }