public ActionResult Sample19() { // Check is data posted if (Request.HttpMethod == "POST") { //### Set variables and get POST data System.Collections.Hashtable result = new System.Collections.Hashtable(); String clientId = Request.Form["clientId"]; String privateKey = Request.Form["privateKey"]; String sourceFileId = ""; String targetFileId = ""; String callbackUrl = Request.Form["callbackUrl"]; String basePath = Request.Form["basePath"]; String sourceId = Request.Form["sourceFileId"]; String targetId = Request.Form["targetFileId"]; String url = Request.Form["url"]; String targetUrl = Request.Form["targetUrl"]; String iframe = ""; var targetFile = Request.Files["targetFile"]; var file = Request.Files["file"]; // Set entered data to the results list result.Add("clientId", clientId); result.Add("privateKey", privateKey); // Check if callbackUrl is not empty if (!String.IsNullOrEmpty(callbackUrl)) { result.Add("callbackUrl", callbackUrl); } String message = null; // Check is all needed fields are entered if (String.IsNullOrEmpty(clientId) || String.IsNullOrEmpty(privateKey)) { // If not all fields entered send error message message = "Please enter all parameters"; result.Add("error", message); return View("Sample19", null, result); } else { //path to settings file - temporary save clientId and apiKey like to property file create_info_file(clientId, privateKey, ""); if (basePath.Equals("")) { basePath = "https://api.groupdocs.com/v2.0"; } // Create service for Groupdocs account GroupdocsService service = new GroupdocsService(basePath, clientId, privateKey); //if URL to web file was provided - upload the file from Web and get it's GUID if (!url.Equals("") || !targetUrl.Equals("")) { if (!url.Equals("")) { //Make request to upload file from entered Url String guid = service.UploadUrl(url); if (guid != null) { //If file uploaded return his GuId sourceFileId = guid; } //If file wasn't uploaded return error else { result.Add("error", "Something wrong with entered data"); return View("Sample19", null, result); } } if (!targetUrl.Equals("")) { //Make request to upload file from entered Url String targetGuid = service.UploadUrl(targetUrl); if (targetGuid != null) { //If file uploaded return his GuId targetFileId = targetGuid; } //If file wasn't uploaded return error else { result.Add("error", "Something wrong with entered data"); return View("Sample19", null, result); } } } //if file was uploaded locally - upload the file and get it's GUID if (!file.FileName.Equals("") || !targetFile.FileName.Equals("")) { if (!file.FileName.Equals("")) { //Upload local file Groupdocs.Api.Contract.UploadRequestResult upload = service.UploadFile(file.FileName, String.Empty, file.InputStream); if (upload.Guid != null) { //If file uploaded return his guid sourceFileId = upload.Guid; } else { //If file wasn't uploaded return error result.Add("error", "Something wrong with entered data"); return View("Sample19", null, result); } } if (!targetFile.FileName.Equals("")) { //Upload local file Groupdocs.Api.Contract.UploadRequestResult targetUpload = service.UploadFile(targetFile.FileName, String.Empty, targetFile.InputStream); if (targetUpload.Guid != null) { //If file uploaded return his guid targetFileId = targetUpload.Guid; } else { //If file wasn't uploaded return error result.Add("error", "Something wrong with entered data"); return View("Sample19", null, result); } } } if (!sourceId.Equals("") || !targetId.Equals("")) { if (!sourceId.Equals("")) { sourceFileId = sourceId; } if (!targetId.Equals("")) { targetFileId = targetId; } } result.Add("sourceFileId", sourceFileId); result.Add("targetFileId", targetFileId); result.Add("basePath", basePath); //Compare two documents and setting collback Url Groupdocs.Api.Comparison.Contract.CompareResponse compare = service.Compare(sourceFileId, targetFileId, callbackUrl); if (compare.Status.Equals("Ok")) { //Delay necessary that the inquiry would manage to be processed System.Threading.Thread.Sleep(5000); //Make request to api for get document info by job id Groupdocs.Api.Contract.GetJobDocumentsResult job = service.GetJobDocuments(compare.Result.JobId); if (job.Outputs[0].Guid != null) { // Generate Embed viewer url with entered file id if (basePath.Equals("https://api.groupdocs.com/v2.0")) { iframe = "https://apps.groupdocs.com/document-viewer/embed/" + job.Outputs[0].Guid; } if (basePath.Equals("https://dev-api-groupdocs.dynabic.com/v2.0")) { iframe = "https://dev-apps-groupdocs.dynabic.com/document-viewer/embed/" + job.Outputs[0].Guid; } if (basePath.Equals("https://stage-api-groupdocs.dynabic.com/v2.0")) { iframe = "https://stage-api-groupdocs.dynabic.com/document-viewer/embed/" + job.Outputs[0].Guid; } if (basePath.Equals("https://realtime-api.groupdocs.com/v2.0")) { iframe = "https://realtime-apps.groupdocs.com/document-viewer/embed/" + job.Outputs[0].Guid; } iframe = Groupdocs.Security.UrlSignature.Sign(iframe, privateKey); result.Add("iframe", iframe); //Return file guid to the template result.Add("guid", job.Outputs[0].Guid); return View("Sample19", null, result); } else { //If file GuId is empty return error result.Add("error", "File GuId is empty"); return View("Sample19", null, result); } } // If request return's null return error to the template else { result.Add("error", compare.ErrorMessage); return View("Sample19", null, result); } } } // If data not posted return to template for filling of necessary fields else { return View("Sample19"); } }