当前位置: 首页>>代码示例>>C#>>正文


C# Proxy.GetInterview方法代码示例

本文整理汇总了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;
        }
开发者ID:W800RDY,项目名称:hotdocs-open-sdk,代码行数:66,代码来源:WebService.Services.cs


注:本文中的System.Proxy.GetInterview方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。