} // end export One public static void fix() { //Check RAIDA Status int totalRAIDABad = 0; for (int i = 0; i < 25; i++) { if (RAIDA_Status.failsEcho[i]) { totalRAIDABad += 1; } } if (totalRAIDABad > 8) { Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine("You do not have enought RAIDA to perform a fix operation."); Console.Out.WriteLine("Check to make sure your internet is working."); Console.Out.WriteLine("Make sure no routers at your work are blocking access to the RAIDA."); Console.Out.WriteLine("Try to Echo RAIDA and see if the status has changed."); Console.ForegroundColor = ConsoleColor.White; return; } Console.Out.WriteLine(" Fixing fracked coins can take many minutes."); Console.Out.WriteLine(" If your coins are not completely fixed, fix fracked again."); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Console.Out.WriteLine(""); Console.Out.WriteLine(" Attempting to fix all fracked coins."); Console.Out.WriteLine(""); Frack_Fixer fixer = new Frack_Fixer(fileUtils, timeout); fixer.fixAll(); stopwatch.Stop(); Console.Out.WriteLine(" Fix Time: " + stopwatch.Elapsed + " ms"); showCoins(); Console.Out.WriteLine(" If your coins are not completely fixed, you may 'fix fracked' again."); } //end fix
}// end Detect constructor /* PUBLIC METHODS */ public int[] gradeAll(int msToFixDangerousFracked, int msToRedetectDangerous) { String[] detectedFileNames = new DirectoryInfo(this.fileUtils.detectedFolder).GetFiles().Select(o => o.Name).ToArray();//Get all files in suspect folder int totalValueToBank = 0; int totalValueToCounterfeit = 0; int totalValueToFractured = 0; int totalValueToKeptInSuspect = 0; int totalValueToLost = 0; CloudCoin newCC; for (int j = 0; j < detectedFileNames.Length; j++)//for every coins in the detected folder { try { if (File.Exists(this.fileUtils.bankFolder + detectedFileNames[j]) || File.Exists(this.fileUtils.frackedFolder + detectedFileNames[j])) {//Coin has already been imported. Delete it from import folder move to trash. //THIS SHOULD NOT HAPPEN - THE COIN SHOULD HAVE BEEN CHECKED DURING IMPORT BEFORE DETECTION TO SEE IF IT WAS IN THE BANK FOLDER Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine("You tried to import a coin that has already been imported."); CoreLogger.Log("You tried to import a coin that has already been imported."); updateLog("You tried to import a coin that has already been imported."); if (File.Exists(this.fileUtils.trashFolder + detectedFileNames[j])) { File.Delete(this.fileUtils.trashFolder + detectedFileNames[j]); } File.Move(this.fileUtils.detectedFolder + detectedFileNames[j], this.fileUtils.trashFolder + detectedFileNames[j]); Console.Out.WriteLine("Suspect CloudCoin was moved to Trash folder."); CoreLogger.Log("Suspect CloudCoin was moved to Trash folder."); updateLog("Suspect CloudCoin was moved to Trash folder."); Console.ForegroundColor = ConsoleColor.White; } else { newCC = this.fileUtils.loadOneCloudCoinFromJsonFile(this.fileUtils.detectedFolder + detectedFileNames[j]); CoinUtils cu = new CoinUtils(newCC); //CoinUtils detectedCC = cu; //cu.sortToFolder();//Tells the Coin Utils to set what folder the coins should go to. cu.consoleReport(); //Suspect, Counterfeit, Fracked, Bank, Trash, Detected, Lost, Dangerous switch (cu.getFolder().ToLower()) { case "bank": totalValueToBank++; fileUtils.writeTo(this.fileUtils.bankFolder, cu.cc); break; case "fracked": totalValueToFractured++; fileUtils.writeTo(this.fileUtils.frackedFolder, cu.cc); break; case "counterfeit": totalValueToCounterfeit++; fileUtils.writeTo(this.fileUtils.counterfeitFolder, cu.cc); break; case "lost": totalValueToLost++; fileUtils.writeTo(this.fileUtils.lostFolder, cu.cc); break; case "suspect": totalValueToKeptInSuspect++; fileUtils.writeTo(this.fileUtils.suspectFolder, cu.cc); Console.ForegroundColor = ConsoleColor.Red; Console.Out.WriteLine(" Not enough RAIDA were contacted to determine if the coin is authentic."); Console.Out.WriteLine(" Try again later."); CoreLogger.Log(" Not enough RAIDA were contacted to determine if the coin is authentic. Try again later."); Console.ForegroundColor = ConsoleColor.White; break; case "dangerous": Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" WARNING: Strings may be attached to this coins"); Console.ForegroundColor = ConsoleColor.White; Console.Out.WriteLine(" Now fixing fracked for " + (j + 1) + " of " + detectedFileNames.Length + " . SN " + string.Format("{0:n0}", newCC.sn) + ", Denomination: " + cu.getDenomination()); CoreLogger.Log(" Now fixing fracked for " + (j + 1) + " of " + detectedFileNames.Length + " . SN " + string.Format("{0:n0}", newCC.sn) + ", Denomination: " + cu.getDenomination()); updateLog("Some of your CloudCoins are still being processed. This should take just a moment."); Frack_Fixer ff = new Frack_Fixer(fileUtils, msToFixDangerousFracked); ff.txtLogs = txtLogs; RAIDA raida = new RAIDA(); Console.WriteLine("folder is " + cu.getFolder().ToLower()); while (cu.getFolder().ToLower() == "dangerous") { // keep fracking fixing until all fixed or no more improvments possible. Console.WriteLine(" calling fix Coin"); cu = ff.fixCoin(cu.cc, msToFixDangerousFracked).Result; Console.WriteLine(" sorting after fixing"); cu.sortFoldersAfterFixingDangerous(); } //while folder still dangerous for (int i = 0; i < 25; i++) { cu.pans[i] = cu.generatePan(); } // end for each pan cu = raida.detectCoin(cu, msToRedetectDangerous); //Detect again to make sure it is powned cu.consoleReport(); cu.sortToFolder(); //Tells the Coin Utils to set what folder the coins should go to. switch (cu.getFolder().ToLower()) { case "bank": totalValueToBank++; fileUtils.writeTo(this.fileUtils.bankFolder, cu.cc); break; case "fracked": totalValueToFractured++; fileUtils.writeTo(this.fileUtils.frackedFolder, cu.cc); break; default: totalValueToCounterfeit++; fileUtils.writeTo(this.fileUtils.counterfeitFolder, cu.cc); break; } //end switch break; }//end switch File.Delete(this.fileUtils.detectedFolder + detectedFileNames[j]);//Take the coin out of the detected folder }//end if file exists } catch (FileNotFoundException ex) { Console.Out.WriteLine(ex); CoreLogger.Log(ex.ToString()); } catch (IOException ioex) { Console.Out.WriteLine(ioex); CoreLogger.Log(ioex.ToString()); } // end try catch } // end for each coin to import results[0] = totalValueToBank; results[1] = totalValueToFractured; results[2] = totalValueToCounterfeit; results[3] = totalValueToKeptInSuspect; results[4] = totalValueToLost; return(results); }//Detect All
public static void Main(params string[] args) { Setup(); updateLog("Loading Network Directory"); SetupRAIDA(); FS.LoadFileSystem(); RAIDA.logger = logger; fixer = new Frack_Fixer(FS, Config.milliSecondsToTimeOut); Console.Clear(); // Program.exe <-g|--greeting|-$ <greeting>> [name <fullname>] // [-?|-h|--help] [-u|--uppercase] #region CommandLineArguments CommandLineApplication commandLineApplication = new CommandLineApplication(throwOnUnexpectedArg: false); CommandArgument names = null; commandLineApplication.Command("name", (target) => names = target.Argument( "fullname", "Enter the full name of the person to be greeted.", multipleValues: true)); CommandOption greeting = commandLineApplication.Option( "-$|-g |--greeting <greeting>", "The greeting to display. The greeting supports" + " a format string where {fullname} will be " + "substituted with the full name.", CommandOptionType.NoValue); CommandOption uppercase = commandLineApplication.Option( "-u | --uppercase", "Display the greeting in uppercase.", CommandOptionType.NoValue); commandLineApplication.HelpOption("-? | -h | --help"); CommandOption stats = commandLineApplication.Option( "-$|-s |--stats ", "Displays RAIDA statistics of all networks", CommandOptionType.NoValue); CommandOption echo = commandLineApplication.Option( "-$|-e |--echo ", "The greeting to display. The greeting supports" + " a format string where {fullname} will be " + "substituted with the full name.", CommandOptionType.NoValue); CommandOption total = commandLineApplication.Option( "-$|-b |--bank ", "Shows details of your coins in bank.", CommandOptionType.NoValue); CommandOption backup = commandLineApplication.Option( "-$|-ba |--backup ", "Backup your coins to specified folder.", CommandOptionType.SingleValue); CommandOption folders = commandLineApplication.Option( "-$|-f |--folders ", "The command to display CloudCoin Working Folder Structure", CommandOptionType.NoValue); CommandOption pown = commandLineApplication.Option( "-$|-p |--pown ", "The command to pown/detect/import your CloudCoins.", CommandOptionType.NoValue); CommandOption detection = commandLineApplication.Option( "-$|-d |--detect ", "The command to pown/detect/import your CloudCoins.", CommandOptionType.NoValue); CommandOption import = commandLineApplication.Option( "-$|-i |--import ", "The command to pown/detect/import your CloudCoins.", CommandOptionType.NoValue); #endregion if (args.Length < 1) { printWelcome(); while (true) { try { int input = DisplayMenu(); ProcessInput(input).Wait(); if (input == 9) { break; } } catch (Exception e) { break; } } } else { commandLineApplication.OnExecute(async() => { if (echo.HasValue()) { //ech(); await EchoRaidas(); } if (folders.HasValue()) { ShowFolders(); } if (pown.HasValue() || detection.HasValue() || import.HasValue()) { await RAIDA.ProcessCoins(false); } if (greeting.HasValue()) { printWelcome(); } if (stats.HasValue()) { await EchoRaidas(); } if (total.HasValue()) { showCoins(); } if (backup.HasValue()) { Console.WriteLine(backup.Value()); } return(0); }); commandLineApplication.Execute(args); } }