public static string obtenerResultados_Click(string id) { List<JobResult> results = new List<JobResult>(); CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(VariablesConfiguracion.containerName); CloudBlockBlob infoSimulation = container.GetBlockBlobReference(VariablesConfiguracion.infoSimulation + "-" + id); //Si existe el id de usuario ingresado if (infoSimulation.Exists()) { string msg; string prefix = VariablesConfiguracion.progressName + "-" + id + "."; Stream output = new MemoryStream(); int i = -1; CloudBlockBlob simulationState = container.GetBlockBlobReference(prefix + i); ; for (int k = 0; k <= 3; k++) { simulationState = container.GetBlockBlobReference(prefix + k); if (simulationState.Exists()) { i = k; break; } } //si ya se crearon sub jobs y estan corriendo en el cluster if (i != -1) { //para cada sub job creo una entrada en la tabla de resultados while (simulationState.Exists()) { msg = simulationState.DownloadText(); JobResult result = new JobResult(); result.IdUsuario = id; result.IdJob = i.ToString(); result.estado = msg; result.showMdl = true; result.showMcellOutput = true; result.showResults = false; string mcellText = VariablesConfiguracion.mcellOutput.Replace("ID", id + "." + i); CloudBlockBlob mcellOut = container.GetBlockBlobReference(mcellText); string mapperText = VariablesConfiguracion.mapperErrorOutput.Replace("ID", id + "." + i); CloudBlockBlob mapperOut = container.GetBlockBlobReference(mapperText); if (msg.Equals(VariablesConfiguracion.JOB_SUCCESS) || msg.Equals(VariablesConfiguracion.JOB_RUNNING)) { //dio succes y termino de correr el job if (mcellOut.Exists()) { string errorText = VariablesConfiguracion.mcellErrorOutput.Replace("ID", id + "." + i); CloudBlockBlob errorBlob = container.GetBlockBlobReference(errorText); if (errorBlob.Exists()) { result.estado = VariablesConfiguracion.JOB_FAIL; } else { result.showResults = true; result.estado = VariablesConfiguracion.JOB_SUCCESS; } } //Si dio success pero todavia no termino de correr el job, lo dejo como running else { //Chequeo si fallo el mapper if (mapperOut.Exists()) { result.estado = VariablesConfiguracion.JOB_FAIL; result.showMcellOutput = false; } else { result.estado = VariablesConfiguracion.JOB_RUNNING; result.showMcellOutput = false; } } } else { result.estado = VariablesConfiguracion.JOB_FAIL; result.showMcellOutput = false; } results.Add(result); //iteration step i++; simulationState = container.GetBlockBlobReference(prefix + i); } } //Si existe el id de la simulacion ingresado pero aun no se lanzaron los jobs al cluster else { JobResult result = new JobResult(); result.IdUsuario = id; result.IdJob = "-"; result.estado = infoSimulation.DownloadText(); result.showMdl = false; result.showMcellOutput = false; result.showResults = false; results.Add(result); } } // instanciar el serializador JavaScriptSerializer TheSerializer = new JavaScriptSerializer(); TheSerializer.RegisterConverters(new JavaScriptConverter[] { }); var json = TheSerializer.Serialize(results.ToList()); return json; }
public static string obtenerResultados_Click(string id) { List <JobResult> results = new List <JobResult>(); CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference(VariablesConfiguracion.containerName); CloudBlockBlob infoSimulation = container.GetBlockBlobReference(VariablesConfiguracion.infoSimulation + "-" + id); //Si existe el id de usuario ingresado if (infoSimulation.Exists()) { string msg; string prefix = VariablesConfiguracion.progressName + "-" + id + "."; Stream output = new MemoryStream(); int i = -1; CloudBlockBlob simulationState = container.GetBlockBlobReference(prefix + i);; for (int k = 0; k <= 3; k++) { simulationState = container.GetBlockBlobReference(prefix + k); if (simulationState.Exists()) { i = k; break; } } //si ya se crearon sub jobs y estan corriendo en el cluster if (i != -1) { //para cada sub job creo una entrada en la tabla de resultados while (simulationState.Exists()) { msg = simulationState.DownloadText(); JobResult result = new JobResult(); result.IdUsuario = id; result.IdJob = i.ToString(); result.estado = msg; result.showMdl = true; result.showMcellOutput = true; result.showResults = false; string mcellText = VariablesConfiguracion.mcellOutput.Replace("ID", id + "." + i); CloudBlockBlob mcellOut = container.GetBlockBlobReference(mcellText); string mapperText = VariablesConfiguracion.mapperErrorOutput.Replace("ID", id + "." + i); CloudBlockBlob mapperOut = container.GetBlockBlobReference(mapperText); if (msg.Equals(VariablesConfiguracion.JOB_SUCCESS) || msg.Equals(VariablesConfiguracion.JOB_RUNNING)) { //dio succes y termino de correr el job if (mcellOut.Exists()) { string errorText = VariablesConfiguracion.mcellErrorOutput.Replace("ID", id + "." + i); CloudBlockBlob errorBlob = container.GetBlockBlobReference(errorText); if (errorBlob.Exists()) { result.estado = VariablesConfiguracion.JOB_FAIL; } else { result.showResults = true; result.estado = VariablesConfiguracion.JOB_SUCCESS; } } //Si dio success pero todavia no termino de correr el job, lo dejo como running else { //Chequeo si fallo el mapper if (mapperOut.Exists()) { result.estado = VariablesConfiguracion.JOB_FAIL; result.showMcellOutput = false; } else { result.estado = VariablesConfiguracion.JOB_RUNNING; result.showMcellOutput = false; } } } else { result.estado = VariablesConfiguracion.JOB_FAIL; result.showMcellOutput = false; } results.Add(result); //iteration step i++; simulationState = container.GetBlockBlobReference(prefix + i); } } //Si existe el id de la simulacion ingresado pero aun no se lanzaron los jobs al cluster else { JobResult result = new JobResult(); result.IdUsuario = id; result.IdJob = "-"; result.estado = infoSimulation.DownloadText(); result.showMdl = false; result.showMcellOutput = false; result.showResults = false; results.Add(result); } } // instanciar el serializador JavaScriptSerializer TheSerializer = new JavaScriptSerializer(); TheSerializer.RegisterConverters(new JavaScriptConverter[] { }); var json = TheSerializer.Serialize(results.ToList()); return(json); }