Exemple #1
0
        protected override void BeginWork()
        {
            base.BeginWork();

            var jobParameters = Utils.SmartXmlDeserializer(BootParameters);

            var profileBEO = jobParameters as ProfileBEO;

            if (profileBEO != null)
            {
                ThreadsLinkingRequested  = profileBEO.IsMapEmailThread;
                FamiliesLinkingRequested = profileBEO.IsImportFamilyRelations;

                if (profileBEO.ImportTypeName.Contains("E-docs"))
                {
                    ThreadsLinkingRequested  = true;
                    FamiliesLinkingRequested = true;
                }

                CollectionId = profileBEO.DatasetDetails.CollectionId;
                MatterId     = profileBEO.DatasetDetails.Matter.FolderID;
                IsOverlay    = !profileBEO.IsAppend;
            }

            var lawImportBEO = jobParameters as LawImportBEO;

            if (lawImportBEO != null)
            {
                ThreadsLinkingRequested  = lawImportBEO.CreateThreads;
                FamiliesLinkingRequested = lawImportBEO.CreateFamilyGroups;

                CollectionId = lawImportBEO.CollectionId;
                MatterId     = lawImportBEO.MatterId;
                IsOverlay    = lawImportBEO.ImportOptions != ImportOptionsBEO.AppendNew;
            }

            if (profileBEO == null && lawImportBEO == null)
            {
                throw new EVException().AddDbgMsg("Unknown type of bootparameters: {0}", BootParameters);
            }

            vaultHelper = new VaultHelper(MatterId, CollectionId);

            Tracer.Info(
                "MatterId = {0}, CollectionId = {1}, VaultConnectionString = {2}, IsOverlay = {3}, ThreadsLinkingRequested = {4}, FamiliesLinkingRequested = {5}",
                MatterId, CollectionId, vaultHelper.VaultConnectionString, IsOverlay, ThreadsLinkingRequested,
                FamiliesLinkingRequested);

            Dictionary <DocumentId, ExistingThreadRecord> existingThreads = null;

            if (IsOverlay)
            {
                existingThreads = vaultHelper.LoadExistingThreads();
            }

            _threadsProcessor = new ThreadsProcessor(IsOverlay, existingThreads);

            resultsAccumulator = new ThreadsCalculationResults();
        }
        protected override void BeginWork()
        {
            base.BeginWork();

            var jobParameters = Utils.SmartXmlDeserializer(BootParameters);

            var profileBEO = jobParameters as ProfileBEO;
            if (profileBEO != null)
            {
                ThreadsLinkingRequested = profileBEO.IsMapEmailThread;
                FamiliesLinkingRequested = profileBEO.IsImportFamilyRelations;

                if (profileBEO.ImportTypeName.Contains("E-docs"))
                {
                    ThreadsLinkingRequested = true;
                    FamiliesLinkingRequested = true;
                }

                CollectionId = profileBEO.DatasetDetails.CollectionId;
                MatterId = profileBEO.DatasetDetails.Matter.FolderID;
                IsOverlay = !profileBEO.IsAppend;
            }

            var lawImportBEO = jobParameters as LawImportBEO;
            if (lawImportBEO != null)
            {
                ThreadsLinkingRequested = lawImportBEO.CreateThreads;
                FamiliesLinkingRequested = lawImportBEO.CreateFamilyGroups;

                CollectionId = lawImportBEO.CollectionId;
                MatterId = lawImportBEO.MatterId;
                IsOverlay = lawImportBEO.ImportOptions != ImportOptionsBEO.AppendNew;
            }

            if (profileBEO == null && lawImportBEO == null)
            {
                throw new EVException().AddDbgMsg("Unknown type of bootparameters: {0}", BootParameters);
            }

            vaultHelper = new VaultHelper(MatterId, CollectionId);

            Tracer.Info(
                "MatterId = {0}, CollectionId = {1}, VaultConnectionString = {2}, IsOverlay = {3}, ThreadsLinkingRequested = {4}, FamiliesLinkingRequested = {5}",
                MatterId, CollectionId, vaultHelper.VaultConnectionString, IsOverlay, ThreadsLinkingRequested,
                FamiliesLinkingRequested);

            Dictionary<DocumentId, ExistingThreadRecord> existingThreads = null;
            if (IsOverlay)
            {
                existingThreads = vaultHelper.LoadExistingThreads();
            }

            _threadsProcessor = new ThreadsProcessor(IsOverlay, existingThreads);

            resultsAccumulator = new ThreadsCalculationResults();
        }
        private void FinalizeRelationships()
        {
            Tracer.Debug("Families calculation started.");

            if (ThreadsLinkingRequested || IsOverlay)
            {
                var existingThreads = vaultHelper.LoadExistingThreads();

                Tracer.Debug("FamiliesLinker got {0} existing thread records.", existingThreads.Count);

                familiesProcessor.AppendThreadsRecords(existingThreads);
            }

            var finalParentRecords = familiesProcessor.FinalizeRelationships();

            Tracer.Debug("Families calculation completed. Starting production: Insert {0}, Update {1}, LeaveAlone {2}",
                         finalParentRecords.Count(p => p.Disposition == DispositionEnum.Insert),
                         finalParentRecords.Count(p => p.Disposition == DispositionEnum.Update),
                         finalParentRecords.Count(p => p.Disposition == DispositionEnum.LeaveAlone));

            ProduceFamiliesRecords(finalParentRecords);
            Tracer.Debug("Families production completed.");
        }