Exemplo n.º 1
0
        /// <summary>
        /// Gets the reconversion document beos for job id.
        /// </summary>
        /// <param name="matterId">The matter id.</param>
        /// <param name="jobId">The job id.</param>
        /// <param name="filters">The filters.</param>
        /// <returns></returns>
        public static IEnumerable <ReconversionDocumentBEO> GetReconversionDocumentBeosForJobId(long matterId, long jobId,
                                                                                                string filters)
        {
            IDataReader dataReader = null;

            if (!string.IsNullOrEmpty(filters))
            {
                //user can filter the conversion results then do select all
                //filters has filter key : value with comma a delimiter
                var documentVaultManager = new DocumentVaultManager();
                documentVaultManager.Init(matterId);
                dataReader = documentVaultManager.GetConversionResultsDataReader(matterId, jobId, null, null, filters);
            }
            else
            {
                var          evDbManager = new EVDbManager(matterId);
                const string sqlCommand  =
                    @"SELECT dm.DocID,dm.DocTitle,dm.DocReferenceID, dm.CollectionID, ps.DCN ,T.DocText
                FROM [dbo].[DOC_ProcessSet] AS ps 
                INNER JOIN [dbo].[DOC_DocumentMaster] AS dm ON ps.[DocID] = dm.[DocID] 
                LEFT OUTER JOIN  dbo.DOC_DocumentText T ON DM.DocID = T.DocID AND T.TextTypeID = 2 
                WHERE ps.JobID = @JobID 
                ORDER BY  DM.DocTitle";
                var dbCommand = evDbManager.CreateTextCommand(sqlCommand);
                dbCommand.CommandTimeout = 0;
                evDbManager.AddInParameter(dbCommand, "JobID", DbType.Int64, jobId);
                dataReader = evDbManager.ExecuteDataReader(dbCommand);
            }

            Debug.Assert(dataReader != null);
            ReconversionDocumentBEO reconversionDocumentBeo = null;

            while (dataReader.Read())
            {
                string docRefId     = dataReader["DocReferenceID"].ToString();
                string collectionId = dataReader["CollectionID"].ToString();
                string dcn          = dataReader["DCN"].ToString();

                //new document (need to check this due to that multiple rows are returned in case of one document with multiple file path associated)
                if (reconversionDocumentBeo == null ||
                    !docRefId.Equals(reconversionDocumentBeo.DocumentId) ||
                    !collectionId.Equals(reconversionDocumentBeo.CollectionId) ||
                    !dcn.Equals(reconversionDocumentBeo.DCNNumber))
                {
                    if (reconversionDocumentBeo != null)
                    {
                        //query sorts the results in DCN order
                        //accumulate the file list of the document (DCN) then yield
                        //Example:(DCN File1),(DCN,File2) and (DCN001, File3)
                        //yield DCN,<File1,File2,File3>
                        yield return(reconversionDocumentBeo);
                    }
                    reconversionDocumentBeo = new ReconversionDocumentBEO()
                    {
                        DocumentId   = docRefId,
                        CollectionId = collectionId,
                        DCNNumber    = dcn
                    };
                }
                reconversionDocumentBeo.FileList.Add(dataReader[Constants.ColumnDocText].ToString());
                //add file path to list of file path for the document
            }
            dataReader.Close();
            if (reconversionDocumentBeo != null)
            {
                yield return(reconversionDocumentBeo);
            }
        }
        /// <summary>
        /// Gets the reconversion document beos for job id.
        /// </summary>
        /// <param name="matterId">The matter id.</param>
        /// <param name="jobId">The job id.</param>
        /// <param name="filters">The filters.</param>
        /// <returns></returns>
        public static IEnumerable<ReconversionDocumentBEO> GetReconversionDocumentBeosForJobId(long matterId, long jobId,
                                                                                               string filters)
        {

            IDataReader dataReader = null;

            if (!string.IsNullOrEmpty(filters))
            {
                //user can filter the conversion results then do select all
                //filters has filter key : value with comma a delimiter
                var documentVaultManager = new DocumentVaultManager();
                documentVaultManager.Init(matterId);
                dataReader = documentVaultManager.GetConversionResultsDataReader(matterId, jobId, null, null, filters);
            }
            else
            {
                var evDbManager = new EVDbManager(matterId);
                const string sqlCommand =
                    @"SELECT dm.DocID,dm.DocTitle,dm.DocReferenceID, dm.CollectionID, ps.DCN ,T.DocText
                FROM [dbo].[DOC_ProcessSet] AS ps 
                INNER JOIN [dbo].[DOC_DocumentMaster] AS dm ON ps.[DocID] = dm.[DocID] 
                LEFT OUTER JOIN  dbo.DOC_DocumentText T ON DM.DocID = T.DocID AND T.TextTypeID = 2 
                WHERE ps.JobID = @JobID 
                ORDER BY  DM.DocTitle";
                var dbCommand = evDbManager.CreateTextCommand(sqlCommand);
                dbCommand.CommandTimeout = 0;
                evDbManager.AddInParameter(dbCommand, "JobID", DbType.Int64, jobId);
                dataReader = evDbManager.ExecuteDataReader(dbCommand);
            }

            Debug.Assert(dataReader!=null);
            ReconversionDocumentBEO reconversionDocumentBeo = null;
            while (dataReader.Read())
            {
                string docRefId = dataReader["DocReferenceID"].ToString();
                string collectionId = dataReader["CollectionID"].ToString();
                string dcn = dataReader["DCN"].ToString();

                //new document (need to check this due to that multiple rows are returned in case of one document with multiple file path associated)
                if (reconversionDocumentBeo == null ||
                    !docRefId.Equals(reconversionDocumentBeo.DocumentId) ||
                    !collectionId.Equals(reconversionDocumentBeo.CollectionId) ||
                    !dcn.Equals(reconversionDocumentBeo.DCNNumber))
                {

                    if (reconversionDocumentBeo != null)
                    {
                        //query sorts the results in DCN order
                        //accumulate the file list of the document (DCN) then yield
                        //Example:(DCN File1),(DCN,File2) and (DCN001, File3)
                        //yield DCN,<File1,File2,File3> 
                        yield return reconversionDocumentBeo;
                    }
                    reconversionDocumentBeo = new ReconversionDocumentBEO()
                                                  {
                                                      DocumentId = docRefId,
                                                      CollectionId = collectionId,
                                                      DCNNumber = dcn
                                                  };
                }
                reconversionDocumentBeo.FileList.Add(dataReader[Constants.ColumnDocText].ToString());
                //add file path to list of file path for the document

            }
            dataReader.Close();
            if (reconversionDocumentBeo != null) yield return reconversionDocumentBeo;
        }