public EditJobVM(JobLM lm) { AutoID = lm.AutoID; PlanAutoID = lm.PlanAutoID; Name = lm.Name; PlanTitle = lm.PlanTitle; }
public ActionResult UpdateSettings(SettingsSM settingsSM) { try { Settings settings = settingsSM.ToLM(); EvaluationContext context = Session["Context"] as EvaluationContext; context.Settings = settings; context.Update(); Script.UpdateJobDecimalCount(settingsSM.JobAutoID, settings.DecimalDigitCount); JobLM job = (JobLM)Session["JobLM"]; if (job != null) { job.DecimalCount = settings.DecimalDigitCount; } return(new JsonResult() { Data = new { success = true }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } catch (CustomDataException ex) { Response.StatusCode = 500; return(new JsonResult() { Data = ex.Data, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } }
public ActionResult UpdateJob(int autoID) { ViewData["PageTitle"] = "修改实验"; JobLM job = Script.GetJob(autoID); return(View("EditJob", new EditJobVM(job))); }
public static void UpdateJobName(int autoID, string name) { JobLM job = JobStorage.Get(autoID); job.Name = name; job.DeleteFlag = 0; JobStorage.Save(job); }
public static void InitEvaluationContext(EvaluationContext context, JobLM job) { IDictionary variables = new JsonDeserializer().DeserializeString(job.Variables) as IDictionary; foreach (string key in variables.Keys) { context.SetValueString(key, (string)variables[key]); } }
public static int Save(JobLM lm) { JobDB db = JobDB.ToDB(lm); db.Save(); lm.AutoID = db.AutoID; return(lm.AutoID); }
public static void UpdateJobDecimalCount(int jobAutoID, int decimalCount) { JobLM job = JobStorage.Get(jobAutoID); if (job != null) { job.DecimalCount = decimalCount; JobStorage.Save(job); } }
public static void DeleteJob(int autoID) { JobLM job = JobStorage.Get(autoID); JobStorage.Delete(autoID); if (job != null && job.PlanAutoID > 0) { PlanLM plan = PlanStorage.Get(job.PlanAutoID); plan.ReferenceCount--; PlanStorage.Save(plan); } }
public JobListCellVM(JobLM lm, int pageIndex) { AutoID = lm.AutoID; Name = lm.Name; PlanTitle = lm.PlanTitle; IsComplete = lm.IsComplete; CreateTime = lm.CreateTime; UpdateTime = lm.UpdateTime; ViewLink = string.Format("/Home/ViewJob?autoID={0}", lm.AutoID); UpdateLink = string.Format("/Home/UpdateJob?autoID={0}", lm.AutoID); DeleteLink = string.Format("javascript:deleteJob({0},{1});", lm.AutoID, pageIndex); }
public JobVM(EvaluationContext context, JobLM job) { AutoID = job.AutoID; EditID = Guid.NewGuid().ToString(); Settings = new SettingsVM(context.Settings); PlanTitle = context.Plan.Title; Name = job.Name; Description = context.Plan.Description; Author = context.Plan.Author; Steps = context.Steps.Select((i, index) => new JobStepListCellVM(i, index)).ToArray(); IsCompleted = context.Steps.All(i => i.State != StepState.Unready); ExportButtonClass = IsCompleted ? "button" : "button-disabled"; ExportButtonCode = IsCompleted ? "javascript:exportAsWordDocument()" : null; DrawSourceVariables = context.SourceVariables.Where(m => m.Key.Contains("Draw_")).Select(m => m.Key).ToList(); }
public static JobDB ToDB(JobLM lm) { return(new JobDB() { AutoID = lm.AutoID, PlanAutoID = lm.PlanAutoID, PlanID = lm.PlanID, Name = lm.Name, UserAutoID = lm.UserAutoID, PlanTitle = lm.PlanTitle, IsComplete = lm.IsComplete, CreateTime = lm.CreateTime, UpdateTime = lm.UpdateTime, Variables = lm.Variables, DecimalCount = lm.DecimalCount, DeleteFlag = lm.DeleteFlag }); }
public ActionResult CreateJob(int planAutoID) { //ViewData["PageTitle"] = "创建实验"; PlanLM plan = Script.GetPlanLM(planAutoID); //return View("EditJob", new EditJobVM(new JobLM() //{ // PlanAutoID = plan.AutoID, // Name = plan.Title, // PlanTitle = plan.Title //})); var job = new JobLM() { PlanAutoID = plan.AutoID, PlanID = plan.ID, Name = plan.Title + "_" + DateTime.Now.ToString("yyyyMMddHHmmss"), PlanTitle = plan.Title, DecimalCount = 3, IsComplete = false, Variables = "{}", UserAutoID = Convert.ToInt32(HttpContext.Request.Cookies["userid"].Value) }; var userid = Convert.ToInt32(HttpContext.Request.Cookies["userid"].Value); job.AutoID = Script.CreateJob(userid, job.PlanAutoID, job.Name, 3); Session["JobAutoID"] = job.AutoID; Session["JobLM"] = job; EvaluationContext context = Script.GetPlan(job.PlanAutoID, job.PlanID).CreateEvaluationContext(); context.Settings = new Settings() { DecimalDigitCount = job.DecimalCount }; Session["Context"] = context; Script.InitEvaluationContext(context, job); context.Update(); new JobDAL().DeleteJob(job.AutoID); new PlanDAL().IncreaseQuote(planAutoID); return(View("ViewJob", new JobVM(context, job))); }
public ActionResult ViewJob(int autoID) { JobLM job = Script.GetJob(autoID); Session["JobAutoID"] = job.AutoID; Session["JobLM"] = job; EvaluationContext context = Script.GetPlan(job.PlanAutoID, job.PlanID).CreateEvaluationContext(); context.Settings = new Settings() { DecimalDigitCount = job.DecimalCount }; Session["Context"] = context; Script.InitEvaluationContext(context, job); context.Update(); return(View(new JobVM(context, job))); }
public static void UpdateJob(int jobAutoID, EvaluationContext context) { Dictionary <string, string> variables = new Dictionary <string, string>(); foreach (KeyValuePair <string, object> variable in context.SourceVariables) { if (variable.Value != null) { variables.Add(variable.Key, variable.Value.ToString()); } } JobLM job = JobStorage.Get(jobAutoID); job.IsComplete = context.Steps.All(i => i.State != StepState.Unready); job.Variables = new JsonSerializer().SerializeToString(variables); job.UpdateTime = DateTime.Now; JobStorage.Save(job); }