Пример #1
0
 public DistributedResource ExecuteTask(int taskId, DistributedResource resource)
 {
     if (Disposed)
     {
         throw new ObjectDisposedException(this.ToString());
     }
     else
     {
         try
         {
             Logging.WriteLog("Request for executing task was received");
             TaskLibrary task       = TaskManager.Tasks[taskId];
             var         stream     = new MemoryStream(resource.Get());
             var         serializer = new DataContractSerializer(task.InputData);
             object      input      = null;
             input = serializer.ReadObject(stream);
             var                 process       = Activator.CreateInstance(task.Process);
             MethodInfo          method        = task.Process.GetMethod("Execute");
             object              executeResult = method.Invoke(process, new object[] { input });
             DistributedResource result        = null;
             lock (ResourceManager)
             {
                 result = ResourceManager.CreateDistributedResource(executeResult);
             }
             return(result);
         }
         catch
         {
             return(null);
         }
     }
 }
 public DividedResource CreateDividedResource(T resource)
 {
     if (!Disposed)
     {
         List <T> list = ObjectDivider.Divide(resource);
         List <DistributedResource> result = new List <DistributedResource>();
         foreach (T item in list)
         {
             result.Add(ResourceManager.CreateDistributedResource(item));
         }
         return(new DividedResource()
         {
             Resources = result
         });
     }
     else
     {
         throw new ObjectDisposedException(this.ToString());
     }
 }