示例#1
0
        public IActionResult IsLoginUserOwner([FromBody] Client client)
        {
            try
            {
                #region Error Checking
                GenericResponseVM genericResponse = null;

                if (client == null && string.IsNullOrWhiteSpace(client.Url))
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        Value   = errorSettings.MessageNoInputs,
                        IsError = true
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                bool isLoginUserOwner          = userRepositoy.IsLoginUserOwner(client);
                var  loginUserPartOfOwnerGroup = new
                {
                    IsLoginUserOwner = isLoginUserOwner
                };
                return(matterCenterServiceFunctions.ServiceResponse(loginUserPartOfOwnerGroup, (int)HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
示例#2
0
        public GenericResponseVM UploadFiles(IFormFile uploadedFile, string fileExtension, string originalName,
                                             string folderName, string fileName, string clientUrl, string folder, string documentLibraryName)
        {
            GenericResponseVM genericResponse = null;

            try
            {
                Dictionary <string, string> mailProperties = ContinueUpload(uploadedFile, fileExtension);
                //setting original name property for attachment
                if (string.IsNullOrWhiteSpace(mailProperties[ServiceConstants.MailOriginalName]))
                {
                    mailProperties[ServiceConstants.MAIL_ORIGINAL_NAME] = originalName;
                }

                genericResponse = docRepository.UploadDocument(folderName, uploadedFile, fileName, mailProperties, clientUrl, folder, documentLibraryName);
            }
            catch (Exception ex)
            {
                genericResponse = new GenericResponseVM()
                {
                    Code    = UploadEnums.UploadFailure.ToString(),
                    Value   = folderName,
                    IsError = true
                };
            }
            return(genericResponse);
        }
示例#3
0
        public async Task <IActionResult> GetPin([FromBody] SearchRequestVM searchRequestVM)
        {
            try
            {
                #region Error Checking
                //Input validation
                GenericResponseVM genericResponse = null;
                if (searchRequestVM == null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value   = errorSettings.MessageNoInputs,
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    //If the input validation is failed, send GenericResponseVM which contains the error information
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                ClientContext clientContext = null;
                clientContext = spoAuthorization.GetClientContext(searchRequestVM.Client.Url);
                //Get the documents which are pinned by the user
                var pinResponseVM = await documentProvision.GetPinnedDocumentsAsync(searchRequestVM, clientContext);

                //Return the response with proper http status code
                return(matterCenterServiceFunctions.ServiceResponse(pinResponseVM.DocumentDataList, (int)HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errorResponse = customLogger.GenerateErrorResponse(ex);
                return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK));
            }
        }
        /// <summary>
        /// get users
        /// </summary>
        /// <param name="client">Client object containing Client data</param>
        /// <param name="details">Term Store object containing Term store data</param>
        /// <returns>Returns JSON object to the client</returns>        ///
        public async Task <IActionResult> GetConfigurations([FromBody] string siteCollectionPath)
        {
            try
            {
                spoAuthorization.AccessToken = HttpContext.Request.Headers["Authorization"];
                #region Error Checking
                ErrorResponse errorResponse = null;
                //if the token is not valid, immediately return no authorization error to the user
                if (errorResponse != null && !errorResponse.IsTokenValid)
                {
                    return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.Unauthorized));
                }
                if (string.IsNullOrWhiteSpace(siteCollectionPath))
                {
                    errorResponse = new ErrorResponse()
                    {
                        Message     = errorSettings.MessageNoInputs,
                        ErrorCode   = HttpStatusCode.BadRequest.ToString(),
                        Description = "No input data is passed"
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.BadRequest));
                }
                #endregion
                GenericResponseVM genericResponseVM = await matterRepositoy.GetConfigurationsAsync(siteCollectionPath);

                return(matterCenterServiceFunctions.ServiceResponse(genericResponseVM, (int)HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
示例#5
0
        public async Task <IActionResult> GetDocumentAssets([FromBody] Client client)
        {
            try
            {
                #region Error Checking
                GenericResponseVM genericResponse = null;
                if (client == null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value   = errorSettings.MessageNoInputs,
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    //If the input validation is failed, send GenericResponseVM which contains the error information
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                var documentAsset = await documentRepositoy.GetDocumentAndClientGUIDAsync(client);

                //Return the response with proper http status code and proper response object
                return(matterCenterServiceFunctions.ServiceResponse(documentAsset, (int)HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
        /// <summary>
        /// Validates the roles for the matter and returns the validation status.
        /// </summary>
        /// <param name="requestObject">Request Object containing SharePoint App Token</param>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <param name="client">Client Object</param>
        /// <returns>A string value indicating whether validations passed or fail</returns>
        internal GenericResponseVM RoleCheck(Matter matter)
        {
            GenericResponseVM genericResponse = null;

            try
            {
                if (matter.Roles.Count() <= 0)
                {
                    return(GenericResponse(errorSettings.IncorrectInputUserRolesCode, errorSettings.IncorrectInputUserRolesMessage));
                }
                IList <string> roles = matterRespository.RoleCheck(matterSettings.CentralRepositoryUrl, listNames.DMSRoleListName,
                                                                   camlQueries.DMSRoleQuery);
                if (matter.Roles.Except(roles).Count() > 0)
                {
                    return(GenericResponse(errorSettings.IncorrectInputUserRolesCode, errorSettings.IncorrectInputUserRolesMessage));
                }
                return(genericResponse);
            }
            catch (Exception exception)
            {
                //ToDo: Why in role check function, we are deleting the matter
                //ProvisionHelperFunctions.DeleteMatter(requestObject, client, matter);
                //returnValue = Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
                throw;
            }
        }
示例#7
0
        public GenericResponseVM PerformContentCheck(string clientUrl, string folderUrl, IFormFile uploadedFile, string fileName)
        {
            GenericResponseVM genericResponse = null;

            genericResponse = uploadHelperFunctions.PerformContentCheck(clientUrl, folderUrl, uploadedFile, fileName);
            return(genericResponse);
        }
示例#8
0
        public IActionResult UserProfilePicture([FromBody] Client client)
        {
            try
            {
                #region Error Checking
                GenericResponseVM genericResponse = null;

                if (client == null && string.IsNullOrWhiteSpace(client.Url))
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value   = errorSettings.MessageNoInputs,
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                var userInfo = userRepositoy.GetUserProfilePicture(client);
                return(matterCenterServiceFunctions.ServiceResponse(userInfo, (int)HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(matterCenterServiceFunctions.ServiceResponse("Error in getting user profile picture", (int)HttpStatusCode.OK));
            }
        }
示例#9
0
 public GenericResponseVM CheckSecurityGroupInTeamMembers(Client client, Matter matter, IList <string> userId)
 {
     try
     {
         GenericResponseVM genericResponse = null;
         int securityGroupRowNumber        = -1; // Blocked user field has security group
         List <Tuple <int, Principal> > teamMemberPrincipalCollection = new List <Tuple <int, Principal> >();
         if (null != matter && null != matter.AssignUserNames && null != matter.BlockUserNames)
         {
             teamMemberPrincipalCollection = matterRespository.CheckUserSecurity(client, matter, userId);
             foreach (Tuple <int, Principal> teamMemberPrincipal in teamMemberPrincipalCollection)
             {
                 Principal currentTeamMemberPrincipal = teamMemberPrincipal.Item2;
                 if (currentTeamMemberPrincipal.PrincipalType == PrincipalType.SecurityGroup)
                 {
                     securityGroupRowNumber = teamMemberPrincipal.Item1;
                     return(ServiceUtility.GenericResponse(errorSettings.ErrorCodeSecurityGroupExists,
                                                           errorSettings.ErrorMessageSecurityGroupExists + ServiceConstants.DOLLAR + userId[securityGroupRowNumber]));
                 }
             }
         }
         else
         {
             return(ServiceUtility.GenericResponse(errorSettings.IncorrectTeamMembersCode,
                                                   errorSettings.IncorrectTeamMembersMessage));
         }
         return(genericResponse);
     }
     catch (Exception)
     {
         throw;
     }
 }
        /// <summary>
        /// Creates an item in the specific list with the list of users to whom the matter will be shared.
        /// </summary>
        /// <param name="requestObject">Request Object containing SharePoint App Token</param>
        /// <param name="client">Client object containing Client data</param>
        /// <param name="matter">Matter object containing Matter data</param>
        /// <returns>true if success else false</returns>
        /// /// <summary>
        internal GenericResponseVM ShareMatter(MatterMetdataVM matterMetadata, string matterLandingFlag)
        {
            GenericResponseVM returnFlag = null;
            var matter               = matterMetadata.Matter;
            var matterDetails        = matterMetadata.MatterDetails;
            var client               = matterMetadata.Client;
            var matterConfigurations = matterMetadata.MatterConfigurations;

            if (null != client && null != matter && null != matterDetails)
            {
                try
                {
                    Uri mailListURL = new Uri(string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{4}", matterSettings.ProvisionMatterAppURL,
                                                            ServiceConstants.FORWARD_SLASH, ServiceConstants.LISTS, ServiceConstants.FORWARD_SLASH, matterSettings.SendMailListName));
                    string centralMailListURL = Convert.ToString(mailListURL, CultureInfo.InvariantCulture);
                    string mailSiteURL        = centralMailListURL.Substring(0, centralMailListURL.LastIndexOf(string.Concat(ServiceConstants.FORWARD_SLASH,
                                                                                                                             ServiceConstants.LISTS, ServiceConstants.FORWARD_SLASH), StringComparison.OrdinalIgnoreCase));
                    ///// Retrieve the specific site where the Mail List is present along with the required List Name
                    if (null != mailListURL && null != client.Url)
                    {
                        if (!string.IsNullOrWhiteSpace(mailSiteURL))
                        {
                            returnFlag = ShareMatterUtility(client, matter, matterDetails,
                                                            mailSiteURL, centralMailListURL, matterLandingFlag, matterConfigurations);
                        }
                    }
                }
                catch (Exception ex)
                {
                    customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                    throw;
                }
            }
            return(returnFlag);
        }
        public GenericResponseVM UpdateMatterMetadata(MatterMetdataVM matterMetadata)
        {
            var               matter        = matterMetadata.Matter;
            var               matterDetails = matterMetadata.MatterDetails;
            var               client        = matterMetadata.Client;
            ClientContext     clientContext = null;
            GenericResponseVM returnFlag    = null;

            try
            {
                clientContext = spoAuthorization.GetClientContext(matterMetadata.Client.Url);
                PropertyValues matterStampedProperties   = matterRepositoy.GetStampedProperties(clientContext, matter.Name);
                Dictionary <string, string> propertyList = SetStampProperty(client, matter, matterDetails);
                matterRepositoy.SetPropertBagValuesForList(clientContext, matterStampedProperties, matter.Name, propertyList);
                if (matterMetadata.MatterProvisionFlags.SendEmailFlag)
                {
                    returnFlag = ShareMatter(matterMetadata, matterMetadata.MatterProvisionFlags.MatterLandingFlag);
                }
                else
                {
                    ServiceUtility.GenericResponse("", "Matter Update Success");
                }
            }
            catch (Exception ex)
            {
                DeleteMatter(client, matter);
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
            return(returnFlag);
        }
示例#12
0
        public async Task <IActionResult> Get([FromBody] SearchRequestVM searchRequestVM)
        {
            try
            {
                #region Error Checking
                GenericResponseVM genericResponse = null;
                //Input validation
                if (searchRequestVM == null && searchRequestVM.Client == null && searchRequestVM.SearchObject == null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value   = errorSettings.MessageNoInputs,
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    //If the input validation is failed, send GenericResponseVM which contains the error information
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                var searchResultsVM = await documentProvision.GetDocumentsAsync(searchRequestVM);

                return(matterCenterServiceFunctions.ServiceResponse(searchResultsVM.DocumentDataList, (int)HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                var errorResponse = customLogger.GenerateErrorResponse(ex);
                return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK));
            }
        }
        /// <summary>
        /// Function to validate client information
        /// </summary>
        /// <param name="client">Client object</param>
        /// <param name="methodNumber">Number indicating which method needs to be validated</param>
        /// <returns>String that contains error message</returns>
        internal GenericResponseVM ValidateClientInformation(Client client, int methodNumber)
        {
            GenericResponseVM response = new GenericResponseVM();

            if (string.IsNullOrWhiteSpace(client.Url))
            {
                response.Code  = errorSettings.IncorrectInputClientUrlCode;
                response.Value = errorSettings.IncorrectInputClientUrlMessage;
            }
            else if (int.Parse(ServiceConstants.ProvisionMatterCreateMatter, CultureInfo.InvariantCulture) == methodNumber ||
                     int.Parse(ServiceConstants.ProvisionMatterAssignContentType, CultureInfo.InvariantCulture) == methodNumber ||
                     int.Parse(ServiceConstants.ProvisionMatterUpdateMetadataForList, CultureInfo.InvariantCulture) == methodNumber)
            {
                if (string.IsNullOrWhiteSpace(client.Id))
                {
                    response.Code  = errorSettings.IncorrectInputClientIdCode;
                    response.Value = errorSettings.IncorrectInputClientIdMessage;
                }
                else if (string.IsNullOrWhiteSpace(client.Name))
                {
                    response.Code  = errorSettings.IncorrectInputClientNameCode;
                    response.Value = errorSettings.IncorrectInputClientNameMessage;
                }
            }
            return(response);
        }
        private GenericResponseVM GenericResponse(string code, string value)
        {
            GenericResponseVM genericResponseVM = new GenericResponseVM();

            genericResponseVM.Code  = errorSettings.IncorrectInputUserRolesCode;
            genericResponseVM.Value = errorSettings.IncorrectInputUserRolesMessage;
            return(genericResponseVM);
        }
示例#15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="code"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static GenericResponseVM GenericResponse(string code, string value)
        {
            GenericResponseVM genericResponseVM = new GenericResponseVM();

            genericResponseVM.Code  = code;
            genericResponseVM.Value = value;
            return(genericResponseVM);
        }
示例#16
0
 public IActionResult UploadMail([FromBody] AttachmentRequestVM[] attachmentRequestsVM)
 {
     try
     {
         GenericResponseVM genericResponse = null;
         IList <object>    listResponse    = new List <object>();
         if (attachmentRequestsVM != null && attachmentRequestsVM.Length > 0)
         {
             foreach (var attachmentRequestVM in attachmentRequestsVM)
             {
                 var client         = attachmentRequestVM.Client;
                 var serviceRequest = attachmentRequestVM.ServiceRequest;
                 genericResponse = emailProvision.UploadEmails(attachmentRequestVM);
                 //If there is any error in uploading the email attachment, send that error information to the UI
                 if (genericResponse != null && genericResponse.IsError == true)
                 {
                     var errorFile = new
                     {
                         IsError    = true,
                         Code       = genericResponse.Code.ToString(),
                         Value      = genericResponse.Value.ToString(),
                         FileName   = serviceRequest.Subject,
                         DropFolder = serviceRequest.DocumentLibraryName,
                         MailId     = serviceRequest.MailId
                     };
                     listResponse.Add(errorFile);
                 }
                 var successFile = new
                 {
                     IsError    = false,
                     Code       = HttpStatusCode.OK.ToString(),
                     Value      = UploadEnums.UploadSuccess.ToString(),
                     FileName   = serviceRequest.Subject,
                     DropFolder = serviceRequest.DocumentLibraryName,
                     MailId     = serviceRequest.MailId
                 };
                 listResponse.Add(successFile);
             }
             return(matterCenterServiceFunctions.ServiceResponse(listResponse, (int)HttpStatusCode.OK));
         }
         else
         {
             genericResponse = new GenericResponseVM()
             {
                 Value   = errorSettings.MessageNoInputs,
                 Code    = HttpStatusCode.BadRequest.ToString(),
                 IsError = true
             };
             return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
         }
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         throw;
     }
 }
示例#17
0
        /// <summary>
        /// this method upload dropped emails to the selected matter
        /// </summary>
        /// <param name="attachmentRequestVM"></param>
        /// <returns></returns>
        public GenericResponseVM UploadEmails(AttachmentRequestVM attachmentRequestVM)
        {
            string            message         = string.Empty;
            var               client          = attachmentRequestVM.Client;
            var               serviceRequest  = attachmentRequestVM.ServiceRequest;
            GenericResponseVM genericResponse = uploadHelperFunctions.Upload(client, serviceRequest, ref message);

            return(null);
        }
示例#18
0
        public GenericResponseVM UploadEmails(AttachmentRequestVM attachmentRequestVM)
        {
            string            message         = string.Empty;
            var               client          = attachmentRequestVM.Client;
            var               serviceRequest  = attachmentRequestVM.ServiceRequest;
            GenericResponseVM genericResponse = uploadHelperFunctions.Upload(client, serviceRequest, ServiceConstants.MAIL_SOAP_REQUEST, serviceRequest.MailId, true,
                                                                             serviceRequest.Subject, serviceRequest.FolderPath[0], true, ref message, string.Empty);

            return(genericResponse);
        }
示例#19
0
 public IActionResult UploadAttachments([FromBody] AttachmentRequestVM attachmentRequestVM)
 {
     try
     {
         var client         = attachmentRequestVM.Client;
         var serviceRequest = attachmentRequestVM.ServiceRequest;
         GenericResponseVM genericResponse = null;
         #region Error Checking
         ErrorResponse errorResponse = null;
         if (client == null && serviceRequest == null)
         {
             genericResponse = new GenericResponseVM()
             {
                 Value   = errorSettings.MessageNoInputs,
                 Code    = HttpStatusCode.BadRequest.ToString(),
                 IsError = true
             };
             //If the input validation is failed, send GenericResponseVM which contains the error information
             return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK));
         }
         #endregion
         if (serviceRequest.FolderPath.Count != serviceRequest.Attachments.Count)
         {
             genericResponse = new GenericResponseVM()
             {
                 Value   = "Folder path count and attachment count are not same",
                 Code    = HttpStatusCode.BadRequest.ToString(),
                 IsError = true
             };
             //If the input validation is failed, send GenericResponseVM which contains the error information
             return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK));
         }
         //Upload attachments to the sharepoint document library the user has choosen
         genericResponse = documentProvision.UploadAttachments(attachmentRequestVM);
         //If there is any error in uploading the attachment, send that error information to the UI
         if (genericResponse != null && genericResponse.IsError == true)
         {
             return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
         }
         //
         genericResponse = new GenericResponseVM()
         {
             Code  = HttpStatusCode.OK.ToString(),
             Value = "Attachment upload success"
         };
         //Return the response with proper http status code and proper response object
         return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         throw;
     }
 }
示例#20
0
        /// <summary>
        /// Performs content check
        /// </summary>
        /// <param name="isMailUpload">Mail upload check</param>
        /// <param name="folderPath">The folder path.</param>
        /// <param name="isMsg">Is .msg file</param>
        /// <param name="xmlDocument">XML document object having information for the attachment</param>
        /// <param name="nsmgr">XML Namespace object</param>
        /// <param name="extension">File extension</param>
        /// <param name="uploadFileName">Name of the file.</param>
        /// <param name="clientContext">SP client context</param>
        /// <returns>result message as per document matches or not</returns>
        public GenericResponseVM PerformContentCheckUtility(bool isMailUpload, string folderPath, bool isMsg, XmlDocument xmlDocument,
                                                            XmlNamespaceManager nsmgr, string extension, string uploadFileName, ClientContext clientContext)
        {
            dynamic           bytes           = GetStream(xmlDocument, nsmgr, isMailUpload, extension, isMsg);
            string            message         = string.Empty;
            GenericResponseVM genericResponse = null;

            using (MemoryStream targetStream = new MemoryStream(bytes, 0, bytes.Length, false, true))
            {
                try
                {
                    string serverFileUrl = folderPath + ServiceConstants.FORWARD_SLASH + uploadFileName;
                    if (documentRepository.PerformContentCheck(clientContext, targetStream, serverFileUrl))
                    {
                        //message = string.Format(CultureInfo.InvariantCulture, "{0}{1}{1}{1}{2}", errorSettings.FoundIdenticalContent,
                        //    ServiceConstants.PIPE, ServiceConstants.TRUE);
                        genericResponse = new GenericResponseVM()
                        {
                            IsError = true,
                            Code    = UploadEnums.IdenticalContent.ToString(),
                            Value   = errorSettings.FoundIdenticalContent
                        };
                        return(genericResponse);
                    }
                    else
                    {
                        //message = string.Format(CultureInfo.InvariantCulture, "{0}{1}{1}{1}{2}", errorSettings.FoundNonIdenticalContent,
                        //    ServiceConstants.PIPE, ServiceConstants.FALSE);

                        genericResponse = new GenericResponseVM()
                        {
                            IsError = true,
                            Code    = UploadEnums.NonIdenticalContent.ToString(),
                            Value   = errorSettings.FoundNonIdenticalContent
                        };
                        return(genericResponse);
                    }
                }
                catch (Exception exception)
                {
                    //Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
                    //message = string.Format(CultureInfo.InvariantCulture, "{0}{1}{1}{1}{2}", errorSettings.ContentCheckFailed,
                    //    ServiceConstants.PIPE, ServiceConstants.TRUE);
                    genericResponse = new GenericResponseVM()
                    {
                        IsError = true,
                        Code    = UploadEnums.ContentCheckFailed.ToString(),
                        Value   = errorSettings.ContentCheckFailed
                    };
                    return(genericResponse);
                }
            }
        }
示例#21
0
        public IActionResult DownloadAttachmentsAsStream([FromBody] MailAttachmentDetails mailAttachmentDetails)
        {
            try
            {
                #region Error Checking
                GenericResponseVM genericResponse = null;
                if (mailAttachmentDetails == null && mailAttachmentDetails.FullUrl == null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value   = errorSettings.MessageNoInputs,
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                Stream downloadAttachments = documentProvision.DownloadAttachments(mailAttachmentDetails);

                var fileContentResponse = new HttpResponseMessage(HttpStatusCode.OK);
                fileContentResponse.Headers.Clear();

                fileContentResponse.Content = new StreamContent(downloadAttachments);

                fileContentResponse.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(DocumentProvision.ReturnExtension(string.Empty));
                //fileContentResponse.Headers.Add("Content-Type", ReturnExtension(string.Empty));
                fileContentResponse.Content.Headers.Add("Content-Length", downloadAttachments.Length.ToString());
                fileContentResponse.Content.Headers.Add("Content-Description", "File Transfer");

                //application/octet-stream
                fileContentResponse.Content.Headers.Add("Content-Disposition", "attachment; filename=" + documentSettings.TempEmailName + new Guid().ToString() + ServiceConstants.EMAIL_FILE_EXTENSION);
                fileContentResponse.Content.Headers.Add("Content-Transfer-Encoding", "binary");
                fileContentResponse.Content.Headers.Expires = DateTimeOffset.Now.AddDays(-1);;
                fileContentResponse.Headers.Add("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
                fileContentResponse.Headers.Add("Pragma", "public");
                var fileAttachmentContent = fileContentResponse.Content.ReadAsStringAsync();
                var response = new
                {
                    fileAttachment = fileAttachmentContent,
                    fileName       = documentSettings.TempEmailName + Guid.NewGuid().ToString() + ServiceConstants.EMAIL_FILE_EXTENSION
                };
                return(new ObjectResult(response));
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
        /// <summary>
        /// Validates the matter name.
        /// </summary>
        /// <param name="matter">Matter details</param>
        /// <returns>Matter details validation result</returns>
        private GenericResponseVM MatterNameValidation(Matter matter)
        {
            GenericResponseVM genericResponseVM    = null;
            string            matterNameValidation = string.Empty;

            if (string.IsNullOrWhiteSpace(matter.Name))
            {
                return(GenericResponse(errorSettings.IncorrectInputMatterNameCode, errorSettings.IncorrectInputMatterNameMessage));
            }
            var matterName = Regex.Match(matter.Name, matterSettings.SpecialCharacterExpressionMatterTitle, RegexOptions.IgnoreCase);

            if (int.Parse(matterSettings.MatterNameLength, CultureInfo.InvariantCulture) < matter.Name.Length || matter.Name.Length != matterName.Length)
            {
                return(GenericResponse(errorSettings.IncorrectInputMatterNameCode, errorSettings.IncorrectInputMatterNameMessage));
            }
            return(genericResponseVM);
        }
示例#23
0
        public async Task <IActionResult> GetUsers([FromBody] SearchRequestVM searchRequestVM)
        {
            try
            {
                #region Error Checking
                GenericResponseVM genericResponse = null;
                if (searchRequestVM.Client == null && string.IsNullOrWhiteSpace(searchRequestVM.Client.Url))
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value   = errorSettings.MessageNoInputs,
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                searchRequestVM.SearchObject.SearchTerm = (!string.IsNullOrWhiteSpace(searchRequestVM.SearchObject.SearchTerm)) ?
                                                          searchRequestVM.SearchObject.SearchTerm : string.Empty;
                IList <Users> users = await userRepositoy.GetUsersAsync(searchRequestVM);

                if (users != null && users.Count != 0)
                {
                    return(matterCenterServiceFunctions.ServiceResponse(users, (int)HttpStatusCode.OK));
                }
                else
                {
                    Users noResult = new Users()
                    {
                        Name       = errorSettings.PeoplePickerNoResults,
                        LogOnName  = string.Empty,
                        Email      = string.Empty,
                        EntityType = string.Empty
                    };
                    users.Add(noResult);
                    return(matterCenterServiceFunctions.ServiceResponse(users, (int)HttpStatusCode.OK));
                }
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
示例#24
0
 public IActionResult UploadMail([FromBody] AttachmentRequestVM attachmentRequestVM)
 {
     try
     {
         var client         = attachmentRequestVM.Client;
         var serviceRequest = attachmentRequestVM.ServiceRequest;
         GenericResponseVM genericResponse = null;
         #region Error Checking
         //Input validation
         ErrorResponse errorResponse = null;
         if (client == null && serviceRequest == null && string.IsNullOrWhiteSpace(serviceRequest.MailId))
         {
             genericResponse = new GenericResponseVM()
             {
                 Value   = errorSettings.MessageNoInputs,
                 Code    = HttpStatusCode.BadRequest.ToString(),
                 IsError = true
             };
             return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
         }
         #endregion
         //Upload email to the share point library
         genericResponse = documentProvision.UploadEmails(attachmentRequestVM);
         //If there is any error in uploading the email attachment, send that error information to the UI
         if (genericResponse != null && genericResponse.IsError == true)
         {
             return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
         }
         //If the email attachment is success, send the success response to the user
         genericResponse = new GenericResponseVM()
         {
             Code  = HttpStatusCode.OK.ToString(),
             Value = "Attachment upload success"
         };
         //Return the response with proper http status code and proper response object
         return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
     }
     catch (Exception ex)
     {
         customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
         throw;
     }
 }
 /// <summary>
 /// Check if duplicate document exists 
 /// </summary>
 /// <param name="clientContext">SP client context</param>
 /// <param name="documentLibraryName">Name of the document library</param>
 /// <param name="isMailUpload">Mail upload check</param>
 /// <param name="folderPath">The folder path.</param>
 /// <param name="contentCheck">Content check object</param>
 /// <param name="uploadFileName">Name of the file.</param>
 /// <returns>message as per duplicate exists or not</returns>
 public GenericResponseVM CheckDuplicateDocument(ClientContext clientContext, string documentLibraryName, bool isMailUpload, string folderPath, ContentCheckDetails contentCheck, string uploadFileName, bool allowContentCheck, ref string message)
 {
     GenericResponseVM genericResponse = null;
     DuplicateDocument duplicateDocument = documentRepository.DocumentExists(clientContext, contentCheck, documentLibraryName, folderPath, isMailUpload);
     if (duplicateDocument.DocumentExists)
     {
         string documentPath = string.Concat(generalSettings.SiteURL, folderPath, ServiceConstants.FORWARD_SLASH, uploadFileName);
         string duplicateMessage = (allowContentCheck && duplicateDocument.HasPotentialDuplicate) ? errorSettings.FilePotentialDuplicateMessage : errorSettings.FileAlreadyExistMessage;
         duplicateMessage = $"{duplicateMessage}|{duplicateDocument.HasPotentialDuplicate}";
         genericResponse = new GenericResponseVM()
         {
             IsError = true,
             Code = UploadEnums.DuplicateDocument.ToString(),
             Value = string.Format(CultureInfo.InvariantCulture, duplicateMessage, uploadFileName, documentPath)
         };
         return genericResponse;
     }
     return genericResponse;
 }
示例#26
0
        public async Task <IActionResult> GetDocumentCounts([FromBody] SearchRequestVM searchRequestVM)
        {
            try
            {
                GenericResponseVM genericResponse = null;
                #region Error Checking
                //Input validation
                if (searchRequestVM == null && searchRequestVM.Client == null && searchRequestVM.SearchObject == null)
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value   = errorSettings.MessageNoInputs,
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                //For a given search request entered by the user, this api will get all documents that has been
                //uploaded by him, all documents that are assigned to him and all the documents which are pinned by him
                int allDocumentCounts = await documentProvision.GetAllCounts(searchRequestVM);

                int myDocumentCounts = await documentProvision.GetMyCounts(searchRequestVM);

                int pinnedDocumentCounts = await documentProvision.GetPinnedCounts(searchRequestVM);

                //The object count information that will be sent to the user
                var documentCounts = new
                {
                    AllDocumentCounts    = allDocumentCounts,
                    MyDocumentCounts     = myDocumentCounts,
                    PinnedDocumentCounts = pinnedDocumentCounts,
                };
                //If the input validation is failed, send GenericResponseVM which contains the error information
                return(matterCenterServiceFunctions.ServiceResponse(documentCounts, (int)HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
示例#27
0
        /// <summary>
        /// Check if duplicate document exists
        /// </summary>
        /// <param name="clientContext">SP client context</param>
        /// <param name="documentLibraryName">Name of the document library</param>
        /// <param name="isMailUpload">Mail upload check</param>
        /// <param name="folderPath">The folder path.</param>
        /// <param name="contentCheck">Content check object</param>
        /// <param name="uploadFileName">Name of the file.</param>
        /// <returns>message as per duplicate exists or not</returns>
        public GenericResponseVM CheckDuplicateDocument(ClientContext clientContext, string documentLibraryName, bool isMailUpload, string folderPath, ContentCheckDetails contentCheck, string uploadFileName, bool allowContentCheck, ref string message)
        {
            GenericResponseVM genericResponse   = null;
            DuplicateDocument duplicateDocument = documentRepository.DocumentExists(clientContext, contentCheck, documentLibraryName, folderPath, isMailUpload);

            if (duplicateDocument.DocumentExists)
            {
                string documentPath     = string.Concat(generalSettings.SiteURL, folderPath, ServiceConstants.FORWARD_SLASH, uploadFileName);
                string duplicateMessage = (allowContentCheck && duplicateDocument.HasPotentialDuplicate) ? errorSettings.FilePotentialDuplicateMessage : errorSettings.FileAlreadyExistMessage;
                duplicateMessage = $"{duplicateMessage}|{duplicateDocument.HasPotentialDuplicate}";
                genericResponse  = new GenericResponseVM()
                {
                    IsError = true,
                    Code    = UploadEnums.DuplicateDocument.ToString(),
                    Value   = string.Format(CultureInfo.InvariantCulture, duplicateMessage, uploadFileName, documentPath)
                };
                return(genericResponse);
            }
            return(genericResponse);
        }
示例#28
0
        public GenericResponseVM CheckDuplicateDocument(string clientUrl, string folderName, string documentLibraryName,
                                                        string fileName, ContentCheckDetails contentCheck, bool allowContentCheck)
        {
            GenericResponseVM genericResponse   = null;
            DuplicateDocument duplicateDocument = uploadHelperFunctions.DocumentExists(clientUrl, contentCheck, documentLibraryName, folderName, false);

            if (duplicateDocument != null && duplicateDocument.DocumentExists)
            {
                string documentPath     = string.Concat(generalSettings.SiteURL, folderName, ServiceConstants.FORWARD_SLASH, fileName);
                string duplicateMessage = (allowContentCheck && duplicateDocument.HasPotentialDuplicate) ? errorSettings.FilePotentialDuplicateMessage : errorSettings.FileAlreadyExistMessage;
                duplicateMessage = $"{duplicateMessage}|{duplicateDocument.HasPotentialDuplicate}";
                genericResponse  = new GenericResponseVM()
                {
                    IsError = true,
                    Code    = UploadEnums.DuplicateDocument.ToString(),
                    Value   = string.Format(CultureInfo.InvariantCulture, duplicateMessage, fileName, documentPath)
                };
            }
            return(genericResponse);
        }
示例#29
0
        public async Task <IActionResult> GetPermissionLevels([FromBody] Client client)
        {
            try
            {
                #region Error Checking
                GenericResponseVM genericResponse = null;

                if (client == null && string.IsNullOrWhiteSpace(client.Url))
                {
                    genericResponse = new GenericResponseVM()
                    {
                        Value   = errorSettings.MessageNoInputs,
                        Code    = HttpStatusCode.BadRequest.ToString(),
                        IsError = true
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
                }
                #endregion
                IList <Role> roles = null;

                ServiceUtility.RedisCacheHostName = generalSettings.RedisCacheHostName;
                string result = ServiceUtility.GetDataFromAzureRedisCache(ServiceConstants.CACHE_PERMISSIONS);
                if (string.IsNullOrEmpty(result))
                {
                    roles = await userRepositoy.GetPermissionLevelsAsync(client);

                    ServiceUtility.SetDataIntoAzureRedisCache <IList <Role> >(ServiceConstants.CACHE_PERMISSIONS, roles);
                }
                else
                {
                    roles = JsonConvert.DeserializeObject <IList <Role> >(result);
                }
                return(matterCenterServiceFunctions.ServiceResponse(roles, (int)HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                customLogger.LogError(ex, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
示例#30
0
        public GenericResponseVM UploadAttachments(AttachmentRequestVM attachmentRequestVM)
        {
            int               attachmentCount = 0;
            string            message         = string.Empty;
            var               client          = attachmentRequestVM.Client;
            var               serviceRequest  = attachmentRequestVM.ServiceRequest;
            GenericResponseVM genericResponse = null;

            foreach (AttachmentDetails attachment in serviceRequest.Attachments)
            {
                genericResponse = uploadHelperFunctions.Upload(client, serviceRequest, ServiceConstants.ATTACHMENT_SOAP_REQUEST, attachment.id, false,
                                                               attachment.name, serviceRequest.FolderPath[attachmentCount], false, ref message,
                                                               attachment.originalName);
                if (genericResponse != null && genericResponse.IsError == true)
                {
                    //result = false;
                    break;
                }
                attachmentCount++;
            }
            return(genericResponse);
        }
        public async Task <IActionResult> Get([FromBody] String filter)
        {
            string result = string.Empty;

            try
            {
                #region Error Checking
                ErrorResponse errorResponse = null;

                if (filter == null)
                {
                    errorResponse = new ErrorResponse()
                    {
                        Message     = errorSettings.MessageNoInputs,
                        ErrorCode   = HttpStatusCode.BadRequest.ToString(),
                        Description = "No filter was passed"
                    };
                    return(matterCenterServiceFunctions.ServiceResponse(errorResponse, (int)HttpStatusCode.OK));
                    // return "error";
                }
                #endregion
                var configResultsVM = await configRepository.GetConfigurationsAsync(filter);

                CreateConfig(configResultsVM, "uiconfig.js", false);
                var genericResponse = new GenericResponseVM
                {
                    Code    = HttpStatusCode.OK.ToString(),
                    Value   = "",
                    IsError = false
                };
                return(matterCenterServiceFunctions.ServiceResponse(genericResponse, (int)HttpStatusCode.OK));
            }
            catch (Exception exception)
            {
                customLogger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, logTables.SPOLogTable);
                throw;
            }
        }
        /// <summary>
        /// Reads the XMLDocument and determines whether the request is to upload entire mail/attachment/.eml file/.msg file and calls respective method.
        /// </summary>
        /// <param name="isOverwrite">Overwrite check</param>
        /// <param name="documentLibraryName">Name of the document library</param>
        /// <param name="folderName">Name of the folder</param>
        /// <param name="webResponse">HTTP web response to get the response stream</param>
        /// <param name="isMailUpload">Mail Upload Flag</param>
        /// <param name="requestObject">request object for web</param>
        /// <param name="client">Service Client Object</param>
        /// <param name="fileName">Name of the file</param>
        /// <param name="folderPath">upload folder path</param>
        /// <param name="message">Reference object for the message to be returned</param>
        /// <returns>Returns whether File Uploaded successfully or failed</returns>
        internal GenericResponseVM UploadFilesMail(bool isOverwrite, bool isContentCheckRequired, bool allowContentCheck, 
            string documentLibraryName, HttpWebResponse webResponse, bool isMailUpload, 
            Client client, string fileName, string folderPath, ref string message)
        {
            bool isMsg = true;
            MailMetaData mailMetaData = new MailMetaData();
            var bytes = (dynamic)null;
            string mailMessage = string.Empty;
            string originalName = string.Empty;
            string xmlPath = string.Empty;
            GenericResponseVM genericResponse = null;
            ContentCheckDetails contentCheck = null;
            try
            {
                XmlDocument xmlDocument = RetrieveXMLDocument(webResponse);
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDocument.NameTable);
                nsmgr.AddNamespace("s", ServiceConstants.SOAP_ENVELOP_URI);
                nsmgr.AddNamespace("m", ServiceConstants.EXCHANGE_SERVICE_MESSAGE);
                nsmgr.AddNamespace("t", ServiceConstants.EXCHANGE_SERVICE_TYPES);
                string extension = System.IO.Path.GetExtension(fileName).Trim();
                string uploadFileName = uploadHelperFunctionsUtility.RemoveSpecialChar(fileName);
                if (xmlDocument.SelectSingleNode("/s:Envelope/s:Body/m:GetAttachmentResponse/m:ResponseMessages/m:GetAttachmentResponseMessage/m:Attachments/t:FileAttachment/t:Content", nsmgr) != null)
                {
                    isMsg = false;
                }
                if (string.IsNullOrEmpty(extension) && isMsg)
                {
                    uploadFileName = uploadFileName + ServiceConstants.EMAIL_FILE_EXTENSION;
                }
                using (ClientContext clientContext = spoAuthorization.GetClientContext(client.Url))
                {
                    if (isMailUpload)
                    {
                        bytes = GetEmailProperties(xmlDocument, ref mailMetaData);
                    }
                    else
                    {
                        bytes = uploadHelperFunctionsUtility.GetStream(xmlDocument, nsmgr, isMailUpload, extension, isMsg);
                    }
                    if (null != bytes)
                    {
                        using (MemoryStream memoryStream = new MemoryStream(bytes))
                        {
                            contentCheck = new ContentCheckDetails(uploadFileName, mailMetaData.mailSubject, memoryStream.Length, mailMetaData.mailSender, mailMetaData.sentDate);
                        }
                    }

                    genericResponse = uploadHelperFunctionsUtility.CheckDuplicateDocument(clientContext, documentLibraryName, isMailUpload, folderPath, contentCheck, uploadFileName, allowContentCheck, ref message);

                    if (!isOverwrite && !isContentCheckRequired && (genericResponse!=null && genericResponse.IsError==true))
                    {
                        return genericResponse;
                    }
                    else if (isContentCheckRequired)
                    {
                        genericResponse = uploadHelperFunctionsUtility.PerformContentCheckUtility(isMailUpload, folderPath, isMsg, xmlDocument, nsmgr, extension, uploadFileName, clientContext);
                        return genericResponse;
                    }
                    else
                    {
                        genericResponse = null;
                        if (isMailUpload)       //Upload entire Email
                        {
                            UploadMail(client, folderPath, fileName, documentLibraryName, xmlDocument, ref message);
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(extension) && isMsg)       //Upload .msg file
                            {
                                UploadAttachedMailExtBlank(client, folderPath, fileName, documentLibraryName, xmlDocument, ref message);
                            }
                            else
                            {
                                if (string.Equals(extension, ServiceConstants.EMAIL_FILE_EXTENSION, StringComparison.OrdinalIgnoreCase))
                                {
                                    UploadEMLFile(documentLibraryName, client, folderPath, fileName, ref message, xmlDocument, nsmgr, 
                                        ref mailMetaData, ref bytes, extension);
                                }
                                else
                                {
                                    //get original name
                                    xmlPath = "/s:Envelope/s:Body/m:GetAttachmentResponse/m:ResponseMessages/m:GetAttachmentResponseMessage/m:Attachments/t:FileAttachment/t:Name";
                                    originalName = RetrieveNodeValue(xmlDocument, nsmgr, xmlPath, true);
                                    //get attachment content
                                    xmlPath = "/s:Envelope/s:Body/m:GetAttachmentResponse/m:ResponseMessages/m:GetAttachmentResponseMessage/m:Attachments/t:FileAttachment/t:Content";
                                    mailMessage = RetrieveNodeValue(xmlDocument, nsmgr, xmlPath, false);

                                    bytes = Convert.FromBase64String(mailMessage);
                                    using (MemoryStream memoryStream = new MemoryStream(bytes))
                                    {
                                        mailMetaData.mailImportance = string.Empty;
                                        mailMetaData.mailSubject = string.Empty;
                                        mailMetaData.originalName = originalName;
                                        if (!UploadToFolder(client, folderPath, fileName, string.Empty, memoryStream, documentLibraryName, mailMetaData, ref message))
                                        {
                                            //result = ServiceConstants.UPLOAD_FAILED;
                                            genericResponse = new GenericResponseVM()
                                            {
                                                IsError = true,
                                                Code = UploadEnums.UploadToFolder.ToString(),
                                                Value = message
                                            };
                                            return genericResponse;
                                        }
                                    }
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(message))
                        {
                            //result = ServiceConstants.UPLOAD_FAILED;
                            genericResponse = new GenericResponseVM()
                            {
                                IsError = true,
                                Code = UploadEnums.UploadFailure.ToString(),
                                Value = message
                            };
                            return genericResponse;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                //Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
                genericResponse = new GenericResponseVM()
                {
                    IsError = true,
                    Code = UploadEnums.UploadFailure.ToString(),
                    Value = ""
                };
                
            }
            return genericResponse;
        }
 public GenericResponseVM PerformContentCheck(string clientUrl, string folderUrl, IFormFile uploadedFile, string fileName)
 {
     GenericResponseVM genericResponse = null;
     ClientContext clientContext = spoAuthorization.GetClientContext(clientUrl);
     using (MemoryStream targetStream = new MemoryStream())
     {
         Stream sourceStream = uploadedFile.OpenReadStream();
         try
         {
             byte[] buffer = new byte[sourceStream.Length + 1];
             int read = 0;
             while ((read = sourceStream.Read(buffer, 0, buffer.Length)) > 0)
             {
                 targetStream.Write(buffer, 0, read);
             }
             string serverFileUrl = folderUrl + ServiceConstants.FORWARD_SLASH + fileName;
             bool isMatched = documentRepository.PerformContentCheck(clientContext, targetStream, serverFileUrl);
             if (isMatched)
             {
                 //listResponse.Add(string.Format(CultureInfo.InvariantCulture, "{0}{1}{1}{1}{2}", ConstantStrings.FoundIdenticalContent, ConstantStrings.Pipe, ConstantStrings.TRUE));
                 genericResponse = new GenericResponseVM()
                 {
                     IsError = true,
                     Code = UploadEnums.IdenticalContent.ToString(),
                     Value = string.Format(CultureInfo.InvariantCulture, errorSettings.FoundIdenticalContent)
                 };
             }
             else
             {
                 genericResponse = new GenericResponseVM()
                 {
                     IsError = true,
                     Code = UploadEnums.NonIdenticalContent.ToString(),
                     Value = string.Format(CultureInfo.InvariantCulture, errorSettings.FoundNonIdenticalContent)
                 };                        
             }
         }
         catch (Exception exception)
         {
             //Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, UIConstantStrings.LogTableName);
             //response = string.Format(CultureInfo.InvariantCulture, "{0}{1}{1}{1}{2}", ConstantStrings.ContentCheckFailed, ConstantStrings.Pipe, ConstantStrings.TRUE);
         }
         finally
         {
             sourceStream.Dispose();
         }
     }
     return genericResponse;
 }
        /// <summary>
        /// Performs content check
        /// </summary>
        /// <param name="isMailUpload">Mail upload check</param>
        /// <param name="folderPath">The folder path.</param>
        /// <param name="isMsg">Is .msg file</param>
        /// <param name="xmlDocument">XML document object having information for the attachment</param>
        /// <param name="nsmgr">XML Namespace object</param>
        /// <param name="extension">File extension</param>
        /// <param name="uploadFileName">Name of the file.</param>
        /// <param name="clientContext">SP client context</param>
        /// <returns>result message as per document matches or not</returns>
        public GenericResponseVM PerformContentCheckUtility(bool isMailUpload, string folderPath, bool isMsg, XmlDocument xmlDocument, 
            XmlNamespaceManager nsmgr, string extension, string uploadFileName, ClientContext clientContext)
        {
            dynamic bytes = GetStream(xmlDocument, nsmgr, isMailUpload, extension, isMsg);
            string message = string.Empty;
            GenericResponseVM genericResponse = null;
            using (MemoryStream targetStream = new MemoryStream(bytes, 0, bytes.Length, false, true))
            {
                try
                {
                    string serverFileUrl = folderPath + ServiceConstants.FORWARD_SLASH + uploadFileName;
                    if (documentRepository.PerformContentCheck(clientContext, targetStream, serverFileUrl))
                    {
                        //message = string.Format(CultureInfo.InvariantCulture, "{0}{1}{1}{1}{2}", errorSettings.FoundIdenticalContent, 
                        //    ServiceConstants.PIPE, ServiceConstants.TRUE);
                        genericResponse = new GenericResponseVM()
                        {
                            IsError = true,
                            Code = UploadEnums.IdenticalContent.ToString(),
                            Value = errorSettings.FoundIdenticalContent
                        };
                        return genericResponse;
                    }
                    else
                    {
                        //message = string.Format(CultureInfo.InvariantCulture, "{0}{1}{1}{1}{2}", errorSettings.FoundNonIdenticalContent, 
                        //    ServiceConstants.PIPE, ServiceConstants.FALSE);

                        genericResponse = new GenericResponseVM()
                        {
                            IsError = true,
                            Code = UploadEnums.NonIdenticalContent.ToString(),
                            Value = errorSettings.FoundNonIdenticalContent
                        };
                        return genericResponse;
                    }
                }
                catch (Exception exception)
                {
                    //Logger.LogError(exception, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ServiceConstantStrings.LogTableName);
                    //message = string.Format(CultureInfo.InvariantCulture, "{0}{1}{1}{1}{2}", errorSettings.ContentCheckFailed, 
                    //    ServiceConstants.PIPE, ServiceConstants.TRUE);
                    genericResponse = new GenericResponseVM()
                    {
                        IsError = true,
                        Code = UploadEnums.ContentCheckFailed.ToString(),
                        Value = errorSettings.ContentCheckFailed
                    };
                    return genericResponse;
                }
            }
        }