public void drop_object(object sender, DragEventArgs e) { var f = e.Data; DataObject d_o = new DataObject(); d_o.SetData(f); if (e.Data.GetDataPresent(DataFormats.Text)) { // removing these text blocks... } else if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var obj = e.Data.GetData(DataFormats.FileDrop); string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop); // todo: // add the ability to drop multiple files and open multiple instances... not hard, but time consuming. current_file = new FileInfo(filenames[0]); // only get the first entry; label2.Visible = true; label2.Text = current_file.FullName; current_rex = File.ReadAllLines(filenames[0]); working_file = new ACH_FILE(current_rex); bool proc_on_open = true; #if DEBUG proc_on_open = true; #endif if (proc_on_open) { show_search(working_file); } } }
// maybe I shouldn't let these be static. public void OpenMenuItemClick(object sender, EventArgs e) { try { var m = new OpenFileDialog(); m.ShowDialog(); current_file = new FileInfo(m.FileName); // current_rex = File.ReadAllLines(m.FileName); // that should work well. Might need to handle some kinds of errors. // now, we'll try loading the records into an ACH_FILE object. working_file = new ACH_FILE(current_rex); // #if DEBUG foreach (Tuple <string, string> a in working_file.entryAddenda.Keys) { // with this, I should be able to manipulate the files as I see fit. Console.WriteLine($"Entry: {a.Item1} Amount: {a.Item2} RECORD: ${working_file.entryAddenda[a].Item1}"); } #endif if (Program.PROCESS_ON_OPEN || Program.EXPERT_MODE) { show_search(working_file); } Console.WriteLine(current_file.FullName); label2.Visible = true; label2.Text = current_file.FullName; } catch (Exception ex) { current_rex = new string[0]; // clear rex label2.Visible = false; label2.Text = ""; current_file = null; Console.WriteLine(ex.StackTrace); } }
// after the editor, our fields should be updated with the new records. public void show_search(ACH_FILE open_file) { #if UPDATE_20190718 // we'll be using the following loop only when that record is broken. var m = new FORMS.ACCESS_RECORD(); // don't declare open_file here. // might add an option to prevent it from continuing after this loop - let's find out how it's going. m.InterruptShowDialog(open_file); // allows it to be called with as many arguments. #else // this is being changed based on the new format. var m = new FORMS.ACCESS_RECORD(open_file); m.ShowDialog(); #endif // technically everything from here should be viable to handle in the backgroung, once the new file is built. #if DEBUG string fname = "./Outout_Test_2.txt"; File.WriteAllText(fname, open_file.file_header + "\n"); File.AppendAllText(fname, open_file.batch_header + "\n"); // adding debug hook to try it out. foreach (var a in open_file.entryAddenda.Keys) { var myTup = open_file.entryAddenda[a]; File.AppendAllText(fname, myTup.Item1 + "\n"); // should write the entry files. if (!new List <string> { " ", "0", "" }.Contains(myTup.Item2)) { File.AppendAllText(fname, myTup.Item1 + "\n"); // should write the entry files. } // if this works and matches the record order, then I'll go ahead and add the logic to construct the batch components // *NEED TO ENSURE THAT ADDENDA GET HANDLED TOO. } #else #endif old_rex = current_rex; current_rex = working_file.get_file(); // this should yield the final product. #if DEBUG for (int i = 0; i < current_rex.Length; i++) { Console.WriteLine(current_rex[i]); } File.WriteAllLines("./test_final.ach", current_rex); #endif // // add the condition for this one, wehere we automatically begin using save. // use Expert mode to minimize keystrokes // if (Program.SAVE_ON_CLOSE || Program.EXPERT_MODE) { this.ButtonObjectClick(button3, new EventArgs()); } }
/// <summary> /// get the batch hash amount from this file. /// </summary> /// <returns></returns> public float GetBatchHash() { string[] d = new string[this.entryAddenda.Count]; try { // we'll tie in to the static variant of these methods, but require less input. int i = 0; foreach (var a in this.entryAddenda.Keys) { d[i] = this.entryAddenda[a].Item1; // use the entry i++; } } catch (Exception e) { Program.encountered_Exceptions.Add(e); #if DEBUG Console.WriteLine(e); System.Diagnostics.Debugger.Break(); #endif } return(ACH_FILE.CalculateBatchHashAmount(d)); }