Пример #1
0
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            DateTime       processStartDate     = DateTime.Now;
            DateTime?      lastProcessStartDate = null;
            QueryRunner    queryRunner          = (QueryRunner)e.Argument;
            SyncTaskStatus syncTaskStatus       = SyncTasksManager.GetInstance().GetLastSyncTaskStatus(queryRunner.Task);

            if (syncTaskStatus != null)
            {
                lastProcessStartDate = syncTaskStatus.StartTime;
            }
            SyncTasksManager.GetInstance().ExportSyncTaskItems(queryRunner.Task, true, true, true, queryRunner.backgroundWorker, lastProcessStartDate, 0);
            SyncTasksManager.GetInstance().ProcessSyncTaskExportFiles(queryRunner.Task, queryRunner.backgroundWorker);
            SyncTasksManager.GetInstance().ImportSyncTaskItems(queryRunner.Task, queryRunner.Task.ShouldSkipUpdates, new string[] { }, queryRunner.backgroundWorker);
            SyncTasksManager.GetInstance().SaveSyncTaskStatus(queryRunner.Task, processStartDate, DateTime.Now, true, string.Empty);
            queryRunner.State = RunnerState.Complete;
        }
Пример #2
0
        public static void EnqueueRequests(DateTime referenceTime)
        {
            var time = referenceTime.TimeOfDay;
            //List<SyncTask> synctasks = SyncTasksManager.GetInstance().GetTestListItemSyncTasks().ToList();
            List <SyncTask> synctasks = SyncTasksManager.GetInstance().SyncTasks.Where(t => t.Scheduled == true).ToList();

            foreach (var synctask in synctasks)
            {
                QueryRunner queryRunner = QueuedRequests.Where(t => t.Task.ID == synctask.ID).FirstOrDefault();
                if (queryRunner == null)
                {
                    SyncTasksManager.GetInstance().SaveProcessStatus(synctask.ProcessID, "Queued", referenceTime);
                    EnqueAction(synctask);
                }
                else if (queryRunner.Task.LastRunStartDate.AddSeconds(synctask.ScheduleInterval) < DateTime.Now && queryRunner.State == RunnerState.Complete)
                {
                    QueuedRequests.Remove(queryRunner);
                    SyncTasksManager.GetInstance().SaveProcessStatus(synctask.ProcessID, "Completed", referenceTime);
                    EnqueAction(synctask);
                }
            }
        }