private void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
 {
     if (e.NetworkAccess == NetworkAccess.Internet)
     {
         SyncEngine.PushAllAsync();
     }
 }
Exemple #2
0
        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            // FIND THE CITY DETAILS FROM THE XML
            City city = GetCity.FindCity(CityCode);

            AirportImage.Source = MultimediaLoad.LoadPngImage("Airports/" + city.AirportImage);
            NameLabel.Text      = city.AirportName;
            AdressLabel.Text    = city.AirportAdress;
            PhoneLabel.Text     = city.AirportPhone.ToString();

            if (ConditionDeviceEngine.CheckInternetStatus() == "Off")
            {
                ShowData();
                progressIndicator           = new ProgressIndicator();
                progressIndicator.IsVisible = true;
                progressIndicator.Text      = "Δεν βρέθηκε Σύνδεση στο Διαδίκτυο...";
                SystemTray.SetProgressIndicator(this, progressIndicator);
                //SHOW LAST UPDATED DATA BEFORE TRY TO SYNC AGAIN
            }

            else
            {
                //SYNC
                ShowData();
                SyncEngine syncworker = new SyncEngine();
                syncworker.TestGetSaveWeatherForAirport(CityName, CityCode);

                Timer.Interval = TimeSpan.FromMilliseconds(2000);
                Timer.Tick    += OnTimerTick;
                Timer.Start();
            }
        }
        public async Task SyncEngineSyncsWithoutErrors()
        {
            AssertPocketClientIsValid();

            using (var syncEngine = new SyncEngine(_pocketClient, GetDefaultSyncEngineSettings()))
            {
                await syncEngine.Initialize(default);
 public bool InitEngine(List <Type> AvailableConnectors)
 {
     try
     {
         SE                      = new SyncEngine(RepositoryId, LocalPath, AvailableConnectors, this.RemoteRepositoryConnector, this.RemoteRepositoryParameters);
         SE.SyncStart           += SE_SyncStart;
         SE.SyncStop            += SE_SyncStop;
         SE.LogOutput           += SE_LogOutput;
         SE.StopComplete        += SE_StopComplete;
         SE.NotifyUser          += SE_NotifyUser;
         SE.ProxyError          += SE_ProxyError;
         SE.AuthenticationError += SE_AuthenticationError;
         SE.SyncEngineUploadDownloadCountChanged += SE_UploadDownloadCountChanged;
     }
     catch (Exception ex)
     {
         if (NotifyUser != null)
         {
             NotifyUser(this, "[" + SiteName + "]" + ex.Message);
         }
         logger.Debug(ex.Message);
         return(false);
     }
     return(true);
 }
Exemple #5
0
        static async Task Main()
        {
            string connectionString = ConfigurationManager.AppSettings["BlobTemplatesProvider:ConnectionString"];
            string containerName    = ConfigurationManager.AppSettings["BlobTemplatesProvider:ContainerName"];
            var    cloneProvider    = new BlobTemplatesProvider(connectionString, containerName);

            Uri    baseUrl       = new Uri(ConfigurationManager.AppSettings["GitHubTemplateProvider:BaseUrl"]);
            string repositoryUrl = ConfigurationManager.AppSettings["GitHubTemplateProvider:RepositoryPath"];

            // GitHub Personal Access Token requires scopes:
            // repo
            // read:org
            // read:user
            string personalAccessToken = ConfigurationManager.AppSettings["GitHubTemplateProvider:PersonalAccessToken"];

            var sourceProvider = new GitHubTemplatesProvider(baseUrl, repositoryUrl, personalAccessToken);

            var sync = new SyncEngine(sourceProvider, cloneProvider);

            sync.Log            = Console.WriteLine;
            sync.ExclusionRules = @"[\w|\/]*\/source[\w|\/]*";
#if DEBUG
            await sync.RunAsync(false);
#else
            await sync.RunAsync(true);
#endif
        }
Exemple #6
0
        public async Task SyncTaskAsync_SyncTask_TaskIdsNotEqual()
        {
            await AddPlannerTaskAsync("Task 1");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.NotEqual(_primaryClient.Tasks[0].Id, _secondaryClient.Tasks[0].Id);
        }
Exemple #7
0
        public async Task SyncTaskAsync_SyncTask_TaskTitlesAreEqual()
        {
            await AddPlannerTaskAsync("Task 1");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Equal(_primaryClient.Tasks[0].Title, _secondaryClient.Tasks[0].Title);
        }
Exemple #8
0
        public async Task SyncTasksAsync_OnePrimaryTask_EqualTaskCount()
        {
            await AddPlannerTaskAsync("A Task");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Single(_secondaryClient.Tasks);
        }
Exemple #9
0
        /// <summary>
        /// Resolves path tokens like application folder and working folder.
        /// </summary>
        /// <param name="path">
        /// The path containing token.
        /// </param>
        /// <returns>
        /// the valid resolved path
        /// </returns>
        public static string ResolvePath(string path)
        {
            var engine = new SyncEngine {
                WorkingFolder = Config.WorkingFolder
            };

            return(engine.ReplacePathToken(path));
        }
Exemple #10
0
        /// <summary>
        /// Opens the current working folder using the explorer
        /// </summary>
        public void OpenWorkingFolder()
        {
            var engine = new SyncEngine {
                WorkingFolder = Config.WorkingFolder
            };

            engine.OpenWorkingFolder();
        }
Exemple #11
0
        public async Task SyncTasksAsync_TwoPrimaryTask_EqualTaskCount()
        {
            await AddPlannerTaskAsync("A Task");
            await AddPlannerTaskAsync("Another task");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Equal(2, _secondaryClient.Tasks.Count);
        }
Exemple #12
0
        /// <summary>
        /// Runs the currently selected template with the currently loaded data.
        /// </summary>
        /// <param name="templateScriptPath">
        /// The path to the template script.
        /// </param>
        public void Run(string templateScriptPath)
        {
            if (!File.Exists(templateScriptPath))
            {
                this.ProcessingEvent(this, new ProcessingEventArgs(string.Format(CultureInfo.CurrentCulture, Resources.InstalledFileNotFound, templateScriptPath)));
                return;
            }

            var commands = SyncCollection.LoadSyncList(templateScriptPath);

            if (commands == null)
            {
                return;
            }

            foreach (var command in commands)
            {
                command.SourceCredentials = (command.SourceConnector != null && command.SourceConnector == "{source}") ? this.Source.LogonCredentials : command.SourceCredentials;
                command.SourceCredentials = (command.SourceConnector != null && command.SourceConnector == "{target}") ? this.Target.LogonCredentials : command.SourceCredentials;
                command.TargetCredentials = (command.TargetConnector != null && command.TargetConnector == "{source}") ? this.Source.LogonCredentials : command.TargetCredentials;
                command.TargetCredentials = (command.TargetConnector != null && command.TargetConnector == "{target}") ? this.Target.LogonCredentials : command.TargetCredentials;

                command.SourceConnector  = this.ReplaceToken(command.SourceConnector);
                command.TargetConnector  = this.ReplaceToken(command.TargetConnector);
                command.SourceStorePath  = this.ReplaceToken(command.SourceStorePath);
                command.TargetStorePath  = this.ReplaceToken(command.TargetStorePath);
                command.CommandParameter = this.ReplaceToken(command.CommandParameter);
            }

            var engine = new SyncEngine
            {
                WorkingFolder = Config.WorkingFolder,
                UiProvider    = new UiDispatcher(),
            };

            engine.ProcessingEvent += this.HandleProcessingEvent;
            engine.ProgressEvent   += this.ProgressEvent;

            try
            {
                engine.Execute(commands);
            }
            catch (ProcessAbortException)
            {
            }

            engine.ProcessingEvent -= this.HandleProcessingEvent;
            engine.ProgressEvent   -= this.ProgressEvent;

            if (this.FinishedEvent != null)
            {
                this.FinishedEvent(new ProgressEventArgs {
                    PercentageDone = 100
                });
            }
        }
Exemple #13
0
        public static void Test()
        {
            client1 = new ClientImpl();
            client2 = new ClientImpl();

            client1.List.Add(new Entity(Guid.NewGuid())
            {
                Data = "data1"
            });
            client2.List.Add(new Entity(Guid.NewGuid())
            {
                Data = "data2"
            });

            Console.WriteLine();
            Console.WriteLine("Before...");
            ToConsole();

            SyncEngine.PullAndPushChanges(client1, ServerProxy.Instance);
            SyncEngine.PullAndPushChanges(client2, ServerProxy.Instance);

            Console.WriteLine();
            Console.WriteLine("After sync (Client1 <-> Server, Client2 <-> Server) ...");
            ToConsole();

            Thread.Sleep(2000);

            client1.List[0].Data = "modified";
            client1.List[0].SetModified();
            Console.WriteLine();
            Console.WriteLine("Modified on client1...");
            ToConsole();

            SyncEngine.PullAndPushChanges(client1, ServerProxy.Instance);
            SyncEngine.PullAndPushChanges(client2, ServerProxy.Instance);

            Console.WriteLine();
            Console.WriteLine("After sync (Client1 <-> Server, Client2 <-> Server) ...");
            ToConsole();

            Thread.Sleep(2000);

            client1.List[0].IsDeleted = true;
            client1.List[0].SetModified();
            Console.WriteLine();
            Console.WriteLine("Deleted on client...");
            ToConsole();

            SyncEngine.PullAndPushChanges(client1, ServerProxy.Instance);
            SyncEngine.PullAndPushChanges(client2, ServerProxy.Instance);

            Console.WriteLine();
            Console.WriteLine("After sync (Client1 <-> Server, Client2 <-> Server) ...");
            ToConsole();
        }
Exemple #14
0
        public async Task SyncTasksAsync_UpdateSecondaryDueDate_DatesEqual()
        {
            await AddPlannerTaskAsync("Task 1");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            _secondaryClient.Tasks[0].DueDateTime = DateTime.Now;

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Equal(_primaryClient.Tasks[0].DueDateTime, _secondaryClient.Tasks[0].DueDateTime);
        }
Exemple #15
0
        public async Task SyncTasksAsync_UpdateSecondaryTitle_TitlesEqual()
        {
            await AddPlannerTaskAsync("Task 1");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            _secondaryClient.Tasks[0].Title = "Updated Title";

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Equal("Updated Title", _primaryClient.Tasks[0].Title);
        }
Exemple #16
0
        public async Task SyncTasksAsync_CompleteTaskInSecondary_TaskGoneInPrimary()
        {
            await AddPlannerTaskAsync("Task 1");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            await _secondaryClient.CompleteTaskAsync(_secondaryClient.Tasks[0]);

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Empty(_primaryClient.Tasks);
        }
Exemple #17
0
        public async Task SyncTasksAsync_UpdateSecondaryDescription_DescriptionsEqual()
        {
            await AddPlannerTaskAsync("Task 1");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            _secondaryClient.Tasks[0].Description = "Updated Text";

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Equal("Updated Text", _primaryClient.Tasks[0].Description);
        }
Exemple #18
0
        public async Task SyncTasksAsync_AddThenCompletePrimaryTask_EqualTasks()
        {
            await AddPlannerTaskAsync("Task 1");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            var taskToComplete = _primaryClient.Tasks.First();
            await _primaryClient.CompleteTaskAsync(taskToComplete);

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Empty(_secondaryClient.Tasks);
        }
Exemple #19
0
        public async Task SyncTasksAsync_AddTwoThenCompletePrimaryTask_TasksEqual1()
        {
            await AddPlannerTaskAsync("Task 1");
            await AddPlannerTaskAsync("Task 2");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            await _primaryClient.CompleteTaskAsync(_primaryClient.Tasks[1]);

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Single(_secondaryClient.Tasks);
        }
Exemple #20
0
        public async Task SyncTasksAsync_AddTaskDeleteBoth_LastSyncTasksEmpty()
        {
            await AddPlannerTaskAsync("Task 1");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            await _primaryClient.CompleteTaskAsync(_primaryClient.Tasks[0]);

            await _secondaryClient.CompleteTaskAsync(_secondaryClient.Tasks[0]);

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Empty(_syncStateClient.syncedTasks);
        }
Exemple #21
0
        /// <summary>
        /// Opens the current working folder using the explorer
        /// </summary>
        public static void OpenWorkingFolder()
        {
            var engine = new SyncEngine
            {
                WorkingFolder = Config.WorkingFolder
            };

            engine.Execute(
                new SyncDescription
            {
                Command          = SyncCommand.OpenDocument.ToString(),
                CommandParameter = "{FS:WorkingFolder}"
            });
        }
Exemple #22
0
        public async Task SyncTasksAsync_AddTwoTasksUpdateBoth_PrimaryWins()
        {
            await AddPlannerTaskAsync("Task 1");
            await AddPlannerTaskAsync("Task 2");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            _secondaryClient.Tasks[0].Title = "Secondary Task";
            _primaryClient.Tasks[0].Title   = "Primary Task";

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Equal("Primary Task", _secondaryClient.Tasks[0].Title);
        }
        public async Task RunAsync()
        {
            string connectionString = ConfigurationManager.AppSettings["BlobTemplatesProvider:ConnectionString"];
            string containerName    = ConfigurationManager.AppSettings["BlobTemplatesProvider:ContainerName"];
            var    cloneProvider    = new BlobTemplatesProvider(connectionString, containerName);

            Uri    baseUrl             = new Uri(ConfigurationManager.AppSettings["GitHubTemplateProvider:BaseUrl"]);
            string repositoryUrl       = ConfigurationManager.AppSettings["GitHubTemplateProvider:RepositoryPath"];
            string personalAccessToken = ConfigurationManager.AppSettings["GitHubTemplateProvider:PersonalAccessToken"];

            var sourceProvider = new GitHubTemplatesProvider(baseUrl, repositoryUrl, personalAccessToken);

            var sync = new SyncEngine(sourceProvider, cloneProvider);
            await sync.RunAsync(true);
        }
Exemple #24
0
        public async Task SyncTasksAsync_AddTwoUpdateFirstDate_DatesMatch()
        {
            await AddPlannerTaskAsync("Task 1");

            _primaryClient.Tasks[0].DueDateTime = new DateTime(2020, 06, 01);
            await AddPlannerTaskAsync("Task 2");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            _primaryClient.Tasks[0].DueDateTime = new DateTime(2020, 06, 02);

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Equal(new DateTime(2020, 06, 02), _secondaryClient.Tasks[0].DueDateTime);
        }
Exemple #25
0
        public async Task SyncTasksAsync_ThreePrimaryTasksOverThreeSyncs_EqualTasks()
        {
            await AddPlannerTaskAsync("Task 1");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            await AddPlannerTaskAsync("Task 2");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            await AddPlannerTaskAsync("Task 3");

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Equal(3, _secondaryClient.Tasks.Count);
        }
        private void RefreshButton_Click(object sender, RoutedEventArgs e)
        {
            if (ConditionDeviceEngine.CheckInternetStatus() == "Off")
            {
                MessageBox.Show("Δεν υπάρχει σύνδεση στο διαδίκτυο. Ο έλεγχος δεν μπορεί να πραγματοποιηθεί.");
                return;
            }

            SyncEngine syncworker = new SyncEngine();

            syncworker.GetLastUpdateStatus();

            RefreshCheckTimer.Interval = TimeSpan.FromMilliseconds(60);
            RefreshCheckTimer.Tick    += new EventHandler(RefreshCheckTimer_Tick);
            RefreshCheckTimer.Start();
        }
Exemple #27
0
        public async Task SyncTasksAsync_AddThreePrimaryUpdateTwo_AllAreEqual()
        {
            for (int i = 1; i < 4; i++)
            {
                await AddPlannerTaskAsync($"Task {i.ToString()}");
            }
            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            _primaryClient.Tasks[0].Title   = "Task 1 updated";
            _secondaryClient.Tasks[1].Title = "Task 2 updated";

            await SyncEngine.SyncTasksAsync(_primaryClient, _secondaryClient, _syncStateClient);

            Assert.Equal("Task 1 updated", _secondaryClient.Tasks[0].Title);
            Assert.Equal("Task 2 updated", _primaryClient.Tasks[1].Title);
        }
Exemple #28
0
 public static void set_source_property(RubyModule /*!*/ self, [NotNull] int /*!*/ nSrcID, [NotNull] String /*!*/ strPropName, [NotNull] String /*!*/ strPropValue)
 {
     try
     {
         SyncEngine.getSourceOptions().setProperty(nSrcID, strPropName, strPropValue);
     }
     catch (Exception ex)
     {
         Exception rubyEx = self.Context.CurrentException;
         if (rubyEx == null)
         {
             rubyEx = RubyExceptionData.InitializeException(new RuntimeError(ex.Message.ToString()), ex.Message);
         }
         LOG.ERROR("set_source_property", ex);
         throw rubyEx;
     }
 }
Exemple #29
0
        private void TryUpdateManuallyButton_Click(object sender, RoutedEventArgs e)
        {
            if (ConditionDeviceEngine.CheckInternetStatus() == "Off")
            {
                progressIndicator.IsVisible = true;
                progressIndicator.Text      = "Δεν βρέθηκε Σύνδεση στο Διαδίκτυο...";
                //SHOW LAST UPDATED DATA BEFORE TRY TO SYNC AGAIN
                return;
            }

            SyncEngine syncworker = new SyncEngine();

            syncworker.TestGetSaveWeatherForAirport(CityName, CityCode);

            Timer.Interval = TimeSpan.FromMilliseconds(2000);
            Timer.Tick    += OnTimerTick;
            Timer.Start();
        }
Exemple #30
0
 public static void set_source_property(RubyModule /*!*/ self, [NotNull] int /*!*/ nSrcID, [NotNull] String /*!*/ strPropName, [NotNull] String /*!*/ strPropValue)
 {
     SyncEngine.getSourceOptions().setProperty(nSrcID, strPropName, strPropValue);
 }
 /// <summary>
 /// Called by sync when a table/entity failes to sync
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Sync_OnSyncFailure(object sender, SyncEngine.Events.SyncFailedEventArgs e)
 {
     Console.Clear();
     Console.WriteLine("\n" + e.Status);
     Console.WriteLine("Error: " + (e.ExceptionObject.InnerException?.Message ?? e.ExceptionObject.Message));
     Console.Write("\nPress any key to continue...");
     Console.ReadKey();
 }
 /// <summary>
 /// Called by sync manager when cleaning up SyncRecords
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Sync_OnCleanUp(object sender, SyncEngine.Events.SyncCleanupArgs e)
 {
     Console.WriteLine("\nCleaning up - " + e.Status);
 }
 /// <summary>
 /// Called by sync when all tables have been sync successfully
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Sync_OnSyncComplete(object sender, SyncEngine.Events.SyncCompleteArgs e)
 {
     Console.WriteLine("\n" + e.Status);
     Console.Write("\nPress any key to continue...");
     Console.ReadKey();
 }
        private void OnSyncProgress(ISyncable item, SyncEngine.ProgressType type, int filesTransferred, int totalItems)
        {
            using (new OperationLogger())
            {
                string displayName = null;
                string format = null;
                if (item != null)
                {
                    displayName = item.Properties.ObjectForKey("Name") as string;
                    if (string.IsNullOrEmpty(displayName))
                    {
                        ISyncableMedia media = item as ISyncableMedia;
                        if (media != null)
                        {
                            displayName = media.DisplayName;
                        }
                        if (string.IsNullOrEmpty(displayName) && (item.Location != null))
                        {
                            displayName = item.Location.LocalPath;
                        }
                    }
                }
                switch (type)
                {
                    case SyncEngine.ProgressType.Add:
                    case SyncEngine.ProgressType.Update:
                        format = Resources.TransferProgressCopyText;
                        break;

                    case SyncEngine.ProgressType.Delete:
                        format = Resources.TransferProgressDeleteText;
                        break;

                    case SyncEngine.ProgressType.WaitingForDeferred:
                        format = Resources.TranferProgressTranscoding;
                        break;

                    case SyncEngine.ProgressType.Retrying:
                        format = Resources.TransferProgressRetryText;
                        break;

                    default:
                        throw new ArgumentException("invalid value", "type");
                }
                string caption = string.Format(CultureInfo.CurrentCulture, format, new object[] { string.IsNullOrEmpty(displayName) ? Resources.UnknownFileNameText : displayName });
                string subHeader = string.Format(CultureInfo.CurrentCulture, Resources.SyncProgressRemainingItems, new object[] { totalItems - filesTransferred });
                this.UpdateProgressBar(null, subHeader, caption, (float) (filesTransferred * 100), (float) (totalItems * 100), false);
            }
        }
 /// <summary>
 /// Called by sync manager when a record is synced
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Sync_OnUpdateStatus(object sender, SyncEngine.Events.ProgressEventArgs e)
 {
     Console.WriteLine(e.Status);
 }
 /// <summary>
 /// Called by sync when a table/entity failes to sync
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Sync_OnSyncFailure(object sender, SyncEngine.Events.SyncFailedEventArgs e)
 {
     Console.Clear();
     Console.WriteLine("\n" + e.Status);
     Console.WriteLine("Error: " + e.ExceptionObject.Message);
 }
 /// <summary>
 /// Called by sync manager when starting a new table
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private static void Sync_OnSyncStart(object sender, SyncEngine.Events.SyncStartedArgs e)
 {
     Console.WriteLine("\nSyncing... " + e.Status);
 }