/// <summary>
 /// Creates Mail Processor object based on mail store type
 /// </summary>
 /// <param name="evCorlibEntity"> evCorlibEntity is expected to have mail store details </param>
 /// <returns> object of class implementing IMailProcessor </returns>
 public IMailProcessor CreateMailProcessor(EvCorlibEntity evCorlibEntity)
 {
     if (evCorlibEntity != null && evCorlibEntity.HasMailStores && evCorlibEntity.MailStoreEntity.Count > 0)
     {
         if (evCorlibEntity.MailStoreEntity[0].EmailType == EmailType.Outlook) return new OutlookAdapter();
         if (evCorlibEntity.MailStoreEntity[0].EmailType == EmailType.LotusNotes) return new LotusNotesAdapater();
         throw new EVException().AddResMsg(ErrorCodes.MailProcessorCreateFailure);
     }
     throw new EVException().AddResMsg(ErrorCodes.MailProcessorCreateFailure);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Extracts specified mail document and converts to a BEO which could be interpreted by rest of the application.
        /// Overload allows intermediate operations be performed as documents are extracted. 
        /// In an example, a PST file extraction returns multiple documents. As each document is extracted import can be performed. 
        /// The logic to import need to be written in event handler for EvDocumentDataEntityAvailable
        /// This approach is useful when there is a loop of time taking operations to be done.
        /// </summary>
        /// <param name="mailEntity">List of mail stores to be processed</param>        
        /// <param name="temporaryWorkingDirectory"> Specify working directory to be used for extracting contents</param>
        /// <param name="batchSize"> Batch size used while extracting mail stores </param>        
        /// <param name="errorCallback"> Loop of operations expected - an error in the loop shouldn't break the loop - hence error call back. </param>        
        /// <returns> EvDocumentDataEntity that abstracts documents and relationships </returns>
        public void ProcessMailDocuments(EvCorlibEntity evCorlibEntity, DirectoryInfo temporaryWorkingDirectory, int batchSize)
        {

            try
            {
                // if file processor instance is null, create new instance.
                if (FileProcessorInstance == null)
                    FileProcessorInstance = new EvCorlibManager(outputDirectory: temporaryWorkingDirectory, outputBatchSize: batchSize);

                // If DeleteAll is the option, let EVCorlibManager delete all files/folders. 
                // If not this Adapter will manage deleting files.
                FileProcessorInstance.IsDeleteTemporaryFiles =
                    (IsDeleteTemporaryFiles == DeleteExtractedFilesOptions.DeleteNonNativeFiles) ? true : false;

                FileProcessorInstance.ProcessMailStores(evCorlibEntity, TransformOutlookEDRMToDocumentBusinessEntity);

            }
            catch (EVException evException)
            {
                ((Exception)evException).Trace().Swallow();
            }
            catch (Exception exception)
            {
                string errorCode = ErrorCodes.OutlookMailStoreProcessFailure;
                exception.AddErrorCode(errorCode).Trace().Swallow();
            }
        }