public void RunStep(string prefix, string step) { if (failed) { steps.Add(new Step(Step.yellow, prefix + " " + step)); return; } // replace numbers and strings with ___ and save in object[] args List <object> args = new List <object>(); foreach (Match match in Regex.Matches(Regex.Replace(step, " ", " "), @"(?:^| )(-?[0-9]+(?:\.[0-9]+)?|'[^']*')(?:$| )")) { string value = match.Value.Trim(); if (value.StartsWith("'")) { args.Add(Regex.Replace(value.Trim("'".ToCharArray()), " ", " ")); } else if (value.Contains(".")) { args.Add(float.Parse(value)); } else { args.Add(int.Parse(value)); } } string methodName = Regex.Replace(Regex.Replace(Regex.Replace(step.ToLower(), " ", " "), @"(?:^| )(-?[0-9]+(?:\.[0-9]+)?|'[^']*')(?:$| )", "__"), "[^a-z_]", ""); try { bool methodFound = false; foreach (MethodInfo method in GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public)) { if (method.Name.ToLower() == methodName) { method.Invoke(this, args.ToArray()); methodFound = true; break; } } if (methodFound) { steps.Add(new Step(Step.green, prefix + " " + step)); } else { steps.Add(new Step(Step.yellow, prefix + " " + step)); failed = true; } } catch (Exception e) { Exception error = e.InnerException ?? e; steps.Add(new Step(Step.red, prefix + " " + step + "\n" + error.ToString())); failed = true; } }
///// <summary> ///// 已经排到的最后一天 ///// </summary> //public DateTime? CapEndTime { get; set; } ///// <summary> ///// 最后一天剩余的能力值 ///// </summary> //public double LastCap { get; set; } ///// <summary> ///// 添加Step到数组中,并记录最后的完成时间 ///// </summary> ///// <param name="step"></param> //public DateTime? AddStep(MOItemTask step) //{ // DateTime? EndTime = null ; // if (!StepList.Where(p => p.MOItemTaskId == step.MOItemTaskId).Any()) // { // StepList.Add(step); // this.endTime = step.PlannedDateTo; // EndTime = this.endTime; // } // SetTimeslice(); // return EndTime; //} //public void AddStep(MOItemTask step,double cap) //{ // double sum = LastCap + cap; // double maxcap = VentureCap * 1.2; // if (sum <= maxcap) // { // LastCap = VentureCap - sum; // } // else // { // LastCap = VentureCap - cap; // if(CapEndTime == null) // { // CapEndTime = DateTime.Now; // } // do // { // CapEndTime = CapEndTime.Value.AddDays(1); // } // while (IsWorkTime(CapEndTime.Value)); // } // step.PlannedDateFrom = new DateTime(CapEndTime.Value.Year, CapEndTime.Value.Month, CapEndTime.Value.Day, 8, 0, 0); // step.PlannedDateTo = new DateTime(CapEndTime.Value.Year, CapEndTime.Value.Month, CapEndTime.Value.Day, 17, 0, 0); // StepList.Add(step); //} public DateTime?AddStep(MOItemTask step, DateTime?lastTime, double cap) { if (lastTime != null) { var workTime = VenTureDayModel.GetWorkTime((DateTime)lastTime, VentureId); var venTureDayModel = this.VenTureDayModelList.Where(p => p.DayDate.Year == workTime.Year && p.DayDate.Month == workTime.Month && p.DayDate.Day == workTime.Day && p.LastCap > 0).FirstOrDefault(); if (venTureDayModel == null) { this.VenTureDayModelList.Add(new VenTureDayModel(workTime, VentureCap, new List <MOItemTask>())); venTureDayModel = this.VenTureDayModelList.Where(p => p.DayDate >= lastTime).FirstOrDefault(); } if (venTureDayModel.LastCap < cap && VentureCap * 0.25 < cap) { } var retModel = venTureDayModel.AddStep(step, cap, lastTime, this.VentureId); StepList.Add(retModel.MOItemTask); return(retModel.EndTime); } else { return(null); } }
public void Add(int docId, Payload payload) { lock (_LockObj) { _DocPayload.Add(new DocPayload(docId, payload)); } //_DocPayload.Add(docId, payload); }
public void ShowProcessFlowSummary(Step lastProcessFlowStep) { List <StepAnswer> stepAnswersList = new List <StepAnswer>(); if (lastProcessFlowStep != null) { StepList.Add(lastProcessFlowStep); } // loop throuch each of the steps and display the question and answers depending on the Step Type (Button, Text, Numeric, Date) foreach (var step in StepList) { var stepIndex = StepList.IndexOf(step); //skip the first step since it is the root step if (stepIndex > 0) { //get the step interacted with before the current one var stepBefore = StepList[stepIndex - 1]; // if the step before the current one is of type button then the NavigationText attribute is the answer to the prior step if (stepBefore.Type == (int)StepInputTypeEnum.Options) { //Logger.Verbose(stepBefore.HeaderText + " : " + step.NavigationText); //Logger.Verbose(""); stepAnswersList.Add(new StepAnswer { AnswerValue = step.NavigationText, QuestionValue = stepBefore.HeaderText }); } else { // else if the step before the current one is of type text/numeric/date then get the answer from the dictionary string stepAnwer = ""; if (StepAnswersDictionary.TryGetValue(stepBefore.Id, out stepAnwer)) { Logger.Verbose(stepBefore.HeaderText + " : " + stepAnwer); //Logger.Verbose(""); stepAnswersList.Add(new StepAnswer { AnswerValue = stepAnwer, DataKey = stepBefore.DataKey, QuestionValue = stepBefore.HeaderText }); } } } } //set the serialiazed string of step answers StepAnswerListStringDefinition = JsonConvert.SerializeObject(stepAnswersList); //set the OutcomeId of the last step (with an Endpoint) if (lastProcessFlowStep != null) { OutComeIdString = lastProcessFlowStep.Outcome.ToString(); } //display the process flow summary ReplaceFragment(ProcessFlowSummaryFragmentInstance, Resource.Id.ticket_placeholder, SummaryFragmentTag); }
public void AddStep(object obj) { Step step = new Step(); scene.steps.Add(step); StepViewModel stepVm = new StepViewModel(this); stepVm.step = step; StepList.Add(stepVm); }
private void M_ConfirmEvent(object sender, T_LogicStep Step) { if (Step.OrderIndex == 0) { int orderIndex = 1; if (StepList.Count > 0) { orderIndex = StepList[StepList.Count - 1].OrderIndex + 1; } Step.OrderIndex = orderIndex; StepList.Add(Step); } }
public void Copy() { if (SelectedStep == null) { return; } List <T_LogicStep> selsteps = new List <T_LogicStep>(SelectedStep.ToArray()); foreach (var selstep in selsteps) { var NewStep = TransExpUtil <T_LogicStep, T_LogicStep> .Trans(selstep); NewStep.ID = 0; int orderIndex = 1; if (StepList.Count > 0) { orderIndex = StepList[StepList.Count - 1].OrderIndex + 1; } NewStep.OrderIndex = orderIndex; StepList.Add(NewStep); } }
internal void SetPivotVariable(GremlinVariable newPivotVariable) { PivotVariable = newPivotVariable; StepList.Add(newPivotVariable); newPivotVariable.HomeContext = this; }
public async void ShowStep(Step processFlowStep) { //either display the step or remove it from the persisted step list if (processFlowStep != null) { var stepToAddRemove = processFlowStep; if (StepList.Contains(stepToAddRemove)) { //text/numeric/date input answers to be removed from state if (stepToAddRemove.Type != (int)StepInputTypeEnum.Options) { //remove the saved answer from persisted state StepAnswersDictionary.Remove(stepToAddRemove.Id); } //if it already exists in the persisted step list, remove it StepList.Remove(stepToAddRemove); if (StepList.Any()) { //and get the step before it stepToAddRemove = StepList.Last(); } else { //if after removing and there are no more steps, go back to the previous activity base.OnBackPressed(); } } else { //if it doesnt exist in the persisted step list, add it StepList.Add(stepToAddRemove); } //instantiate a new Step Fragment var processFlowFragment = new ProcessFlowFragment(); Bundle args = new Bundle(); //serialize the object to a step definition string var processFlowString = JsonConvert.SerializeObject(stepToAddRemove); //pass the step string definition to the fragment in the bundle args.PutString(ProcessFlowStep, processFlowString); // if the step to be shown is a text/numeric/date input, check the dictionary for a saved answer entered previously and pass it to the fragment if (stepToAddRemove.Type != (int)StepInputTypeEnum.Options) { string stepAnwer = null; if (StepAnswersDictionary.TryGetValue(stepToAddRemove.Id, out stepAnwer)) { Logger.Verbose(stepToAddRemove.HeaderText + " : Answer found in Dictionary to be shown in Fragment : " + stepAnwer); } args.PutString(ProcessFlowStepAnswer, stepAnwer); } processFlowFragment.Arguments = args; //display the fragment ReplaceFragment(processFlowFragment, Resource.Id.ticket_placeholder, TicketFragmentTag); } }
protected void AddStep(ScenarioStep step) { StepList.Add(step); }
internal void SetPivotVariable(GremlinVariable newPivotVariable) { PivotVariable = newPivotVariable; StepList.Add(newPivotVariable); }