Exemplo n.º 1
0
        public DocuViewareRESTOutputResponse GetDocuViewareControl(DocuViewareConfiguration controlConfiguration)
        {
            String path     = String.Empty;
            string userType = String.Empty;

            if (!DocuViewareManager.IsSessionAlive(controlConfiguration.SessionId))
            {
                if (!string.IsNullOrEmpty(controlConfiguration.SessionId) && !string.IsNullOrEmpty(controlConfiguration.ControlId))
                {
                    DocuViewareManager.CreateDocuViewareSession(controlConfiguration.SessionId, controlConfiguration.ControlId, WebApiApplication.SESSION_TIMEOUT);
                }
                else
                {
                    throw new Exception("Invalid session identifier and/or invalid control identifier.");
                }
            }
            using (DocuVieware docuVieware = new DocuVieware(controlConfiguration.SessionId))
            {
                docuVieware.AllowPrint                       = controlConfiguration.AllowPrint;
                docuVieware.EnablePrintButton                = controlConfiguration.EnablePrintButton;
                docuVieware.AllowUpload                      = controlConfiguration.AllowUpload;
                docuVieware.EnableFileUploadButton           = controlConfiguration.EnableFileUploadButton;
                docuVieware.CollapsedSnapIn                  = controlConfiguration.CollapsedSnapIn;
                docuVieware.ShowAnnotationsSnapIn            = controlConfiguration.ShowAnnotationsSnapIn;
                docuVieware.EnableRotateButtons              = controlConfiguration.EnableRotateButtons;
                docuVieware.EnableZoomButtons                = controlConfiguration.EnableZoomButtons;
                docuVieware.EnablePageViewButtons            = controlConfiguration.EnablePageViewButtons;
                docuVieware.EnableMultipleThumbnailSelection = controlConfiguration.EnableMultipleThumbnailSelection;
                docuVieware.EnableMouseModeButtons           = controlConfiguration.EnableMouseModeButtons;
                docuVieware.EnableFormFieldsEdition          = controlConfiguration.EnableFormFieldsEdition;
                docuVieware.EnableTwainAcquisitionButton     = controlConfiguration.EnableTwainAcquisitionButton;
                docuVieware.EnableSaveButton                 = controlConfiguration.EnableSaveButton;
                docuVieware.MaxUploadSize                    = 36700160; // 35MB



                using (StringWriter controlOutput = new StringWriter())
                {
                    docuVieware.RenderControl(controlOutput);
                    docuVieware.Dispose();
                    DocuViewareRESTOutputResponse output = new DocuViewareRESTOutputResponse
                    {
                        HtmlContent = controlOutput.ToString()
                    };

                    return(output);
                }
            }
        }
Exemplo n.º 2
0
 public IActionResult GetDocuViewareControl([FromBody] DocuViewarConfiguration controlConfiguration)
 {
     if (!DocuViewareManager.IsSessionAlive(controlConfiguration.SessionId))
     {
         if (!string.IsNullOrEmpty(controlConfiguration.SessionId) && !string.IsNullOrEmpty(controlConfiguration.ControlId))
         {
             DocuViewareManager.CreateDocuViewareSession(controlConfiguration.SessionId,
                                                         controlConfiguration.ControlId, 20);
         }
         else
         {
             throw new Exception("Invalid session identifier and/or invalid control identifier.");
         }
     }
     using var docuVieware = new DocuViewareControl(controlConfiguration.SessionId)
           {
               AllowPrint                       = controlConfiguration.AllowPrint,
               EnablePrintButton                = controlConfiguration.EnablePrintButton,
               AllowUpload                      = controlConfiguration.AllowUpload,
               EnableFileUploadButton           = controlConfiguration.EnableFileUploadButton,
               CollapsedSnapIn                  = controlConfiguration.CollapsedSnapIn,
               ShowAnnotationsSnapIn            = controlConfiguration.ShowAnnotationsSnapIn,
               EnableRotateButtons              = controlConfiguration.EnableRotateButtons,
               EnableZoomButtons                = controlConfiguration.EnableZoomButtons,
               EnablePageViewButtons            = controlConfiguration.EnablePageViewButtons,
               EnableMultipleThumbnailSelection = controlConfiguration.EnableMultipleThumbnailSelection,
               EnableMouseModeButtons           = controlConfiguration.EnableMouseModeButtons,
               EnableFormFieldsEdition          = controlConfiguration.EnableFormFieldsEdition,
               EnableTwainAcquisitionButton     = controlConfiguration.EnableTwainAcquisitionButton,
               MaxUploadSize                    = 36700160 // 35MB
           };
     using StringWriter controlOutput = new StringWriter();
     docuVieware.RenderControl(controlOutput);
     return(new OkObjectResult(new DocuViewareRESTOutputResponse
     {
         HtmlContent = controlOutput.ToString()
     }));
 }