private List <ArregloCubo> CrearOjetoCubo(string[] informacion, ref RespuestaGeneral respuestaGeneral) { List <ArregloCubo> listCubo = new List <ArregloCubo>(); ArregloCubo cubo = new ArregloCubo(); for (int i = 1; i < informacion.Length; i++) { string[] datos = informacion[i].Split(' '); if (datos.Length == 2) { if (!ValidarTamanoMatrizOperaciones(datos, ref respuestaGeneral)) { return(new List <ArregloCubo>()); } cubo = new ArregloCubo { TamanoMatriz = Convert.ToInt32(informacion[i].Split(' ')[0]), CantidadOperaciones = Convert.ToInt32(informacion[i].Split(' ')[1]), OperacionesCubo = new List <OperacionCubo>() }; listCubo.Add(cubo); continue; } cubo.OperacionesCubo.Add(new OperacionCubo { TipoOperacion = datos[0], InformacionOperacion = ObtenerInformacionOperacion(datos) }); } return(listCubo); }
private RespuestaGeneral ResolverOperacionesMatriz(long[,,] matriz, ArregloCubo cubo, RespuestaGeneral respuestaGeneral) { if (!respuestaGeneral.EstadoOperacion) { return(respuestaGeneral); } return(ResolverOperaciones(cubo, matriz)); }
public void ValidarCoordenadas(long[] informacionOperacion, ArregloCubo cubo, string tipoOperacion, ref RespuestaGeneral respuestaGeneral) { if (!respuestaGeneral.EstadoOperacion) { return; } int length = tipoOperacion.Equals(TipoOperacion.UPDATE.ToString()) ? informacionOperacion.Length - 1 : informacionOperacion.Length; for (int i = 0; i < length; i++) { if (informacionOperacion[i] > cubo.TamanoMatriz || informacionOperacion[i] <= 0) { respuestaGeneral.EstadoOperacion = false; respuestaGeneral.Mensaje = "Las coordenadas deben de ser menor o igual que el tamaño de la matriz y mayores que cero(0)."; return; } } }
private RespuestaGeneral ResolverOperaciones(ArregloCubo cubo, long[,,] matriz) { foreach (OperacionCubo operacionCubo in cubo.OperacionesCubo) { string tipoOperacion = operacionCubo.TipoOperacion.ToUpper(); if (!respuestaGeneral.EstadoOperacion) { return(respuestaGeneral); } validacionDatos.ValidarCoordenadas(operacionCubo.InformacionOperacion, cubo, tipoOperacion, ref respuestaGeneral); if (tipoOperacion.Equals(TipoOperacion.UPDATE.ToString())) { EjecutarUpdate(operacionCubo, matriz); } if (tipoOperacion.Equals(TipoOperacion.QUERY.ToString())) { EjecutarQuery(operacionCubo, matriz); } } return(respuestaGeneral); }
private RespuestaGeneral ProcesarCubo(ArregloCubo cubo, RespuestaGeneral respuestaGeneral) { long[,,] matriz = new long[cubo.TamanoMatriz, cubo.TamanoMatriz, cubo.TamanoMatriz]; return(ResolverOperacionesMatriz(matriz, cubo, respuestaGeneral)); }