public int CreateTask(DistributedTaskLibrary libraries) { if (Disposed) { throw new ObjectDisposedException(this.ToString()); } else { Logging.WriteLog("Request for creating new library was received"); return(TaskManager.CreateTask(libraries)); } }
public int CreateTask(DistributedTaskLibrary distributedLibrary) { int taskId = -1; var Service = RemoteConnection.CreateProxy <IDistributedTaskLibraryService>(UriTemplates.CreateLibrariesUri(distributedLibrary.Holder)); lock (Locker) { File.WriteAllBytes("temp", Service.Get(distributedLibrary.Files[0])); var assembly = Assembly.LoadFrom("temp"); Type processType = assembly.GetTypes().Where(type => type.Name == distributedLibrary.ProcessTypeName).First(); for (int i = 0; i < Tasks.Count; i++) { if (Tasks[i].Process == processType) { taskId = i; break; } } } if (taskId == -1) { int i = 1; string folder; if (!Directory.Exists(Folder)) { Directory.CreateDirectory(Folder); } while (Directory.Exists(folder = (Folder + "/" + "task" + i))) { i++; } Directory.CreateDirectory(folder); List <string> files = new List <string>(); foreach (string filename in distributedLibrary.Files) { string name = folder + "/" + new DirectoryInfo(filename).Name; File.WriteAllBytes(name, Service.Get(filename)); files.Add(name); } Tasks.Add(new TaskLibrary(files, distributedLibrary.ProcessTypeName)); taskId = Tasks.Count - 1; Save(); } return(taskId); }
public int CreateTask(DistributedTaskLibrary libraries) { Logging.WriteLog("Request for creating new library was received"); int taskId = Server.TaskLibraryManager.CreateTask(libraries); DistributedTaskLibrary distributedLibrary = Server.TaskLibraryManager.Tasks[taskId].CreateDistributedTaskLibrary(Server.ServerUri); List <int> list = new List <int>(); lock (Server.Workers) { foreach (WorkerInfo workerInfo in Server.Workers) { if (!workerInfo.Tasks.Keys.ToList().Contains(taskId)) { var service = RemoteConnection.CreateProxy <IWorkerTaskService>(UriTemplates.CreateTasksUri(workerInfo.WorkerUri)); workerInfo.Tasks.Add(taskId, service.CreateTask(distributedLibrary)); } } } return(taskId); }
public ClientTask CreateTask(String typename, List <string> filenames) { if (Disposed) { throw new NoServerConnectionException(); } else { var libraries = new DistributedTaskLibrary(LocalUri, filenames, typename); var service = RemoteConnection.CreateProxy <IServerTaskService>(UriTemplates.CreateTasksUri(ServerUri)); int taskid = 0; try { taskid = service.CreateTask(libraries); } catch { throw new ServerUnavailableException(); } return(new ClientTask(taskid, ServerUri, LocalUri)); } }