Example #1
0
        /// <summary>
        /// Called by the host application when answers have been posted back from a browser interview.
        /// </summary>
        /// <param name="interviewAnswers">The answers that were posted back from the interview.</param>
        public void FinishInterview(TextReader interviewAnswers)
        {
            // pseudocode:
            // overlay interviewAnswers over the session answer set,
            // if the current template is an interview template
            //     "assemble" it
            //     add pending assemblies to the queue as necessary
            // mark this interview workitem as complete.  (This will cause the WorkSession to advance to the next workItem.)

            AnswerCollection.OverlayXml(interviewAnswers);
            if (CurrentWorkItem is InterviewWorkItem)
            {
                InterviewResult interviewResult = _service.GetInterview(CurrentWorkItem.Template, new StringReader(AnswerCollection.XmlAnswers), InterviewSettings.Default, null, "");

                CurrentWorkItem.IsCompleted = true;
            }
        }
        /// <summary>
        /// Called by the host application when answers have been posted back from a browser interview.
        /// </summary>
        /// <param name="interviewAnswers">The answers that were posted back from the interview.</param>
        public void FinishInterview(TextReader interviewAnswers)
        {
            // overlay interviewAnswers over the session answer set,
            AnswerCollection.OverlayXml(interviewAnswers);

            // skip past completed work items to get the current workItem
            WorkItem workItem  = null;
            int      itemIndex = 0;

            for (; itemIndex < _workItems.Count; itemIndex++)
            {
                workItem = _workItems[itemIndex];
                if (!workItem.IsCompleted)
                {
                    break;
                }
                workItem = null;
            }
            if (workItem != null && workItem is InterviewWorkItem)
            {
                // if the current template is an interview template
                if (workItem.Template.TemplateType == TemplateType.InterviewOnly)
                {
                    //     "assemble" it...
                    AssembleDocumentSettings asmOpts = new AssembleDocumentSettings(DefaultAssemblySettings);
                    asmOpts.Format = DocumentType.Native;
                    // if this is not the last work item in the queue, force retention of transient answers
                    asmOpts.RetainTransientAnswers |= (itemIndex < _workItems.Count - 1);

                    // assemble the item
                    using (var asmResult = _service.AssembleDocument(workItem.Template, new StringReader(AnswerCollection.XmlAnswers), asmOpts, ""))
                    {
                        // replace the session answers with the post-assembly answers
                        AnswerCollection.ReadXml(asmResult.Answers);
                        // add pendingAssemblies to the queue as necessary
                        InsertNewWorkItems(asmResult.PendingAssemblies, itemIndex);
                    }
                }
                // mark this interview workitem as complete.  (This will cause the WorkSession to advance to the next workItem.)
                CurrentWorkItem.IsCompleted = true;
            }
        }