private void OpenDCBWithCreds()
        {
            //Adding one more empty pair to handle the case where user passes credentials for the
            //unsecured dcbs
            DcbOpticonJobBEO.DcbCredentialList.Add(Convert.ToString((char)174));

            //If it is a secured dcb
            foreach (var usernamepasswordpair in DcbOpticonJobBEO.DcbCredentialList)
            {
                if (usernamepasswordpair == null)
                {
                    continue;
                }
                var uidpwd   = usernamepasswordpair.Split(new[] { (char)174 });
                var login    = uidpwd[0];
                var password = (uidpwd.Length > 1) ? uidpwd[1] : "";
                if (!string.IsNullOrEmpty(password))
                {
                    password = ApplicationConfigurationManager.Decrypt(password,
                                                                       ApplicationConfigurationManager.GetValue(UNPWEncryption, UNPWDataSecurity));
                }

                try
                {
                    Tracer.Debug("DcbSlicer: Opening secured DCB database {0}", DcbOpticonJobBEO.DcbSourcePath);
                    DcbFacade.OpenDCB(DcbOpticonJobBEO.DcbSourcePath, login, password);
                    DcbCredentials = new DcbCredentials {
                        Login = login, Password = password
                    };
                    return;
                }
                catch (Dcb2EvException ex)
                {
                    if (ex.ErrorCode != (int)DcbFacadeErrorCodes.AccessDenied)
                    {
                        throw;
                    }
                    ex.Trace().Swallow();
                }
            }
            var message = String.Format("Tried all login/password pairs for {0} and none worked",
                                        DcbOpticonJobBEO.DcbSourcePath);

            throw new Dcb2EvException(message, (int)DcbFacadeErrorCodes.AccessDenied);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Processes the work item. pushes give document files for conversion
        /// </summary>
        /// <param name="message">The message.</param>
        protected override void ProcessMessage(PipeMessageEnvelope message)
        {
            base.ProcessMessage(message);

            try
            {
                DocumentExtractionMessageEntity documentExtractionMessageEntity = message.Body as DocumentExtractionMessageEntity;
                Debug.Assert(documentExtractionMessageEntity != null, "documentExtractionMessageEntity != null");
                IEnumerable <string> listOfFiles = documentExtractionMessageEntity.FileCollection;

                if (listOfFiles == null || !listOfFiles.Any())
                {
                    throw new EVException().AddErrorCode(ErrorCodes.EDLoaderExtractionWorker_NoFilesToProcess);
                }
                List <FileInfo> files = new List <FileInfo>();
                listOfFiles.SafeForEach(p => files.Add(new FileInfo(p)));

                if (files.Count <= 0)
                {
                    throw new EVException().AddResMsg(ErrorCodes.EDLoaderExtractionWorker_NoFilesToProcess);
                }

                Debug.Assert(m_FileProcessor != null);

                //?? 1. need to make it configurable item
                //?? 2. Need to ensure output.xmls are deleted.
                // ED Loader job should not delete native files ever, hence if delete temporary files is set to true - delete NON native files else delete none
                // Delete none is mostly used for debugging so that EDRM files extracted can be examined.
                //?? need to fix before end of sprint 3
                m_FileProcessor.IsDeleteTemporaryFiles = (false)
                    ? DeleteExtractedFilesOptions.DeleteNonNativeFiles
                    : DeleteExtractedFilesOptions.DeleteNone;

                // if password list (used for password protected archive files extraction) is set, assign it to File Processor after decryption
                if (m_Parameters != null && m_Parameters.PasswordList != null && m_Parameters.PasswordList.Count > 0)
                {
                    List <string> decryptedPasswordList = new List <string>();
                    m_Parameters.PasswordList.SafeForEach(
                        x => decryptedPasswordList.Add(ApplicationConfigurationManager.Decrypt(x, m_DecryptionKey)));
                    m_FileProcessor.Passwords = decryptedPasswordList;
                }

                Debug.Assert(m_Parameters != null, "m_Parameters != null");
                m_FileProcessor.DatasetBeo           = m_Parameters.DatasetDetails;
                m_FileProcessor.FilterByMappedFields = m_Parameters.FieldMapping;

                long jobRunId;
                long.TryParse(PipelineId, out jobRunId);

                List <EmailThreadingEntity> rawDocumentRelationships = new List <EmailThreadingEntity>();

                // this call performs document extraction and calls ImportEvDocumentDataEntity as and when extraction is done for each file.
                m_FileProcessor.ProcessDocumentWithCallBack <double>(files,
                                                                     new DirectoryInfo(m_Parameters.DatasetDetails.CompressedFileExtractionLocation),
                                                                     m_OutputBatchSize,
                                                                     jobRunId,
                                                                     ProcessDocumentEntities,
                                                                     OnHandleException,
                                                                     m_PercenatgeCompletion,
                                                                     rawDocumentRelationships);

                if (rawDocumentRelationships.Any())
                {
                    SendRelationshipsInfo(rawDocumentRelationships);
                }

                // if it's the last message send remaining documents
                if ((documentExtractionMessageEntity.IsLastMessageInBatch && m_Documents != null && m_Documents.Any()) ||
                    (m_OutlookMailStoreDataEntities != null && m_OutlookMailStoreDataEntities.Any()))
                {
                    Send(m_Documents, true);
                    m_Documents.Clear();
                }
            }
            catch (Exception ex)
            {
                ReportToDirector(ex);
                ex.Trace();
                if (ex.GetErrorCode() == ErrorCodes.ImportDiskFullErrorMessage)
                {
                    // if the disk is full then we throw the exception to stop the job and log the message
                    LogMessage(false, Constants.DiskFullErrorMessage, false);
                    throw;
                }
                LogMessage(false, ex.ToUserString(), false);
                ex.Swallow();
            }
        }