コード例 #1
0
        public void Init()
        {
            handlers = new SortedList<int, ISyncHandler>();

            var types = TypeFinder.FindClassesOfType<ISyncHandler>();

            LogHelper.Info<uSyncBackOfficeContext>("Loading up Sync Handlers : {0}", () => types.Count());
            foreach (var t in types)
            {
                var typeInstance = Activator.CreateInstance(t) as ISyncHandler;
                if (typeInstance != null)
                {
                    LogHelper.Debug<uSyncBackOfficeContext>("Adding Instance: {0}", () => typeInstance.Name);
                    handlers.Add(typeInstance.Priority, typeInstance);
                }
            }

            uSyncCoreContext.Instance.Init();
            _config = new uSyncBackOfficeConfig();

            Tracker = new Helpers.ActionTracker(_config.Settings.MappedFolder());
        }
コード例 #2
0
        public void Init()
        {
            handlers = new SortedList <int, ISyncHandler>();

            var types = TypeFinder.FindClassesOfType <ISyncHandler>();

            LogHelper.Info <uSyncBackOfficeContext>("Loading up Sync Handlers : {0}", () => types.Count());
            foreach (var t in types)
            {
                var typeInstance = Activator.CreateInstance(t) as ISyncHandler;
                if (typeInstance != null)
                {
                    LogHelper.Debug <uSyncBackOfficeContext>("Adding Instance: {0}", () => typeInstance.Name);
                    handlers.Add(typeInstance.Priority, typeInstance);
                }
            }

            uSyncCoreContext.Instance.Init();
            _config = new uSyncBackOfficeConfig();

            Tracker = new Helpers.ActionTracker(_config.Settings.MappedFolder());
        }
コード例 #3
0
        /// <summary>
        ///  workout what is a delete, anything that isn't in the target but is in the master
        ///  should be a delete.
        /// </summary>
        /// <param name="master"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        private void IdentifyDeletes(string master, string target)
        {
            var missingFiles = MigrationIO.LeftOnlyFiles(master, target);

            var actionTracker = new ActionTracker(target);

            foreach(var file in missingFiles)
            {
                // work out the type of file...
                if (File.Exists(file.FullName))
                {
                    XElement node = XElement.Load(file.FullName);
                    var itemType = node.GetUmbracoType();
                    var key = node.NameFromNode();

                    // we need to find id's to handle deletes,
                    // and we need to check that the thing hasn't been renamed. 
                    // so if it exsits only in master we need to double check its id 
                    // doesn't still exist somewhere else on the install with the 
                    // same id but a different name, 

                    // we basically need some id hunting shizzel. 
                    if (itemType != default(Type))
                    {
                        var fileKey = MigrationIDHunter.GetItemId(node);
                        if (!string.IsNullOrEmpty(fileKey))
                        {
                            if (MigrationIDHunter.FindInFiles(target, fileKey))
                            {
                                // the key exists somewhere else in the 
                                // folder, so it's a rename of something
                                // we won't add this one to the delete pile.

                                // but we will need to signal somehow that 
                                // the old name is wrong, so that on a full
                                // merge the two files don't get included.
                                actionTracker.AddAction(SyncActionType.Obsolete, file.FullName, itemType);

                                continue;
                            }
                        }
                    }

                    // if we can't workout what type of thing it is, we assume
                    // it's a file, then we can deal with it like a delete 
                    // later on.
                    if (itemType == default(Type))
                        itemType = typeof(FileInfo);

                    actionTracker.AddAction(SyncActionType.Delete, key, itemType);
                }

            }

            actionTracker.SaveActions();
        }