예제 #1
0
        public static void UpdateJobName(int autoID, string name)
        {
            JobLM job = JobStorage.Get(autoID);

            job.Name       = name;
            job.DeleteFlag = 0;
            JobStorage.Save(job);
        }
예제 #2
0
        public static void UpdateJobDecimalCount(int jobAutoID, int decimalCount)
        {
            JobLM job = JobStorage.Get(jobAutoID);

            if (job != null)
            {
                job.DecimalCount = decimalCount;
                JobStorage.Save(job);
            }
        }
예제 #3
0
        /*
         * public static UserLM GetAuthUser(string userID, string password)
         * {
         *  AuthUser authUser = AppStore.UserAuthenticator.GetAuthUser(userID, password);
         *
         *  if (authUser == null)
         *  {
         *      return null;
         *  }
         *
         *
         *  UserLM user = UserStorage.Get(userID);
         *
         *  if (user == null)
         *  {
         *      user = new UserLM { ID = userID, Name = authUser.Name };
         *  }
         *
         *  UserStorage.Save(user);
         *
         *
         *  return user;
         * }
         */

        public static int CreateJob(int userAutoID, int planAutoID, string name, int decimalCount)
        {
            DateTime now = DateTime.Now;

            if (planAutoID > 0)
            {
                PlanLM planLM = GetPlanLM(planAutoID);
                Plan   plan   = GetPlan(planLM.AutoID);

                string id = Guid.NewGuid().ToString();
                AppStore.PlanRepository.Copy(planLM.ID, id);
                planLM.ReferenceCount++;
                PlanStorage.Save(planLM);
                return(JobStorage.Save(
                           new JobLM()
                {
                    Name = name,
                    CreateTime = now,
                    IsComplete = plan.Variables.Length == 0,
                    PlanAutoID = planAutoID,
                    PlanID = id,
                    PlanTitle = plan.Title,
                    UpdateTime = now,
                    UserAutoID = userAutoID,
                    Variables = new JsonSerializer().SerializeToString(new Dictionary <string, object>()),
                    DecimalCount = decimalCount,
                    DeleteFlag = 0
                }));
            }

            return(JobStorage.Save(
                       new JobLM()
            {
                Name = name,
                CreateTime = now,
                IsComplete = false,
                PlanAutoID = planAutoID,
                PlanID = "",
                PlanTitle = planAutoID == -1 ? "蒙特卡洛计算" : "蒙特卡洛计算(自适应)",
                UpdateTime = now,
                UserAutoID = userAutoID,
                Variables = new JsonSerializer().SerializeToString(new Dictionary <string, object>()),
                DecimalCount = decimalCount,
                DeleteFlag = 0
            }));
        }
예제 #4
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);
        }