Beispiel #1
0
        public override NodeResult Run()
        {
            BasicProfile profile = new BasicProfile();

            profile.DiffType = diffType.Value;
            profile.SyncType = syncType.Value;

            profile.Exclusions.AddRange(exclusions.Value);

            profile.Left  = BuildStorage(leftType.Value, "L.");
            profile.Right = BuildStorage(rightType.Value, "R.");

            try
            {
                // Compute differences and actions
                Diff[] differences = profile.GetDifferences().ToArray();
                global::SmartSync.Common.Action[] actions = differences.Select(d => d.GetAction(profile.SyncType)).ToArray();

                if (actions.Length > 0)
                {
                    // Process actions
                    for (int i = 0; i < actions.Length; i++)
                    {
                        Log.Info("{1} % - {0} ...", actions[i], i * 100 / actions.Length);
                        actions[i].Process();
                    }

                    Log.Info("Flushing data to storage...");
                }

                profile.Dispose();

                Log.Info("Everything is in sync. {0} actions processed.", actions.Length);

                return(NodeResult.Success);
            }
            catch (Exception e)
            {
                Log.Error("Error while trying to sync specified profile: " + e.Message);
                return(NodeResult.Fail);
            }
        }