/// <summary>
        /// Acts as entry point from service to place the request to upload email/attachment. Reads the web request headers and requests applicable methods based on headers.
        /// </summary>
        /// <param name="requestObject">The request object.</param>
        /// <param name="client">The client object</param>
        /// <param name="serviceRequest">The Service request object</param>
        /// <param name="soapRequest">The SOAP request</param>
        /// <param name="attachmentOrMailID">The attachment or mail identifier.</param>
        /// <param name="isMailUpload">Mail upload check</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="folderPath">The folder path.</param>
        /// <param name="isFirstCall">Determines if it is first call or not</param>
        /// <param name="message">Reference object for the message to be returned</param>
        /// <param name="originalFileName">Original file name of the attachment</param>
        /// <returns>It returns a string object, that contains the execution status of the function.</returns>
        internal static string Upload(RequestObject requestObject, Client client, ServiceRequest serviceRequest, string soapRequest, string attachmentOrMailID, bool isMailUpload, string fileName, string folderPath, bool isFirstCall, ref string message, string originalFileName)
        {
            string result = ConstantStrings.UploadFailed;
            try
            {
                if (null != requestObject && null != client && null != serviceRequest && !string.IsNullOrWhiteSpace(soapRequest) && !string.IsNullOrWhiteSpace(attachmentOrMailID) && !string.IsNullOrWhiteSpace(fileName) && !string.IsNullOrWhiteSpace(folderPath))
                {
                    string documentLibraryName = serviceRequest.DocumentLibraryName;

                    //// Make the request to the Exchange server and get the response.
                    HttpWebResponse webResponse = UploadHelperFunctionsUtility.GetWebResponse(serviceRequest.EwsUrl, serviceRequest.AttachmentToken, soapRequest, attachmentOrMailID);

                    if (!isFirstCall)
                    {
                        XmlDocument xmlDocument = RetrieveXMLDocument(webResponse);
                        string attachmentID = string.Empty;
                        //// Check original file name is empty
                        if (!string.IsNullOrWhiteSpace(originalFileName))
                        {
                            attachmentID = UploadHelperFunctionsUtility.GetAttachmentID(xmlDocument, originalFileName);
                        }
                        else
                        {
                            attachmentID = UploadHelperFunctionsUtility.GetAttachmentID(xmlDocument, fileName);
                        }
                        if (!string.IsNullOrWhiteSpace(attachmentID))
                        {
                            attachmentOrMailID = attachmentID;
                        }

                        //// Make the request to the Exchange server and get the response.
                        webResponse = UploadHelperFunctionsUtility.GetWebResponse(serviceRequest.EwsUrl, serviceRequest.AttachmentToken, ServiceConstantStrings.AttachmentSoapRequest, attachmentOrMailID);
                    }

                    //// If the response is okay, create an XML document from the response and process the request.
                    if (webResponse.StatusCode == HttpStatusCode.OK)
                    {
                        result = UploadFilesMail(serviceRequest.Overwrite, serviceRequest.PerformContentCheck, serviceRequest.AllowContentCheck, documentLibraryName, webResponse, isMailUpload, requestObject, client, fileName, folderPath, ref message);
                    }
                    if (string.IsNullOrWhiteSpace(message) && result.Equals(ConstantStrings.UploadFailed) && isFirstCall)
                    {
                        result = Upload(requestObject, client, serviceRequest, ServiceConstantStrings.MailSoapRequest, serviceRequest.MailId, isMailUpload, fileName, folderPath, false, ref message, originalFileName);
                    }
                }
                else
                {
                    result = ConstantStrings.UploadFailed;
                }
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
                result = ConstantStrings.UploadFailed;
            }
            return result;
        }
Esempio n. 2
0
        public string UploadAttachment(RequestObject requestObject, Client client, ServiceRequest serviceRequest)
        {
            string resultFlag = string.Empty;
            if (null != requestObject && null != client && null != serviceRequest && ValidationHelperFunctions.CheckRequestValidatorToken())
            {
                ///// check if folder path and attachment length are same
                if (serviceRequest.FolderPath.Count == serviceRequest.Attachments.Count)
                {
                    bool result = true;
                    ///// StringBuilder builder = new StringBuilder();
                    int attachmentCount = 0;
                    string message = string.Empty;
                    foreach (AttachmentDetails attachment in serviceRequest.Attachments)
                    {
                        if (UploadHelperFunctions.Upload(requestObject, client, serviceRequest, ServiceConstantStrings.AttachmentSoapRequest, attachment.id, false, attachment.name, serviceRequest.FolderPath[attachmentCount], true, ref message, attachment.originalName).Equals(ConstantStrings.UploadFailed))
                        {
                            result = false;
                            break;
                        }

                        attachmentCount++;
                    }

                    if (result)
                    {
                        resultFlag = "True";
                    }
                    else if (!string.IsNullOrEmpty(message))
                    {
                        resultFlag = message;
                    }
                    else
                    {
                        resultFlag = "False";
                    }
                }
                else
                {
                    resultFlag = "False";
                }
            }
            else
            {
                resultFlag = TextConstants.MessageNoInputs;
            }
            return resultFlag;
        }
Esempio n. 3
0
 public string UploadMail(RequestObject requestObject, Client client, ServiceRequest serviceRequest)
 {
     string message = string.Empty;
     string result = "True";
     if (null != requestObject && null != client && null != serviceRequest && ValidationHelperFunctions.CheckRequestValidatorToken())
     {
         if (UploadHelperFunctions.Upload(requestObject, client, serviceRequest, ServiceConstantStrings.MailSoapRequest, serviceRequest.MailId, true, serviceRequest.Subject, serviceRequest.FolderPath[0], true, ref message, string.Empty).Equals(ConstantStrings.UploadFailed))
         {
             if (!string.IsNullOrEmpty(message))
             {
                 result = message;
             }
             else
             {
                 result = "False";
             }
         }
     }
     else
     {
         result = TextConstants.MessageNoInputs;
     }
     return result;
 }