public CleanupTaskData CreateCleanupTask(string machineName, EnumCleanupTaskType taskType, string folderPath, int ageMinutes)
 {
     if(string.IsNullOrEmpty(machineName))
     {
         throw new ArgumentNullException("Missing machine name");
     }
     if(string.IsNullOrEmpty(folderPath))
     {
         throw new ArgumentNullException("Missing folder path");
     }
     var dbItem = new CleanupTaskData
     {
         Id = Guid.NewGuid().ToString(),
         TaskType = taskType,
         MachineName = machineName,
         FolderPath = folderPath,
         AgeMinutes = ageMinutes,
         Status = EnumQueueStatus.New,
         TargetCleanupDateTimeUtc = DateTime.UtcNow.AddMinutes(ageMinutes),
         CreatedByUserName = _userIdentity.UserName,
         CreatedDateTimeUtc = DateTime.UtcNow,
         UpdatedByUserName = _userIdentity.UserName,
         UpdatedDateTimeUtc = DateTime.UtcNow
     };
     using(var db = _sqlConnectionInfo.GetDB())
     {
         var sql = PetaPoco.Sql.Builder
                         .Append("INSERT INTO DeployCleanupTaskData (ID, EnumCleanupTaskTypeID, MachineName, FolderPath, AgeMinutes, EnumQueueStatusID, TargetCleanupDateTimeUtc, CreatedByUserName, CreatedDateTimeUtc, UpdatedByUserName, UpdatedDateTimeUtc)")
                         .Append("VALUES (@Id, @TaskType, @MachineName, @FolderPath, @AgeMinutes, @Status, @TargetCleanupDateTimeUtc, @CreatedByUserName, @CreatedDateTimeUtc, @UpdatedByUserName, @UpdatedDateTimeUtc)", dbItem);
         db.Execute(sql);
     }
     return this.GetCleanupTask(dbItem.Id);
 }
		public CleanupTaskData CreateCleanupTask(string machineName, EnumCleanupTaskType taskType, string folderPath, int ageMinutes)
		{
            if(string.IsNullOrEmpty(machineName))
            {
                throw new ArgumentNullException("Missing Machine Name");
            }
            if(string.IsNullOrEmpty(folderPath))
            {
                throw new ArgumentNullException("Missing Folder Path");
            }
            //if(ageMinutes <= 0)
            //{
            //    throw new ArgumentNullException("Missing Age Minutes");
            //}
			var task = new CleanupTaskData
			{
				Id = Guid.NewGuid().ToString(),
				TaskType = taskType,
				MachineName = machineName,
				FolderPath = folderPath,
				AgeMinutes = ageMinutes,
				Status = EnumQueueStatus.New,
				TargetCleanupDateTimeUtc = DateTime.UtcNow.AddMinutes(ageMinutes),
				CreatedByUserName = _userIdentity.UserName,
				CreatedDateTimeUtc = DateTime.UtcNow,
				UpdatedByUserName = _userIdentity.UserName,
				UpdatedDateTimeUtc = DateTime.UtcNow
			};
			return _documentSession.StoreSaveEvict(task);
		}
Пример #3
0
		public void CleanupFolder(CleanupTaskData item)
		{
			if(Directory.Exists(item.FolderPath))
			{
				Directory.Delete(item.FolderPath, true);
			}
		}
Пример #4
0
		public void MarkItemFailed(CleanupTaskData item, Exception err)
		{
			_cleanupRepository.MarkItemFailed(item.Id, err);
		}
Пример #5
0
		public void MarkItemSuccessful(CleanupTaskData item)
		{
			_cleanupRepository.MarkItemSuccessful(item.Id);
		}