/// <summary>
 /// The method is called when a preview is request.
 /// </summary>
 /// <param name="request">The <see cref="ManualCompareRequest"/> request to compare.</param>
 /// <returns>The <see cref="RootCompareObject"/> containing information of the comparison.</returns>
 public RootCompareObject Preview(ManualCompareRequest request)
 {
     _currPreviewProgress = new PreviewProgress(request.TagName);
     RootCompareObject rco = ManualSyncer.Compare(request, _currPreviewProgress);
     _currPreviewProgress = null;
     return rco;
 }
Esempio n. 2
0
        /// <summary>
        /// Preview a Sync of a Tag 
        /// </summary>
        /// <param name="tagName">The name of the tag to preview</param>
        /// <exception cref="UnhandledException">Unhandled Exception</exception>
        /// <returns>The RootCompareObject representing the Preview Result. null if the tag does not exist.</returns>
        public RootCompareObject PreviewSync(string tagName)
        {
            //if tagName is null , return null.
            //Write to Developer Log as it cannot be null. 
            if (tagName == null)
            {
                ServiceLocator.GetLogger(ServiceLocator.DEVELOPER_LOG).Write("argument (TagName) @ PreviewSync is null");
                return null;
            }
            try
            {
                //Retrieve the Tag. 
                //If tag is null , throw Tag not found exception.
                Tag tag = TaggingLayer.Instance.RetrieveTag(tagName, false);
                if (tag == null)
                {
                    throw new TagNotFoundException(tagName);
                }
                //Retrieve the list of path that is in the tag that are not deleted.
                List<string> paths = tag.FilteredPathListString;
                //Convert and Filter the file to find all the existing paths.
                List<string>[] filteredPaths = ProfilingLayer.Instance.ConvertAndFilter(paths);
                //If the filter path is more than 1, create a manual compare object.
                //  Call the Method to compare in the CompareAndSyncController.
                //Else Return null.
                if (filteredPaths[0].Count >= 2)
                {
                    ManualCompareRequest request = new ManualCompareRequest(filteredPaths[0].ToArray(), tag.Filters, SyncConfig.Instance, tagName);
                    return CompareAndSyncController.Instance.Preview(request);
                }

                return null;
            }
            catch (TagNotFoundException)
            {
                throw;
            }
            catch (Exception e)
            {
                //Handle some unexpected exception so that it does not hang the UI.
                ServiceLocator.GetLogger(ServiceLocator.DEBUG_LOG).Write(e);
                throw new UnhandledException(e);
            }

        }
Esempio n. 3
0
        /// <summary>
        /// Compares/previews a job given a <see cref="ManualCompareRequest"/> and a <see cref="PreviewProgress"/>.
        /// </summary>
        /// <param name="request">The <see cref="ManualCompareRequest"/> to pass in.</param>
        /// <param name="progress">The <see cref="PreviewProgress"/> to pass in.</param>
        /// <returns></returns>
        public static RootCompareObject Compare(ManualCompareRequest request, PreviewProgress progress)
        {
            List<Filter> filters = request.Filters.ToList();
            filters.Add(FilterFactory.CreateArchiveFilter(request.Config.ArchiveName));
            filters.Add(FilterFactory.CreateArchiveFilter(request.Config.ConflictDir));
            RootCompareObject rco = new RootCompareObject(request.Paths);

            List<string> typeConflicts = new List<string>();
            CompareObjectHelper.PreTraverseFolder(rco, new BuilderVisitor(filters, typeConflicts, progress), progress);
            CompareObjectHelper.PreTraverseFolder(rco, new XMLMetadataVisitor(), progress);
            CompareObjectHelper.PreTraverseFolder(rco, new ProcessMetadataVisitor(), progress);
            CompareObjectHelper.LevelOrderTraverseFolder(rco, new FolderRenameVisitor(), progress);
            ComparerVisitor comparerVisitor = new ComparerVisitor();
            CompareObjectHelper.PostTraverseFolder(rco, comparerVisitor, progress);

            return rco;
        }