public ActionResult Sign(string SPHostURL, string SPListItemId, string SPListId, string SPSource, string SPListURLDir, string SPItemUrl, string Method) { // Prepare the document var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); var document = GetDocumentForSigningFromSPList(spContext, SPListId, SPListItemId); // Prepare the request to the Signicat document service var request = GetRequest(document, Method, SPListId, SPSource, SPListURLDir); // Send the request to Signicat createrequestresponse response; using (var client = new DocumentEndPointClient()) { response = client.createRequest(request); } // And then forward the end user to the signature process URL String signHereUrl = String.Format("https://{0}.signicat.com/std/docaction/{1}?request_id={2}&task_id={3}&artifact={4}", "preprod", "signicat", response.requestid[0], request.request[0].task[0].id, response.artifact); return(Redirect(signHereUrl)); }
internal taskstatusinfo[] getStatus(string requestId) { try { using (var client = new DocumentEndPointClient()) { var request = new getstatusrequest { password = "******", service = "prosesspilotene", requestid = new string[] { requestId } }; var taskStatusInfo = client.getStatus(request); return(taskStatusInfo); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Return(string rid, string SPListId, string documentName, string SPSource, string SPListURLDir) { // Get the tokens string spAppToken = Request.Cookies["SPAppToken"].Value; string spHostURL = Request.Cookies["SPHostURL"].Value; using (var client = new DocumentEndPointClient()) { var getStatusResponse = client.getStatus(new getstatusrequest { password = PASSWORD, service = SERVICE, requestid = new string[] { rid } }); // If there's no signature result available, we assume it's been cancelled // and just send the user back to the document list he/she came from if (getStatusResponse.First().documentstatus == null) { return Redirect(SPSource); } // Otherwise, we get the URI to the SDO (signed document object) string resultUri = getStatusResponse.First().documentstatus.First().resulturi; // Let's just use an old school HTTP WebClient with Basic authentication // to download the signed document from Signicat Session Data Storage byte[] sdo; string contentType; using (var webClient = new System.Net.WebClient()) { webClient.Credentials = new System.Net.NetworkCredential(SERVICE, PASSWORD); sdo = webClient.DownloadData(resultUri); contentType = webClient.ResponseHeaders["Content-Type"]; } // Now, let's upload it to the same document list as the original SharePointContextToken contextToken = TokenHelper.ReadAndValidateContextToken(spAppToken, Request.Url.Authority); string accessToken = TokenHelper.GetAccessToken(contextToken, new Uri(spHostURL).Authority).AccessToken; using (var clientContext = TokenHelper.GetClientContextWithAccessToken(spHostURL.ToString(), accessToken)) { if (clientContext != null) { List list = clientContext.Web.Lists.GetById(Guid.Parse(SPListId)); var fileCreationInformation = new FileCreationInformation { Content = sdo, Overwrite = true, Url = spHostURL + SPListURLDir + "/" + documentName + " - SIGNED" + GetFileExtensionForContentType(contentType) }; var uploadFile = list.RootFolder.Files.Add(fileCreationInformation); uploadFile.ListItemAllFields.Update(); clientContext.ExecuteQuery(); } } } return Redirect(SPSource); }
public ActionResult Return(string rid, string SPListId, string documentName, string SPSource, string SPListURLDir) { // Get the tokens string spAppToken = Request.Cookies["SPAppToken"].Value; string spHostURL = Request.Cookies["SPHostURL"].Value; using (var client = new DocumentEndPointClient()) { var getStatusResponse = client.getStatus(new getstatusrequest { password = PASSWORD, service = SERVICE, requestid = new string[] { rid } }); // If there's no signature result available, we assume it's been cancelled // and just send the user back to the document list he/she came from if (getStatusResponse.First().documentstatus == null) { return(Redirect(SPSource)); } // Otherwise, we get the URI to the SDO (signed document object) string resultUri = getStatusResponse.First().documentstatus.First().resulturi; // Let's just use an old school HTTP WebClient with Basic authentication // to download the signed document from Signicat Session Data Storage byte[] sdo; string contentType; using (var webClient = new System.Net.WebClient()) { webClient.Credentials = new System.Net.NetworkCredential(SERVICE, PASSWORD); sdo = webClient.DownloadData(resultUri); contentType = webClient.ResponseHeaders["Content-Type"]; } // Now, let's upload it to the same document list as the original SharePointContextToken contextToken = TokenHelper.ReadAndValidateContextToken(spAppToken, Request.Url.Authority); string accessToken = TokenHelper.GetAccessToken(contextToken, new Uri(spHostURL).Authority).AccessToken; using (var clientContext = TokenHelper.GetClientContextWithAccessToken(spHostURL.ToString(), accessToken)) { if (clientContext != null) { List list = clientContext.Web.Lists.GetById(Guid.Parse(SPListId)); var fileCreationInformation = new FileCreationInformation { Content = sdo, Overwrite = true, Url = spHostURL + SPListURLDir + "/" + documentName + " - SIGNED" + GetFileExtensionForContentType(contentType) }; var uploadFile = list.RootFolder.Files.Add(fileCreationInformation); uploadFile.ListItemAllFields.Update(); clientContext.ExecuteQuery(); } } } return(Redirect(SPSource)); }
/// <summary> /// /// </summary> /// <param name="requestId"></param> /// <returns></returns> internal taskstatusinfo[] GetStatus(string requestId) { using (var client = new DocumentEndPointClient()) { var request = new getstatusrequest { password = "******", service = "prosesspilotene", requestid = new string[] { requestId } }; var taskStatusInfo = client.getStatus(request); return(taskStatusInfo); } }
internal void AddSmsNotification(createrequestresponse response, createrequestrequest request, SigningInfo signingInfo, int i, string url, string phonenr) { using (var client = new DocumentEndPointClient()) { var smsnotify = new notification { notificationid = "send_sms_" + i, type = notificationtype.SMS, recipient = phonenr, message = signingInfo.SMSText + " " + url }; var notifySmsReq = new addnotificationrequest { service = "prosesspilotene", notification = smsnotify, password = "******", requestid = response.requestid[0], taskid = request.request[0].task[i].id }; client.addNotification(notifySmsReq); } }
public string CreateSignRequest(sdsdocument uploadedDocument, string customerorg, string language, int method) { var lang = "en"; if (language == "1044") { lang = "nb"; } var signmethodText = new SignatureHandler().GetMethod(method); var signInfo = new SigningInfo(); signInfo.signingMetodText = signmethodText; signInfo.isInk = true; var authMethod = new SignatureHandler().GetAuthSignatures(signInfo); var signatures = new SignatureHandler().GetSignatures(signInfo); bool bundle = signInfo.signingMetodText == "nbid"; var request = new createrequestrequest { password = "******", service = "prosesspilotene", request = new request[] { new request { clientreference = "cliref1", language = lang, profile = "default", document = new document[] { new sdsdocument { id = uploadedDocument.id, refsdsid = uploadedDocument.refsdsid, description = uploadedDocument.description } }, subject = new subject[] { new subject { id = "subj_1", mobile = "99999999" //nationalid = "1909740939" } }, task = new task[] { new task { id = "task_1", subjectref = "subj_1", bundle = true, bundleSpecified = bundle, documentaction = new documentaction[] { new documentaction { type = documentactiontype.sign, documentref = uploadedDocument.id } }, authenticationbasedsignature = authMethod, signature = signatures } } } } }; for (int i = 0; i < request.request[0].task.Length; i++) { var callbackOnTaskCompleteUrl = "https://prosesspilotenesignicatwebapi-preprod.azurewebsites.net:443/api/Callback/Landingpage?lcid=" + Convert.ToString(language); var callbackNotificationUrl = "https://prosesspilotenesignicatwebapi-preprod.azurewebsites.net:443/api/Callback/GetSigning?orgname=" + customerorg; request.request[0].task[i].ontaskcomplete = callbackOnTaskCompleteUrl; request.request[0].task[i].notification = new[] { new notification { notificationid = "req_callback_" + i, type = notificationtype.URL, recipient = callbackNotificationUrl, message = "callbackurl", schedule = new [] { new schedule { stateis = taskstatus.completed } } } }; } createrequestresponse response; using (var client = new DocumentEndPointClient()) { response = client.createRequest(request); } return (String.Format("https://preprod.signicat.com/std/docaction/prosesspilotene?request_id={0}&task_id={1}", response.requestid[0], request.request[0].task[0].id)); }
public async Task <List <string> > Post() { var signHereUrlList = new List <string>(); if (HttpContext.Current.Request.Files.AllKeys.Any()) { var postedFiles = new List <HttpPostedFile>(); // Get the uploaded image from the Files collection for (int i = 0; i < HttpContext.Current.Request.Files.Count; i++) { postedFiles.Add(HttpContext.Current.Request.Files["file" + i]); } // Get the uploaded recipients var recipients = new List <ContactInfo>(); var postedRecipientEmails = HttpContext.Current.Request.Params["RecipientEmails"]; var postedRecipientMobiles = HttpContext.Current.Request.Params["RecipientMobiles"]; //var postedRecipientSSN = HttpContext.Current.Request.Params["RecipientSSN"]; if (postedRecipientEmails != null) { var recipientEmailList = postedRecipientEmails.Split(','); var recipientMobileList = postedRecipientMobiles.Split(','); //var recipientSSNList = postedRecipientSSN.Split(','); for (int i = 0; i < recipientEmailList.Length; i++) { if (recipientEmailList[i] == "null") { continue; } var contactInfo = new ContactInfo(); contactInfo.email = recipientEmailList[i]; contactInfo.mobile = recipientMobileList[i]; //contactInfo.ssn = recipientSSNList[i]; recipients.Add(contactInfo); } } var signingInfo = Helpers.GetSignInfo(HttpContext.Current.Request); if (postedFiles.Count > 0) { var signHandler = new SignRequestHandler(); sdsdocument[] uploadedDocuments = await signHandler.UploadDocument(postedFiles); if (uploadedDocuments == null) { return(null); } signingInfo.signingMetodText = new SignatureHandler().GetMethod(signingInfo.signMethod); //signingInfo.isInk = new SignatureHandler().CheckIfInk(signingInfo.signMethod); createrequestrequest request = signHandler.GetCreateRequest(uploadedDocuments, recipients, signingInfo); new SignatureHandler().AddAuthMethod(signingInfo, request); try { createrequestresponse response; using (var client = new DocumentEndPointClient()) { response = client.createRequest(request); } for (int i = 0; i < request.request[0].task.Length; i++) { var url = String.Format( "https://preprod.signicat.com/std/docaction/prosesspilotene?request_id={0}&task_id={1}", response.requestid[0], request.request[0].task[i].id); signHereUrlList.Add(url); var phonenr = request.request[0].task[i].subject.mobile; if (signingInfo.SendSMS && !string.IsNullOrWhiteSpace(phonenr)) { new NotificationHandler().AddSmsNotification(response, request, signingInfo, i, url, phonenr); } } } catch (Exception ex) { throw new Exception(ex.Message); } } } return(signHereUrlList); }
public ActionResult Sign(string SPHostURL, string SPListItemId, string SPListId, string SPSource, string SPListURLDir, string SPItemUrl, string Method) { // Prepare the document var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); var document = GetDocumentForSigningFromSPList(spContext, SPListId, SPListItemId); // Prepare the request to the Signicat document service var request = GetRequest(document, Method, SPListId, SPSource, SPListURLDir); // Send the request to Signicat createrequestresponse response; using (var client = new DocumentEndPointClient()) { response = client.createRequest(request); } // And then forward the end user to the signature process URL String signHereUrl = String.Format("https://{0}.signicat.com/std/docaction/{1}?request_id={2}&task_id={3}&artifact={4}", "preprod", "signicat", response.requestid[0], request.request[0].task[0].id, response.artifact); return Redirect(signHereUrl); }