コード例 #1
0
		static FTaskSpecification MarshalTaskSpecification(IntPtr SpecificationPtr)
		{
			FTaskSpecificationMarshalHelper Helper = (FTaskSpecificationMarshalHelper)Marshal.PtrToStructure(SpecificationPtr, typeof(FTaskSpecificationMarshalHelper));
			FTaskSpecification Specification = new FTaskSpecification(Helper.TaskGuid, FStringMarshaler.MarshalNativeToManaged(Helper.Parameters), Helper.Flags);
			Specification.Cost = Helper.Cost;
			Specification.DependencyCount = Helper.DependencyCount;
			Specification.Dependencies = new String[Specification.DependencyCount];
			for (UInt32 Index = 0; Index < Specification.DependencyCount; Index++)
			{
				Specification.Dependencies[Index] = FStringMarshaler.MarshalNativeToManaged(Marshal.ReadIntPtr(Helper.Dependencies, (Int32)Index * 8));
			}
			return Specification;
		}
コード例 #2
0
		/**
		 * Adds a Task to the current Job
		 *
		 * @param Specification A structure describing the new Task
		 *
		 * @return Int32 Error code (< 0 is an error)
		 */
		public virtual Int32 AddTask(FTaskSpecification Specification)
		{
			StartTiming("AddTask-Managed", true);

			Int32 ReturnValue = Constants.INVALID;
			if (Connection != null)
			{
				if (ConnectionConfiguration.AgentJobGuid != null)
				{
					// Convert the parameters from native to managed
					AgentGuid TaskGuid = new AgentGuid(Specification.TaskGuid.A,
													   Specification.TaskGuid.B,
													   Specification.TaskGuid.C,
													   Specification.TaskGuid.D);

					String Parameters = Specification.Parameters;

					List<String> Dependencies = null;
					if (Specification.DependencyCount > 0)
					{
						Dependencies = new List<String>();
						for (UInt32 i = 0; i < Specification.DependencyCount; i++)
						{
							Dependencies.Add(Specification.Dependencies[i]);
						}
					}

					AgentTaskSpecification NewSpecification =
						new AgentTaskSpecification(ConnectionConfiguration.AgentJobGuid, TaskGuid, (Int32)Specification.Flags, Parameters, (Int32)Specification.Cost, Dependencies);

					// Ensure all the files are in the cache with the right cache compatible name
					ReturnValue = CacheAllFiles(NewSpecification);
					if (ReturnValue >= 0)
					{
						// Queue up all tasks until the specification is complete and submit them all at once
						PendingTasks.Add(NewSpecification);
					}
				}
				else
				{
					ReturnValue = Constants.ERROR_JOB_NOT_FOUND;
				}
			}
			else
			{
				ReturnValue = Constants.ERROR_CONNECTION_NOT_FOUND;
			}

			StopTiming();
			return ReturnValue;
		}