//--------------------------------------------------------------------------------------------------------->>> // Sobrecarga de GetFiles para ejecutar todas las operaciones SELECT (siempre se ejecuta después del 1ero) public static List <FileModel> GetFiles(ClientsModeling.Client client, string fname, string fformat, string farea, string fdate) { // Instancia del cliente y de la lista a retornar Client cli = new Client(); List <FileModel> files = new List <FileModel>(); try { // Serializamos información a enviar string dataSend = SendReceiveStructures.JsonSerialize(client, null, fname, fformat, farea, fdate); // Inicia Cliente y proceso de envío y recepción de datos string dataReceive = cli.MakePetition(dataSend); // Deserializamos información ClientsModeling.Data result = SendReceiveStructures.JsonDeserialize(dataReceive); // Evaluación de la bandera recibida if (result.flag) { files = result.filesData; } else { files = null; } } catch (Exception ex) { } return(files); }
//------------------------------------------------------------------>>> // Botón para buscar documentos por coincidencia de caracteres protected void FinderBtn_Click(object sender, EventArgs e) { // Creamos una onstancia de operacion de cliente ClientsModeling.Client client; // Declaramos lista a mostrar en la tabla List <FileModel> files = new List <FileModel>(); string Fname = WordFilterTxt.Text; if (Fname.Equals("")) { scriptMessage("No puedes hacer una búsqueda sin un parametro a buscar...");// ---------------------------------------------->>> JERRY DEL FUTURO, TERMINA ESTA FUNCIÓN POR MI... } else { client = new ClientsModeling.Client() { rfc = (string)Session["RFC"], username = (string)Session["UserName"], operation = OperationType.GetFilesx1, topRange = 25, index = 1 }; files = Operations.GetFiles(client, Fname, null, null, null); } ShowDocs(false, files); }
protected void loginB_Click(object sender, EventArgs e) { try { if (rfcT.Text.Length > 1 && (rfcT.Text.Length < 12 || rfcT.Text.Length > 13)) { errorSesion.Text = ""; errorLengthRFC.Text = "Verifique que el RFC contenga 12 o 13 caracteres"; } else if (userNameT.Text.Length == 0 || passwordT.Text.Length == 0 || rfcT.Text.Length == 0) { errorLengthRFC.Text = ""; errorSesion.Text = "Verifique que todos los campos hayan sido llenados"; } else { errorLengthRFC.Text = ""; errorSesion.Text = ""; ClientsModeling.Client dataLogin = new ClientsModeling.Client() { operation = OperationType.requestAuthentication, rfc = rfcT.Text, username = userNameT.Text, password = passwordT.Text }; // Ejecutamos autenticación ClientsModeling.Data response = op.RequestAuthentication(dataLogin); //Evaluamos if (response == null) { errorSesion.Text = "Parece que hubo un error con la conexión"; } else { if (response.flag) { // Seteamos información para conexión al sistema Session["RFC"] = rfcT.Text; Session["userName"] = userNameT.Text; Session["userData"] = response.userData; Session["privilegeData"] = response.privilegeData; Session["userviewData"] = response.userviewData; // Redirigimos al Gestor //Response.Redirect("https://www.google.com.mx"); Response.Redirect("~/View/LoggedSession.aspx"); } else { errorSesion.Text = "Verifique que sus datos sean correctos"; } } } } catch (Exception ex) { scriptMessage("ERROR: " + ex.Message + ", " + ex.StackTrace); } }
//------------------------------------------------------------------>>> // Comenzamos proceso de petición de carga protected void panelAccept_Click(object sender, EventArgs e) { // Declaramos lista a mostrar en la tabla List <FileModel> files = new List <FileModel>(); // Hay archivos cargados??? if (FileUpload1.HasFiles) { if (!areaLPanel.SelectedValue.Equals("")) { // Creamos data del cliente a enviar ClientsModeling.Client client = new ClientsModeling.Client() { operation = OperationType.requestUploadFile, username = (string)Session["userName"], rfc = (string)Session["RFC"], topRange = 25, index = 1, mountFiles = FileUpload1.PostedFiles.Count }; foreach (HttpPostedFile file in FileUpload1.PostedFiles) { // Hacemos petición de carga con un fragmento de cada archivo y para todos los archivos de uno en uno Operations.LoadPetition(client, areaLPanel.SelectedValue, file); } // Proceso de envio para archivos files = Operations.LoadFiles(FileUpload1.PostedFiles);//------------------------------->>>Asincronía?? // Mostramos datos if (files.Count > 0) { ShowDocs(false, files); } else { files = Operations.GetFiles((string)Session["userName"], (string)Session["RFC"]); ShowDocs(false, files); } } else { scriptMessage("No se seleccionó un área!!!"); } } else { scriptMessage("No hay archivos que cargar!!!"); } }
//--------------------------------------------------------------------------------------------------------->>>[!!!! MODIFIED !!!!] // Lineas que tengan '***', son nuevas // Función para peticion de carga (Cada petición de carga llevará un fragmento del archivo) public static void LoadPetition(ClientsModeling.Client client, string areaDestiny, HttpPostedFile file) { // Instanciamos CLiente Client cli = new Client(); // Generamos fragmentos de archivo List <FileModel> fragments = FileSplitter(file); // *** foreach (FileModel fragment in fragments) // *** { // *** // Serializamos información a enviar string dataSend = SendReceiveStructures.JsonSerialize(client, fragment, null, null, areaDestiny, null); // Inicia proceso de envío y recepción de datos cli.MakePetition(dataSend); } // *** }
// Función para petición de autenticación public ClientsModeling.Data RequestAuthentication(ClientsModeling.Client dataLogin) { ClientsModeling.Data petitionResponse = new ClientsModeling.Data(); try { // Serializamos y convertimos en bytes string dataSend = SendReceiveStructures.JsonSerialize(dataLogin, null, null, null, null, null); // Inicia Cliente y proceso de envío y recepción de datos string dataReceive = client.MakePetition(dataSend); // Deserializamos información petitionResponse = SendReceiveStructures.JsonDeserialize(dataReceive); } catch (Exception ex) { //Context.scriptMessage("Error al intentar conectar...\r\n" + ex.Message); Context.Logger("Error: " + ex.Message + ",\r\n" + ex.HResult + ",\r\n" + ex.StackTrace); } return(petitionResponse); }
//--------------------------------------------------------------------------------------------------------->>> // Función para ejecutar Select por 1era vez public static List <FileModel> GetFiles(string userName, string rfc) { // Instancia del cliente y de la lista a retornar Client cli = new Client(); List <FileModel> files = new List <FileModel>(); // Creamos la petición por Default (1er ingreso) ClientsModeling.Client clientData = new ClientsModeling.Client() { operation = OperationType.GetFiles, username = userName, rfc = rfc, topRange = 25, index = 1, }; try { // Se serializa Información string dataSend = SendReceiveStructures.JsonSerialize(clientData, null, null, null, null, null); // Inicia Cliente y proceso de envío y recepción de datos string dataReceive = cli.MakePetition(dataSend); // Deserializamos información ClientsModeling.Data result = SendReceiveStructures.JsonDeserialize(dataReceive); // Evaluación de la bandera recibida if (result.flag) { files = result.filesData; } else { files = null; } } catch (Exception ex) { } return(files); }
//------------------------------------------------------------------>>> // Botón para aplicar filtros de búsqueda protected void ApplyFilter_Click(object sender, EventArgs e) { // Declaramos lista a mostrar en la tabla List <FileModel> files = new List <FileModel>(); // Declaramos y asignamos valor a variables string Farea = areaFilter.SelectedValue, Fformat = formatFilter.SelectedValue, Fdate = DateTxt.Text; // Creamos una onstancia de operacion de cliente ClientsModeling.Client client; // Evaluar que operación realizar if (Farea.Equals("") && Fformat.Equals("") && Fdate.Equals(""))// Búsqueda sin ningún filtro (*) { client = new ClientsModeling.Client() { rfc = (string)Session["RFC"], username = (string)Session["UserName"], operation = OperationType.GetFiles, topRange = 25, index = 1 }; Operations.GetFiles(client, null, null, null, null); } else if (!Farea.Equals("") && !Fformat.Equals("") && !Fdate.Equals(""))// Búsqueda con los 3 filtros activos { client = new ClientsModeling.Client() { rfc = (string)Session["RFC"], username = (string)Session["UserName"], operation = OperationType.GetFilesxFAD, topRange = 25, index = 1 }; files = Operations.GetFiles(client, null, Fformat, Farea, Fdate); } else if (!Fformat.Equals("") && Farea.Equals("") && Fdate.Equals(""))// Búsqueda por Formato { client = new ClientsModeling.Client() { rfc = (string)Session["RFC"], username = (string)Session["UserName"], operation = OperationType.GetFilesxFormat, topRange = 25, index = 1 }; files = Operations.GetFiles(client, null, Fformat, null, null); } else if (Fformat.Equals("") && !Farea.Equals("") && Fdate.Equals(""))// Búsqueda por Área { client = new ClientsModeling.Client() { rfc = (string)Session["RFC"], username = (string)Session["UserName"], operation = OperationType.GetFilesxArea, topRange = 25, index = 1 }; files = Operations.GetFiles(client, null, null, Farea, null); } else if (Fformat.Equals("") && Farea.Equals("") && !Fdate.Equals(""))// Búsqueda por Fecha { client = new ClientsModeling.Client() { rfc = (string)Session["RFC"], username = (string)Session["UserName"], operation = OperationType.GetFilesxDate, topRange = 25, index = 1 }; files = Operations.GetFiles(client, null, null, null, Fdate); } else if (Fformat.Equals("") && !Farea.Equals("") && !Fdate.Equals(""))// Búsqueda por Área y Fecha { client = new ClientsModeling.Client() { rfc = (string)Session["RFC"], username = (string)Session["UserName"], operation = OperationType.GetFilesxAD, topRange = 25, index = 1 }; files = Operations.GetFiles(client, null, null, Farea, Fdate); } else if (!Fformat.Equals("") && Farea.Equals("") && !Fdate.Equals(""))// Búsqueda por Formato y Fecha { client = new ClientsModeling.Client() { rfc = (string)Session["RFC"], username = (string)Session["UserName"], operation = OperationType.GetFilesxFD, topRange = 25, index = 1 }; files = Operations.GetFiles(client, null, Fformat, null, Fdate); } else if (!Fformat.Equals("") && !Farea.Equals("") && Fdate.Equals(""))// Búsqueda por Formato y Área { client = new ClientsModeling.Client() { rfc = (string)Session["RFC"], username = (string)Session["UserName"], operation = OperationType.GetFilesxFA, topRange = 25, index = 1 }; files = Operations.GetFiles(client, null, Fformat, Farea, null); } ShowDocs(false, files); }
// Serialización de un objecto ClientsModeling.Client public static string JsonSerialize(ClientsModeling.Client client, FileModel fileFragment, string fname, string fformat, string farea, string fdate) { //convert data to JSON string try { ClientsModeling.PetitionData package = new ClientsModeling.PetitionData(); String data = null; switch (client.operation) { case OperationType.requestAuthentication: case OperationType.GetFiles: { package = new ClientsModeling.PetitionData() { clientData = client, fileArea = "%%", fileFormat = "%%", fileLoadDate = "%%", fileName = "%%" }; } break; case OperationType.GetFilesx1: package = new ClientsModeling.PetitionData() { clientData = client, fileName = "%" + fname + "%", fileArea = "%%", fileFormat = "%%", fileLoadDate = "%%" }; break; case OperationType.GetFilesxFormat: package = new ClientsModeling.PetitionData() { clientData = client, fileFormat = fformat, fileArea = "%%", fileLoadDate = "%%", fileName = "%%" }; break; case OperationType.GetFilesxArea: package = new ClientsModeling.PetitionData() { clientData = client, fileArea = farea, fileFormat = "%%", fileLoadDate = "%%", fileName = "%%" }; break; case OperationType.GetFilesxDate: package = new ClientsModeling.PetitionData() { clientData = client, fileLoadDate = fdate, fileFormat = "%%", fileArea = "%%", fileName = "%%" }; break; case OperationType.GetFilesxAD: package = new ClientsModeling.PetitionData() { clientData = client, fileArea = farea, fileLoadDate = fdate, fileFormat = "%%", fileName = "%%" }; break; case OperationType.GetFilesxFD: package = new ClientsModeling.PetitionData() { clientData = client, fileFormat = fformat, fileLoadDate = fdate, fileArea = "%%", fileName = "%%" }; break; case OperationType.GetFilesxFA: package = new ClientsModeling.PetitionData() { clientData = client, fileFormat = fformat, fileArea = farea, fileLoadDate = "%%", fileName = "%%" }; break; case OperationType.GetFilesxFAD: package = new ClientsModeling.PetitionData() { clientData = client, fileFormat = fformat, fileArea = farea, fileLoadDate = fdate, fileName = "%%" }; break; case OperationType.requestUploadFile: package = new ClientsModeling.PetitionData() { clientData = client, fileToUpload = fileFragment, fileArea = farea, fileFormat = "%%", fileLoadDate = "%%", fileName = "%%" }; break; } data = JsonConvert.SerializeObject(package); return(data); } catch (Exception ex) { Context.scriptMessage("ERROR AL SERIALIZAR: " + ex.Message); } return(null); }