private void DeleteOrganizationSource(OrganizationSource os)
 {
     if (os != null)
     {
         os.Source.RemoveOrganizationSource(os);
         os.Organization.RemoveOrganizationSource(os);
         this.orgSourceRepo.Delete(os);
     }
 }
Exemple #2
0
        public virtual void AddOrganizationSource(OrganizationSource os)
        {
            if (this.OrganizationSources.Contains(os))
            {
                return;
            }

            this.OrganizationSources.Add(os);
        }
Exemple #3
0
        public void MergeOrganizationSourceDuplicates()
        {
            IList <ObjectSourceDuplicateDTO> duplicates = this.objectSourceDuplicatesQuery.GetOrganizationSourceDuplicates();

            log.Info("Found " + duplicates.Count + " OrganizationSource duplicates.");
            foreach (ObjectSourceDuplicateDTO dto in duplicates)
            {
                log.Info("Merging " + dto.Count + " OrganizationSources OrganizationID=" + dto.ObjectID + " SourceID=" + dto.SourceID);

                // retrieve all duplicates
                IList <OrganizationSource> orgSources = this.sourceAttachmentTasks.GetOrganizationSources(
                    this.orgTasks.GetOrganization(dto.ObjectID),
                    this.sourceTasks.GetSource(dto.SourceID));

                // select OrganizationSource with highest OrganizationSource.Reliability
                OrganizationSource keep = orgSources.OrderBy(x => x.Reliability).Last();
                orgSources.Remove(keep);

                // merge
                string mergedCommentary = keep.Commentary;
                string mergedNotes      = keep.Notes;
                foreach (OrganizationSource os in orgSources)
                {
                    if (!string.Equals(keep.Commentary, os.Commentary))
                    {
                        mergedCommentary += "; " + os.Commentary;
                    }

                    if (!string.Equals(keep.Notes, os.Notes))
                    {
                        mergedNotes += "; " + os.Notes;
                    }

                    this.sourceAttachmentTasks.DeleteOrganizationSource(os.Id);
                }

                // save merged OrganizationSource
                keep.Commentary = mergedCommentary;
                keep.Notes      = "Merged with duplicates on " + string.Format("{0:ddd MMM yyyy}", DateTime.Now) + ".\n" + mergedNotes;
                this.sourceAttachmentTasks.SaveOrganizationSource(keep);
            }
            log.Info("Finished merging OrganizationSource duplicates.");
        }
 public OrganizationSource SaveOrganizationSource(OrganizationSource os)
 {
     os.Organization.AddOrganizationSource(os);
     os.Source.AddOrganizationSource(os);
     return(this.orgSourceRepo.SaveOrUpdate(os));
 }
Exemple #5
0
 public virtual void RemoveOrganizationSource(OrganizationSource os)
 {
     this.OrganizationSources.Remove(os);
 }