예제 #1
0
		public void FileSystemWatcherCreated(object sender, FileSystemEventArgs e)
		{
            Logger.LogInfo("Notified of new SendLink job. Job directory = " + e.FullPath);

			string jobDirectory = Path.GetDirectoryName(e.FullPath);
			string workingDir = Path.Combine(GetWorkingDirectory(), jobDirectory);

            var job = new SkyDoxUploadJob(jobDirectory, _url, workingDir, _userName, "SendLinkJobInfo.xml", new ApiHelper(), _deviceToken);
			var uploadJob = new SendLinkJob(job);
			if (!_uploadJobs.Any(m => m.Id == uploadJob.Id))
			{
				uploadJob.OnJobCompleted += uploadJob_OnJobCompleted;
				uploadJob.Aborted += uploadJob_OnJobCompleted;
				uploadJob.OnError += uploadJob_OnErrorOccurred;
			    uploadJob.OnJobStatusChanged += UploadJobOnJobStatusChanged;
				uploadJob.OnQueueFinalizeJob += uploadJob_OnQueueFinalizeJob;               

				uploadJob.Execute();
				_uploadJobs.Add(uploadJob);

                Logger.LogInfo("New SendLink job added to the upload collection and upload started. JobId = " + uploadJob.Id);

				if (JobAdded != null)
				{
					JobAdded(this, new JobEventArgs() {Job = uploadJob});
				}
			}
		}
예제 #2
0
		public List<ISendLinkJob> GetActiveJobs()
		{
			if ( _uploadJobs == null )
			{
				_uploadJobs = new List<ISendLinkJob>();
			}

	        string workingDirectory = GetWorkingDirectory();

			string[] jobs = Directory.GetDirectories(workingDirectory);

			foreach (var jobDir in jobs)
			{
				string workingDir = Path.Combine(workingDirectory, jobDir);

				if (!File.Exists(Path.Combine(workingDir, SignalFile)))
				{
					continue;
				}

				const string jobFileName = "SendLinkJobInfo.xml";

			    var skyDoxUploadJob = new SkyDoxUploadJob(jobDir, _url, workingDir, _userName, jobFileName, new ApiHelper(), _deviceToken);
			    var uploadJob = new SendLinkJob(skyDoxUploadJob);
				if (!_uploadJobs.Any(m => m.Id.Equals(uploadJob.Id)))
				{
					uploadJob.OnJobCompleted += uploadJob_OnJobCompleted;
					uploadJob.Aborted += uploadJob_OnJobCompleted;
					uploadJob.OnError += uploadJob_OnErrorOccurred;
                    uploadJob.OnJobStatusChanged += UploadJobOnJobStatusChanged;
                    uploadJob.OnQueueFinalizeJob += uploadJob_OnQueueFinalizeJob;
					_uploadJobs.Add(uploadJob);

                    Logger.LogInfo("New SendLink job added to the upload collection. JobId = " + uploadJob.Id);

					if (JobAdded != null)
					{
						JobAdded(this, new JobEventArgs{Job = uploadJob});
					}
				}
			}

			if( _uploadJobs.Any())
			{
				RestartManager.ScheduleClient();
			}

			return _uploadJobs;
		}