Ejemplo n.º 1
0
        public void AddJobToQueue(SyncJob job)
        {
            JobQueue.Enqueue(job);

            // no reason to wait if queue was empty
            if (JobQueue.Count == 1)
            {
                JobTimer_Elapsed(null, null);
            }
            else
            {
                if (job.SyncDocument != null)
                {
                    Debug.WriteLine(string.Format("Added {0} to job queue", job.SyncDocument.Title));
                }
                else
                {
                    Debug.WriteLine(string.Format("Added {0} to job queue", job.Id));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Will be invoked by the syncTimer to add a sync-check-job in
        /// Synchronizer's Queue, unless it has already been added.
        /// </summary>
        void SynchronizerTimerElapsed(object sender, ElapsedEventArgs e)
        {
            // let's make sure this document isn't already queued
            if (!_synchronizer.IsJobAlreadyQueued(Document.ResourceId))
            {
                // let's remove a job and execute it
                var job = new SyncJob
                {
                    Id             = Document.ResourceId,
                    SyncDocument   = Document,
                    ErrorsOccurred = 0,
                    Type           = SyncJobType.CheckForChanges
                };

                _synchronizer.AddJobToQueue(job);
            }
            else
            {
                Debug.WriteLine("Job already added to queue: " + Document.Title);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Will be invoked by the syncTimer to add a sync-check-job in
        /// Synchronizer's Queue, unless it has already been added.
        /// </summary>
        void SynchronizerTimerElapsed(object sender, ElapsedEventArgs e)
        {
            // let's make sure this document isn't already queued
            if (!_synchronizer.IsJobAlreadyQueued(Document.ResourceId))
            {
                // let's remove a job and execute it
                var job = new SyncJob
                {
                    Id = Document.ResourceId,
                    SyncDocument = Document,
                    ErrorsOccurred = 0,
                    Type = SyncJobType.CheckForChanges
                };

                _synchronizer.AddJobToQueue(job);
            }
            else
            {
                Debug.WriteLine("Job already added to queue: " + Document.Title);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Will be called every 15 minutes in order to keep documents checked.
 /// </summary>
 private void AutoFetchAllEntriesTimerElapsed(object sender, ElapsedEventArgs e)
 {
     if (!BgWorkerGetAllItems.IsBusy && !_synchronizer.IsJobAlreadyQueued(AutoFetchId))
     {
         var autofetchJob = new SyncJob
         {
             Id = AutoFetchId,
             ErrorsOccurred = 0,
             Type = SyncJobType.UpdateAllEntries
         };
         _synchronizer.AddJobToQueue(autofetchJob);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Will execute any given SyncJob.
 /// </summary>
 /// <param name="job">A SyncJob object that includes all the sync-related info.</param>
 private void ExecuteJob(SyncJob job)
 {
     // let's pause the timer first
     Stop();
     _bgWorker.RunWorkerAsync(job);
 }