public ActionResult Sample40() { // 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 formGuid = Request.Form["formGuid"]; String basePath = Request.Form["basePath"]; String callbackUrl = Request.Form["callbackUrl"]; String iframe = ""; result.Add("formGuid", formGuid); result.Add("clientId", clientId); result.Add("privateKey", privateKey); String message = null; if (clientId == null || privateKey == null || formGuid == null) { // If not all fields entered send error message message = "Please enter all parameters"; result.Add("error", message); return View("Sample40", null, result); } else { //Set base path if its not entered if (basePath == "") { basePath = "https://api.groupdocs.com/v2.0"; } result.Add("basePath", basePath); // Check if callbackUrl is not empty if (!String.IsNullOrEmpty(callbackUrl)) { result.Add("callbackUrl", callbackUrl); } // Create service for Groupdocs account GroupdocsService service = new GroupdocsService(basePath, clientId, privateKey); // Create text file with user data for callbackUrl handler create_info_file(clientId, privateKey, ""); String callbackInfo = AppDomain.CurrentDomain.BaseDirectory + "callback_info.txt"; //Remove temporary file with callback info if (System.IO.File.Exists(callbackInfo)) { System.IO.File.Delete(callbackInfo); } //Set form name System.Random rand = new System.Random(); String formName = "test" + rand.Next(0, 1000); //Copy form Groupdocs.Api.Contract.Signature.SignatureFormResponse createForm = service.CreateForm("", "", formName, false, "", "", formGuid, true, false, false, false, false); //If form created if (createForm.Status.Equals("Ok")) { //Publish form Groupdocs.Api.Contract.Signature.SignatureStatusResponse postForm = service.PublishForm(createForm.Result.Form.Id, callbackUrl); if (postForm.Status.Equals("Ok")) { message = "Form is published successfully"; result.Add("message", message); //Generate iframe url if (basePath.Equals("https://api.groupdocs.com/v2.0")) { iframe = "https://apps.groupdocs.com/signature2/forms/signembed/" + createForm.Result.Form.Id; //iframe to dev server } else if (basePath.Equals("https://dev-api-groupdocs.dynabic.com/v2.0")) { iframe = "https://dev-apps-groupdocs.dynabic.com/signature2/forms/signembed/" + createForm.Result.Form.Id; //iframe to test server } else if (basePath.Equals("https://stage-api-groupdocs.dynabic.com/v2.0")) { iframe = "https://stage-apps-groupdocs.dynabic.com/signature2/forms/signembed/" + createForm.Result.Form.Id; } else if (basePath.Equals("http://realtime-api-groupdocs.dynabic.com")) { iframe = "https://relatime-apps-groupdocs.dynabic.com/signature2/forms/signembed/" + createForm.Result.Form.Id; } iframe = Groupdocs.Security.UrlSignature.Sign(iframe, privateKey); result.Add("iframe", iframe); } else { message = postForm.ErrorMessage; result.Add("error", message); } } else { message = createForm.ErrorMessage; result.Add("error", message); } return View("Sample40", null, result); } } // If data not posted return to template for filling of necessary fields else { return View("Sample40"); } }
public ActionResult Sample32() { // 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 formGuid = Request.Form["formGuid"]; String email = Request.Form["email"]; String templateGuid = Request.Form["templateGuid"]; String basePath = Request.Form["basePath"]; String callbackUrl = Request.Form["callbackUrl"]; String iframe = ""; result.Add("formGuid", formGuid); result.Add("templateGuid", templateGuid); result.Add("clientId", clientId); result.Add("privateKey", privateKey); String message = null; if (clientId == null || privateKey == null) { // If not all fields entered send error message message = "Please enter all parameters"; result.Add("error", message); return View("Sample32", null, result); } else { if (basePath == "") { basePath = "https://api.groupdocs.com/v2.0"; } result.Add("basePath", basePath); // Create service for Groupdocs account GroupdocsService service = new GroupdocsService(basePath, clientId, privateKey); // Create text file with user data for callbackUrl handler create_info_file(clientId, privateKey, email); //If user enter form GUID if (!formGuid.Equals("")) { //Post form by it's GUID Groupdocs.Api.Contract.Signature.SignatureStatusResponse postForm = service.PublishForm(formGuid, callbackUrl); //If form posted if (postForm.Status.Equals("Ok")) { message = "Form is published successfully"; result.Add("message", message); //Generate iframe url if (basePath.Equals("https://api.groupdocs.com/v2.0")) { iframe = "https://apps.groupdocs.com/signature2/forms/signembed/" + formGuid; //iframe to dev server } else if (basePath.Equals("https://dev-api.groupdocs.com/v2.0")) { iframe = "https://dev-apps.groupdocs.com/signature2/forms/signembed/" + formGuid; //iframe to test server } else if (basePath.Equals("https://stage-api-groupdocs.dynabic.com/v2.0")) { iframe = "https://stage-api-groupdocs.dynabic.com/signature2/forms/signembed/" + formGuid; } else if (basePath.Equals("http://realtime-api.groupdocs.com")) { iframe = "https://relatime-apps.groupdocs.com/signature2/forms/signembed/" + formGuid; } iframe = Groupdocs.Security.UrlSignature.Sign(iframe, privateKey); result.Add("iframe", iframe); } else { message = postForm.ErrorMessage; result.Add("error", message); } } //If user enter template GUID else { //Create form settings object Groupdocs.Api.Contract.Signature.SignatureFormSettingsInfo formSettings = new Groupdocs.Api.Contract.Signature.SignatureFormSettingsInfo(); //Set notification to true formSettings.NotifyOwnerOnSign = true; //Set form name System.Random rand = new System.Random(); String formName = "test" + rand.Next(0, 1000); //Create form from template Groupdocs.Api.Contract.Signature.SignatureFormResponse createForm = service.CreateForm(templateGuid, "", formName, false, "", "", "", true, false, false, false, false); //If form created if (createForm.Status.Equals("Ok")) { //Publish form Groupdocs.Api.Contract.Signature.SignatureStatusResponse postForm = service.PublishForm(createForm.Result.Form.Id, callbackUrl); if (postForm.Status.Equals("Ok")) { message = "Form is published successfully"; result.Add("message", message); //Generate iframe url if (basePath.Equals("https://api.groupdocs.com/v2.0")) { iframe = "https://apps.groupdocs.com/signature2/forms/signembed/" + createForm.Result.Form.Id; //iframe to dev server } else if (basePath.Equals("https://dev-api.groupdocs.com/v2.0")) { iframe = "https://dev-apps.groupdocs.com/signature2/forms/signembed/" + createForm.Result.Form.Id; //iframe to test server } else if (basePath.Equals("https://stage-api-groupdocs.dynabic.com/v2.0")) { iframe = "https://stage-api-groupdocs.dynabic.com/signature2/forms/signembed/" + createForm.Result.Form.Id; } else if (basePath.Equals("http://realtime-api.groupdocs.com")) { iframe = "https://relatime-apps.groupdocs.com/signature2/forms/signembed/" + createForm.Result.Form.Id; } iframe = Groupdocs.Security.UrlSignature.Sign(iframe, privateKey); result.Add("iframe", iframe); } else { message = postForm.ErrorMessage; result.Add("error", message); } } else { message = createForm.ErrorMessage; result.Add("error", message); } } return View("Sample32", null, result); } } // If data not posted return to template for filling of necessary fields else { return View("Sample32"); } }