Beispiel #1
0
        public static void TraceInformation(string message)
        {
            AppLog log = new AppLog();

            log.LogType = "Информация";
            log.Message = message;

            context.AppLogs.Add(log);
            context.SaveChanges();
        }
Beispiel #2
0
        public ActionResult Create(Position position)
        {
            if (ModelState.IsValid)
            {
                db.Positions.Add(position);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(position));
        }
        public void UpdateData(Position[] positions, Int64 lastModifiedDate, AucTraderDbContext db)
        {
            const int MX           = 300;
            int       mx           = MX;
            DateTime  baseDateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            DateTime  datetime     = baseDateTime.AddMilliseconds(lastModifiedDate).ToLocalTime();

            for (int i = 0; i < positions.Length; i++)
            {
                Position aucPosition = positions[i];
                aucPosition.LoadDateTime = datetime;

                db.Positions.Add(aucPosition);

                if (i == mx)
                {
                    mx += MX;
                    db.SaveChanges();
                    db.Dispose();
                    db = new AucTraderDbContext();
                }
            }

            db.SaveChanges();
        }
Beispiel #4
0
        public ActionResult Update()
        {
            UpdateModel model = new UpdateModel()
            {
                Status = "Fail"
            };

            IAucDataLoader aucDataLoader = new AucDataLoader();

            model.Data = aucDataLoader.GetAucResponse();

            DateTime datetime;
            var      file = aucDataLoader.GetAucJsonFile(out datetime);

            Task task = new Task(() =>
            {
                AucTraderDbContext db = new AucTraderDbContext();
                const int MX          = 300;
                int mx = MX;

                StringBuilder builder = new StringBuilder();
                builder.Append("select * from Position where Auc in (");
                Int64 last = file.AucPositions.Last().Auc;
                file.AucPositions
                .ForEach(el =>
                {
                    builder.Append(el.Auc);
                    if (el.Auc != last)
                    {
                        builder.Append(", ");
                    }
                });
                builder.Append(")");

                for (int i = 0; i < file.AucPositions.Length; i++)
                {
                    Position aucPosition     = file.AucPositions[i];
                    aucPosition.LoadDateTime = datetime;

                    db.Positions.Add((Position)aucPosition);

                    if (i == mx)
                    {
                        mx += MX;
                        db.SaveChanges();
                        db.Dispose();
                        db = new AucTraderDbContext();
                    }
                }

                db.SaveChanges();
            });

            task.Start();

            return(View("Index", model));
        }