/// <summary> /// <c>GetInterview</c> returns an HTML fragment suitable for inclusion in any standards-mode web page, which embeds a HotDocs interview /// directly in that web page. /// </summary> /// <param name="template">An instance of the Template class, for which the interview will be requested.</param> /// <param name="answers">The initial set of answers to include in the interview.</param> /// <param name="settings">Settings that define various interview behaviors.</param> /// <param name="markedVariables">A collection of variables that should be marked with special formatting in the interview.</param> /// <param name="logRef">A string to display in logs related to this request.</param> /// <returns>An object which contains an HTML fragment to be inserted in a web page to display the interview.</returns> public InterviewResult GetInterview(Template template, TextReader answers, InterviewSettings settings, IEnumerable <string> markedVariables, string logRef) { // Validate input parameters, creating defaults as appropriate. string logStr = logRef == null ? string.Empty : logRef; if (template == null) { throw new ArgumentNullException("template", string.Format(@"WebServices.Services.GetInterview: the ""template"" parameter passed in was null, logRef: {0}", logStr)); } if (settings == null) { settings = new InterviewSettings(); } // Configure interview options InterviewOptions itvOpts = InterviewOptions.OmitImages; // Instructs HDS not to return images used by the interview; we'll get them ourselves from the template folder. if (settings.DisableDocumentPreview) { itvOpts |= InterviewOptions.NoPreview; // Disables (omits) the Document Preview button on the interview toolbar. } if (settings.DisableSaveAnswers) { itvOpts |= InterviewOptions.NoSave; // Disables (omits) the Save Answers button on the interview toolbar. } if (!settings.RoundTripUnusedAnswers) { itvOpts |= InterviewOptions.ExcludeStateFromOutput; // Prevents original answer file from being encrypted and sent to the interview and then posted back at the end. } // Get the interview. InterviewResult result = new InterviewResult(); BinaryObject[] interviewFiles = null; using (Proxy client = new Proxy(_endPointName)) { string fileName = GetRelativePath(template.GetFullPath()); interviewFiles = client.GetInterview( fileName, answers == null ? null : new BinaryObject[] { Util.GetBinaryObjectFromTextReader(answers) }, // answers settings.Format, itvOpts, markedVariables != null ? markedVariables.ToArray <string>() : null, // variables to highlight as unanswered settings.PostInterviewUrl, // page to which interview will submit its answers settings.InterviewRuntimeUrl, // location (under this app's domain name) where HotDocs Server JS files are available settings.StyleSheetUrl + "/" + settings.ThemeName + ".css", // URL of CSS stylesheet (typically called hdsuser.css). hdssystem.css must exist in same directory. Util.GetInterviewImageUrl(settings, template), // interview images will be requested from GetInterviewFile.ashx, which will stream them from the template directory !settings.DisableSaveAnswers ? settings.SaveAnswersUrl : "", //for the save answers button; if this is null the "Save Answers" button does not appear !settings.DisableDocumentPreview ? settings.DocumentPreviewUrl : "", // document previews will be requested from here; if null the "Document Preview" button does not appear Util.GetInterviewDefinitionUrl(settings, template)); // Interview definitions (Silverlight or JavaScript) will be requested from here -- careful with relative URLs!! if (interviewFiles != null) { StringBuilder interview = new StringBuilder(Util.ExtractString(interviewFiles[0])); Util.AppendSdkScriptBlock(interview, template, settings); result.HtmlFragment = interview.ToString(); // The Web Services do not have a way to set the title of the template--it always uses the title from the component file. // So here we are replacing the title that was put in the html fragment with the template's title, which may have // been set later and does not match its component file. result.HtmlFragment = Regex.Replace(result.HtmlFragment, "HDTemplateName=\\\".+?\"", "HDTemplateName=\"" + settings.Title + "\""); } SafeCloseClient(client, logRef); } return(result); }
/// <summary> /// Call GetInterview on HotDocs Server via web services. /// </summary> /// <param name="templateID"></param> /// <param name="answers"></param> /// <param name="format"></param> /// <param name="options"></param> /// <param name="markedVariables"></param> /// <param name="formActionUrl"></param> /// <param name="serverFilesUrl"></param> /// <param name="styleUrl"></param> /// <param name="tempInterviewUrl"></param> /// <param name="saveAnswersUrl"></param> /// <param name="previewUrl"></param> /// <param name="interviewDefinitionUrl"></param> /// <returns></returns> public BinaryObject[] GetInterview(string templateID, BinaryObject[] answers, InterviewFormat format, InterviewOptions options, string[] markedVariables, string formActionUrl, string serverFilesUrl, string styleUrl, string tempInterviewUrl, string saveAnswersUrl, string previewUrl, string interviewDefinitionUrl) { return(base.Channel.GetInterview(templateID, answers, format, options, markedVariables, formActionUrl, serverFilesUrl, styleUrl, tempInterviewUrl, saveAnswersUrl, previewUrl, interviewDefinitionUrl)); }