Beispiel #1
0
 /// <summary>
 /// Bulks the update process set status.
 /// </summary>
 /// <param name="documentConversionLogBeos">The document conversion log beos.</param>
 private void BulkUpdateProcessSetStatus(IList <DocumentConversionLogBeo> documentConversionLogBeos)
 {
     try
     {
         using (var transScope = new EVTransactionScope(TransactionScopeOption.Required))
         {
             if (!documentConversionLogBeos.Any())
             {
                 return;
             }
             documentVaultMngr.BulkUpdateConversionLogs(_matterId, documentConversionLogBeos);
             transScope.Complete();
         }
     }
     catch (Exception exception)
     {
         //continue the production process with out updating the conversion /process status
         exception.Trace().Swallow();
     }
 }
        private void AssignDocumentControlNumber(List <LoadFileRecord> records)
        {
            long numericPartOfDcn = 0;

            #region Delegate - logic to get complete DCN readily, given the numeric value as input

            Func <string, string> getDcn = delegate(string newLastDcnNumericPart)
            {
                var padString = string.Empty;
                // pad zeros
                if (newLastDcnNumericPart.Length < m_Dataset.DCNStartWidth.Length)
                {
                    var numberOfZerosTobePadded = m_Dataset.DCNStartWidth.Length - newLastDcnNumericPart.Length;

                    for (var i = 0; i < numberOfZerosTobePadded; i++)
                    {
                        padString += "0";
                    }
                }
                return(m_Dataset.DCNPrefix + padString + newLastDcnNumericPart);
            };

            #endregion Delegate - logic to get complete DCN readily, given the numeric value as input

            using (var lowerTransScope = new EVTransactionScope(TransactionScopeOption.Suppress))
            {
                m_CurrentDcn = DataSetBO.GetLastDocumentControlNumber(m_Dataset.FolderID);

                // If DCN is not obtained, no documents are imported for the dataset till now.
                // So set current DCN to first DCN value.
                if (string.IsNullOrWhiteSpace(m_CurrentDcn))
                {
                    m_CurrentDcn = m_Dataset.DCNPrefix + Constants.StringZero;
                }
                else
                {
                    if (!m_CurrentDcn.Contains(m_Dataset.DCNPrefix))
                    {
                        var currentNumber = Convert.ToInt32(m_CurrentDcn);
                        currentNumber = currentNumber - 1;
                        m_CurrentDcn  = currentNumber.ToString();
                        m_CurrentDcn  = m_Dataset.DCNPrefix + m_CurrentDcn;
                    }
                }
                // 1) Get Last DCN from EVMaster DB and 2) Pick Numeric part of it
                // throws exception if numeric part couldn't be retrieved, throw Exception.
                if (IsNumeric(m_CurrentDcn.Substring(m_Dataset.DCNPrefix.Length), out numericPartOfDcn))
                {
                    // Update new DCN after bulk add, assuming bulk add would be successful.
                    // The delegate, GetNewLastDCNAfterBulkAdd gets DCN to be updated back to DB.
                    // Delegates takes numeric part of WOULD BE DCN value as input, returns complete DCN - so that it can readily be updated back to Dataset table.
                    m_NewDcn = getDcn((numericPartOfDcn + records.Count()).ToString(CultureInfo.InvariantCulture));
                    DataSetBO.UpdateLastDocumentControlNumber(m_Dataset.FolderID, m_NewDcn);
                    lowerTransScope.Complete();
                }
                else
                {
                    throw new Exception(ErrorCodes.InvalidDCNValueObtainedForDataset);
                }
            }

            #region Assign DCN to all documents

            var dCNIncrementalCounter = numericPartOfDcn;
            records.ForEach(p =>
            {
                dCNIncrementalCounter  += 1;
                p.DocumentControlNumber = getDcn(dCNIncrementalCounter.ToString(CultureInfo.InvariantCulture));
            });

            #endregion
        }
 /// <summary>
 /// Bulks the update process set status.
 /// </summary>
 /// <param name="documentConversionLogBeos">The document conversion log beos.</param>
 private void BulkUpdateProcessSetStatus(IList<DocumentConversionLogBeo> documentConversionLogBeos)
 {
     try
     {
         using (var transScope = new EVTransactionScope(TransactionScopeOption.Required))
         {
             if (!documentConversionLogBeos.Any()) return;
             documentVaultMngr.BulkUpdateConversionLogs(_matterId, documentConversionLogBeos);
             transScope.Complete();
         }
     }
     catch (Exception exception)
     {
         //continue the production process with out updating the conversion /process status
         exception.Trace().Swallow();
     }
 }
        /// <summary>
        /// To assign document control number for new documents
        /// </summary>
        /// <param name="documents"></param>
        private void AssignDocumentControlNumber(List<RVWDocumentBEO> documents)
        {
            long numericPartOfDcn;

            #region Delegate - logic to get complete DCN readily, given the numeric value as input

            Func<string, string> getDcn = delegate(string newLastDcnNumericPart)
            {
                var padString = string.Empty;
                // pad zeros
                if (newLastDcnNumericPart.Length < _datasetDetails.DCNStartWidth.Length)
                {
                    var numberOfZerosTobePadded = _datasetDetails.DCNStartWidth.Length -
                                                  newLastDcnNumericPart.Length;
                    for (var i = 0; i < numberOfZerosTobePadded; i++)
                    {
                        padString += "0";
                    }
                }
                return _datasetDetails.DCNPrefix + padString + newLastDcnNumericPart;
            };

            #endregion Delegate - logic to get complete DCN readily, given the numeric value as input

            using (var lowerTransScope = new EVTransactionScope(TransactionScopeOption.Suppress))
            {
                var currentDcn = DataSetBO.GetLastDocumentControlNumber(_datasetDetails.FolderID);

                // If DCN is not obtained, no documents are imported for the dataset till now.
                // So set current DCN to first DCN value.
                if (string.IsNullOrWhiteSpace(currentDcn))
                {
                    currentDcn = _datasetDetails.DCNPrefix + Constants.StringZero;
                }
                else
                {
                    if (!currentDcn.Contains(_datasetDetails.DCNPrefix))
                    {
                        var currentNumber = Convert.ToInt32(currentDcn);
                        currentNumber = currentNumber - 1;
                        currentDcn = currentNumber.ToString(CultureInfo.InvariantCulture);
                        currentDcn = _datasetDetails.DCNPrefix + currentDcn;
                    }
                }
                // 1) Get Last DCN from EVMaster DB and 2) Pick Numeric part of it
                // throws exception if numeric part couldn't be retrieved, throw Exception.
                if (IsNumeric(currentDcn.Substring(_datasetDetails.DCNPrefix.Length), out numericPartOfDcn))
                {
                    // Update new DCN after bulk add, assuming bulk add would be successful.
                    // The delegate, GetNewLastDCNAfterBulkAdd gets DCN to be updated back to DB.
                    // Delegates takes numeric part of WOULD BE DCN value as input, returns complete DCN - so that it can readily be updated back to Dataset table.
                    var newDcn = getDcn((numericPartOfDcn + documents.Count()).ToString(CultureInfo.InvariantCulture));
                    DataSetBO.UpdateLastDocumentControlNumber(_datasetDetails.FolderID, newDcn);
                    lowerTransScope.Complete();
                }
                else
                {
                    throw new Exception(ErrorCodes.InvalidDCNValueObtainedForDataset);
                }
            }

            #region Assign DCN to all documents

            var dCnIncrementalCounter = numericPartOfDcn;
            foreach (var document in documents)
            {
                dCnIncrementalCounter += 1;
                document.DocumentControlNumber = getDcn(dCnIncrementalCounter.ToString(CultureInfo.InvariantCulture));
            }

            #endregion
        }