/// <summary> /// This method loads CSV data in from the TXT_BOX_KEYENCE.Text and binds it to DGV1. It does some controls formatting as well. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LOAD_CSV_DATA(object sender, EventArgs e) //Logged and documented. { EVENTS.LOG_MESSAGE(1, "ENTER"); //Load in data. bool IS_VALID = BACKEND.VALIDATE_FILE(TXT_BOX_KEYENCE.Text); //Check to make sure the filepath is valid. if (!IS_VALID) //If the file is not valid... { EVENTS.LOG_MESSAGE(1, "EXIT_FAIL"); return; //Break out of method. VALIDATE_FILE method will notify user of problems. } TABLE_PROCESSOR KEYENCE_PROCESSOR = new TABLE_PROCESSOR(); //Create a table processor. EVENTS.LOG_MESSAGE(3, "Created a new TABLE_PROCESSOR."); DataTable GRID_DATA = new DataTable(); //Create a datatable that will hold all the csv data. DataTable INSTRUCTIONS = INSTRUCTION_SET.CREATE_INSTRUCTION_TABLE(); //We need to create a simple instruction table to load in the file. KEYENCE_PROCESSOR.PROCESS_INSTRUCTIONS(ref GRID_DATA, ref INSTRUCTIONS, TXT_BOX_KEYENCE.Text, ',', null, ','); //Load in the data into GRID_DATA. EVENTS.LOG_MESSAGE(3, "Data loaded in."); EVENTS.LOG_MESSAGE(3, "Naming each column."); foreach (DataColumn COLUMN in GRID_DATA.Columns) //Modification to prevent some null references later on. { COLUMN.ColumnName = COLUMN.Ordinal.ToString(); } DGV1.DataSource = GRID_DATA; //Bind the DGV to the data. The DGV will be where we can pull the table from on future calls. EVENTS.LOG_MESSAGE(3, "Data bound to DGV."); //Format DGV. DGV1.RowHeadersVisible = false; DGV1.ColumnHeadersVisible = true; DGV1.ReadOnly = true; DGV1.AllowUserToOrderColumns = false; DGV1.AllowUserToResizeRows = false; DGV1.AllowUserToResizeColumns = false; foreach (DataGridViewColumn COLUMN in DGV1.Columns) { COLUMN.SortMode = DataGridViewColumnSortMode.NotSortable; } EVENTS.LOG_MESSAGE(3, "Formatted DGV."); //Enable controls for working with table. GRP_BOX_COLUMN_ASSIGNERS.Enabled = true; EVENTS.LOG_MESSAGE(3, "Assigner controls enabled."); EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS"); }
private void button1_Click(object sender, EventArgs e) { EVENTS.LOG_MESSAGE(1, "ENTER"); //Get the currently selected recipe data. RECIPE_DATA DATA = new RECIPE_DATA(); GET_CURRENTLY_SELECTED_RECIPE_DATA(out DATA); //Process the key sequence from the recipe into a list and table. SEQUENCE_LIST.Clear(); SEQUENCE_DATATABLE.Clear(); BACKEND.LOAD_IN_KEY_SEQUENCE(DATA.key_sequence, ref SEQUENCE_LIST, ref SEQUENCE_DATATABLE); //Get data from file. TABLE_PROCESSOR KEYENCE_PROCESSOR = new TABLE_PROCESSOR(); DataTable TABLE = new DataTable(); DataTable INSTRUCTIONS = INSTRUCTION_SET.CREATE_INSTRUCTION_TABLE(); KEYENCE_PROCESSOR.PROCESS_INSTRUCTIONS(ref TABLE, ref INSTRUCTIONS, DATA.csv_location, ','); //Label the columns. BACKEND.LABEL_DATATABLE_COLUMNS(ref TABLE, DATA); //Check the timestamp. string TIME_STRING = null; for (int i = TABLE.Rows.Count - 1; i >= 0; i--) { TIME_STRING = TABLE.Rows[i][DATA.timestamp_col].ToString(); if (TIME_STRING != "" && TIME_STRING != null) { break; } } DateTime TIME = DateTime.Parse(TIME_STRING); TimeSpan TIME_AGO = DateTime.Now.Subtract(TIME); if (TIME_AGO.TotalHours > 1) { string MESSAGE = string.Format("The last entry detected is {0} Days, {1} Hours and {2} Minutes old. Are you sure this is correct?", TIME_AGO.Days, TIME_AGO.Hours, TIME_AGO.Minutes); if (MessageBox.Show(MESSAGE, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } FORM_REPLAY NEW_FORM = new FORM_REPLAY(); NEW_FORM.Show(); NEW_FORM.TopMost = true; //Fill out the injection table. BACKEND.MOVE_CSV_DATA_INTO_INJECTION_TABLE(TABLE, INJECTION_TABLE); //Start the keylogger. REPLAY_SEQUENCE_START(null, null); EVENTS.LOG_MESSAGE(1, "EXIT_SUCCESS"); }