Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiManager" /> class.
 /// </summary>
 /// <param name="securityService">A gateway into the Security subsystem.</param>
 /// <param name="formGateway">A gateway into the Forms subsystem.</param>
 /// <param name="workbenchManager">An instance that manages Workbench operations.</param>
 /// <param name="migrationDataImporter">A data importer.</param>
 /// <param name="migrationDataValidator">An import data validator.</param>
 /// <param name="apiDataAccess">The API data access layer.</param>
 /// <param name="pdfWriterSettings">A PDF writer settings object.</param>
 /// <param name="pdfFilenameFormat">The PDF filename format.</param>
 /// <param name="stringFormatter">A string formatter.</param>
 public ApiManager(
     ISecurityService securityService,
     IFormServiceGateway formGateway,
     WorkbenchManager workbenchManager,
     MigrationDataImporter migrationDataImporter,
     MigrationDataValidator migrationDataValidator,
     IDataAccess apiDataAccess,
     PdfWriterSettings pdfWriterSettings,
     string pdfFilenameFormat,
     StringFormatter stringFormatter)
 {
     this.securityService = securityService;
     this.formGateway = formGateway;
     this.workbenchManager = workbenchManager;
     this.migrationDataImporter = migrationDataImporter;
     this.migrationDataValidator = migrationDataValidator;
     this.apiDataAccess = apiDataAccess;
     this.pdfWriterSettings = pdfWriterSettings;
     this.pdfFilenameFormat = pdfFilenameFormat;
     this.stringFormatter = stringFormatter;
 }
        /// <summary>
        /// Composes the content for an HTML control, replacing placeholders with application values.
        /// </summary>
        /// <param name="sessionData">The session data.</param>
        /// <param name="formId">The form id.</param>
        /// <param name="applicationId">The application id.</param>
        /// <param name="applicationData">The application data.</param>
        /// <param name="controlName">The name of the HTML control to compose.</param>
        /// <param name="versionNumber">The version number.</param>
        /// <returns>
        /// The content for an HTML control.
        /// </returns>
        public string ComposeHtmlContent(SessionData sessionData, string formId, string applicationId, ApplicationData applicationData, string controlName, int? versionNumber = null)
        {
            Application application;
            ProductDefinition product;

            if (string.IsNullOrEmpty(applicationId))
            {
                application = new Application();
                product = this.GetProduct(formId, versionNumber);
            }
            else
            {
                RetrieveApplicationResponse response = this.GetApplicationSecure(sessionData, applicationId);
                application = response.Application;
                product = response.Product;
            }

            application.ApplicationData = applicationData;
            HtmlControl htmlControl = product.FormDefinition.Pages.AllControls.FindRecursive<HtmlControl>(controlName);
            StringFormatter formatter = new StringFormatter("{%", "%}");
            string content = formatter.Format(htmlControl.Content, application, product.FormDefinition.Pages.AllControls);
            return content;
        }