Exemplo n.º 1
0
        public JsonResult saveData(string price_data, int count, string coin)
        {
            dynamic stuff = JsonConvert.DeserializeObject(price_data);


            string[] Users = stuff[0].ToObject <string[]>();

            // int ac = 0;
            do
            {
                // string subArray = stuff[1];
                string[] SubArrayData = stuff[count].ToObject <string[]>();
                string   price        = SubArrayData[1];
                decimal  price2       = Convert.ToDecimal(price);
                string   date1        = SubArrayData[0];
                double   epoch        = Convert.ToDouble(date1);
                DateTime datex        = new DateTime(1970, 1, 1).AddSeconds(epoch / 1000);
                //DateTime date4 = ConvertUnixTimeStamp(date1);


                // string date2 = Regex.Replace(date1, @"[^\d\s\.:]", string.Empty);
                // DateTime date3 = DateTime.ParseExact(date1, "MM.dd.yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                //DateTime time = DateTime.ParseExact(SubArrayData[0], "dd/MM/yyyy", null);

                // string data1 = subArray[0];
                //Decimal price = stuff[ac].price;
                //DateTime time = stuff[ac].price_timestamp;
                //decimal? rank = stuff[ac].rank;
                //decimal? rankdelta = stuff[ac].rank_delta;
                //decimal marketcap = stuff[ac].market_cap;
                //string symbol = stuff[ac].symbol;
                //textBox1.AppendText(coinname + Environment.NewLine);
                //textBox1.AppendText(price + Environment.NewLine);
                //textBox1.AppendText(time + Environment.NewLine);
                using (var context = new db61a6afb29dc84f4597e3a2b500ebed20Entities())
                {
                    var t = new PriceData
                    {
                        Coin  = coin,
                        Price = price2,
                        //Rank = rank,
                        //Rankdelta = rankdelta,
                        //Marketcap = marketcap,
                        //Symbol = symbol,
                        Timestamp = datex
                    };

                    context.PriceDatas.Add(t);

                    context.SaveChanges();
                }

                count--;
            } while (count > 0);



            return(Json(new { status = "saved" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public JsonResult saveChangeData(string time_start, string time_end, decimal up, decimal down, int duration, string coin, decimal profit)
        {
            DateTime start_epoch = new DateTime(1970, 1, 1).AddSeconds(Convert.ToDouble(time_start) / 1000);
            DateTime end_epoch   = new DateTime(1970, 1, 1).AddSeconds(Convert.ToDouble(time_end) / 1000);
            string   uniqueID    = coin + time_start + time_end + up.ToString() + down.ToString() + duration.ToString();
            string   status;
            var      dataContext = new db61a6afb29dc84f4597e3a2b500ebed20Entities();

            var data = from y in dataContext.PriceChanges
                       where y.UniqueID == uniqueID
                       select y;


            int ct = data.Count();

            if (ct == 0)
            {
                using (var context = new db61a6afb29dc84f4597e3a2b500ebed20Entities())
                {
                    var t = new PriceChanx
                    {
                        Coin       = coin,
                        Time_start = start_epoch,
                        Time_end   = end_epoch,
                        Up         = up,
                        Down       = down,
                        Duration   = duration,
                        UniqueID   = uniqueID,
                        profit     = profit
                    };

                    context.PriceChanges.Add(t);

                    context.SaveChanges();

                    status = "Saved: " + duration;
                }
            }
            else
            {
                status = "Not saved: " + duration;
            }


            return(Json(new { status = status }, JsonRequestBehavior.AllowGet));
        }