Beispiel #1
0
    }    // end parse Jpeg

    public void moveFile(string fromPath, string tooPath)
    {
        string path  = fromPath;
        string path2 = tooPath;

        try
        {
            if (!File.Exists(path))
            {
                // This statement ensures that the file is created,
                // but the handle is not kept.
                using (FileStream fs = File.Create(path)) { }
            }

            // Ensure that the target does not exist.
            if (File.Exists(path2))
            {
                File.Delete(path2);
            }

            // Move the file.
            File.Move(path, path2);
            //Console.WriteLine("{0} was moved to {1}.", path, path2);
        }
        catch (Exception e)
        {
            Console.WriteLine("The process failed: {0}", e.ToString());
            CoreLogger.Log(e.ToString());
        }
    }
Beispiel #2
0
    }    //Constructor

    /* PUBLIC METHODS */
    public bool importAll()
    {
        var ext = new List <string> {
            ".jpg", ".stack", ".jpeg"
        };
        var fnamesRaw = Directory.GetFiles(this.fileUtils.importFolder, "*.*", SearchOption.TopDirectoryOnly).Where(s => ext.Contains(Path.GetExtension(s)));

        string[] fnames = new string[fnamesRaw.Count()];
        for (int i = 0; i < fnamesRaw.Count(); i++)
        {
            fnames[i] = Path.GetFileName(fnamesRaw.ElementAt(i));
        }
        ;

        //String[] fnames = new DirectoryInfo(this.fileUtils.importFolder).GetFiles().Select(o => o.Name).ToArray();//Get a list of all in the folder except the directory "imported"

        if (fnames.Length == 0)    //   Console.Out.WriteLine("There were no CloudCoins to import. Please place our CloudCoin .jpg and .stack files in your imports" + " folder at " + this.fileUtils.importFolder );
        {
            return(false);
        }
        else
        {
            //  Console.ForegroundColor = ConsoleColor.Green;
            //  Console.Out.WriteLine("Importing the following files: ");
            CoreLogger.Log("Importing the following files: ");
            //  Console.ForegroundColor = ConsoleColor.White;
            for (int i = 0; i < fnames.Length; i++)    // Loop through each file.
            {
                Console.Out.WriteLine(fnames[i]);
                CoreLogger.Log(fnames[i]);
                this.importOneFile(fnames[i]);
            } // end for each file name
            return(true);
        }     //end if no files
    }         // End Import All
Beispiel #3
0
    }    //import stack

    public bool seemsValidJSON(string json)
    {
        /*This does some simple tests to see if the JSON is valid. It is not precise.*/


        if (json.Count(f => f == '{') != json.Count(f => f == '}'))
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Out.WriteLine("The stack file did not have a matching number of { }. There were " + json.Count(f => f == '{') + " {, and " + json.Count(f => f == '}') + " }");
            CoreLogger.Log("The stack file did not have a matching number of { }. There were " + json.Count(f => f == '{') + " {, and " + json.Count(f => f == '}') + " }");
            Console.ForegroundColor = ConsoleColor.White;
            return(false);
        }    //Check if number of currly brackets open are the same as closed
        if (json.Count(f => f == '[') != json.Count(f => f == ']'))
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Out.WriteLine("The stack file did not have a matching number of []. There were " + json.Count(f => f == '[') + " [, and " + json.Count(f => f == ']') + " ]");
            CoreLogger.Log("The stack file did not have a matching number of []. There were " + json.Count(f => f == '[') + " [, and " + json.Count(f => f == ']') + " ]");
            Console.ForegroundColor = ConsoleColor.White;
            return(false);
        }    //Check if number of  brackets open are the same as closed
        if (IsOdd(json.Count(f => f == '\"')))
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Out.WriteLine("The stack file did not have a matching number of double quotations");
            CoreLogger.Log("The stack file did not have a matching number of double quotations");
            Console.ForegroundColor = ConsoleColor.White;
            return(false);
        } //Check if number of
        return(true);
    }     //end seems valid
Beispiel #4
0
    }      // End constructor

    /* PUBLIC METHODS */

    // This loads a JSON file (.stack) from the hard drive that contains only one CloudCoin and turns it into an object.
    //   This uses Newton soft but causes a enrror System.IO.FileNotFoundException. Could not load file 'Newtonsoft.Json'
    public FoundersCloudCoin loadOneCloudCoinFromJsonFile(String loadFilePath)
    {
        FoundersCloudCoin returnCC = new FoundersCloudCoin();

        //Load file as JSON
        String incomeJson = this.importJSON(loadFilePath);
        //STRIP UNESSARY test
        int secondCurlyBracket     = ordinalIndexOf(incomeJson, "{", 2) - 1;
        int firstCloseCurlyBracket = ordinalIndexOf(incomeJson, "}", 0) - secondCurlyBracket;

        // incomeJson = incomeJson.Substring(secondCurlyBracket, firstCloseCurlyBracket);
        incomeJson = incomeJson.Substring(secondCurlyBracket, firstCloseCurlyBracket + 1);
        // Console.Out.WriteLine(incomeJson);
        //Deserial JSON

        try
        {
            returnCC = JsonConvert.DeserializeObject <FoundersCloudCoin>(incomeJson);
        }
        catch (JsonReaderException)
        {
            Console.WriteLine("There was an error reading files in your bank.");
            CoreLogger.Log("There was an error reading files in your bank.");
            Console.WriteLine("You may have the aoid memo bug that uses too many double quote marks.");
            Console.WriteLine("Your bank files are stored using and older version that did not use properly formed JSON.");
            Console.WriteLine("Would you like to upgrade these files to the newer standard?");
            Console.WriteLine("Your files will be edited.");
            Console.WriteLine("1 for yes, 2 for no.");
            KeyboardReader reader = new KeyboardReader();
            int            answer = reader.readInt(1, 2);
            if (answer == 1)
            {
                //Get rid of ed and aoid
                //Get file names in bank folder
                String[] fileNames = new DirectoryInfo(bankFolder).GetFiles().Select(o => o.Name).ToArray();
                for (int i = 0; i < fileNames.Length; i++)
                {
                    Console.WriteLine("Fixing " + bankFolder + "\\" + fileNames[i]);
                    CoreLogger.Log("Fixing " + bankFolder + "\\" + fileNames[i]);
                    string text = File.ReadAllText(bankFolder + "\\" + fileNames[i]);
                    text = text.Replace("\"aoid\": [\"memo\"=\"\"]", "");
                    File.WriteAllText(bankFolder + "\\" + fileNames[i], text);
                }    //End for all files in bank
                CoreLogger.Log("Done Fixing. The program will now exit. Please restart. Press any key.");
                Console.WriteLine("Done Fixing. The program will now exit. Please restart. Press any key.");
                Console.Read();
                Environment.Exit(0);
            }
            else
            {
                CoreLogger.Log("Leaving files as is. You maybe able to fix the manually by editing the files.");
                Console.WriteLine("Leaving files as is. You maybe able to fix the manually by editing the files.");
                Console.WriteLine("Done Fixing. The program will now exit. Please restart. Press any key.");
                Console.Read();
                Environment.Exit(0);
            }
        }

        return(returnCC);
    }    //end load one CloudCoin from JSON
Beispiel #5
0
    }    //end load one CloudCoin from JSON

    public String importJSON(String jsonfile)
    {
        String jsonData = "";
        String line;

        try
        {
            // Create an instance of StreamReader to read from a file.
            // The using statement also closes the StreamReader.

            using (var sr = File.OpenText(jsonfile))
            {
                // Read and display lines from the file until the end of
                // the file is reached.
                while (true)
                {
                    line = sr.ReadLine();
                    if (line == null)
                    {
                        break;
                    } //End if line is null
                    jsonData = (jsonData + line + "\n");
                }     //end while true
            }         //end using
        }
        catch (Exception e)
        {
            // Let the user know what went wrong.
            Console.WriteLine("The file " + jsonfile + " could not be read:");
            CoreLogger.Log("The file " + jsonfile + " could not be read:");
            Console.WriteLine(e.Message);
            CoreLogger.Log(e.Message);
        }
        return(jsonData);
    }    //end importJSON
Beispiel #6
0
    }    //end load one CloudCoin from JSON

    public CloudCoin loadOneCloudCoinFromJPEGFile(String loadFilePath)
    {
        /* GET the first 455 bytes of he jpeg where the coin is located */
        String wholeString = "";

        byte[] jpegHeader = new byte[455];
        Console.Out.WriteLine("Load file path " + loadFilePath);
        CoreLogger.Log("Load file path " + loadFilePath);
        using (FileStream fileStream = new FileStream(loadFilePath, FileMode.Open, FileAccess.Read))
        {
            try
            {
                int count;                                // actual number of bytes read
                int sum = 0;                              // total number of bytes read

                // read until Read method returns 0 (end of the stream has been reached)
                while ((count = fileStream.Read(jpegHeader, sum, 455 - sum)) > 0)
                {
                    sum += count;      // sum is a buffer offset for next reading
                }
            }
            finally { }
        }
        wholeString = bytesToHexString(jpegHeader);
        CloudCoin returnCC = this.parseJpeg(wholeString);

        // Console.Out.WriteLine("From FileUtils returnCC.fileName " + returnCC.fileName);
        return(returnCC);
    }    //end load one CloudCoin from JSON
Beispiel #7
0
    }               //end detect coin

    public async Task <CoinUtils> detectCoin(CoinUtils cu, int milliSecondsToTimeOut)
    {
        cu.generatePan();

        var t00 = detectOne(00, cu.cc.nn, cu.cc.sn, cu.cc.an[00], cu.pans[00], cu.getDenomination());
        var t01 = detectOne(01, cu.cc.nn, cu.cc.sn, cu.cc.an[01], cu.pans[01], cu.getDenomination());
        var t02 = detectOne(02, cu.cc.nn, cu.cc.sn, cu.cc.an[02], cu.pans[02], cu.getDenomination());
        var t03 = detectOne(03, cu.cc.nn, cu.cc.sn, cu.cc.an[03], cu.pans[03], cu.getDenomination());
        var t04 = detectOne(04, cu.cc.nn, cu.cc.sn, cu.cc.an[04], cu.pans[04], cu.getDenomination());
        var t05 = detectOne(05, cu.cc.nn, cu.cc.sn, cu.cc.an[05], cu.pans[05], cu.getDenomination());
        var t06 = detectOne(06, cu.cc.nn, cu.cc.sn, cu.cc.an[06], cu.pans[06], cu.getDenomination());
        var t07 = detectOne(07, cu.cc.nn, cu.cc.sn, cu.cc.an[07], cu.pans[07], cu.getDenomination());
        var t08 = detectOne(08, cu.cc.nn, cu.cc.sn, cu.cc.an[08], cu.pans[08], cu.getDenomination());
        var t09 = detectOne(09, cu.cc.nn, cu.cc.sn, cu.cc.an[09], cu.pans[09], cu.getDenomination());
        var t10 = detectOne(10, cu.cc.nn, cu.cc.sn, cu.cc.an[10], cu.pans[10], cu.getDenomination());
        var t11 = detectOne(11, cu.cc.nn, cu.cc.sn, cu.cc.an[11], cu.pans[11], cu.getDenomination());
        var t12 = detectOne(12, cu.cc.nn, cu.cc.sn, cu.cc.an[12], cu.pans[12], cu.getDenomination());
        var t13 = detectOne(13, cu.cc.nn, cu.cc.sn, cu.cc.an[13], cu.pans[13], cu.getDenomination());
        var t14 = detectOne(14, cu.cc.nn, cu.cc.sn, cu.cc.an[14], cu.pans[14], cu.getDenomination());
        var t15 = detectOne(15, cu.cc.nn, cu.cc.sn, cu.cc.an[15], cu.pans[15], cu.getDenomination());
        var t16 = detectOne(16, cu.cc.nn, cu.cc.sn, cu.cc.an[16], cu.pans[16], cu.getDenomination());
        var t17 = detectOne(17, cu.cc.nn, cu.cc.sn, cu.cc.an[17], cu.pans[17], cu.getDenomination());
        var t18 = detectOne(18, cu.cc.nn, cu.cc.sn, cu.cc.an[18], cu.pans[18], cu.getDenomination());
        var t19 = detectOne(19, cu.cc.nn, cu.cc.sn, cu.cc.an[19], cu.pans[19], cu.getDenomination());
        var t20 = detectOne(20, cu.cc.nn, cu.cc.sn, cu.cc.an[20], cu.pans[20], cu.getDenomination());
        var t21 = detectOne(21, cu.cc.nn, cu.cc.sn, cu.cc.an[21], cu.pans[21], cu.getDenomination());
        var t22 = detectOne(22, cu.cc.nn, cu.cc.sn, cu.cc.an[22], cu.pans[22], cu.getDenomination());
        var t23 = detectOne(23, cu.cc.nn, cu.cc.sn, cu.cc.an[23], cu.pans[23], cu.getDenomination());
        var t24 = detectOne(24, cu.cc.nn, cu.cc.sn, cu.cc.an[24], cu.pans[24], cu.getDenomination());


        var taskList = new List <Task> {
            t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24
        };
        await Task.WhenAll(taskList.ToArray());

        //Get data from the detection agents

        for (int i = 0; i < 25; i++)
        {
            if (responseArray[i] != null)
            {
                cu.setPastStatus(responseArray[i].outcome, i);
                CoreLogger.Log(cu.cc.sn + " detect:" + i + " " + responseArray[i].fullResponse);
            }
            else
            {
                cu.setPastStatus("undetected", i);
            }; // should be pass, fail, error or undetected.
        }      //end for each detection agent

        cu.setAnsToPansIfPassed();
        cu.calculateHP();
        // cu.gradeCoin(); // sets the grade and figures out what the file extension should be (bank, fracked, counterfeit, lost
        cu.calcExpirationDate();
        cu.grade();

        return(cu);
    }    //end detect coin
        }//End detectMulti All


        private void coinExists(String suspectFileName)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.Out.WriteLine("  You tried to import a coin that has already been imported: " + suspectFileName);
            CoreLogger.Log("  You tried to import a coin that has already been imported: " + suspectFileName);
            File.Move(this.fileUtils.suspectFolder + suspectFileName, this.fileUtils.trashFolder + suspectFileName);
            Console.Out.WriteLine("  Suspect CloudCoin was moved to Trash folder.");
            CoreLogger.Log("  Suspect CloudCoin was moved to Trash folder.");
            Console.ForegroundColor = ConsoleColor.White;
        }//end coin exists
Beispiel #9
0
    }    //end echo

    public async Task echoAll(int milliSecondsToTimeOut)
    {
        Response[] results = new Response[25];
        var        t00     = echoOne(00);
        var        t01     = echoOne(01);
        var        t02     = echoOne(02);
        var        t03     = echoOne(03);
        var        t04     = echoOne(04);
        var        t05     = echoOne(05);
        var        t06     = echoOne(06);
        var        t07     = echoOne(07);
        var        t08     = echoOne(08);
        var        t09     = echoOne(09);
        var        t10     = echoOne(10);
        var        t11     = echoOne(11);
        var        t12     = echoOne(12);
        var        t13     = echoOne(13);
        var        t14     = echoOne(14);
        var        t15     = echoOne(15);
        var        t16     = echoOne(16);
        var        t17     = echoOne(17);
        var        t18     = echoOne(18);
        var        t19     = echoOne(19);
        var        t20     = echoOne(20);
        var        t21     = echoOne(21);
        var        t22     = echoOne(22);
        var        t23     = echoOne(23);
        var        t24     = echoOne(24);

        var taskList = new List <Task> {
            t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24
        };
        await Task.WhenAll(taskList.ToArray());

        for (int i = 0; i < 25; i++)
        {
            if (responseArray[i] != null)
            {
                CoreLogger.Log("echo:" + i + " " + responseArray[i].fullResponse);
            }
        }


        //return results;
    }    //end echo
Beispiel #10
0
    }     // end set ans to pans if passed

    public void consoleReport()
    {
        // Used only for console apps
        //  System.out.println("Finished detecting coin index " + j);
        // PRINT OUT ALL COIN'S RAIDA STATUS AND SET AN TO NEW PAN
        char[] pownArray = cc.pown.ToCharArray();
        sortToFolder();
        Console.Out.WriteLine("");
        Console.ForegroundColor = ConsoleColor.White;
        Console.Out.WriteLine("                                                        ");
        Console.Out.WriteLine("   Authenticity Report SN #" + string.Format("{0,8}", cc.sn) + ", Denomination: " + string.Format("{0,3}", this.getDenomination()) + "  ");

        CoreLogger.Log("   Authenticity Report SN #" + string.Format("{0,8}", cc.sn) + ", Denomination: " + string.Format("{0,3}", this.getDenomination()) + "  ");
        Console.Out.WriteLine("                                                        ");
        Console.Out.Write("    "); a(pownArray[0]); Console.Out.Write("       "); a(pownArray[1]); Console.Out.Write("       "); a(pownArray[2]); Console.Out.Write("       "); a(pownArray[3]); Console.Out.Write("       "); a(pownArray[4]); Console.Out.WriteLine("    ");
        Console.Out.WriteLine("                                                        ");
        Console.Out.Write("    "); a(pownArray[5]); Console.Out.Write("       "); a(pownArray[6]); Console.Out.Write("       "); a(pownArray[7]); Console.Out.Write("       "); a(pownArray[8]); Console.Out.Write("       "); a(pownArray[9]); Console.Out.WriteLine("    ");
        Console.Out.WriteLine("                                                        ");
        Console.Out.Write("    "); a(pownArray[10]); Console.Out.Write("       "); a(pownArray[11]); Console.Out.Write("       "); a(pownArray[12]); Console.Out.Write("       "); a(pownArray[13]); Console.Out.Write("       "); a(pownArray[14]); Console.Out.WriteLine("    ");
        Console.Out.WriteLine("                                                        ");
        Console.Out.Write("    "); a(pownArray[15]); Console.Out.Write("       "); a(pownArray[16]); Console.Out.Write("       "); a(pownArray[17]); Console.Out.Write("       "); a(pownArray[18]); Console.Out.Write("       "); a(pownArray[19]); Console.Out.WriteLine("    ");
        Console.Out.WriteLine("                                                ");
        Console.Out.Write("    "); a(pownArray[20]); Console.Out.Write("       "); a(pownArray[21]); Console.Out.Write("       "); a(pownArray[22]); Console.Out.Write("       "); a(pownArray[23]); Console.Out.Write("       "); a(pownArray[24]); Console.Out.WriteLine("    ");
        Console.Out.WriteLine("   Status: " + getFolder());
        Console.Out.WriteLine("                                                        ");
        Console.Out.WriteLine("");
        Console.ForegroundColor = ConsoleColor.White;

        // check if failed
        //  string fmt = "00";
        // string fi = i.ToString(fmt); // Pad numbers with two digits
        //    Console.Out.WriteLine("RAIDA" + i + " " + pastStatus[i] + " | ");
        // Console.Out.WriteLine("AN " + i + ans[i]);
        // Console.Out.WriteLine("PAN " + i + pans[i]);
        //  }

        // End for each cloud coin GUID statu
        //  Console.Out.WriteLine("ed " + ed);
        //  Console.Out.WriteLine("edHex " + edHex);
        //  Console.Out.WriteLine("edhp " + hp);
        // Console.Out.WriteLine("fileName " + fileName);
        // Console.Out.WriteLine("YEARSTILEXPIRE " + YEARSTILEXPIRE);
        //   Console.Out.WriteLine("extension " + extension);
    }    //Console Report
Beispiel #11
0
    }    //end read all bytes

    public bool writeTo(String folder, FoundersCloudCoin cc)
    {
        CoinUtils    cu            = new CoinUtils(cc);
        const string quote         = "\"";
        const string tab           = "\t";
        String       wholeJson     = "{" + Environment.NewLine; //{
        bool         alreadyExists = true;
        String       json          = this.setJSON(cc);

        if (!File.Exists(folder + cu.fileName + ".stack"))
        {
            wholeJson += tab + quote + "cloudcoin" + quote + ": [" + Environment.NewLine;     // "cloudcoin" : [
            wholeJson += json;
            wholeJson += Environment.NewLine + tab + "]" + Environment.NewLine + "}";
            File.WriteAllText(folder + cu.fileName + ".stack", wholeJson);
        }
        else
        {
            if (folder.Contains("Counterfeit") || folder.Contains("Trash"))
            {
                //Let the program delete it
                alreadyExists = false;
                return(alreadyExists);
            }
            else if (folder.Contains("Imported"))
            {
                File.Delete(folder + cu.fileName + ".stack");
                File.WriteAllText(folder + cu.fileName + ".stack", wholeJson);
                alreadyExists = false;
                return(alreadyExists);
            }
            else
            {
                Console.WriteLine(cu.fileName + ".stack" + " already exists in the folder " + folder);
                CoreLogger.Log(cu.fileName + ".stack" + " already exists in the folder " + folder);
                return(alreadyExists);
            } //end else
        }     //File Exists
        File.WriteAllText(folder + cu.fileName + ".stack", wholeJson);
        alreadyExists = false;
        return(alreadyExists);
    }    //End Write To
Beispiel #12
0
    }    //end get ticket

    public async Task get_Tickets(int[] triad, String[] ans, int nn, int sn, int denomination, int millisecondsToTimeout)
    {
        //Empty the status of any old ticket info.
        // RAIDA_Status.resetTickets();
        //Console.WriteLine("Get Tickets called. ");
        var t00 = get_Ticket(0, triad[00], nn, sn, ans[00], denomination, millisecondsToTimeout);
        var t01 = get_Ticket(1, triad[01], nn, sn, ans[01], denomination, millisecondsToTimeout);
        var t02 = get_Ticket(2, triad[02], nn, sn, ans[02], denomination, millisecondsToTimeout);

        var taskList = new List <Task> {
            t00, t01, t02
        };
        await Task.WhenAll(taskList.ToArray());

        try
        {
            CoreLogger.Log(sn + " get ticket:" + triad[00] + " " + responseArray[triad[00]].fullResponse);
            CoreLogger.Log(sn + " get ticket:" + triad[01] + " " + responseArray[triad[01]].fullResponse);
            CoreLogger.Log(sn + " get ticket:" + triad[02] + " " + responseArray[triad[02]].fullResponse);
        }
        catch { }
        //Get data from the detection agents
    } //end detect coin
Beispiel #13
0
    }         // End Import All

    /* PRIVATE METHODS */

    /* IMPORT ONE FILE. COULD BE A JPEG, STACK or CHEST */
    private bool importOneFile(String fname)
    {
        String extension = "";
        int    indx      = fname.LastIndexOf('.');//Get file extension

        if (indx > 0)
        {
            extension = fname.Substring(indx + 1);
        }

        extension = extension.ToLower();
        if (extension == "jpeg" || extension == "jpg")    //Run if file is a jpeg
        {
            if (!this.importJPEG(fname))
            {
                if (!File.Exists(this.fileUtils.trashFolder + fname))
                {
                    File.Move(this.fileUtils.importFolder + fname, this.fileUtils.trashFolder + fname);
                    Console.Out.WriteLine("File moved to trash: " + fname);
                    CoreLogger.Log("File moved to trash: " + fname);
                }
                else
                {
                    File.Delete(this.fileUtils.importedFolder + fname);
                    File.Move(this.fileUtils.importFolder + fname, this.fileUtils.importedFolder + fname);
                }

                return(false); //"Failed to load JPEG file");
            }                  //end if import fails
        }                      //end if jpeg

        /*
         * else if (extension == "chest" || extension == ".chest")//Run if file is a jpeg
         * {
         *  if (!this.importChest(fname))
         *  {
         *      if (!File.Exists(this.fileUtils.trashFolder + fname))
         *      {
         *          File.Move(this.fileUtils.importFolder + fname, this.fileUtils.trashFolder + fname);
         *          Console.Out.WriteLine("File moved to trash: " +  fname);
         *      }
         *      return false;//"Failed to load JPEG file");
         *  }//end if import fails
         * }//end if jpeg
         */
        else if (!this.importStack(fname))    // run if file is a stack
        {
            if (!File.Exists(this.fileUtils.trashFolder + fname))
            {
                File.Move(this.fileUtils.importFolder + fname, this.fileUtils.trashFolder + fname);
                Console.Out.WriteLine("File moved to trash: " + fname);
                CoreLogger.Log("File moved to trash: " + fname);
            }
            return(false);   //"Failed to load .stack file");
        }

        if (!File.Exists(this.fileUtils.importedFolder + fname))
        {
            File.Move(this.fileUtils.importFolder + fname, this.fileUtils.importedFolder + fname);
        }
        else
        {
            File.Delete(this.fileUtils.importedFolder + fname);
            File.Move(this.fileUtils.importFolder + fname, this.fileUtils.importedFolder + fname);
        }

        //End if the file is there
        return(true);
    }    //End importOneFile
Beispiel #14
0
    public string importJson(String incomeJson)
    {
        string returnString = "true";

        //  System.out.println("Trying to load: " + importFolder + fileName );
        try
        {
            //String incomeJson = fileUtils.importJSON(this.fileUtils.importFolder + fileName);//Load file as JSON .stack or .chest
            FoundersStack tempCoins = null;
            if (seemsValidJSON(incomeJson))
            {
                try
                {
                    tempCoins = this.fileUtils.loadManyCloudCoinFromJsonFile(null, incomeJson);
                }
                catch (JsonReaderException e)
                {
                    //Console.WriteLine("Moving corrupted file to trash: " + fileName);
                    Console.WriteLine("Error reading " + ". Moving to trash.");
                    CoreLogger.Log("Error reading " + ". Moving to trash.");
                    Console.WriteLine(e);
                    CoreLogger.Log(e.ToString());
                    returnString = "Error reading JSON. Moving to trash. " + e.ToString();
                }    //end catch json error
            }


            if (tempCoins == null)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Out.WriteLine("  The following file does not appear to be valid JSON. It will be moved to the Trash Folder: ");

                CoreLogger.Log("  The following file does not appear to be valid JSON. It will be moved to the Trash Folder: ");
                Console.Out.WriteLine("  Paste the text into http://jsonlint.com/ to check for validity.");
                Console.ForegroundColor = ConsoleColor.White;
                return(returnString = "The following file does not appear to be valid JSON. Moving to trash. ");                       //CloudCoin was null so move to trash
            }
            else
            {
                for (int i = 0; i < tempCoins.cc.Length; i++)
                {
                    this.fileUtils.writeTo(this.fileUtils.suspectFolder, tempCoins.cc[i]);
                } //end for each temp Coin
                return("true");
            }     //end if no coins.
        }
        catch (FileNotFoundException ex)
        {
            Console.Out.WriteLine("File not found: " + ex);
            CoreLogger.Log("File not found: " + ex);
            return(returnString = "File not found: " + ex.ToString());
        }
        catch (IOException ioex)
        {
            Console.Out.WriteLine("IO Exception:" + ioex);
            CoreLogger.Log("IO Exception:" + ioex);
            return(returnString = "File not found: " + ioex.ToString());
        }

        // end try catch
        return(returnString);
    } //import stack
Beispiel #15
0
    }                       // 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;
        FoundersCloudCoin 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]))
                {    //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.");
                    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.");
                    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());

/*
 *                              Frack_Fixer ff = new Frack_Fixer(fileUtils, msToFixDangerousFracked);
 *                              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);
 *                                  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).Result;//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
Beispiel #16
0
    }    //end detectOneMulti

    public async Task <CoinUtils[]> detectMultiCoin(CoinUtils[] cu, int milliSecondsToTimeOut)
    {
        //Make arrays to stripe the coins

        responseArrayMulti = new Response[25, cu.Length];

        int[]    nns     = new int[cu.Length];
        int[]    sns     = new int[cu.Length];
        String[] ans_0   = new String[cu.Length];
        String[] ans_1   = new String[cu.Length];
        String[] ans_2   = new String[cu.Length];
        String[] ans_3   = new String[cu.Length];
        String[] ans_4   = new String[cu.Length];
        String[] ans_5   = new String[cu.Length];
        String[] ans_6   = new String[cu.Length];
        String[] ans_7   = new String[cu.Length];
        String[] ans_8   = new String[cu.Length];
        String[] ans_9   = new String[cu.Length];
        String[] ans_10  = new String[cu.Length];
        String[] ans_11  = new String[cu.Length];
        String[] ans_12  = new String[cu.Length];
        String[] ans_13  = new String[cu.Length];
        String[] ans_14  = new String[cu.Length];
        String[] ans_15  = new String[cu.Length];
        String[] ans_16  = new String[cu.Length];
        String[] ans_17  = new String[cu.Length];
        String[] ans_18  = new String[cu.Length];
        String[] ans_19  = new String[cu.Length];
        String[] ans_20  = new String[cu.Length];
        String[] ans_21  = new String[cu.Length];
        String[] ans_22  = new String[cu.Length];
        String[] ans_23  = new String[cu.Length];
        String[] ans_24  = new String[cu.Length];
        String[] pans_0  = new String[cu.Length];
        String[] pans_1  = new String[cu.Length];
        String[] pans_2  = new String[cu.Length];
        String[] pans_3  = new String[cu.Length];
        String[] pans_4  = new String[cu.Length];
        String[] pans_5  = new String[cu.Length];
        String[] pans_6  = new String[cu.Length];
        String[] pans_7  = new String[cu.Length];
        String[] pans_8  = new String[cu.Length];
        String[] pans_9  = new String[cu.Length];
        String[] pans_10 = new String[cu.Length];
        String[] pans_11 = new String[cu.Length];
        String[] pans_12 = new String[cu.Length];
        String[] pans_13 = new String[cu.Length];
        String[] pans_14 = new String[cu.Length];
        String[] pans_15 = new String[cu.Length];
        String[] pans_16 = new String[cu.Length];
        String[] pans_17 = new String[cu.Length];
        String[] pans_18 = new String[cu.Length];
        String[] pans_19 = new String[cu.Length];
        String[] pans_20 = new String[cu.Length];
        String[] pans_21 = new String[cu.Length];
        String[] pans_22 = new String[cu.Length];
        String[] pans_23 = new String[cu.Length];
        String[] pans_24 = new String[cu.Length];

        int[] dens = new int[cu.Length];    //Denominations
        //Stripe the coins

        for (int i = 0; i < cu.Length; i++)    //For every coin
        {
            cu[i].generatePan();
            nns[i]    = cu[i].cc.nn;
            sns[i]    = cu[i].cc.sn;
            ans_0[i]  = cu[i].cc.an[0];
            ans_1[i]  = cu[i].cc.an[1];
            ans_2[i]  = cu[i].cc.an[2];
            ans_3[i]  = cu[i].cc.an[3];
            ans_4[i]  = cu[i].cc.an[4];
            ans_5[i]  = cu[i].cc.an[5];
            ans_6[i]  = cu[i].cc.an[6];
            ans_7[i]  = cu[i].cc.an[7];
            ans_8[i]  = cu[i].cc.an[8];
            ans_9[i]  = cu[i].cc.an[9];
            ans_10[i] = cu[i].cc.an[10];
            ans_11[i] = cu[i].cc.an[11];
            ans_12[i] = cu[i].cc.an[12];
            ans_13[i] = cu[i].cc.an[13];
            ans_14[i] = cu[i].cc.an[14];
            ans_15[i] = cu[i].cc.an[15];
            ans_16[i] = cu[i].cc.an[16];
            ans_17[i] = cu[i].cc.an[17];
            ans_18[i] = cu[i].cc.an[18];
            ans_19[i] = cu[i].cc.an[19];
            ans_20[i] = cu[i].cc.an[20];
            ans_21[i] = cu[i].cc.an[21];
            ans_22[i] = cu[i].cc.an[22];
            ans_23[i] = cu[i].cc.an[23];
            ans_24[i] = cu[i].cc.an[24];

            pans_0[i]  = cu[i].pans[0];
            pans_1[i]  = cu[i].pans[1];
            pans_2[i]  = cu[i].pans[2];
            pans_3[i]  = cu[i].pans[3];
            pans_4[i]  = cu[i].pans[4];
            pans_5[i]  = cu[i].pans[5];
            pans_6[i]  = cu[i].pans[6];
            pans_7[i]  = cu[i].pans[7];
            pans_8[i]  = cu[i].pans[8];
            pans_9[i]  = cu[i].pans[9];
            pans_10[i] = cu[i].pans[10];
            pans_11[i] = cu[i].pans[11];
            pans_12[i] = cu[i].pans[12];
            pans_13[i] = cu[i].pans[13];
            pans_14[i] = cu[i].pans[14];
            pans_15[i] = cu[i].pans[15];
            pans_16[i] = cu[i].pans[16];
            pans_17[i] = cu[i].pans[17];
            pans_18[i] = cu[i].pans[18];
            pans_19[i] = cu[i].pans[19];
            pans_20[i] = cu[i].pans[20];
            pans_21[i] = cu[i].pans[21];
            pans_22[i] = cu[i].pans[22];
            pans_23[i] = cu[i].pans[23];
            pans_24[i] = cu[i].pans[24];

            dens[i] = cu[i].getDenomination();
        }    //end for every coin put in an array

        var t00 = detectOneMulti(00, nns, sns, ans_0, pans_0, dens, milliSecondsToTimeOut);
        var t01 = detectOneMulti(01, nns, sns, ans_1, pans_1, dens, milliSecondsToTimeOut);
        var t02 = detectOneMulti(02, nns, sns, ans_2, pans_2, dens, milliSecondsToTimeOut);
        var t03 = detectOneMulti(03, nns, sns, ans_3, pans_3, dens, milliSecondsToTimeOut);
        var t04 = detectOneMulti(04, nns, sns, ans_4, pans_4, dens, milliSecondsToTimeOut);
        var t05 = detectOneMulti(05, nns, sns, ans_5, pans_5, dens, milliSecondsToTimeOut);
        var t06 = detectOneMulti(06, nns, sns, ans_6, pans_6, dens, milliSecondsToTimeOut);
        var t07 = detectOneMulti(07, nns, sns, ans_7, pans_7, dens, milliSecondsToTimeOut);
        var t08 = detectOneMulti(08, nns, sns, ans_8, pans_8, dens, milliSecondsToTimeOut);
        var t09 = detectOneMulti(09, nns, sns, ans_9, pans_9, dens, milliSecondsToTimeOut);
        var t10 = detectOneMulti(10, nns, sns, ans_10, pans_10, dens, milliSecondsToTimeOut);
        var t11 = detectOneMulti(11, nns, sns, ans_11, pans_11, dens, milliSecondsToTimeOut);
        var t12 = detectOneMulti(12, nns, sns, ans_12, pans_12, dens, milliSecondsToTimeOut);
        var t13 = detectOneMulti(13, nns, sns, ans_13, pans_13, dens, milliSecondsToTimeOut);
        var t14 = detectOneMulti(14, nns, sns, ans_14, pans_14, dens, milliSecondsToTimeOut);
        var t15 = detectOneMulti(15, nns, sns, ans_15, pans_15, dens, milliSecondsToTimeOut);
        var t16 = detectOneMulti(16, nns, sns, ans_16, pans_16, dens, milliSecondsToTimeOut);
        var t17 = detectOneMulti(17, nns, sns, ans_17, pans_17, dens, milliSecondsToTimeOut);
        var t18 = detectOneMulti(18, nns, sns, ans_18, pans_18, dens, milliSecondsToTimeOut);
        var t19 = detectOneMulti(19, nns, sns, ans_19, pans_19, dens, milliSecondsToTimeOut);
        var t20 = detectOneMulti(20, nns, sns, ans_20, pans_20, dens, milliSecondsToTimeOut);
        var t21 = detectOneMulti(21, nns, sns, ans_21, pans_21, dens, milliSecondsToTimeOut);
        var t22 = detectOneMulti(22, nns, sns, ans_22, pans_22, dens, milliSecondsToTimeOut);
        var t23 = detectOneMulti(23, nns, sns, ans_23, pans_23, dens, milliSecondsToTimeOut);
        var t24 = detectOneMulti(24, nns, sns, ans_24, pans_24, dens, milliSecondsToTimeOut);


        var taskList = new List <Task> {
            t00, t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24
        };

        await Task.WhenAll(taskList.ToArray());

        //Get data from the detection agents
        for (int i = 0; i < nns.Length; i++)
        {
            for (int j = 0; j < 25; j++)    //For each coin
            {
                if (responseArrayMulti[j, i] != null)
                {
                    cu[i].setPastStatus(responseArrayMulti[j, i].outcome, j);
                    CoreLogger.Log(cu[i].cc.sn + " detect:" + j + " " + responseArrayMulti[j, i].fullResponse);
                }
                else
                {
                    cu[i].setPastStatus("undetected", j);
                }; // should be pass, fail, error or undetected, or No response.
            }      //end for each coin checked

            cu[i].setAnsToPansIfPassed();
            cu[i].calculateHP();
            cu[i].calcExpirationDate();
            cu[i].grade();
        }           //end for each detection agent

        return(cu); //Return the array of coins detected
    }               //end detect coin
        }// end Detect constructor



        public async Task<int> detectMulti(int detectTime, string receiptFile)
        {
            bool stillHaveSuspect = true;
            int coinNames = 0;

            while (stillHaveSuspect)
            {
                // LOAD ALL SUSPECT COIN NAMES IN AN ARRAY OF NAMES
                String[] suspectFileNames = new DirectoryInfo(this.fileUtils.suspectFolder).GetFiles().Select(o => o.Name).ToArray();//Get all files in suspect folder

                //CHECK TO SEE IF ANY OF THE FILES ARE ALREADY IN BANK. DELETE IF SO
                for (int i = 0; i < suspectFileNames.Length; i++)//for up to 200 coins in the suspect folder
                {

                    try
                    {
                        if (File.Exists(this.fileUtils.bankFolder + suspectFileNames[i]) || File.Exists(this.fileUtils.detectedFolder + suspectFileNames[i]))
                        {//Coin has already been imported. Delete it from import folder move to trash.
                            coinExists(suspectFileNames[i]);
                        }
                    }
                    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 see if in bank


                //DUPLICATES HAVE BEEN DELETED, NOW DETECT
                suspectFileNames = new DirectoryInfo(this.fileUtils.suspectFolder).GetFiles().Select(o => o.Name).ToArray();//Get all files in suspect folder


                //HOW MANY COINS WILL WE DETECT? LIMIT IT TO 200

                if (suspectFileNames.Length > 200)
                {
                    coinNames = 200;//do not detect more than 200 coins. 
                }
                else
                {
                    coinNames = suspectFileNames.Length;
                    stillHaveSuspect = false;// No need to get more names
                }

                //BUILD AN ARRAY OF COINS FROM THE FILE NAMES - UPTO 200
                FoundersCloudCoin[] cloudCoin = new FoundersCloudCoin[coinNames];
                CoinUtils[] cu = new CoinUtils[coinNames];
                Receipt receipt = createReceipt(coinNames, receiptFile);

                    for (int i = 0; i < coinNames; i++)//for up to 200 coins in the suspect folder
                {

                    try
                    {
                            cloudCoin[i] = this.fileUtils.loadOneCloudCoinFromJsonFile(this.fileUtils.suspectFolder + suspectFileNames[i]);
                            cu[i] = new CoinUtils(cloudCoin[i]);
                            Console.Out.WriteLine("  Now scanning coin " + (i + 1) + " of " + suspectFileNames.Length + " for counterfeit. SN " + string.Format("{0:n0}", cloudCoin[i].sn) + ", Denomination: " + cu[i].getDenomination());
                            CoreLogger.Log("  Now scanning coin " + (i + 1) + " of " + suspectFileNames.Length + " for counterfeit. SN " + string.Format("{0:n0}", cloudCoin[i].sn) + ", Denomination: " + cu[i].getDenomination());
                        ReceitDetail detail = new ReceitDetail();
                        detail.sn = cloudCoin[i].sn;
                        detail.nn = cloudCoin[i].nn;
                        detail.status = "suspect";
                        detail.pown = "uuuuuuuuuuuuuuuuuuuuuuuuu";
                        detail.note = "Waiting";
                        receipt.rd[i] = detail;
                    }
                    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


                //ALL COINS IN THE ARRAY, NOW DETECT

                CoinUtils[] detectedCC = await raida.detectMultiCoin(cu, detectTime);

                //create receits
                using (StreamWriter sw = File.CreateText(fileUtils.receiptsFolder + receiptFile + ".json"))
                {
                    sw.WriteLine(JsonConvert.SerializeObject(receipt));
                }


                    //Write the coins to the detected folder delete from the suspect
                    for (int c = 0; c < detectedCC.Length; c++)
                    {
                        fileUtils.writeTo(fileUtils.detectedFolder, detectedCC[c].cc);
                        File.Delete(fileUtils.suspectFolder + suspectFileNames[c]);//Delete the coin out of the suspect folder
                    }
            }//end while still have suspect
            return coinNames;
        }//End detectMulti All
Beispiel #18
0
    }    //Detect All

    public int[] gradeAll(int msToFixDangerousFracked, int msToRedetectDangerous, string receiptFileName)
    {
        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;
        FoundersCloudCoin newCC;
        Receipt           receipt;

        using (StreamReader sr = new StreamReader(fileUtils.receiptsFolder + receiptFileName + ".json")) {
            string json = sr.ReadLine();
            receipt = JsonConvert.DeserializeObject <Receipt>(json);
        }
        receipt.rd = new ReceitDetail[detectedFileNames.Length];

        for (int j = 0; j < detectedFileNames.Length; j++)    //for every coins in the detected folder
        {
            try
            {
                if (File.Exists(this.fileUtils.bankFolder + 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.");
                    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.");
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    newCC = this.fileUtils.loadOneCloudCoinFromJsonFile(this.fileUtils.detectedFolder + detectedFileNames[j]);
                    CoinUtils    cu     = new CoinUtils(newCC);
                    ReceitDetail detail = new ReceitDetail();
                    detail.nn   = newCC.nn;
                    detail.sn   = newCC.sn;
                    detail.pown = newCC.pown;
                    //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++;
                        receipt.total_authentic++;
                        detail.status = "authentic";
                        detail.note   = "Moved to Bank";
                        fileUtils.writeTo(this.fileUtils.bankFolder, cu.cc);
                        break;

                    case "fracked":
                        totalValueToFractured++;
                        receipt.total_fracked++;
                        detail.status = "authentic";
                        detail.note   = "Moved to Fracked";
                        fileUtils.writeTo(this.fileUtils.frackedFolder, cu.cc);
                        break;

                    case "counterfeit":
                        totalValueToCounterfeit++;
                        receipt.total_counterfeit++;
                        detail.status = "counterfeit";
                        detail.note   = "Sent to trash";
                        fileUtils.writeTo(this.fileUtils.counterfeitFolder, cu.cc);
                        break;

                    case "lost":
                        totalValueToLost++;
                        receipt.total_lost++;
                        detail.status = "lost";
                        detail.note   = "Moved to lost";
                        fileUtils.writeTo(this.fileUtils.lostFolder, cu.cc);
                        break;

                    case "suspect":
                        totalValueToKeptInSuspect++;
                        detail.status = "suspect";
                        detail.note   = "Stayed in Suspect";
                        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":
 *
 *                              detail.status = "lost";
 *                              detail.note = "STRINGS ATTACHED!";
 *                              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());
 *
 *                              Frack_Fixer ff = new Frack_Fixer(fileUtils, msToFixDangerousFracked);
 *                              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);
 *                                  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).Result;//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++;
 *                                      receipt.total_authentic++;
 *                                      detail.status = "authentic";
 *                                      detail.note = "Moved to Bank";
 *                                      fileUtils.writeTo(this.fileUtils.bankFolder, cu.cc);
 *                                      break;
 *
 *                                  case "fracked":
 *                                      totalValueToFractured++;
 *                                      receipt.total_fracked++;
 *                                      detail.status = "authentic";
 *                                      detail.note = "Moved to Fracked";
 *                                      fileUtils.writeTo(this.fileUtils.frackedFolder, cu.cc);
 *                                      break;
 *
 *                                  default:
 *                                      totalValueToCounterfeit++;
 *                                      receipt.total_lost++;
 *                                      fileUtils.writeTo(this.fileUtils.counterfeitFolder, cu.cc);
 *                                      break;
 *
 *                              }//end switch
 *
 *                              break;
 */
                    }                                                                  //end switch
                    receipt.rd[j] = detail;
                    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

        JsonSerializer serializer = new JsonSerializer();

        using (StreamWriter sw = File.CreateText(fileUtils.receiptsFolder + receipt.receipt_id + ".json"))
            using (JsonWriter writer = new JsonTextWriter(sw))
            {
                writer.Formatting = Formatting.Indented;
                serializer.Serialize(writer, receipt);
            }

        results[0] = totalValueToBank;
        results[1] = totalValueToFractured;
        results[2] = totalValueToCounterfeit;
        results[3] = totalValueToKeptInSuspect;
        results[4] = totalValueToLost;
        return(results);
    } //Detect All