Ejemplo n.º 1
0
 public LabelAsCompleteTask(JobInfo jobInfo, SkyDoxUploadJob skyDoxUploadJob, CancellationToken token,
                            IApiHelper apiHelper)
     : base(apiHelper)
 {
     _jobInfo = jobInfo;
     _job = skyDoxUploadJob;
     _token = token;
 }
Ejemplo n.º 2
0
		public bool Restart()
		{
			if (JobStatus == JobStatus.Running || JobStatus == JobStatus.Completed || JobStatus == JobStatus.Authenticating)
			{
				return false;
			}

			if (File.Exists(_jobXmlPath))
			{
				File.Delete(_jobXmlPath);
			}

			if (File.Exists(_jobBackupXmlPath))
			{
				File.Delete(_jobBackupXmlPath);
			}

			_jobInfo = new JobInfo();
			_jobStatus = JobStatus.Stopped;
			return true;
		}
Ejemplo n.º 3
0
		public static JobInfo CreateJobInfo(string id, string jobDefinitionPath, string loginName, int chunkSize)
		{
			var jobInfo = new JobInfo();
			jobInfo.LocalId = id;

			SendLinkJobInfo sendLinkJobInfo = LoadSendLinkJobInfo(jobDefinitionPath);
            jobInfo.PrSearchKey = sendLinkJobInfo.PrSearchKey;

			var files = from a in sendLinkJobInfo.SendLinks
			          select new UploadInfo
			                 	{
			                 		FilePath = (string) a.FilePath,
									DisplayName = (string) a.DisplayName,
			                 	};

			foreach( var uploadInfo in files)
			{
				var fileInfo = new FileInfo(uploadInfo.FilePath);

				// Remove the display name's extension. This is because the
				// SkyDox display names are taken from the given "display name" property and
				// have the "local file name" property's extension appended (!).


                var displayName = uploadInfo.DisplayName;
                var invalidChars = Path.GetInvalidFileNameChars();
                if (!string.IsNullOrEmpty(uploadInfo.DisplayName) && uploadInfo.DisplayName.IndexOfAny(invalidChars) == -1)
                {
                    displayName = Path.GetFileNameWithoutExtension(uploadInfo.DisplayName);
                }

			    uploadInfo.DisplayName = displayName;
				uploadInfo.FileSize = fileInfo.Length;
				uploadInfo.Stage = AttachmentStage.Pending;
				uploadInfo.CurrentChunk = 1;
				uploadInfo.UploadInChunks = fileInfo.Length > chunkSize;
				jobInfo.Files.Add(uploadInfo);
				jobInfo.TotalSize += fileInfo.Length;
			}
			jobInfo.ExpiryUtc = sendLinkJobInfo.ExpiryUtc;
			jobInfo.GetReturnReceipt = sendLinkJobInfo.GetReturnReceipt;
			jobInfo.Recipients = sendLinkJobInfo.EmailAddresses;
			jobInfo.EmailSubject = sendLinkJobInfo.Subject; 
			jobInfo.SkydoxLoginName = loginName;
			jobInfo.SkydoxFolderDescription = "Secure File Transfer";
			jobInfo.SkydoxFolder = CreateFolderName(jobInfo.EmailSubject);
			jobInfo.CurrentStage = JobStage.CreateFolder;
			jobInfo.LocalJobDirectory = Path.GetDirectoryName(jobDefinitionPath);
			return jobInfo;
		}
Ejemplo n.º 4
0
		public SkyDoxUploadJob(string id, string skydoxServiceUrl, string localJobDirectoryPath, string loginName, string jobFileName, IApiHelper apiHelper, string deviceToken)
		{
			LocalId = id;
			LoginName = loginName;
		    DeviceToken = deviceToken;
			WorkingDirectory = localJobDirectoryPath;
			JobDefinitionPath = Path.Combine(WorkingDirectory, jobFileName);
			ServiceUrl = skydoxServiceUrl;

			_apiHelper = apiHelper;
			_jobXmlPath = Path.Combine(WorkingDirectory, "80517EA2-9283-4CA1-8E35-31CCB737E417.xml");
			_jobBackupXmlPath = Path.Combine(WorkingDirectory, "86405CE9-22BA-4241-8D51-03C882461986.backup");
			_signalFilePath = Path.Combine(WorkingDirectory, "EC264018-93C4-48BF-A736-2BB5FC43C81A.signal");

			_jobInfo = JobInfo.LoadJobInfo(id, _jobXmlPath, _jobBackupXmlPath, JobDefinitionPath, LoginName, _apiHelper.FILE_UPLOAD_CHUNK_SIZE);
		}
Ejemplo n.º 5
0
		public static void WriteJobInfo(JobInfo jobInfo, string file)
		{
			using (var stream = new FileStream(file, FileMode.Create))
			{
				var serializer = new System.Xml.Serialization.XmlSerializer(typeof(JobInfo));
				serializer.Serialize(stream, jobInfo);
			}
		}