public async Task <List <string> > PostWord() { var signHereUrlList = new List <string>(); HttpRequestMessage request1 = this.Request; if (request1.Content.IsMimeMultipartContent()) { var wordHandler = new WordSignRequest(); var provider = new MultipartMemoryStreamProvider(); await Request.Content.ReadAsMultipartAsync(provider); foreach (var item in provider.Contents) { var param = item.Headers.ContentDisposition.Parameters; var orgname = param.First(x => x.Name == "orgname").Value; var language = param.First(x => x.Name == "language").Value; var method = param.First(x => x.Name == "method").Value; //var docName = item.Headers.ContentDisposition.FileName; //docName = Helpers.HandleFileName(docName); //docName = Encoding.UTF8.GetString(Convert.FromBase64String(docName)); if (HttpContext.Current.Request.Files.Count < 1) { return(null); } var file = HttpContext.Current.Request.Files[0]; //var docName = Encoding.UTF8.GetString(Convert.FromBase64String(file.FileName)); //HttpPostedFile postedFile = HttpContext.Current.Request.Files[docName]; //if (postedFile != null) //{ //string orgname = "processpilots"; sdsdocument uploadedDocument = await wordHandler.UploadDocument(file, item); var url = wordHandler.CreateSignRequest(uploadedDocument, orgname, language, Convert.ToInt32(method)); signHereUrlList.Add(url); return(signHereUrlList); //} } } return(null); }
internal async Task <sdsdocument[]> UploadDocument(List <HttpPostedFile> postedFiles) { try { var sdsdocuments = new sdsdocument[postedFiles.Count]; var httpClientHandler = new HttpClientHandler { Credentials = new NetworkCredential("prosesspilotene", "Bond007") }; using (var client = new HttpClient(httpClientHandler)) { for (int i = 0; i < postedFiles.Count; i++) { var helpers = new Helpers(); string documentId = ""; if (postedFiles[i].ContentType == "application/pdf") { var fileBytes = helpers.ReadToEnd(postedFiles[i].InputStream); HttpContent content = new ByteArrayContent(fileBytes); content.Headers.ContentType = new MediaTypeHeaderValue(postedFiles[i].ContentType); HttpResponseMessage response = await client.PostAsync("https://preprod.signicat.com/doc/prosesspilotene/sds", content); documentId = await response.Content.ReadAsStringAsync(); } var docName = postedFiles[i].FileName.Split('.'); if (string.IsNullOrWhiteSpace(documentId)) { return(null); } sdsdocuments[i] = new sdsdocument { id = docName[0], refsdsid = documentId, description = docName[0] }; } return(sdsdocuments); } } catch (Exception ex) { throw new Exception(ex.Message); } }
private document[] GetDocuments(sdsdocument[] documentInSds, List <ContactInfo> recipients) { try { var documents = new document[documentInSds.Length]; for (int i = 0; i < documentInSds.Length; i++) { var doc = new sdsdocument { id = documentInSds[i].id, //id = "doc_" + i, refsdsid = documentInSds[i].refsdsid, description = documentInSds[i].description }; documents[i] = doc; } return(documents); } catch (Exception ex) { throw new Exception(ex.Message); } }
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)); }