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));
        }
예제 #3
0
        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);
            }
        }