コード例 #1
0
        public long WriteToClientDocumentation(string fileName, byte[] pdfBytes, int clientId, long? siteId)
        {
            long documentID = 0;

            var fullFileName = _holdingPath + Guid.NewGuid();
            try
            {
                _impersonator.ImpersonateValidUser(_username, _domain, _encryptedPassword);
                File.WriteAllBytes(fullFileName, pdfBytes);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _impersonator.Dispose();
            }

            using(var securityService = new SecurityServiceClient())
            using (new OperationContextScope(securityService.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Username", "Peninsula.Common", "SafeCheckUser"));
                securityService.EnsureUserExists(null);
            }

            using(var clientDocumentService = new ClientDocumentServiceClient())
            using (new OperationContextScope(clientDocumentService.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Username", "Peninsula.Common", "SafeCheckUser"));

                var createClientDocumentRequest = new CreateClientDocumentRequest()
                                                      {
                                                          ClientId = clientId,
                                                          DocumentTypeId = 131, //MAGIC NUMBER: refactor out
                                                          OriginalFilename = fileName,
                                                          PhysicalFilePath = fullFileName,
                                                          Title = fileName,
                                                          SiteId = siteId
                                                      };

                documentID = clientDocumentService.CreateDocument(createClientDocumentRequest);
            }

            File.Delete(fullFileName);

            return documentID;
        }
コード例 #2
0
 public long CreateDocument(CreateClientDocumentRequest request)
 {
     throw new NotImplementedException();
 }