Ejemplo n.º 1
0
 public SyncTaskImpl(Feature owner, string name, SyncAction action, SyncActionConnection actionConnection)
 {
     this._owner            = owner;
     this._name             = name;
     this._action           = action;
     this._actionConnection = actionConnection;
 }
Ejemplo n.º 2
0
        TestFileResult ProcessBeforeCheckout(SyncItem item, bool ignoreSharedFiles, TrackBranch branch)
        {
            TestFileResult result;

            switch (item.SyncAction)
            {
            case SyncAction.New:
                result = BeforeCheckOutCreateFile(item.VcsPath, item.LocalPath, ignoreSharedFiles, branch);
                break;

            case SyncAction.Modify:
                result = BeforeCheckOutModifyFile(item.VcsPath, item.LocalPath, ignoreSharedFiles, item.SingleSharedFile, branch);
                break;

            case SyncAction.Delete:
                result = BeforeCheckOutDeleteFile(item.VcsPath, item.LocalPath, ignoreSharedFiles, branch);
                break;

            case SyncAction.Move:
                SyncAction newAction = SyncAction.Move;
                result          = BeforeCheckOutMoveFile(item.VcsPath, item.NewVcsPath, item.LocalPath, item.NewLocalPath, ignoreSharedFiles, branch, ref newAction);
                item.SyncAction = newAction;
                break;

            default:
                throw new ArgumentException("SyncAction");
            }
            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Starts <paramref name="entity"/> synchronization action for users that has synchronization.
        /// </summary>
        /// <param name="entity"><see cref="Entity"/> instance.</param>
        /// <param name="e"><paramref name="entity"/> event arguments instance.</param>
        /// <param name="action">Synchronization action.</param>
        protected void SyncEntity(Entity entity, EntityAfterEventArgs e, SyncAction action)
        {
            var userConnection = entity.UserConnection;

            if (!userConnection.GetIsFeatureEnabled("ExchangeCalendarWithoutMetadata") ||
                !ClassFactory.HasBinding(typeof(ISynchronizationUCManager)))
            {
                return;
            }
            var asyncExecutor = ClassFactory.Get <IEntityEventAsyncExecutor>(new ConstructorArgument("userConnection", userConnection));

            foreach (var user in GetUsers(entity, action, entity.UserConnection))
            {
                var controllerNames = user.Value;
                if (e.ModifiedColumnValues == null)
                {
                    e.ModifiedColumnValues = new EntityColumnValueCollection(userConnection);
                }
                var operationArgs = new SyncEntityEventAsyncOperationArgs(entity, e);
                operationArgs.Controllers   = controllerNames;
                operationArgs.UserContactId = user.Key;
                operationArgs.Action        = action;
                asyncExecutor.ExecuteAsync <SynchronizationControllerManager>(operationArgs);
            }
        }
Ejemplo n.º 4
0
 public static IRunner CreateRunnerWithPrintCommand()
 {
     return(new Runner
     {
         SyncAction.WithSingleArgument("print", Console.WriteLine, "value"),
     });
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Collects users with synchronizations list, using <see cref="ISynchronizationUCManager"/> implementations.
        /// </summary>
        /// <param name="entity"><see cref="Entity"/> instance.</param>
        /// <param name="action">Synchronization action for <paramref name="entity"/>.</param>
        /// <param name="userConnection"><see cref="UserConnection"/> instance.</param>
        /// <returns>Users with synchronizations list.</returns>
        private Dictionary <Guid, List <string> > GetUsers(Entity entity, SyncAction action, UserConnection userConnection)
        {
            var ucManagers = ClassFactory.GetAll <ISynchronizationUCManager>();
            var users      = new Dictionary <Guid, List <string> >();

            foreach (var ucManager in ucManagers)
            {
                var synchronizationUsers = ucManager.GetSynchronizationUsers(entity, action, userConnection);
                foreach (var userName in synchronizationUsers)
                {
                    if (!users.ContainsKey(userName))
                    {
                        var syncControllers = new List <string> {
                            ucManager.SynchronizationControllerName
                        };
                        users.Add(userName, syncControllers);
                    }
                    else
                    {
                        users[userName].Add(ucManager.SynchronizationControllerName);
                    }
                }
            }
            return(users);
        }
Ejemplo n.º 6
0
 public ItemSyncResult(string name, SyncAction action, SyncState state, Exception exception)
 {
     Name      = name;
     Action    = action;
     State     = state;
     Exception = exception;
 }
Ejemplo n.º 7
0
        private void ExecuteSyncAction(SaveFileHandler saveHandler, SyncAction action)
        {
            if (action != SyncAction.None)
            {
                Logger.Info($"Performing Sync Action: {action}, on {saveHandler.LocalSaveFile.GameTitle}");
            }
            else
            {
                Logger.Debug($"Performing Sync Action: {action}, on {saveHandler.LocalSaveFile.GameTitle}");
            }
            switch (action)
            {
            case SyncAction.Push:
            {
                saveHandler.RemoteSaveFile.PushSaves();
                break;
            }

            case SyncAction.Pull:
            {
                saveHandler.RemoteSaveFile.PullSaves();
                break;
            }

            case SyncAction.None:
            {
                break;
            }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Sets<paramref name="exchangeTask"/> properties to <paramref name="activity"/>.
        /// </summary>
        /// <param name="activity">Activity instance.</param>
        /// <param name="exchangeTask"><see cref="Exchange.Task"/> instance.</param>
        /// <param name="context"><see cref="SyncContext"/> instance.</param>
        /// <param name="action">Current synchronization action.</param>
        protected virtual void SetActivityProperties(Entity activity, Exchange.Task exchangeTask, SyncContext context,
                                                     SyncAction action)
        {
            activity.SetColumnValue("ShowInScheduler", false);
            DateTime startDate;
            DateTime dueDate;

            SetStartAndDueDate(context.UserConnection, exchangeTask, out startDate, out dueDate);
            if (action == SyncAction.Update)
            {
                startDate = startDate.Date + activity.GetTypedColumnValue <DateTime>("StartDate").TimeOfDay;
                dueDate   = dueDate.Date + activity.GetTypedColumnValue <DateTime>("DueDate").TimeOfDay;
            }
            activity.SetColumnValue("Title", exchangeTask.Subject);
            activity.SetColumnValue("StartDate", startDate);
            activity.SetColumnValue("DueDate", dueDate);
            activity.SetColumnValue("OwnerId", context.UserConnection.CurrentUser.ContactId);
            activity.SetColumnValue("AuthorId", context.UserConnection.CurrentUser.ContactId);
            activity.SetColumnValue("PriorityId", exchangeTask.Importance.GetActivityPriority());
            activity.SetColumnValue("StatusId", exchangeTask.Status.GetActivityStatus());
            SetActivityRemindToOwner(context, activity, exchangeTask);
            if (activity.GetTypedColumnValue <bool>("RemindToOwner"))
            {
                activity.SetColumnValue("RemindToOwnerDate", exchangeTask.SafeGetValue <DateTime>(
                                            Exchange.TaskSchema.ReminderDueBy).GetUserDateTime(context.UserConnection));
            }
            else
            {
                activity.SetColumnValue("RemindToOwnerDate", null);
            }
            activity.SetColumnValue("Notes", exchangeTask.Body.Text);
        }
        public SyncActionType Choose(SyncAction action)
        {
            if (action.Remote == null || action.Remote.IsDeleted)
            {
                if (action.Local != null)
                {
                    return(SyncActionType.DeleteLocal);
                }
                else
                {
                    return(SyncActionType.None);
                }
            }

            if (action.Local == null)
            {
                return(SyncActionType.Download);
            }

            if (action.Local.IsFolder ||
                action.Remote.ServerRev == action.Local.ServerRev ||
                action.Remote.Hash == action.Local.Hash)
            {
                return(SyncActionType.None);
            }

            return(SyncActionType.Download);
        }
        /// <summary>
        /// <see cref="ISynchronizationUCManager.GetSynchronizationUsers(Entity, SyncAction, UserConnection)"/>
        /// </summary>
        public IEnumerable <Guid> GetSynchronizationUsers(Entity entity, SyncAction action, UserConnection userConnection)
        {
            var result = new List <Guid>();

            if (!userConnection.GetIsFeatureEnabled("ExchangeCalendarWithoutMetadata"))
            {
                return(result);
            }
            var entityId = GetRelatedEntityId(entity);

            if (entityId.IsEmpty())
            {
                return(result);
            }
            if (action == SyncAction.Delete)
            {
                return(GetUsersForDeleteAction(entityId, userConnection));
            }
            var select = GetUsersSelect(userConnection, entityId);

            if (select != null)
            {
                using (DBExecutor dbExecutor = userConnection.EnsureDBConnection()) {
                    using (IDataReader reader = select.ExecuteReader(dbExecutor)) {
                        while (reader.Read())
                        {
                            result.AddIfNotExists(reader.GetColumnValue <Guid>("CreatedById"));
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 11
0
        public ISyncActionInformation CreateSyncActionInformation(SyncAction action)
        {
            var sa = new SyncActionInformation(action);

            SyncActionInformations.Add(sa);
            return(sa);
        }
Ejemplo n.º 12
0
        public static IEnumerable <CssRuleBlockSyncAction> ComputeSyncActions(RuleSet existingRule, string newText, string oldText = null)
        {
            var realOldText = oldText ?? existingRule.Text;
            var parser      = new CssParser();
            var oldDoc      = parser.Parse(realOldText, false);
            var oldDict     = ProduceKeyValuePairsFromRuleSet(oldDoc.Children.OfType <RuleSet>().Single());

            if (newText == null && oldText != null)
            {
                return(OrderAndExtractSyncActions(oldDict.Keys.Select(x => SyncAction.Delete(existingRule, x))));
            }

            var newDoc            = parser.Parse(newText, false);
            var newDict           = ProduceKeyValuePairsFromRuleSet(newDoc.Children.OfType <RuleSet>().Single());
            var oldToNewDiff      = CompareNewRuleAndOldRule(existingRule, newDict, oldDict);
            var processedElements = new HashSet <string>(oldToNewDiff.Select(x => x.PropertyName));

            foreach (var item in oldDict.Keys.Except(processedElements))
            {
                //Delete
                oldToNewDiff.Add(SyncAction.Delete(existingRule, item));
                processedElements.Add(item);
            }

            if (oldText == null)
            {
                return(oldToNewDiff.Select(x => x.Action));
            }

            var priorityDiff = ReconcileExistingRuleWithDiff(existingRule, oldToNewDiff);
            var combined     = priorityDiff.Union(oldToNewDiff);
            var simplified   = SimplifySyncActions(combined);

            return(OrderAndExtractSyncActions(simplified));
        }
Ejemplo n.º 13
0
 public SyncLog(SyncAction action, SyncType type, dynamic item, string message)
 {
     Action     = action;
     Type       = type;
     Item       = item;
     Successful = false;
     Message    = message;
 }
Ejemplo n.º 14
0
 public AGoto(SyncAction targetAction)
 {
     if (targetAction == null)
     {
         throw new ArgumentNullException(nameof(targetAction));
     }
     _targetAction = targetAction;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Returns true if <see cref="Microsoft.Exchange.WebServices.Data.Appointment"/> must be saved
        /// without participants notifications.</summary>
        /// <param name="exchangeAppointment">Exchange appointment instance.</param>
        /// <param name="exchangeItem">Exchange item instance.</param>
        /// <returns>Dont send notifications flag.</returns>
        public bool GetDontSendNotifications(ExchangeAppointment exchangeAppointment, Exchange.Appointment exchangeItem)
        {
            SyncAction action = exchangeAppointment.Action;

            return(!(exchangeAppointment.SendNotifications &&
                     (action == SyncAction.Create || HasAnotherAttendees(exchangeItem))
                     ));
        }
Ejemplo n.º 16
0
 /// <summary>
 /// <see cref="ExchangeSyncProvider.GetCurrentActionIgnored"/>
 /// </summary>
 protected override bool GetCurrentActionIgnored(SyncAction action)
 {
     if (_userConnection.GetIsFeatureEnabled("SyncDeletedAppointments"))
     {
         return(false);
     }
     return(base.GetCurrentActionIgnored(action));
 }
Ejemplo n.º 17
0
 public SyncMap(SyncProfile profile,
                SyncDirection direction,
                SyncAction defaultAction)
 {
     this._profile = profile;
     _defaultSyncAction = defaultAction;
     _syncDirection = direction;
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Handles the execution of a selection-dependent action that runs synchronous to MMC.
        /// </summary>
        /// <param name="action">The executed action.</param>
        /// <param name="status">The object that holds the status information.</param>
        protected override void OnSyncSelectionAction(SyncAction action, SyncStatus status)
        {
            if (action == this.CopyToClipboardAction)
            {
                OnCopyToClipboard(status);
            }

            base.OnSyncAction(action, status);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// return true if assign was ok, false if action already existsts
 /// </summary>
 /// <param name="action"></param>
 /// <returns></returns>
 public bool AssignAction(SyncAction action)
 {
     if (m_next == null)
     {
         m_next = action;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 20
0
        public ISyncActionInformation CreateSyncActionInformation(SyncAction action)
        {
            var sa = new SyncActionInformation(action);

            _interactionService.CheckBeginInvokeOnUi(() =>
            {
                SyncActionInformations.Add(sa);
            });
            return(sa);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Checks if remote entity already locked for synchronization.
        /// </summary>
        /// <param name="context">Synchronization context.</param>
        /// <param name="action"><see cref="SyncAction"/> instance.</param>
        /// <returns><c>True</c> if appointment already locked for synchronization, <c>false</c> otherwise.
        /// </returns>
        protected bool GetRemoteItemLockedForSync(SyncContext context, SyncAction action)
        {
            if (action != SyncAction.Create)
            {
                return(false);
            }
            var helper = ClassFactory.Get <EntitySynchronizerHelper>();

            return(!helper.CanCreateEntityInLocalStore(Id, context.UserConnection, "Exchange integration"));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// <see cref="ExchangeSyncProvider.ApplyChanges"/>
        /// </summary>
        public override void ApplyChanges(SyncContext context, IRemoteItem syncItem)
        {
            base.ApplyChanges(context, syncItem);
            SyncAction action = syncItem.Action;

            if (action == SyncAction.Create)
            {
                ((ExchangeContact)syncItem).InitIdProperty(context, true);
            }
        }
Ejemplo n.º 23
0
 public void ResolveAction()
 {
     //Debug.Log("Resolving Next Action");
     if (m_next != null)
     {
         //Debug.Log(name +" Executing Action");
         m_next.Execute();
         m_next = null;
     }
 }
Ejemplo n.º 24
0
 public static IRunner CreateRunnerWithSyncSleepCommand()
 {
     return(new Runner
     {
         SyncAction.WithSingleArgument(
             "sync-sleep",
             argument => Thread.Sleep(Convert.ToInt32(argument)),
             "millisecondsDelay"),
     });
 }
Ejemplo n.º 25
0
        private void SyncChange(SyncAction action)
        {
            if (suspendCount > 0 || Other == null)
            {
                return;
            }

            using (Other.SuspendLogic())
                action(Other);
        }
Ejemplo n.º 26
0
        public void CommandsTest()
        {
            var action     = SyncAction.WithSingleArgument("print", Console.WriteLine, "value");
            var dictionary = new InvariantStringDictionary <IAction>
            {
                { "print", action },
            };

            BaseContainsTest(dictionary, "print", action);
        }
        public static void Sync(Control control, SyncAction action)
        {
            if (control.InvokeRequired)
            {
                control.Invoke(action, new object[] { });
                return;
            }

            action();
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Writes log message.
 /// </summary>
 /// <param name="context"><see cref="SyncContext"/> instance.</param>
 /// <param name="action"><see cref="SyncAction"/> enumeration.</param>
 /// <param name="syncDirection"><see cref="SyncDirection"/> enumeration.</param>
 /// <param name="format">String a composite format.</param>
 /// <param name="ex">Exception.</param>
 /// <param name="args">An array of additional parameters.</param>
 public virtual void LogMessage(SyncContext context, SyncAction action, SyncDirection syncDirection, string format, Exception ex, params object[] args)
 {
     if (ex == null)
     {
         context.LogInfo(action, syncDirection, format, args);
     }
     else
     {
         context.LogError(action, syncDirection, format, ex, args);
     }
 }
Ejemplo n.º 29
0
        protected string RunAndCaptureInternalLog(SyncAction action, LogLevel internalLogLevel)
        {
            var stringWriter = new Logger();

            InternalLogger.LogWriter        = stringWriter;
            InternalLogger.LogLevel         = LogLevel.Trace;
            InternalLogger.IncludeTimestamp = false;
            action();

            return(stringWriter.ToString());
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Adds a synchronisation task.
        /// </summary>
        /// <param name="owner">The feature owning the task.</param>
        /// <param name="name">The task's name, for logging.</param>
        /// <param name="action">The action to execute.</param>
        public SyncTask AddTask(Feature owner, string name, SyncAction action)
        {
            if (_started)
            {
                throw new Exception("Already started, cannot add task");
            }
            SyncTaskImpl task = new SyncTaskImpl(owner, name, action, null);

            _tasks.Add(task);
            return(task);
        }
Ejemplo n.º 31
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            SyncAction action = (SyncAction)value;

            if (action.ChangeType == ChangeType.RENAMED)
            {
                return(((RenameAction)action).PreviousRelativeFilePath);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 32
0
		private ISyncronizationProvider GetProvider(SyncAction action)
		{
			//TODO - Place in container?
			switch (action)
			{
				case SyncAction.Download:
					return new DownloadDeleteSyncronizationProvider(_messageBus, _fileSystem);
				case SyncAction.DownloadKeep:
					return new DownloadKeepSyncronizationProvider(_messageBus, _fileSystem);
				case SyncAction.Upload:
					return new UploadSyncronizationProvider(_messageBus, _fileSystem);
				default:
					return new UploadAnalysisSyncronizationProvider(this._fileSystem);
			}
		}
Ejemplo n.º 33
0
        public void AddDataRow(FileUnit u, SyncAction action)
        {
            string path = "";
            AddImageToList(u);

            DataRow row = dtCompare.NewRow();

            if (u.AbsolutePath.StartsWith(source))
            {
                path = u.AbsolutePath.Substring(source.Length);
                if (!u.IsDirectory)
                {
                    row[1] = u.Size;
                    row[2] = u.LastWriteTime;
                }
            }
            else
            {
                path = u.AbsolutePath.Substring(target.Length);
                if (!u.IsDirectory)
                {
                    row[5] = u.Size;
                    row[6] = u.LastWriteTime;
                }
            }

            if (u.Match != null)
            {
               row[5] = u.Match.Size;
               row[6] = u.Match.LastWriteTime;
            }

            row[0] = path;
            row[3] = action;
            row[4] = path;
            row[7] = u.Extension;
            row[8] = u;

            dtCompare.Rows.Add(row);
        }
Ejemplo n.º 34
0
        public void AddDataRow(FileUnit u, SyncAction action)
        {
            AddImageToList(u);
            DataRow row = _dtCompare.NewRow();

            if (u.AbsolutePath.StartsWith(_source))
            {
                row[0] = u.AbsolutePath.Substring(_source.Length);
                row[4] = u.MatchingPath;
                if (!u.IsDirectory)
                {
                    row[1] = u.Size;
                    row[2] = u.LastWriteTime;
                }
                if (u.Match != null)
                {
                    row[5] = u.Match.Size;
                    row[6] = u.Match.LastWriteTime;
                }
            }
            else
            {
                row[4] = u.AbsolutePath.Substring(_target.Length);
                row[0] = u.MatchingPath;
                if (!u.IsDirectory)
                {
                    row[5] = u.Size;
                    row[6] = u.LastWriteTime;
                }
            }

            row[3] = row[9] = action;
            row[7] = u.Extension;
            row[8] = u;
            row[10] = (u.IsDirectory) ? "dir" : "file";
            _dtCompare.Rows.Add(row);
        }
Ejemplo n.º 35
0
        public override void InsertOrIgnoreAction(SyncAction action, SQLiteCommand cmd)
        {
            string actionVal = action.ToString();
            cmd.Parameters.Clear();

            cmd.CommandText =
                //"INSERT OR IGNORE INTO SyncAction (SyncActionValue) VALUES (@actionVal)";
                "INSERT OR IGNORE INTO " + NwdContract.TABLE_SYNC_ACTION +
                " (" + NwdContract.COLUMN_SYNC_ACTION_VALUE +
                ") VALUES (@actionVal)";

            cmd.Parameters.AddWithValue("@actionVal", actionVal);
            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 36
0
 public abstract void InsertOrIgnoreAction(SyncAction action, SQLiteCommand cmd);
Ejemplo n.º 37
0
 protected void Sync(SyncAction syncAction)
 {
     this.syncAction = syncAction;
     Helpers.Sync();
 }
Ejemplo n.º 38
0
        TestFileResult BeforeCheckOutMoveFile(string vcsPath, string newVcsPath, string localPath, string newLocalPath, bool ignoreSharedFiles, TrackBranch branch, ref SyncAction newAction)
        {
            bool isOldPathTracking = branch.IsTrackingVcsPath(vcsPath);
            bool isNewPathTracking = branch.IsTrackingVcsPath(newVcsPath);

            if (isOldPathTracking && !PerformHasFileTestBeforeCheckout(vcsPath)) {
                Log.Error($"Check move capability. Source file {vcsPath} is not found in vcs.");
                return TestFileResult.Fail;
            }
            if (isNewPathTracking && PerformHasFileTestBeforeCheckout(newVcsPath)) {
                Log.Error($"Check move capability. Target file {newVcsPath} is found in vcs.");
                return TestFileResult.Fail;
            }

            if(!isNewPathTracking && !isOldPathTracking)
                return TestFileResult.Ignore;
            if(isNewPathTracking && !isOldPathTracking) {
                newAction = SyncAction.New;
                return BeforeCheckOutCreateFile(newVcsPath, localPath, ignoreSharedFiles, branch);
            }
            else if(!isNewPathTracking && isOldPathTracking) {
                newAction = SyncAction.Delete;
                return BeforeCheckOutDeleteFile(vcsPath, localPath, ignoreSharedFiles, branch);
            }

            var oldPathResult = PerformSimpleTestBeforeCheckout(vcsPath, ignoreSharedFiles, false, false);
            if (oldPathResult != TestFileResult.Ok)
                return oldPathResult;
            return PerformSimpleTestBeforeCheckout(newVcsPath, ignoreSharedFiles, false, false);
        }
        private void SyncChange(SyncAction action)
        {
            if (suspendCount > 0 || Other == null)
                return;

            using (Other.SuspendLogic())
                action(Other);
        }
Ejemplo n.º 40
0
        private void setChildSyncAction(SyncAction action)
        {
            if (lvCompare.FocusedItem == null) return;

            int idx = lvCompare.FocusedItem.Index;

            if (dvCompare[idx][7].ToString().Equals("dir"))
            {
                String parent = ((FileUnit)dvCompare[idx][8]).AbsolutePath;

                foreach (DataRowView r in dvCompare)
                {
                    FileUnit cur = (FileUnit)r[8];
                    if (cur.AbsolutePath.StartsWith(parent))
                        r[3] = action;
                }
            }
            else
                dvCompare[idx][3] = action;

            lvCompare.Invalidate();
        }
Ejemplo n.º 41
0
        private void ChangeSyncAction(SyncAction action, int idx)
        {
            if (((SyncAction)_dvCompare[idx][3]) == action) return;

            if (((SyncAction)_dvCompare[idx][3]) == SyncAction.Skip)
            {
                FileUnit cur = ((FileUnit)_dvCompare[idx][8]);
                PreviewUnit preview = null;
                try
                {
                    preview = _previewFoldersList.GetByPrimary(
                       Directory.GetParent(cur.AbsolutePath).FullName);
                }
                catch
                {
                }

                if (preview == null || (preview != null && preview.sAction != SyncAction.Skip))
                {
                    _dvCompare[idx][3] = action;
                    UpdatePreviewList(idx, action);
                }
            }
            else
            {
                _dvCompare[idx][3] = action;
                UpdatePreviewList(idx, action);
            }
            lvCompare.Invalidate(lvCompare.Items[idx].SubItems[3].Bounds);
        }
Ejemplo n.º 42
0
        protected string RunAndCaptureInternalLog(SyncAction action, LogLevel internalLogLevel)
        {
            var stringWriter = new StringWriter();
            var oldWriter = InternalLogger.LogWriter;
            var oldLevel = InternalLogger.LogLevel;
            var oldIncludeTimestamp = InternalLogger.IncludeTimestamp;
            try
            {
                InternalLogger.LogWriter = stringWriter;
                InternalLogger.LogLevel = LogLevel.Trace;
                InternalLogger.IncludeTimestamp = false;
                action();

                return stringWriter.ToString();
            }
            finally
            {
                InternalLogger.LogWriter = oldWriter;
                InternalLogger.LogLevel = oldLevel;
                InternalLogger.IncludeTimestamp = oldIncludeTimestamp;
            }
        }
Ejemplo n.º 43
0
 internal void AddToSync(Entity entity, SyncAction syncAction)
 {
     entity.SyncAction |= syncAction;
     _entitySyncList.Add(entity);
 }
Ejemplo n.º 44
0
 internal void AddToSync(Component component, SyncAction syncAction)
 {
     component.SyncAction |= syncAction;
     _componentSyncList.Add(component);
     AddToSync(component.Owner, SyncAction.Resolve);
 }
Ejemplo n.º 45
0
 protected void CancelSync()
 {
     syncAction = null;
 }
Ejemplo n.º 46
0
        private void ChangeSyncAction(SyncAction action, int idx)
        {
            if (((SyncAction)_dvCompare[idx][3]) == action) return;

            if (((SyncAction)_dvCompare[idx][3]) == SyncAction.Skip)
            {
                FileUnit cur = ((FileUnit)_dvCompare[idx][8]);
                PreviewUnit preview = null;
                try
                {
                    string parent = (new DirectoryInfo(cur.AbsolutePath)).Parent.FullName + "\\";

                    if (cur.AbsolutePath.StartsWith(_source))
                        parent = parent.Substring(_source.Length);
                    else
                        parent = parent.Substring(_target.Length);

                    preview = _previewFoldersList.GetByPrimary(parent);
                }
                catch
                {
                }

                if (preview == null || (preview != null && preview.sAction != SyncAction.Skip))
                {
                    _dvCompare[idx][3] = action;
                    UpdatePreviewList(idx, action);
                }
            }
            else
            {
                _dvCompare[idx][3] = action;
                UpdatePreviewList(idx, action);
            }
            lvCompare.Invalidate(lvCompare.Items[idx].SubItems[3].Bounds);
        }
Ejemplo n.º 47
0
 public void InsertOrIgnoreAction(SyncAction action, SQLiteCommand cmd)
 {
     db.InsertOrIgnoreAction(action, cmd);
 }
Ejemplo n.º 48
0
        private void UpdatePreviewList(int idx, SyncAction action)
        {
            string path = _dvCompare[idx][0].ToString();
            FileUnit cur = (FileUnit)_dvCompare[idx][8];

            if (cur.IsDirectory)
            {
               PreviewUnit unit = _previewFoldersList.GetByPrimary(path);
               unit.sAction = action;
               _previewFoldersList.SetByPrimary(path, unit);
            }
            else
            {
                PreviewUnit unit = _previewFilesList.GetByPrimary(path);
                unit.sAction = action;
                _previewFilesList.SetByPrimary(path, unit);
            }
        }
Ejemplo n.º 49
0
        private void ChangeSyncAction(SyncAction action)
        {
            if (lvCompare.FocusedItem == null) return;

            int idx = lvCompare.FocusedItem.Index;
            dvCompare[idx][3] = action;
            lvCompare.Invalidate(lvCompare.FocusedItem.SubItems[3].Bounds);
        }
Ejemplo n.º 50
0
        private void SetChildSyncAction(SyncAction action, int idx)
        {
            if (_dvCompare[idx][7].ToString().Equals("dir"))
            {
                String parent = ((FileUnit)_dvCompare[idx][8]).AbsolutePath;

                for (int i = 0; i < _dvCompare.Count; i++)
                {
                    FileUnit cur = (FileUnit)_dvCompare[i][8];
                    if (cur.AbsolutePath.StartsWith(parent))
                    {
                        _dvCompare[i][3] = action;
                        UpdatePreviewList(i, action);
                    }
                }
            }
            else
            {
                _dvCompare[idx][3] = action;
                UpdatePreviewList(idx, action);
            }
            lvCompare.Invalidate();
        }
Ejemplo n.º 51
0
        private void ComputeStatisticsResult(FileUnit u, SyncAction action)
        {
            switch (action)
            {
                case SyncAction.CopyFileToSource:
                    _numOfTFilesCpy++;
                    if (u.Match != null)
                    {
                        _tFilesCpySize += u.Match.Size;
                        _numOfSFilesOW++;
                        _sFilesOWSize += u.Size;
                    }
                    else
                        _tFilesCpySize += u.Size;

                    break;

                case SyncAction.CopyFileToTarget:
                    _numOfSFilesCpy++;
                    _sFilesCpySize += u.Size;
                    if (u.Match != null)
                    {
                        _numOfTFilesOW++;
                        _tFilesOWSize += u.Match.Size;
                    }
                    break;

                case SyncAction.DeleteSourceFile:
                    _numOfSFilesDel++;
                    _sFilesDelSize += u.Size;
                    break;

                case SyncAction.DeleteTargetFile:
                    _numOfTFilesDel++;
                    _tFilesDelSize += u.Size;
                    break;

                case SyncAction.KeepBothCopies:
                    _numOfSFilesCpy++;
                    _numOfTFilesCpy++;
                    _sFilesCpySize += u.Size;
                    _tFilesCpySize += u.Match.Size;
                    break;

                case SyncAction.CreateSourceDir:
                    _numOfSFoldersC++;
                    break;

                case SyncAction.CreateTargetDir:
                    _numOfTFoldersC++;
                    break;

                case SyncAction.DeleteBothDir:
                    _numOfSFoldersDel++;
                    _numOfTFoldersDel++;
                    break;

                case SyncAction.DeleteSourceDir:
                    _numOfSFoldersDel++;
                    break;

                case SyncAction.DeleteTargetDir:
                    _numOfTFoldersDel++;
                    break;
            }
        }
Ejemplo n.º 52
0
        protected string RunAndCaptureInternalLog(SyncAction action, LogLevel internalLogLevel)
        {
            var stringWriter = new StringWriter();
            InternalLogger.LogWriter = stringWriter;
            InternalLogger.LogLevel = LogLevel.Trace;
            InternalLogger.IncludeTimestamp = false;
            action();

            return stringWriter.ToString();
        }
Ejemplo n.º 53
0
 /// <summary>
 /// Constructs a new SyncOperation recording a single synchronisation action.
 /// </summary>
 /// <param name="source">The source file (eg copy from)</param>
 /// <param name="target">The target file (eg copy to)</param>
 /// <param name="action">The action taken</param>
 public SyncOperation(string source, string target, SyncAction action)
 {
     SourceFile = source;
     TargetFile = target;
     Action = action;
 }
Ejemplo n.º 54
0
 public int GetActionId(SyncAction action)
 {
     return actionIds[action];
 }
Ejemplo n.º 55
0
 protected void Sync(SyncAction syncAction, string data)
 {
     this.syncAction = syncAction;
     Helpers.Sync(data);
 }
Ejemplo n.º 56
0
 protected void Sync(SyncAction syncAction, string data, int timeout)
 {
     this.syncAction = syncAction;
     Helpers.Sync(data, timeout);
 }