コード例 #1
0
		public FtpOutboundData QueueUploadItem(string fileData, string targetDirectory, string targetFileName, string ftpSettingsKey, EnumSettingSource ftpSettingsSource)
		{
			string attachmentID = Guid.NewGuid().ToString();

			using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = IsolationLevel.Serializable }))
			{
				bool anyExistingItems = _documentSession.Query<FtpOutboundData>()
											.Customize(i => i.WaitForNonStaleResultsAsOfNow(TimeSpan.FromSeconds(120)))
											.Where(i=>i.TargetFileName == targetFileName)
											.Any();
				if (anyExistingItems)
				{
					throw new Exception(string.Format("FtpOutputData record for file name {0} already exists", targetFileName));
				}
				_ravenManager.SetAttachment(attachmentID, fileData);
				var newItem = new FtpOutboundData
				{
					AttachmentId = attachmentID,
					QueuedDateTimeUtc = DateTime.UtcNow,
					SettingKey = ftpSettingsKey,
					SettingSource = ftpSettingsSource,
					Status = EnumJobStatus.New,
					TargetDirectory = targetDirectory,
					TargetFileName = targetFileName
				};
				_documentSession.Store(newItem);
				_documentSession.SaveChanges();
				transaction.Complete();

				return newItem;
			}
		}
コード例 #2
0
		public void MarkItemSuccessful(FtpOutboundData jobData)
		{
			jobData.Status = EnumJobStatus.Complete;
			_documentSession.SaveChanges();
		}
コード例 #3
0
		public void MarkItemFailed(FtpOutboundData jobData, Exception err)
		{
			var errorObject = _eventReporter.ExceptionForObject(err, jobData);
			jobData.Status = EnumJobStatus.Error;
            jobData.AddException(err);
			jobData.ExceptionIdList.Add(errorObject.Id);
			_documentSession.SaveChanges();	
		}
コード例 #4
0
		public void UploadFile(FtpOutboundData jobItem)
		{
			var settings = _settingsManager.Load<FtpConnectionSettings>(jobItem.SettingSource, jobItem.SettingKey);
			var attachmentData = _ravenManager.GetAttachment(jobItem.AttachmentId);
			_ftpCommunicator.UploadFile(jobItem.SettingSource, jobItem.SettingKey, jobItem.TargetFileName, jobItem.TargetDirectory, attachmentData);
		}