Пример #1
0
        private void OnStepCompleted(NativeActivityContext context, ActivityInstance completedInstance)
        {
            int  completedInstanceIndex = this.LastIndex.Get(context);
            Step completedstep          = completedInstance.Activity as Step;

            if (completedstep.Skipped)
            {
                int         current         = completedInstanceIndex + 1;
                Queue <int> currentposition = (Queue <int>)context.Properties.Find(Constants._CurrentPosition);
                if (currentposition.Count > 0)
                {
                    currentposition.Dequeue();
                }
                currentposition.Enqueue(current);
                context.Properties.Update(Constants._CurrentPosition, currentposition);
                ScheduleStep(context, current);
            }
            else
            {
                if (!completedstep.ContainsChildWizard)
                {
                    Stack <CustomBookmark> bmlist          = context.Properties.Find(Constants._BookmarkHistory) as Stack <CustomBookmark>;
                    Queue <int>            currentPosition = context.Properties.Find(Constants._CurrentPosition) as Queue <int>;
                    CustomBookmark         currentbookmark = new CustomBookmark();
                    currentbookmark.StepID   = currentPosition.ToPlainString();
                    currentbookmark.StepName = completedInstance.Activity.DisplayName;
                    currentbookmark.HasBack  = (bool)context.Properties.Find(Constants._HasBack);
                    currentbookmark.HasNext  = (bool)context.Properties.Find(Constants._HasNext);
                    bmlist.Push(currentbookmark);
                    context.Properties.Update(Constants._BookmarkHistory, bmlist);
                }
            }
        }
        private IDictionary<string, object> ProcessCommand(Command cmd, Dictionary<string, object> input, CustomBookmark bm)
        {
            input = input ?? new Dictionary<string, object> { };

            input["BookmarkHistory"] = history;
            input["Action"] = cmd;
            input["Bookmark"] = bm;
            IDictionary<string, object> output = WorkflowInvoker.Invoke(wizard, input);
            history = output["BookmarkHistory"] as List<CustomBookmark>;
            return output;
        }
        private void OnStepCompleted(NativeActivityContext context, ActivityInstance completedInstance)
        {
            int completedInstanceIndex = this.LastIndex.Get(context);
            Step completedstep = completedInstance.Activity as Step;

            if (completedstep.Skipped)
            {
                int current = completedInstanceIndex + 1;
                Queue<int> currentposition = (Queue<int>)context.Properties.Find(Constants._CurrentPosition);
                if (currentposition.Count > 0) currentposition.Dequeue();
                currentposition.Enqueue(current);
                context.Properties.Update(Constants._CurrentPosition, currentposition);
                ScheduleStep(context, current);
            }
            else
            {
                if (!completedstep.ContainsChildWizard)
                {

                    Stack<CustomBookmark> bmlist = context.Properties.Find(Constants._BookmarkHistory) as Stack<CustomBookmark>;
                    Queue<int> currentPosition = context.Properties.Find(Constants._CurrentPosition) as Queue<int>;
                    CustomBookmark currentbookmark = new CustomBookmark();
                    currentbookmark.StepID = currentPosition.ToPlainString();
                    currentbookmark.StepName = completedInstance.Activity.DisplayName;
                    currentbookmark.HasBack = (bool)context.Properties.Find(Constants._HasBack);
                    currentbookmark.HasNext = (bool)context.Properties.Find(Constants._HasNext);
                    bmlist.Push(currentbookmark);
                    context.Properties.Update(Constants._BookmarkHistory, bmlist);

                }
            }
        }
 public IDictionary<string, object> GoTo(Dictionary<string, object> input,string StepID)
 {
     CustomBookmark bm = new CustomBookmark() { StepID = StepID };
     IDictionary<string, object> output = ProcessCommand(Command.GoTo, input, bm);
     return output;
 }
        private void Initialize(NativeActivityContext context)
        {
            Command cmd = this.Action.Get(context) as Command? ?? Command.Start;


            Stack <CustomBookmark> history = (this.BookmarkHistory.Get(context) as List <CustomBookmark>).ToStack();

            history = history ?? new Stack <CustomBookmark>();
            CustomBookmark lastbookmark = null;

            switch (cmd)
            {
            case Command.Start:
                //clear the old history
                history      = new Stack <CustomBookmark>();
                lastbookmark = null;
                break;

            case Command.Next:
                lastbookmark = history.Count > 0 ? history.Peek() : null;
                break;

            case Command.Back:
                if (history.Count > 0)
                {
                    history.Pop();
                }
                lastbookmark = (history.Count > 0) ? history.Pop() : null;
                break;

            case Command.GoTo:
                CustomBookmark inputbm  = this.Bookmark.Get(context) as CustomBookmark ?? new CustomBookmark();
                bool           Notfound = true;

                while (Notfound && history.Count > 0)
                {
                    CustomBookmark temp = history.Pop();
                    if (temp.StepID.Equals(inputbm.StepID))
                    {
                        lastbookmark = inputbm;
                        Notfound     = false;
                    }
                }

                break;
            }


            string laststepid = lastbookmark != null ? lastbookmark.StepID : string.Empty;

            context.Properties.Add(Constants._LastPosition, laststepid.ToQueue());
            //if lastbook mark is null , set the commad to start
            if (lastbookmark == null)
            {
                cmd = Command.Start;
            }

            context.Properties.Add(Constants._Command, cmd);
            context.Properties.Add(Constants._CurrentPosition, new Queue <int>());
            context.Properties.Add(Constants._BookmarkHistory, history);
            context.Properties.Add(Constants._HasNext, false);
            context.Properties.Add(Constants._HasBack, false);
        }
        public IDictionary<string, object> GoTo(Dictionary<string, object> input,CustomBookmark bm)
        {
            IDictionary<string, object> output = ProcessCommand(Command.GoTo, input, bm);
            return output;

        }