public ActionResult Update(HttpPostedFileBase TaskDll, tb_task_model model, string tempdatajson)
 {
     return(this.Visit(Core.EnumUserRole.Admin, () =>
     {
         try
         {
             tb_task_dal dal = new tb_task_dal();
             tb_version_dal dalversion = new tb_version_dal();
             tb_tempdata_dal tempdatadal = new tb_tempdata_dal();
             byte[] dllbyte = null;
             string filename = "";
             int change = model.taskversion;
             if (change == -1)
             {
                 if (TaskDll == null)
                 {
                     throw new Exception("没有文件!");
                 }
                 filename = TaskDll.FileName;
                 Stream dll = TaskDll.InputStream;
                 dllbyte = new byte[dll.Length];
                 dll.Read(dllbyte, 0, Convert.ToInt32(dll.Length));
                 //model.taskcreateuserid = Common.GetUserId(this);
             }
             using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
             {
                 PubConn.Open();
                 var task = dal.GetOneTask(PubConn, model.id);
                 if (task.taskstate == (int)Dyd.BaseService.TaskManager.Core.EnumTaskState.Running)
                 {
                     throw new Exception("当前任务在运行中,请停止后提交");
                 }
                 if (change == -1)
                 {
                     model.taskversion = dalversion.GetVersion(PubConn, model.id) + 1;
                 }
                 model.taskupdatetime = DateTime.Now;
                 ConvertServiceTypeToFlag(model);
                 dal.UpdateTask(PubConn, model);
                 if (change == -1)
                 {
                     dalversion.Add(PubConn, new tb_version_model()
                     {
                         taskid = model.id,
                         version = model.taskversion,
                         versioncreatetime = DateTime.Now,
                         zipfile = dllbyte,
                         zipfilename = System.IO.Path.GetFileName(filename),
                         commit_id = string.Empty
                     });
                 }
                 tempdatadal.UpdateByTaskID(PubConn, new tb_tempdata_model()
                 {
                     taskid = model.id,
                     tempdatajson = tempdatajson,
                     tempdatalastupdatetime = DateTime.Now
                 });
                 return RedirectToAction("index");
             }
         }
         catch (Exception exp)
         {
             ModelState.AddModelError("", exp.Message);
             return View();
         }
     }));
 }
        public JsonResult Update(HttpPostedFileBase TaskDll, tb_task_model model, string tempdatajson)
        {
            HttpPostedFileBase file = Request.Files[0];

            return(this.Visit(Core.EnumUserRole.Admin, () =>
            {
                try
                {
                    tb_task_dal dal = new tb_task_dal();
                    tb_version_dal dalversion = new tb_version_dal();
                    tb_tempdata_dal tempdatadal = new tb_tempdata_dal();
                    byte[] dllbyte = null;
                    string filename = "";
                    int change = model.taskversion;
                    if (change == -1)
                    {
                        if (TaskDll == null)
                        {
                            return Json(new { code = -1, message = "没有文件" });
                        }
                        filename = TaskDll.FileName;
                        Stream dll = TaskDll.InputStream;
                        dllbyte = new byte[dll.Length];
                        dll.Read(dllbyte, 0, Convert.ToInt32(dll.Length));
                        //model.taskcreateuserid = Common.GetUserId(this);
                    }
                    using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString))
                    {
                        PubConn.Open();
                        var task = dal.GetOneTask(PubConn, model.id);
                        if (task.taskstate == (int)Dyd.BaseService.TaskManager.Core.EnumTaskState.Running)
                        {
                            return Json(new { code = -1, message = "当前任务在运行中,请停止后提交" });
                        }
                        if (change == -1)
                        {
                            model.taskversion = dalversion.GetVersion(PubConn, model.id) + 1;
                        }
                        model.taskupdatetime = DateTime.Now;
                        dal.UpdateTask(PubConn, model);
                        if (change == -1)
                        {
                            dalversion.Add(PubConn, new tb_version_model()
                            {
                                taskid = model.id,
                                version = model.taskversion,
                                versioncreatetime = DateTime.Now,
                                zipfile = dllbyte,
                                zipfilename = System.IO.Path.GetFileName(filename)
                            });
                        }
                        tempdatadal.UpdateByTaskID(PubConn, new tb_tempdata_model()
                        {
                            taskid = model.id,
                            tempdatajson = tempdatajson,
                            tempdatalastupdatetime = DateTime.Now
                        });
                        return Json(new { code = 0, message = "上传成功" });
                    }
                }
                catch (Exception exp)
                {
                    return Json(new { code = -1, message = exp.Message });
                }
            }));
        }