本文整理汇总了C#中System.Proxy.GetInterview方法的典型用法代码示例。如果您正苦于以下问题:C# Proxy.GetInterview方法的具体用法?C# Proxy.GetInterview怎么用?C# Proxy.GetInterview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Proxy
的用法示例。
在下文中一共展示了Proxy.GetInterview方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetInterview
/// <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;
}