Esempio n. 1
0
 public EditJobVM(JobLM lm)
 {
     AutoID     = lm.AutoID;
     PlanAutoID = lm.PlanAutoID;
     Name       = lm.Name;
     PlanTitle  = lm.PlanTitle;
 }
Esempio n. 2
0
        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
                });
            }
        }
Esempio n. 3
0
        public ActionResult UpdateJob(int autoID)
        {
            ViewData["PageTitle"] = "修改实验";

            JobLM job = Script.GetJob(autoID);

            return(View("EditJob", new EditJobVM(job)));
        }
Esempio n. 4
0
        public static void UpdateJobName(int autoID, string name)
        {
            JobLM job = JobStorage.Get(autoID);

            job.Name       = name;
            job.DeleteFlag = 0;
            JobStorage.Save(job);
        }
Esempio n. 5
0
        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]);
            }
        }
Esempio n. 6
0
        public static int Save(JobLM lm)
        {
            JobDB db = JobDB.ToDB(lm);

            db.Save();

            lm.AutoID = db.AutoID;
            return(lm.AutoID);
        }
Esempio n. 7
0
        public static void UpdateJobDecimalCount(int jobAutoID, int decimalCount)
        {
            JobLM job = JobStorage.Get(jobAutoID);

            if (job != null)
            {
                job.DecimalCount = decimalCount;
                JobStorage.Save(job);
            }
        }
Esempio n. 8
0
        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);
            }
        }
Esempio n. 9
0
 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);
 }
Esempio n. 10
0
        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();
        }
Esempio n. 11
0
 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
     });
 }
Esempio n. 12
0
        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)));
        }
Esempio n. 13
0
        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)));
        }
Esempio n. 14
0
        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);
        }