CmisSync.Lib.Consumer.SituationSolver.LocalObjectMovedRemoteObjectMoved.Solve C# (CSharp) Method

Solve() public method

Solve the specified situation by using localFile and remote object.
public Solve ( IFileSystemInfo localFileSystemInfo, IObjectId remoteId, ContentChangeType localContent, ContentChangeType remoteContent ) : void
localFileSystemInfo IFileSystemInfo Local filesystem info instance.
remoteId IObjectId Remote identifier or object.
localContent ContentChangeType Hint if the local content has been changed.
remoteContent ContentChangeType Information if the remote content has been changed.
return void
        public override void Solve(
            IFileSystemInfo localFileSystemInfo,
            IObjectId remoteId,
            ContentChangeType localContent,
            ContentChangeType remoteContent)
        {
            if (localFileSystemInfo is IDirectoryInfo) {
                IDirectoryInfo localFolder = localFileSystemInfo as IDirectoryInfo;
                IDirectoryInfo localParent = localFolder.Parent;
                IFolder remoteFolder = remoteId as IFolder;
                string remoteParentId = remoteFolder.ParentId;
                IMappedObject mappedParent = this.Storage.GetObjectByRemoteId(remoteParentId);
                IMappedObject mappedObject = this.Storage.GetObjectByRemoteId(remoteFolder.Id);
                if (localParent.Uuid == mappedParent.Guid) {
                    // Both folders are in the same parent folder
                    this.SyncNamesAndDates(localFolder, remoteFolder, mappedObject);
                } else {
                    OperationsLogger.Warn(
                        string.Format(
                        "Synchronization Conflict: The local directory {0} has been moved to {1} with id {2},{4}" +
                        "but the remote folder was moved to {3}{4}You can fix this situation by moving them into the same folder",
                        localFileSystemInfo.Name,
                        localFileSystemInfo.FullName,
                        remoteFolder.Path,
                        Environment.NewLine));
                    return;
                }
            } else if (localFileSystemInfo is IFileInfo) {
                IFileInfo localFile = localFileSystemInfo as IFileInfo;
                IDirectoryInfo localParent = localFile.Directory;
                IDocument remoteFile = remoteId as IDocument;
                string remoteParentId = remoteFile.Parents[0].Id;
                IMappedObject mappedParent = this.Storage.GetObjectByRemoteId(remoteParentId);
                IMappedObject mappedObject = this.Storage.GetObjectByRemoteId(remoteFile.Id);
                if (localParent.Uuid == mappedParent.Guid) {
                    // Both files are in the same parent folder
                    this.SyncNamesAndDates(localFile, remoteFile, mappedObject);
                    return;
                } else {
                    OperationsLogger.Warn(
                        string.Format(
                        "Synchronization Conflict: The local file {0} has been moved to {1} with id {2},{4}" +
                        "but the remote file was moved to {3}{4}You can fix this situation by moving them into the same folder",
                        localFileSystemInfo.Name,
                        localFileSystemInfo.FullName,
                        remoteFile.Paths[0],
                        Environment.NewLine));
                    return;
                }
            }
        }