static void Main(string[] args) { // ServiceBase.Run(new Program()); // SoftwareSandy.Program p = new Program(); log = new LogLogger("Application", "SoftwareSandy Claims Scrubber"); //p.ParseFiles(); ParseFiles(); }
static public void ParseFiles() { QuickCap qc = new QuickCap(); qc.log = log; log = new LogLogger("Application", "SoftwareSandy Claims Scrubber"); log.LogInformation("Starting"); claimLinesList = new Dictionary <string, ClaimLinesIndex>(); qc.ClaimScrubRead(); //log.LogInformation("Parsing Files"); ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["SQLConnection"]; SqlConnection con = new SqlConnection(settings.ConnectionString); using (con) { try { con.Open(); GetCPTExclusions(con); } catch (SqlException sex) { log.LogError(String.Format("Cannot connect {0}", sex.Message)); } string _directories = ConfigurationManager.AppSettings["NetworksLocation"]; string[] networks = getNetworks(_directories); for (int i = 0; i < networks.Length; i++) { gCompany = networks[i].Substring(_directories.Length + 1); FixPercentages(); log.LogInformation("Deliting previous working files"); string[] files = Directory.GetFiles(networks[i] + @"\WORKING"); if (files.Length > 0) { for (int k = 0; k < files.Length; k++) { File.Delete(files[k]); } } files = Directory.GetFiles(networks[i] + @"\IN"); // Looking for files in the "IN" directory if (files.Length > 0) { log.LogInformation("Spliting files"); for (int j = 0; j < files.Length; j++) { try { SplitFiles(files[j], networks[i], con); } catch (Exception ex) { log.LogError(String.Format("Error Spliting Files {0}", ex.Message)); } } for (int j = 0; j < files.Length; j++) { try { if (File.Exists(files[j].Replace(@"\IN", @"\PROCESS"))) { log.LogInformation(String.Format("Deleting file {0}", files[j].Replace(@"\IN", @"\PROCESS"))); File.Delete(files[j].Replace(@"\IN", @"\PROCESS")); } File.Move(files[j], files[j].Replace(@"\IN", @"\PROCESS")); } catch (Exception ef) { log.LogError(String.Format("Moving files {0} {1}", files[j], ef.Message)); } } files = Directory.GetFiles(networks[i] + @"\WORKING"); for (int j = 0; j < files.Length; j++) { log.LogInformation("Sending File: " + files[j]); // had bug using the wrong index try { SendFiles(files[j], networks[i]); } catch (Exception ex) { log.LogError(String.Format("Outside SendFiles {0}", ex.Message)); } } if (claimLinesList.Count() > 0) { claimLinesList.Clear(); } } } } qc.ClaimScrubWrite(); }