public JsonResult Copy(int id) { tb_task_model model = new tb_task_model(); tb_version_model vermodel = new tb_version_model(); tb_tempdata_model tempdatamodel = new tb_tempdata_model(); 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(); using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString)) { PubConn.Open(); //取出需要复制的数据 model = dal.GetOneTask(PubConn, id); tempdatamodel = tempdatadal.GetByTaskID(PubConn, id); vermodel = dalversion.GetCurrentVersion(PubConn, id, model.taskversion); //分别插入 model.taskstate = 0; model.taskcreatetime = DateTime.Now; model.taskversion = 1; int taskid = dal.AddTask(PubConn, model); vermodel.taskid = taskid; vermodel.version = 1; vermodel.versioncreatetime = DateTime.Now; vermodel.commit_id = string.Empty; dalversion.Add(PubConn, vermodel); tempdatamodel.taskid = taskid; tempdatamodel.tempdatalastupdatetime = DateTime.Now; tempdatadal.Add(PubConn, tempdatamodel); } return Json(new { code = 1, state = "复制成功" }); } catch (Exception ex) { return Json(new { code = -1, msg = ex.Message }); } })); }
public ActionResult Add(IFormFile TaskDll, tb_task_model model, string tempdatajson) { return(this.Visit(EnumUserRole.Admin, () => { string filename = TaskDll.FileName; byte[] dllbyte; using (var dll = TaskDll.OpenReadStream()) { dllbyte = new byte[dll.Length]; dll.Read(dllbyte, 0, Convert.ToInt32(dll.Length)); } tb_task_dal dal = new tb_task_dal(); tb_version_dal dalversion = new tb_version_dal(); tb_tempdata_dal tempdatadal = new tb_tempdata_dal(); //model.taskcreateuserid = Common.GetUserId(this); using (DbConn PubConn = DbConn.CreateConn(Config.TaskConnectString)) { PubConn.Open(); model.taskcreatetime = DateTime.Now; model.taskversion = 1; int taskid = dal.AddTask(PubConn, model); dalversion.Add(PubConn, new tb_version_model() { taskid = taskid, version = 1, versioncreatetime = DateTime.Now, zipfile = dllbyte, zipfilename = System.IO.Path.GetFileName(filename) }); tempdatadal.Add(PubConn, new tb_tempdata_model() { taskid = taskid, tempdatajson = tempdatajson, tempdatalastupdatetime = DateTime.Now }); } return RedirectToAction("index"); })); }
public ActionResult Add(HttpPostedFileBase TaskDll, tb_task_model model, string tempdatajson) { return(this.Visit(Core.EnumUserRole.Admin, () => { string filename = TaskDll.FileName; Stream dll = TaskDll.InputStream; byte[] dllbyte = new byte[dll.Length]; dll.Read(dllbyte, 0, Convert.ToInt32(dll.Length)); tb_task_dal dal = new tb_task_dal(); tb_version_dal dalversion = new tb_version_dal(); tb_tempdata_dal tempdatadal = new tb_tempdata_dal(); //model.taskcreateuserid = Common.GetUserId(this); using (DbConn PubConn = DbConfig.CreateConn(Config.TaskConnectString)) { PubConn.Open(); model.taskcreatetime = DateTime.Now; model.taskversion = 1; ConvertServiceTypeToFlag(model); int taskid = dal.AddTask(PubConn, model); dalversion.Add(PubConn, new tb_version_model() { taskid = taskid, version = 1, versioncreatetime = DateTime.Now, zipfile = dllbyte, zipfilename = System.IO.Path.GetFileName(filename), commit_id = string.Empty }); tempdatadal.Add(PubConn, new tb_tempdata_model() { taskid = taskid, tempdatajson = tempdatajson, tempdatalastupdatetime = DateTime.Now }); } return RedirectToAction("index"); })); }