コード例 #1
0
ファイル: SendLinkJob.cs プロジェクト: killbug2004/WSProf
		public SendLinkJob(SkyDoxUploadJob job)
		{
			Id = job.LocalId;
            _job = job;
		    _job.OnJobStatusChanged += (sender, args) => 
                                        { 
                                            if(OnJobStatusChanged != null)
                                            {
                                                OnJobStatusChanged(this, EventArgs.Empty);
                                            }
                                        };

			_job.OnJobStageChanged += _job_OnJobStageChanged;
			_job.OnAttachmentProgress += _job_OnAttachmentProgress;
			_job.OnJobProgress += _job_OnJobProgress;
			_job.OnErrorOccurred += _job_OnErrorOccurred;
		    _job.OnCaptionChanged += _job_OnCaptionChanged;

			Logger.LogInfo(string.Format("Creating new job object. Id: {0}, Subject: {1}, SearchKey: {2}", Id,
							  string.IsNullOrEmpty(job.EmailSubject) ? "<Empty Subject>" : job.EmailSubject, job.PrSearchKey));

			_attachments = new List<ISendLinkAttachment>();
			foreach (string attachmentPath in _job.Attachments)
			{
				Logger.LogInfo(string.Format("Add attachment: {0}", attachmentPath));
				SendLinkAttachment attachment = new SendLinkAttachment(attachmentPath);
				_attachments.Add(attachment);
			}
			_attachments.Reverse();
		}
コード例 #2
0
ファイル: StorageLinks.cs プロジェクト: killbug2004/WSProf
        public void GetLinks(string defaultUserEmail, List<SendLinkInfo> sendLinkInfos, List<string> emailAddresses, string subject, List<IActionProperty> actionPropertySet, string workingDirectory, string id)
        {
            IDoxSession session = null;
            AbortIfFail(() =>
                {
                    session = CreateAuthenticatedSession(defaultUserEmail);
                    return session != null;
                }, "Unable to authenticate");

            OptionApi.SetString("SendLinkCloudStorageLoginName", session.Credentials.UserName);
            OptionApi.SetEncrypted("SendLinkDeviceToken", session.Credentials.DeviceToken, _entropy);
            OptionApi.SetEncrypted("SendLinkAccountId", session.CurrentUser.AccountId, _entropy);
            OptionApi.SetEncrypted("SendLinkUserId", session.CurrentUser.Id, _entropy);

            IDoxFolderProperties properties;
            IDoxFolderPermissions permissions;
            GetFolderProperties(subject, actionPropertySet, out properties, out permissions);

            IDoxFolder folder = null;
            AbortIfFail(() => { 
                                folder = session.CreateFolder(properties);
                                return folder != null;
                               }, "Unable to create folder");

            if (!session.CurrentUser.IsValidated)
            {
                if (!session.IsNewUser)
                {
                    session.ResendAuthenticationEmail();
                }
            }

            foreach (string member in emailAddresses)
            {
                string memberCopy = member;
                AbortIfFail(() => folder.AddMember(memberCopy), "Unable to add member to folder");
            }

            AbortIfFail(()=>folder.UpdatePermissions(permissions), "Unable to set folder permissions");

            // record job info for deterministic send
            SaveSendLinkJobInfo(sendLinkInfos, emailAddresses, subject, permissions, folder, workingDirectory);

            // ensure the replacement attachments point to the folder url we just created
            foreach (var sendLinkInfo in sendLinkInfos)
            {
                sendLinkInfo.Link = folder.Url;
            }

            // record job info for sendlink tray
            var uploadJob = new SkyDoxUploadJob(id, session.Api.ServiceUrl, workingDirectory, session.Credentials.UserName, "SendLinkJobInfo.xml", session.ApiHelper, session.Credentials.DeviceToken);
            uploadJob.SetFolder(folder.Url, folder.Id, DoxFolderPermissions.Convert(permissions));

            if (!session.CurrentUser.IsValidated)
                _loginUi.ShowRegistrationSteps(session.Credentials.UserName);
        }
コード例 #3
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});
				}
			}
		}
コード例 #4
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;
		}