public FileContentResult Download(string id, string mode, AttachmentRequest request) { Tuple <Byte[], string> fileTuple; if (mode == "http") { fileTuple = _attachmentHandler.DownloadViaHttpById(id); } else if (mode == "ws") { fileTuple = _attachmentHandler.DownloadViaParentWS(id, request.ParentId, request.ParentApplication, request.ParentSchemaId); } else { throw new NotImplementedException(String.Format("{0} mode not implemented. Please use 'http' or 'ws'", mode)); } if (fileTuple != null) { var result = new FileContentResult(fileTuple.Item1, System.Net.Mime.MediaTypeNames.Application.Octet) { FileDownloadName = fileTuple.Item2 }; return(result); } else { return(null); } }
public string SaveAttachment(AttachmentRequest request) { try { DropNetClient _client = new DropNetClient(AppConstants.DropboxClientId, AppConstants.DropboxClientSecret); _client.UserLogin = Storage.Dropbox.Token; DropNet.Models.UserLogin login = _client.GetAccessToken(); Attachment attachment = AppUtility.GetAttachment(request.AttachmentId, request.AuthToken, request.EwsUrl); _client.UploadFile("/", attachment.AttachmentName, attachment.AttachmentBytes); return("Uploaded Sucessfully."); } catch (Exception s) { return(s.Message); } //return ""; }
private async Task <ICollection <Attachment> > UploadAttachments(AttachmentRequest request) { ICollection <IFormFile> files = request.FormFiles; ICollection <Attachment> response = new List <Attachment>(); Attachment model; long size = files.Sum(f => f.Length); string storagePath = _configuration["StoragePath:Key"]; foreach (IFormFile formFile in files) { if (formFile.Length > 0) { Guid g = Guid.NewGuid(); string guidString = g.ToString("N"); string originalFilename = ContentDispositionHeaderValue.Parse(formFile.ContentDisposition).FileName.Trim('"'); string[] parts = originalFilename.Split("."); string filename = $"{guidString}.{parts[parts.Length - 1]}"; using (FileStream stream = File.Create(Path.Combine(storagePath, filename))) { await formFile.CopyToAsync(stream); model = new Attachment { Comment = await _commentRepository.FindById(request.CommentId), Route = storagePath, Name = filename }; } response.Add(model); } } return(response); }
public byte[] GetAttachment(int id) { var executor = new ApiRequestExecutor(_baseUrl, _authToken); var request = new AttachmentRequest(id); return(executor.Execute <byte[]>(request)); }
public HttpResponseMessage UpdateAttachment(AttachmentRequest request) { try { var request1 = new AttachmentRequest(); var httpPostedFile = System.Web.HttpContext.Current.Request.Files["file"]; var data = System.Web.HttpContext.Current.Request.Params["file"]; if (httpPostedFile != null) { request1.AttachmentFile = ReadFully(httpPostedFile.InputStream); request1.AttachmentName = httpPostedFile.FileName; request1.AttachmentLength = httpPostedFile.ContentLength; request1.AttachmentType = httpPostedFile.ContentType; } var result = _attachmentServices.SaveAttachment(request1); if (result != 0) { return(Request.CreateResponse(HttpStatusCode.OK, new { results = result })); } return(Request.CreateResponse(HttpStatusCode.NotModified, false)); } catch (Exception exception) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception.Message)); } }
public AttachmentResponse Post([FromBody] AttachmentRequest value) { //riceve le informazioni dalla chiamata REST attraverso l'oggetto AttachmentRequest e lo passa //al metodo che effettua la chiamata al server Exchange var resp = GetAttachmentsFromExchangeServerUsingEWSManagedApi(value); return(resp); }
/// <summary> /// Adds a document to the repository /// </summary> /// <param name="attachment"></param> public void Add(AttachmentRequest attachment) { //valid attachment type. if (ValidateAttachment(attachment, "application/pdf")) { _documentRepo.Add(); } }
public async Task<IHttpActionResult> ProcessMailAttachment(AttachmentRequest request) { if (request.ServiceType == "soap") { return Ok(await O365AttachmentHelper.GetAttachmentFromEwsAndUpload(request)); } else { return Ok(await O365AttachmentHelper.GetAttachmentFromO365AndUpload(request)); } }
public AttachmentResponse GeAttachment(AttachmentRequest request) { AttachmentResponse response = new AttachmentResponse(); Attachment attachment = attachmentRepository.FindBy(Convert.ToInt16(request.AttachmentViewModel.DocumentID)); if (attachment != null) { AttachmentViewModel attachmentViewModel = Mapper.Map <Attachment, AttachmentViewModel>(attachment); response.AttachmentViewModel = attachmentViewModel; } return(response); }
public string SaveAttachment(AttachmentRequest request) { try { Attachment attachment = AppUtility.GetAttachment(request.AttachmentId, request.AuthToken, request.EwsUrl); return(SaveAttachment(attachment)); } catch (Exception e) { return("There was an exception: " + e.Message + "\n\n" + e.StackTrace); } }
public static async Task<UploadResponse> GetAttachmentFromO365AndUpload(AttachmentRequest request) { //Debug & StopWatch introduced just to calculate & overview performance with response time. Need remove once have stable. Debug.WriteLine("AttachmentUrl={0}{1}", request.ApiUrl, string.Empty); Debug.WriteLine("ApiToken=Bearer {0}{1}", request.Token, string.Empty); var uri = new Uri(request.ApiUrl); using (var client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false }) { DefaultRequestHeaders = { Authorization = new AuthenticationHeaderValue("Bearer", request.Token) } }) { client.DefaultRequestHeaders.Add("x-AnchorMailbox", request.UserEmail); var watch = Stopwatch.StartNew(); using (var response = await client.GetStreamAsync(uri)) { watch.Stop(); Debug.WriteLine("Time taken to get attachment from o365 reset api {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); using (var streamReader = new StreamReader(response)) { watch.Stop(); Debug.WriteLine("Time taken to initialize StreamReader {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); using (var jsonTextReader = new JsonTextReader(streamReader)) { watch.Stop(); Debug.WriteLine("Time taken to initialize JsonTextReader {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); var serializer = new JsonSerializer(); var attachmentResponse = serializer.Deserialize<AttachmentResponse>(jsonTextReader); watch.Stop(); Debug.WriteLine("Time taken to Deserialize {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); var bytes = Convert.FromBase64String(attachmentResponse.ContentBytes); watch.Stop(); Debug.WriteLine("Time taken to ConvertBase64 to bytes array {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); var byteArrayContent = new ByteArrayContent(bytes); watch.Stop(); Debug.WriteLine("Time taken to prepare to ByteArrayContent {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); var result = await PostDocumentAsync(byteArrayContent, request.DocumentServiceUrl, request.DocumentServiceToken); watch.Stop(); Debug.WriteLine("Time taken to post and upload on ncore server {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); return result; } } } } }
public string GetAttachment(AttachmentRequest request) { try { Attachment attachment = GetAttachment(request.AttachmentId, request.AuthToken, request.EwsUrl); System.IO.File.WriteAllBytes(@"c:\users\alexpark\desktop\temp\" + attachment.AttachmentName, attachment.AttachmentBytes); } catch (Exception e) { return("There was an exception: " + e.Message + "\n\n" + e.StackTrace); } return("Done!"); }
public void GivenIHaveANon_PdfToUpload() { //Given I have a non-pdf to upload var attachment = new AttachmentRequest() { Data = new byte[] { 0x00, 0x21, 0x60, 0x1F, 0xA1, 0xA1 }, FileName = "Chambers.pdf", Type = "application/docx", Location = "A" }; //PS: in real world we don't need the user or shouldn't trust the user to provide the mime type // When I send the non-pdf to the API _docService.Add(attachment); //Then the API does not accept the file and returns the appropriate messaging and status //Exception is thrown }
public async Task <HttpResponseMessage> SaveAttachments(string channelName, [FromBody] AttachmentRequest req) { if (req == null || !ModelState.IsValid) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState)); } ITelegramPostSaver attachment = new TelegFtpTools(req.FtpUrl, req.FtpUser, req.FtpPassword); var manager = new JobAttachmentManager(_cTools, attachment); var job = await manager.CreateJobAsync(channelName, req.FromId, req.ToId); HostingEnvironment.QueueBackgroundWorkItem(ct => manager.ExecuteJobAsync(job.Id)); return(Request.CreateResponse(HttpStatusCode.Accepted, job)); }
public HttpResponseMessage UpdateAttachment(AttachmentRequest request) { try { var result = _attachmentServices.SaveAttachment(request); if (result != 0) { return(Request.CreateResponse(HttpStatusCode.OK, new { results = result })); } return(Request.CreateResponse(HttpStatusCode.NotModified, false)); } catch (Exception exception) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exception.Message)); } }
public async Task <ActionResult> AttachmentRequest([FromForm] AttachmentRequest model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(await _attachmentService.SaveFiles(model))); } catch (Exception ex) { return(BadRequest(ex)); } }
public void GivenIhaveaPDFtoupload() { //Given I have a PDF to upload var attachment = new AttachmentRequest() { Data = new byte[] { 0x00, 0x21, 0x60, 0x1F, 0xA1, 0xA1 }, FileName = "Chambers.pdf", Type = "application/pdf" }; //PS: in real world we don't need the user or shouldn't trust the user to provide the mime type // When I send the PDF to the API _docService.Add(attachment); // Then it is uploaded successfully //no errors. Response from Add will be void. Assert.AreEqual(1, 1); }
/// <summary> /// Validates if an attachment is of a mime type /// </summary> /// <param name="attachment"></param> /// <param name="applicationPdf"></param> private bool ValidateAttachment(AttachmentRequest attachment, string applicationPdf) { //TODO: the file type needs to be got from the byte array and not the extension as this can be faked. //for the test purpose, I'm using the file extension :-) if (attachment.Type != applicationPdf) { throw new NotSupportedException("Invalid file. Only PDF's are supported"); } var MaxFileSize = 5; //move to web.config if (GetSizeInMB(attachment.Data) > MaxFileSize) { throw new NotSupportedException("Max file size is 5 MB"); } return(true); }
public int SaveAttachment(AttachmentRequest _request) { var entity = Mapper.Map<AttachmentRequest, Attachment>(_request); entity.IsDeleted = false; entity.CreatedBy = 1; entity.CreatedDate = System.DateTime.Now; entity.Remark = "None"; entity.ReportId = 1; entity.ModifiedBy = 1; entity.ModifiedDate = System.DateTime.Now; _attachmentRepository.Add(entity); if (_attachmentRepository.Commit()) { return entity.Id; } else { return 0; } }
public string SaveAttachments(AttachmentRequest request) { try { // Get the attachments using the EWS Managed API Attachment[] attachments = GetAttachmentsWithManagedApi (request.AttachmentIds, request.AuthToken, request.EwsUrl); // NOTE: The GetAttachmentsWithSOAP method doesn't use the managed // API, and instead just builds the SOAP request manually. This is // here to illustrate how this can be done without the managed API. //Attachment[] attachments = GetAttachmentsWithSOAP(request.AttachmentIds, // request.AuthToken, request.EwsUrl); return(SaveAttachments(attachments, request.UserEmail)); } catch (Exception e) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "There was an exception: " + e.Message + "\n\n" + e.StackTrace)); } }
public IEnumerable <string> Get([FromBody] AttachmentRequest request) { ExchangeService service = new ExchangeService(); service.Credentials = new OAuthCredentials(request.AttachmentToken); service.Url = new Uri(request.EWSURL); List <string> attachmentIds = request.Attachments.Select(x => x.ID).ToList(); List <string> attachmentNames = new List <string>(); var response = service.GetAttachments(attachmentIds.ToArray(), null, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent)); if (response.OverallResult == ServiceResult.Success) { foreach (var attachmentResponse in response) { attachmentNames.Add(attachmentResponse.Attachment.Name); if (attachmentResponse.Attachment is FileAttachment) { FileAttachment a = attachmentResponse.Attachment as FileAttachment; using (Stream ms = new MemoryStream(a.Content)) using (FileStream fs = new FileStream($@"C:\Users\Af\Desktop\{attachmentResponse.Attachment.Name}", FileMode.Create, FileAccess.Write)) { byte[] bytes = new byte[ms.Length]; ms.Read(bytes, 0, (int)ms.Length); fs.Write(bytes, 0, bytes.Length); } } if (attachmentResponse.Attachment is ItemAttachment) { ItemAttachment attachment = attachmentResponse.Attachment as ItemAttachment; } } } return(attachmentNames); }
public string SaveAttachment(AttachmentRequest request) { try { DriveRestClient restClient = new DriveRestClient(AppConstants.GoogleDriveClientId, AppConstants.DropboxClientSecret, googledriveRedirectUrl.ToString()); restClient.Token = Storage.GoogleDrive.Token; AttachmentsDemoWeb.Constants.Attachment attachment = AppUtility.GetAttachment(request.AttachmentId, request.AuthToken, request.EwsUrl); string uploadText = restClient.UploadFile(attachment.AttachmentName, attachment.AttachmentBytes); return("Uploaded Sucessfully."); } catch (Exception s) { return(s.Message); } //return ""; }
public async Task <Response> SaveFiles(AttachmentRequest model) { ICollection <Attachment> attachmentDTO = await UploadAttachments(model); int result = await _attachmentRepository.Create(attachmentDTO); if (result > 0) { return(new Response { IsSuccess = true, Message = Messages.Created.ToString(), Result = result }); } else { return(new Response { IsSuccess = false, Message = Messages.NotCreated.ToString() }); } }
public Task <AttachmentUploadDataResponse> PostCipherAttachmentAsync(string id, AttachmentRequest request) { return(SendAsync <AttachmentRequest, AttachmentUploadDataResponse>(HttpMethod.Post, $"/ciphers/{id}/attachment/v2", request, true, true)); }
public static async Task<UploadResponse> GetAttachmentFromEwsAndUpload(AttachmentRequest request) { var soapString = string.Format(AttachmentSoapRequest, request.Attachment.Id); using (var client = new HttpClient { DefaultRequestHeaders = { Authorization = new AuthenticationHeaderValue("Bearer", request.EwsToken) }, Timeout = TimeSpan.FromDays(1) }) { client.DefaultRequestHeaders.Add("x-AnchorMailbox", request.UserEmail); var uri = new Uri(request.EwsUrl); var watch = Stopwatch.StartNew(); var contentRequest = new StringContent(soapString, Encoding.UTF8, "text/xml"); using (var response = await client.PostAsync(uri, contentRequest)) { Debug.WriteLine("Time taken to post to EWS {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); using (var stream = await response.Content.ReadAsStreamAsync()) { Debug.WriteLine("Time taken to read Stream {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); ByteArrayContent contentToUpload = null; using (var xmlReader = XmlReader.Create(stream)) { Debug.WriteLine("Time create xml reader {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); var contentFound = false; while (xmlReader.Read()) { if (contentFound && xmlReader.NodeType == XmlNodeType.Text) { watch.Stop(); Debug.WriteLine("Time taken to Reach to cotent in xml stream {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); var bytes = Convert.FromBase64String(xmlReader.Value); watch.Stop(); Debug.WriteLine("Time taken to ConvertBase64 to bytes array {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); watch = Stopwatch.StartNew(); contentToUpload = new ByteArrayContent(bytes); watch.Stop(); Debug.WriteLine("Time taken to prepare to ByteArrayContent {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); break; } if (!xmlReader.Name.Equals("t:Content")) continue; contentFound = true; } watch = Stopwatch.StartNew(); var result = await PostDocumentAsync(contentToUpload, request.DocumentServiceUrl, request.DocumentServiceToken); watch.Stop(); Debug.WriteLine("Time taken to post and upload on ncore server {0}ms. AttachmentName={1} Size={2}", watch.ElapsedMilliseconds, request.Attachment.Name, request.Attachment.Size); return result; } } } } }
private AttachmentResponse GetAttachmentsFromExchangeServerUsingEWSManagedApi(AttachmentRequest request) { var attachmentsProcessedCount = 0; var attachmentNames = new List <string>(); // Creo un oggetto di tipo ExchangeService ExchangeService service = new ExchangeService(); //imposto il token di autenticazione ricevuto dall'add-in service.Credentials = new OAuthCredentials(request.attachmentToken); //imposto la url del server Exchange service.Url = new Uri(request.ewsUrl); // Richiede gli allegati al server var getAttachmentsResponse = service.GetAttachments( request.attachments.Select(a => a.id).ToArray(), null, new PropertySet(BasePropertySet.FirstClassProperties, ItemSchema.MimeContent)); if (getAttachmentsResponse.OverallResult == ServiceResult.Success) { foreach (var attachmentResponse in getAttachmentsResponse) { attachmentNames.Add(attachmentResponse.Attachment.Name); if (attachmentResponse.Attachment is FileAttachment) { //mette il contenuto dell'allegato in uno stream FileAttachment fileAttachment = attachmentResponse.Attachment as FileAttachment; Stream s = new MemoryStream(fileAttachment.Content); // Qui è possibile processare il contenuto dell'allegato } if (attachmentResponse.Attachment is ItemAttachment) { //mette il contenuto dell'allegato in uno stream ItemAttachment itemAttachment = attachmentResponse.Attachment as ItemAttachment; Stream s = new MemoryStream(itemAttachment.Item.MimeContent.Content); // Qui è possibile processare il contenuto dell'allegato } attachmentsProcessedCount++; } } // La risposta contiene il nome ed il numero degli allegati che sono stati // processati dal servizio var response = new AttachmentResponse(); response.attachmentNames = attachmentNames.ToArray(); response.attachmentsProcessed = attachmentsProcessedCount; return(response); }
private void Send(long contractId, List <long> documentIds) { //设置接收人,名称、联系方式必填 List <Receiver> receivers = new List <Receiver>(); List <StandardStamper> platestampers = new List <StandardStamper>(); //指定本方签署位置 StandardStamper sealStamper = new StandardStamper(); sealStamper.documentId = documentIds[0]; sealStamper.page = 1; sealStamper.offsetX = 0.5; sealStamper.offsetY = 0.5; sealStamper.type = StandardSignType.SEAL; StandardStamper stStamper = new StandardStamper(); stStamper.documentId = documentIds[0]; stStamper.page = 1; stStamper.offsetX = 0.5; stStamper.offsetY = 0.45; stStamper.type = StandardSignType.SEAL_TIMESTAMP; // StandardStamper lpStamper = new StandardStamper(); // lpStamper.documentId = documentIds[1]; // lpStamper.page = 1; // lpStamper.offsetX = 0.6; // lpStamper.offsetY = 0.2; // lpStamper.type = StandardSignType.LEGAL_PERSON; platestampers.Add(sealStamper); platestampers.Add(stStamper); //platestampers.Add(lpStamper); //需要本方签署,则将本方加入接收者列表 Receiver platform = new Receiver(); platform.type = AccountType.PLATFORM; platform.ordinal = 0; platform.stampers = platestampers; //指定签署位置 platform.legalPersonRequired = false; //指定法人签署 receivers.Add(platform); StandardStamper pStamper = new StandardStamper(); pStamper.documentId = documentIds[0]; pStamper.page = 1; pStamper.offsetX = 0.64; pStamper.offsetY = 0.105; pStamper.type = StandardSignType.PERSONAL; StandardStamper ptStamper = new StandardStamper(); ptStamper.documentId = documentIds[0]; ptStamper.page = 1; ptStamper.offsetX = 0.655; ptStamper.offsetY = 0.058; ptStamper.type = StandardSignType.PERSONAL_TIMESTAMP; StandardStamper pStamper_d = new StandardStamper(); pStamper_d.documentId = documentIds[0]; pStamper_d.page = 1; pStamper_d.offsetX = 0.658; pStamper_d.offsetY = 0.09; pStamper_d.type = StandardSignType.PERSONAL; StandardStamper ptStamper_d = new StandardStamper(); ptStamper_d.documentId = documentIds[0]; ptStamper_d.page = 1; ptStamper_d.keyword = null; ptStamper_d.offsetX = 0.662; ptStamper_d.offsetY = 0.05; ptStamper_d.type = StandardSignType.PERSONAL_TIMESTAMP; List <StandardStamper> personalStampers = new List <StandardStamper>(); personalStampers.Add(pStamper); personalStampers.Add(ptStamper); personalStampers.Add(pStamper_d); personalStampers.Add(ptStamper_d); Receiver receiver = new Receiver(); receiver.name = "张忱昊"; receiver.mobile = "17621699044"; receiver.type = AccountType.PERSONAL; receiver.authLevel = AuthenticationLevel.BASIC; receiver.ordinal = 1; receiver.stampers = personalStampers;//个人签署位置 List <AttachmentRequest> attachments = new List <AttachmentRequest>(); AttachmentRequest attachmentRequest1 = new AttachmentRequest(); attachmentRequest1.title = "附件名称"; attachmentRequest1.required = true; attachmentRequest1.needSign = false; attachments.Add(attachmentRequest1); receiver.attachments = attachments; receivers.Add(receiver); List <DocumentParam> documentParams = new List <DocumentParam>(); DocumentParam documentParam1 = new DocumentParam(); documentParam1.documentId = documentIds[0]; documentParam1.name = "参数名称"; documentParam1.value = "参数默认值"; documentParam1.receiverNo = 1; documentParams.Add(documentParam1); SendRequest request = new SendRequest(); request.contractId = contractId; //指定发起的合同ID request.categoryId = null; //不指定业务分类 request.receivers = receivers; request.documentParams = documentParams; request.receiveType = ReceiveType.SEQ;//设置签署人顺序签署 try { signService.Send(request); Console.WriteLine("合同成功发起!"); } catch (Exception e) { throw e; } }
public AttachmentResponse DeleteAttachment(AttachmentRequest request) { attachmentRepository.DeleteAttachment(request.AttachmentViewModel.DocumentID); return(new AttachmentResponse()); }
public TicketSaveResponse Save([FromBody] Ticket ticket) { if (ticket.Attachments != null && ticket.Attachments.Count != 0) { if (string.IsNullOrEmpty(ticket.AttachmentToken)) { return(new TicketSaveResponse { Status = "failed", Message = "Attachment token missing", Ticket = ticket }); } if (string.IsNullOrEmpty(ticket.EWSURL)) { return(new TicketSaveResponse { Status = "failed", Message = "EWS Url missing", Ticket = ticket }); } if (string.IsNullOrEmpty(ticket.EmailId)) { return(new TicketSaveResponse { Status = "failed", Message = "EmailId missing", Ticket = ticket }); } if (string.IsNullOrEmpty(ticket.ConversationId)) { return(new TicketSaveResponse { Status = "failed", Message = "ConversationId missing", Ticket = ticket }); } } //get attachments var selectedAttachments = ticket.Attachments.Where(x => x.Selected); if (selectedAttachments.Count() != 0) { AttachmentRequest attachmentRequest = new AttachmentRequest { Attachments = selectedAttachments.ToArray(), AttachmentToken = ticket.AttachmentToken, EWSURL = ticket.EWSURL }; ExchangeAttachmentService.GetAttachments(attachmentRequest); } //save ticket ticket.TicketId = 9999; return(new TicketSaveResponse { Status = "success", Ticket = ticket }); }