Exemple #1
0
        public ActionResult CreateExecutions(Executions Executions, string[] AccountIdList)
        {
            if (ModelState.IsValid)
            {
                var NowTime = DateTime.Now;
                var UserID  = Session["UserID"].ToString();

                Executions.id       = Guid.NewGuid();
                Executions.CreateID = UserID;
                Executions.Createdt = NowTime;
                Executions.UpdateID = UserID;
                Executions.Updatedt = NowTime;

                db.Executions.Add(Executions);

                if (AccountIdList != null)
                {
                    foreach (var AccountId in AccountIdList)
                    {
                        if (!string.IsNullOrEmpty(AccountId))
                        {
                            ExecutionsAccount ExecutionsAccount = new ExecutionsAccount
                            {
                                ExecutionsId = Executions.id,
                                AccountId    = Guid.Parse(AccountId),
                                CreateID     = UserID,
                                Createdt     = NowTime
                            };

                            db.ExecutionsAccount.Add(ExecutionsAccount);
                        }
                    }
                }
                db.SaveChanges();
                return(Json(new { success = true }));
            }
            else
            {
                return(Json(new { success = false }));
            }
        }
Exemple #2
0
        public ActionResult EditExecutions(Executions Executions, string[] AccountIdList)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var sql = db.Executions.Find(Executions.id);
                    sql.Name                = Executions.Name;
                    sql.Status              = Executions.Status;
                    sql.MinQuantity         = Executions.MinQuantity;
                    sql.MinDifferencePrices = Executions.MinDifferencePrices;
                    sql.ExchangeType        = Executions.ExchangeType;
                    sql.CurrencyValue       = Executions.CurrencyValue;
                    sql.UpdateID            = Session["UserID"].ToString();
                    sql.Updatedt            = DateTime.Now;

                    db.ExecutionsAccount.RemoveRange(sql.ExecutionsAccount);
                    if (AccountIdList != null)
                    {
                        foreach (var AccountId in AccountIdList)
                        {
                            if (!string.IsNullOrEmpty(AccountId))
                            {
                                ExecutionsAccount ExecutionsAccount = new ExecutionsAccount
                                {
                                    ExecutionsId = Executions.id,
                                    AccountId    = Guid.Parse(AccountId),
                                    CreateID     = Session["UserID"].ToString(),
                                    Createdt     = DateTime.Now
                                };

                                db.ExecutionsAccount.Add(ExecutionsAccount);
                            }
                        }
                    }

                    db.SaveChanges();

                    //開啟搬磚程式
                    if (Executions.Status == 1)
                    {
                        SetExecutions.KillProcess(Executions.id.ToString());
                        string ProcessName = Server.MapPath("~") + @"cmd\BitcoinDeveloper.exe";
                        var    Url         = Request.Url.Scheme + "://" + Request.Url.Authority + "/api/api.asmx?op=ReturnMessage";
                        SetExecutions.StartProcess(ProcessName, Executions.id.ToString(), Url);
                    }
                    else if (Executions.Status == 0)
                    {
                        SetExecutions.KillProcess(Executions.id.ToString());
                    }

                    return(Json(new { success = true }));
                }
                catch (Exception)
                {
                    return(Json(new { success = false }));
                }
            }
            else
            {
                return(Json(new { success = false }));
            }
        }