public static CardProcessor SetupProcessorFromFile(string filename) { AdmitListInfo info = GetAdmitListInfo(filename); CardProcessor cardProcessor = new CardProcessor(info.eventName, info.eventId); try { StreamReader file = new StreamReader(filename); string line; short current_mode = -1; while ((line = file.ReadLine()) != null) { line = line.TrimEnd(); if (line[0] == '#') { continue; } else if (line == "!!!MESSAGES") { current_mode = 0; continue; } else if (line == "!!!IDCARDS") { current_mode = 1; continue; } if (current_mode == 0) { AddMessageLine(cardProcessor,line); } else if (current_mode == 1) { AddSUIDLine(cardProcessor,line); } } } catch (IOException) { throw new Exception(String.Format("Could not read the admit list. Ensure {0} exists", filename)); } return cardProcessor; }
public ScanLog(CardProcessor p) { this.eventName = p.EventName; this.eventId = p.EventId; //Find unix timestamp long ticks = DateTime.UtcNow.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks; ticks /= 10000000; //Convert windows ticks to seconds string timestamp = ticks.ToString(); try { string filename = SaveFolder + String.Format(FileNameFormat, this.eventId, timestamp); FileInfo fileInfo = new FileInfo(filename); oStream = fileInfo.CreateText(); oStream.WriteLine(String.Format(HeaderFormat, eventId, timestamp)); oStream.Flush(); } catch (IOException e) { oStream = null; throw e; } }
private static void AddSUIDLine(CardProcessor p, string line) { string[] fields = line.Split(','); Boolean over_21 = fields[1].Equals("1"); Boolean admit = fields[2].Equals("1"); short message = 0; try { message = Convert.ToInt16(fields[3]); } catch (Exception) { message = 0; } p.AddSUID(new SUID(fields[0], over_21, admit, message)); }
private static void AddMessageLine(CardProcessor p, string line) { string[] fields = line.Split(','); try { short id = Convert.ToInt16(fields[0]); p.AddMessage(new Message(id, fields[1], fields[2])); } catch (Exception) { // pass this line over } }
protected void SetupAdmitList() { if (in_processing) return; in_processing = true; // setup which file to use // show selection window for file (dectivates this window) SelectForm sForm = new SelectForm(); sForm.ShowDialog(); this.ShowSpinner = true; processor = AdmitList.SetupProcessorFromFile(MainForm.admit_file); this.ShowSpinner = false; // alert that we are done! this.scannerServices.ExecuteUIFCommand(UIF_COMMAND.BC_APP_CLICK); this.numAdmitted = 0; admit_processed = true; in_processing = false; }