public static RAIDA GetInstance(Network network)
 {
     {
         MainNetwork = new RAIDA(network);
         return(MainNetwork);
     }
 }
示例#2
0
        public static RAIDA GetInstance(Network network)
        {
            RAIDA raida = new RAIDA(network);

            raida.FS = FileSystem;
            return(raida);
        }
示例#3
0
        public async static Task ProcessCoins(bool ChangeANs = true)
        {
            FileSystem.LoadFileSystem();
            var networks = (from x in IFileSystem.importCoins
                            select x.nn).Distinct().ToList();
            TimeSpan ts     = new TimeSpan();
            DateTime before = DateTime.Now;
            DateTime after;

            foreach (var nn in networks)
            {
                ActiveRAIDA = (from x in RAIDA.networks
                               where x.NetworkNumber == nn
                               select x).FirstOrDefault();
                int NetworkExists = (from x in RAIDA.networks
                                     where x.NetworkNumber == nn
                                     select x).Count();
                if (NetworkExists > 0)
                {
                    updateLog("Starting Coins detection for Network " + nn);
                    await ProcessNetworkCoins(nn, ChangeANs);

                    updateLog("Coins detection for Network " + nn + " Finished.");
                }
            }
            after = DateTime.Now;
            ts    = after.Subtract(before);

            Debug.WriteLine("Detection Completed in : " + ts.TotalMilliseconds / 1000);
            updateLog("Detection Completed in : " + ts.TotalMilliseconds / 1000);

            updateLog("********************************************************************************");
        }
        /* CONSTRUCTORS */
        public Frack_Fixer(IFileSystem fileUtils, int timeout)
        {

            this.fileUtils = fileUtils;
            raida = RAIDA.GetInstance();
            totalValueToBank = 0;
            totalValueToCounterfeit = 0;
            totalValueToFractured = 0;
        }//constructor
示例#5
0
 public static RAIDA GetInstance()
 {
     if (MainNetwork != null)
         return MainNetwork;
     else
     {
         MainNetwork = new RAIDA();
         return MainNetwork;
     }
 }
示例#6
0
 public static RAIDA GetInstance()
 {
     if (MainNetwork != null)
     {
         return(MainNetwork);
     }
     else
     {
         MainNetwork = new RAIDA();
         return(MainNetwork);
     }
 }
示例#7
0
        // This method was introduced breaking the previously used Singleton pattern.
        // This was done in order to support multiple networks concurrently.
        // We can now have multiple RAIDA objects each containing different networks
        // RAIDA details are read from Directory URL first.
        // In case of failure, it falls back to a file on the file system
        public static List <RAIDA> Instantiate()
        {
            string nodesJson = "";

            networks.Clear();
            using (WebClient client = new WebClient())
            {
                try
                {
                    nodesJson = client.DownloadString(Config.URL_DIRECTORY);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    if (System.IO.File.Exists("directory.json"))
                    {
                        nodesJson = System.IO.File.ReadAllText(Environment.CurrentDirectory + @"\directory.json");
                    }
                    else
                    {
                        Exception raidaException = new Exception("RAIDA instantiation failed. No Directory found on server or local path");
                        throw raidaException;
                    }
                }
            }

            try
            {
                RAIDADirectory dir = JsonConvert.DeserializeObject <RAIDADirectory>(nodesJson);

                foreach (var network in dir.networks)
                {
                    networks.Add(RAIDA.GetInstance(network));
                }
            }
            catch (Exception e)
            {
                Exception raidaException = new Exception("RAIDA instantiation failed. No Directory found on server or local path");
                throw raidaException;
            }
            if (networks == null)
            {
                Exception raidaException = new Exception("RAIDA instantiation failed. No Directory found on server or local path");
                throw raidaException;
            }
            if (networks.Count == 0)
            {
                Exception raidaException = new Exception("RAIDA instantiation failed. No Directory found on server or local path");
                throw raidaException;
            }
            return(networks);
        }
示例#8
0
        }//end detect

        public async Task <Response> Detect()
        {
            CloudCoin coin           = RAIDA.GetInstance().coin;
            Response  detectResponse = new Response();

            detectResponse.fullRequest = this.FullUrl + "detect?nn=" + coin.nn + "&sn=" + coin.sn + "&an=" + coin.an[NodeNumber - 1] + "&pan=" + coin.pan[NodeNumber - 1] + "&denomination=" + coin.denomination + "&b=t";
            DateTime before = DateTime.Now;

            coin.SetAnsToPans();
            try
            {
                detectResponse.fullResponse = await Utils.GetHtmlFromURL(detectResponse.fullRequest);

                DateTime after = DateTime.Now; TimeSpan ts = after.Subtract(before);
                detectResponse.milliseconds        = Convert.ToInt32(ts.Milliseconds);
                coin.response[this.NodeNumber - 1] = detectResponse;

                if (detectResponse.fullResponse.Contains("pass"))
                {
                    detectResponse.outcome = "pass";
                    detectResponse.success = true;
                    FailsDetect            = false;
                }
                else if (detectResponse.fullResponse.Contains("fail") && detectResponse.fullResponse.Length < 200)//less than 200 incase their is a fail message inside errored page
                {
                    detectResponse.outcome = "fail";
                    detectResponse.success = false;
                    RAIDANodeStatus        = NodeStatus.Ready;
                    FailsDetect            = true;

                    //RAIDA_Status.failsDetect[RAIDANumber] = true;
                }
                else
                {
                    detectResponse.outcome = "error";
                    detectResponse.success = false;
                    RAIDANodeStatus        = NodeStatus.NotReady;
                    FailsDetect            = true;
                    //RAIDA_Status.failsDetect[RAIDANumber] = true;
                }
            }
            catch (Exception ex)
            {
                detectResponse.outcome      = "error";
                detectResponse.fullResponse = ex.InnerException.Message;
                detectResponse.success      = false;
            }
            return(detectResponse);
        }//end detect
示例#9
0
        public List <Task> GetDetectTasks()
        {
            var raida = RAIDA.GetInstance();

            CloudCoin cc = this;
            int       i  = 0;

            for (int j = 0; j < Config.NodeCount; j++)
            {
                Task t = Task.Factory.StartNew(() => raida.nodes[i].Detect(cc));
                detectTaskList.Add(t);
            }

            return(detectTaskList);
        }
示例#10
0
        public async static Task ProcessCoins(bool ChangeANs = true)
        {
            var networks = (from x in IFileSystem.importCoins
                            select x.nn).Distinct().ToList();

            foreach (var nn in networks)
            {
                updateLog("Starting Coins detection for Network " + nn);
                ActiveRAIDA = (from x in RAIDA.networks
                               where x.NetworkNumber == nn
                               select x).FirstOrDefault();
                await ProcessNetworkCoins(nn, ChangeANs);

                updateLog("Coins detection for Network " + nn + "Finished.");
            }
        }
示例#11
0
        public async Task <string> GetTicketResponse(int nn, int sn, String an, int d)
        {
            RAIDA    raida = RAIDA.GetInstance();
            Response get_ticketResponse = new Response();

            get_ticketResponse.fullRequest = FullUrl + "get_ticket?nn=" + nn + "&sn=" + sn + "&an=" + an + "&pan=" + an + "&denomination=" + d;
            DateTime before = DateTime.Now;

            try
            {
                get_ticketResponse.fullResponse = await Utils.GetHtmlFromURL(get_ticketResponse.fullRequest);

                Console.WriteLine(get_ticketResponse.fullResponse);
                DateTime after = DateTime.Now; TimeSpan ts = after.Subtract(before);
                get_ticketResponse.milliseconds = Convert.ToInt32(ts.Milliseconds);

                if (get_ticketResponse.fullResponse.Contains("ticket"))
                {
                    String[] KeyPairs    = get_ticketResponse.fullResponse.Split(',');
                    String   message     = KeyPairs[3];
                    int      startTicket = Utils.ordinalIndexOf(message, "\"", 3) + 2;
                    int      endTicket   = Utils.ordinalIndexOf(message, "\"", 4) - startTicket;
                    get_ticketResponse.outcome = message.Substring(startTicket - 1, endTicket + 1); //This is the ticket or message
                    get_ticketResponse.success = true;
                    HasTicket     = true;
                    ticketHistory = TicketHistory.Success;
                    Ticket        = get_ticketResponse.outcome;
                }
                else
                {
                    get_ticketResponse.success = false;
                    HasTicket     = false;
                    ticketHistory = TicketHistory.Failed;
                }//end if
            }
            catch (Exception ex)
            {
                get_ticketResponse.outcome      = "error";
                get_ticketResponse.fullResponse = ex.InnerException.Message;
                get_ticketResponse.success      = false;
                HasTicket     = false;
                ticketHistory = TicketHistory.Failed;
            }//end try catch
            //return get_ticketResponse;
            return(get_ticketResponse.fullResponse);
        }//end get ticket
示例#12
0
        }// end of constructor

        private Node[] getTrustedServers(int raidaNumber)
        {
            Node[] result = new Node[8];
            var    i      = raidaNumber;

            return(result = new Node[]
            {
                RAIDA.GetInstance().nodes[(i + 19) % 25],
                RAIDA.GetInstance().nodes[(i + 20) % 25],
                RAIDA.GetInstance().nodes[(i + 21) % 25],
                RAIDA.GetInstance().nodes[(i + 24) % 25],
                RAIDA.GetInstance().nodes[(i + 26) % 25],
                RAIDA.GetInstance().nodes[(i + 29) % 25],
                RAIDA.GetInstance().nodes[(i + 30) % 25],
                RAIDA.GetInstance().nodes[(i + 31) % 25]
            });
        }
示例#13
0
        public async static Task ProcessCoins(bool ChangeANs = true)
        {
            var networks = (from x in IFileSystem.importCoins
                            select x.nn).Distinct().ToList();

            printStarLine();
            updateLog("Starting EOS Stealth Import.");
            updateLog("Please do not close the EOS Stealth Nerd Edition program until it is finished.");
            updateLog("Otherwise it may result in loss of EOS Stealth.");
            printStarLine();
            updateLog("Starting Detect..");
            printStarLine();
            TimeSpan ts     = new TimeSpan();
            DateTime before = DateTime.Now;
            DateTime after;

            foreach (var nn in networks)
            {
                ActiveRAIDA = (from x in RAIDA.networks
                               where x.NetworkNumber == nn
                               select x).FirstOrDefault();
                int NetworkExists = (from x in RAIDA.networks
                                     where x.NetworkNumber == nn
                                     select x).Count();
                if (NetworkExists > 0)
                {
                    //updateLog("Starting Coins detection for Network " + nn);
                    updateLog("Depositing: Checking all authenticity numbers and changing them on the RAIDA.");

                    await ProcessNetworkCoins(nn, ChangeANs);

                    updateLog("Coins detection for Network " + nn + " Finished.");
                }
            }
            after = DateTime.Now;
            ts    = after.Subtract(before);

            Debug.WriteLine("Detection Completed in:" + ts.TotalMilliseconds / 1000 + " s");
            if (ts.Milliseconds == 0)
            {
                updateLog("No coins detected in Import folder.");
            }
            updateLog("Detection Completed in:" + ts.TotalMilliseconds / 1000 + " s");
            printStarLine();
        }
示例#14
0
        }     // end setAnsToPans

        public void SetAnsToPansIfPassed(bool partial = false)
        {
            // now set all ans that passed to the new pans
            char[] pownArray = pown.ToCharArray();

            for (int i = 0; (i < Config.NodeCount); i++)
            {
                if (pownArray[i] == 'p')//1 means pass
                {
                    an[i] = pan[i];
                }
                else if (pownArray[i] == 'u' && !(RAIDA.GetInstance().nodes[i].RAIDANodeStatus == NodeStatus.NotReady) && partial == false)//Timed out but there server echoed. So it probably changed the PAN just too slow of a response
                {
                    an[i] = pan[i];
                }
                else
                {
                    // Just keep the ans and do not change. Hopefully they are not fracked.
                }
            } // for each guid in coin
        }     // end set ans to pans if passed
示例#15
0
        }//end is gradable pass

        public String[] grade()
        {
            int total = Config.NodeCount;

            int passed = response.Where(x => x.outcome == "pass").Count();
            int failed = response.Where(x => x.outcome == "fail").Count();
            int other  = total - passed - failed;

            if (passed > Config.PassCount)
            {
                DetectResult = DetectionStatus.Passed;
            }
            else
            {
                DetectResult = DetectionStatus.Failed;
            }

            String passedDesc = "";
            String failedDesc = "";
            String otherDesc  = "";

            // for each status
            // Calculate passed
            if (passed == 25)
            {
                passedDesc = "100% Passed!";
            }
            else if (passed > 17)
            {
                passedDesc = "Super Majority";
            }
            else if (passed > 13)
            {
                passedDesc = "Majority";
            }
            else if (passed == 0)
            {
                passedDesc = "None";
            }
            else if (passed < 5)
            {
                passedDesc = "Super Minority";
            }
            else
            {
                passedDesc = "Minority";
            }

            // Calculate failed
            if (failed == 25)
            {
                failedDesc = "100% Failed!";
            }
            else if (failed > 17)
            {
                failedDesc = "Super Majority";
            }
            else if (failed > 13)
            {
                failedDesc = "Majority";
            }
            else if (failed == 0)
            {
                failedDesc = "None";
            }
            else if (failed < 5)
            {
                failedDesc = "Super Minority";
            }
            else
            {
                failedDesc = "Minority";
            }

            // Calcualte Other RAIDA Servers did not help.
            switch (other)
            {
            case 0:
                otherDesc = "100% of RAIDA responded";
                break;

            case 1:
            case 2:
                otherDesc = "Two or less RAIDA errors";
                break;

            case 3:
            case 4:
                otherDesc = "Four or less RAIDA errors";
                break;

            case 5:
            case 6:
                otherDesc = "Six or less RAIDA errors";
                break;

            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
                otherDesc = "Between 7 and 12 RAIDA errors";
                break;

            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
            case 24:
            case 25:
                otherDesc = "RAIDA total failure";
                break;

            default:
                otherDesc = "FAILED TO EVALUATE RAIDA HEALTH";
                break;
            }
            // end RAIDA other errors and unknowns
            // Coin will go to bank, counterfeit or fracked
            if (other > 12)
            {
                // not enough RAIDA to have a quorum
                folder = RAIDA.GetInstance().FS.SuspectFolder;
            }
            else if (failed > passed)
            {
                // failed out numbers passed with a quorum: Counterfeit
                folder = RAIDA.GetInstance().FS.CounterfeitFolder;
            }
            else if (failed > 0)
            {
                // The quorum majority said the coin passed but some disagreed: fracked.
                folder = RAIDA.GetInstance().FS.FrackedFolder;
            }
            else
            {
                // No fails, all passes: bank
                folder = RAIDA.GetInstance().FS.BankFolder;
            }

            gradeStatus[0] = passedDesc;
            gradeStatus[1] = failedDesc;
            gradeStatus[2] = otherDesc;
            return(this.gradeStatus);
        }// end gradeStatus
示例#16
0
        public async static Task ProcessCoins(int NetworkNumber)
        {
            IFileSystem FS = FileSystem;
            FileSystem.LoadFileSystem();
            FileSystem.DetectPreProcessing();

            var predetectCoins = FS.LoadFolderCoins(FS.PreDetectFolder);
            predetectCoins = (from x in predetectCoins
                              where x.nn == NetworkNumber
                              select x).ToList();

            IFileSystem.predetectCoins = predetectCoins;

            RAIDA raida = (from x in networks
                           where x.NetworkNumber == NetworkNumber
                           select x).FirstOrDefault();

            // Process Coins in Lots of 200. Can be changed from Config File
            int LotCount = predetectCoins.Count() / Config.MultiDetectLoad;
            if (predetectCoins.Count() % Config.MultiDetectLoad > 0) LotCount++;
            ProgressChangedEventArgs pge = new ProgressChangedEventArgs();

            int CoinCount = 0;
            int totalCoinCount = predetectCoins.Count();
            for (int i = 0; i < LotCount; i++)
            {
                //Pick up 200 Coins and send them to RAIDA
                var coins = predetectCoins.Skip(i * Config.MultiDetectLoad).Take(200);
                raida.coins = coins;

                var tasks = raida.GetMultiDetectTasks(coins.ToArray(), Config.milliSecondsToTimeOut);
                try
                {
                    string requestFileName = Utils.RandomString(16).ToLower() + DateTime.Now.ToString("yyyyMMddHHmmss") + ".stack";
                    // Write Request To file before detect
                    FS.WriteCoinsToFile(coins, FS.RequestsFolder + requestFileName);
                    await Task.WhenAll(tasks.AsParallel().Select(async task => await task()));
                    int j = 0;
                    foreach (var coin in coins)
                    {
                        coin.pown = "";
                        for (int k = 0; k < CloudCoinCore.Config.NodeCount; k++)
                        {
                            coin.response[k] = raida.nodes[k].MultiResponse.responses[j];
                            coin.pown += coin.response[k].outcome.Substring(0, 1);
                        }
                        int countp = coin.response.Where(x => x.outcome == "pass").Count();
                        int countf = coin.response.Where(x => x.outcome == "fail").Count();
                        coin.PassCount = countp;
                        coin.FailCount = countf;
                        CoinCount++;


                        updateLog("No. " + CoinCount + ". Coin Deteced. S. No. - " + coin.sn + ". Pass Count - " + coin.PassCount + ". Fail Count  - " + coin.FailCount + ". Result - " + coin.DetectionResult + "." + coin.pown);
                        Debug.WriteLine("Coin Deteced. S. No. - " + coin.sn + ". Pass Count - " + coin.PassCount + ". Fail Count  - " + coin.FailCount + ". Result - " + coin.DetectionResult);
                        //coin.sortToFolder();
                        pge.MinorProgress = (CoinCount) * 100 / totalCoinCount;
                        Debug.WriteLine("Minor Progress- " + pge.MinorProgress);
                        raida.OnProgressChanged(pge);
                        j++;
                    }
                    pge.MinorProgress = (CoinCount - 1) * 100 / totalCoinCount;
                    Debug.WriteLine("Minor Progress- " + pge.MinorProgress);
                    raida.OnProgressChanged(pge);
                    FS.WriteCoin(coins, FS.DetectedFolder);
                    FS.RemoveCoins(coins, FS.PreDetectFolder);


                    //FS.WriteCoin(coins, FS.DetectedFolder);

                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }
        }//constructor

        public string fixOneGuidCorner(int raida_ID, CloudCoin cc, int corner, int[] trustedTriad)
        {
            //RAIDA raida = RAIDA.GetInstance();
            CoinUtils cu = new CoinUtils(cc);
            ProgressChangedEventArgs pge = new ProgressChangedEventArgs();

            /*1. WILL THE BROKEN RAIDA FIX? check to see if it has problems echo, detect, or fix. */
            if (raida.nodes[raida_ID].FailsFix || raida.nodes[raida_ID].FailsEcho || raida.nodes[raida_ID].FailsEcho)
            {
                Console.Out.WriteLine("RAIDA Fails Echo or Fix. Try again when RAIDA online.");
                pge.MajorProgressMessage = ("RAIDA Fails Echo or Fix. Try again when RAIDA online.");
                raida.OnLogRecieved(pge);
                return "RAIDA Fails Echo or Fix. Try again when RAIDA online.";
            }
            else
            {
                /*2. ARE ALL TRUSTED RAIDA IN THE CORNER READY TO HELP?*/

                if (!raida.nodes[trustedTriad[0]].FailsEcho || !raida.nodes[trustedTriad[0]].FailsDetect || !raida.nodes[trustedTriad[1]].FailsEcho || !!raida.nodes[trustedTriad[1]].FailsDetect || !raida.nodes[trustedTriad[2]].FailsEcho || !raida.nodes[trustedTriad[2]].FailsDetect)
                {
                    /*3. GET TICKETS AND UPDATE RAIDA STATUS TICKETS*/
                    string[] ans = { cc.an[trustedTriad[0]], cc.an[trustedTriad[1]], cc.an[trustedTriad[2]] };
                    raida.GetTickets(trustedTriad, ans, cc.nn, cc.sn, cu.getDenomination(), 3000);

                    /*4. ARE ALL TICKETS GOOD?*/
                    if (raida.nodes[trustedTriad[0]].HasTicket && raida.nodes[trustedTriad[1]].HasTicket && raida.nodes[trustedTriad[2]].HasTicket)
                    {
                        /*5.T YES, so REQUEST FIX*/
                        //DetectionAgent da = new DetectionAgent(raida_ID, 5000);
                        if (!continueExecution)
                        {
                            Debug.WriteLine("Aborting Fix ");
                            return "Aborting for new operation";
                        }
                        Response fixResponse = RAIDA.GetInstance().nodes[raida_ID].Fix(trustedTriad, raida.nodes[trustedTriad[0]].Ticket, raida.nodes[trustedTriad[1]].Ticket, raida.nodes[trustedTriad[2]].Ticket, cc.an[raida_ID]).Result;
                        /*6. DID THE FIX WORK?*/
                        if (fixResponse.success)
                        {
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.Out.WriteLine("");
                            Console.Out.WriteLine("RAIDA" + raida_ID + " unfracked successfully.");
                            pge.MajorProgressMessage = "RAIDA" + raida_ID + " unfracked successfully.";
                            raida.OnLogRecieved(pge);
                            //CoreLogger.Log("RAIDA" + raida_ID + " unfracked successfully.");
                            Console.Out.WriteLine("");
                            Console.ForegroundColor = ConsoleColor.White;
                            return "RAIDA" + raida_ID + " unfracked successfully.";

                        }
                        else
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.Out.WriteLine("");
                            Console.Out.WriteLine("RAIDA failed to accept tickets on corner " + corner);
                            pge.MajorProgressMessage = "RAIDA failed to accept tickets on corner " + corner;
                            raida.OnLogRecieved(pge);
                            //CoreLogger.Log("RAIDA failed to accept tickets on corner " + corner);
                            Console.Out.WriteLine("");
                            Console.ForegroundColor = ConsoleColor.White;
                            return "RAIDA failed to accept tickets on corner " + corner;
                        }//end if fix respons was success or fail
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Out.WriteLine("");
                        Console.Out.WriteLine("Trusted servers failed to provide tickets for corner " + corner);
                        pge.MajorProgressMessage = "Trusted servers failed to provide tickets for corner " + corner;
                        raida.OnLogRecieved(pge);
                        //CoreLogger.Log("Trusted servers failed to provide tickets for corner " + corner);
                        Console.Out.WriteLine("");
                        Console.ForegroundColor = ConsoleColor.White;

                        return "Trusted servers failed to provide tickets for corner " + corner;//no three good tickets
                    }//end if all good
                }//end if trused triad will echo and detect (Detect is used to get ticket)

                Console.ForegroundColor = ConsoleColor.Red;
                Console.Out.WriteLine("");
                Console.Out.WriteLine("One or more of the trusted triad will not echo and detect.So not trying.");
                pge.MajorProgressMessage = "One or more of the trusted triad will not echo and detect.So not trying.";
                raida.OnLogRecieved(pge);

                //CoreLogger.Log("One or more of the trusted triad will not echo and detect.So not trying.");
                Console.Out.WriteLine("");
                Console.ForegroundColor = ConsoleColor.White;
                return "One or more of the trusted triad will not echo and detect. So not trying.";
            }//end if RAIDA fails to fix. 

        }//end fix one
        }//end delete coin


        public CoinUtils fixCoin(CloudCoin brokeCoin)
        {
            CoinUtils cu = new CoinUtils(brokeCoin);
            ProgressChangedEventArgs pge = new ProgressChangedEventArgs();
            /*0. RESET TICKETS IN RAIDA STATUS TO EMPTY*/

            //RAIDA_Status.resetTickets();
            RAIDA.GetInstance().nodes.ToList().ForEach(x => x.ResetTicket());

            /*0. RESET THE DETECTION to TRUE if it is a new COIN */
            RAIDA.GetInstance().nodes.ToList().ForEach(x => x.NewCoin());

            //RAIDA_Status.newCoin();

            cu.setAnsToPans();// Make sure we set the RAIDA to the cc ans and not new pans. 
            DateTime before = DateTime.Now;

            String fix_result = "";
            FixitHelper fixer;

            /*START*/
            /*1. PICK THE CORNER TO USE TO TRY TO FIX */
            int corner = 1;
            // For every guid, check to see if it is fractured
            for (int raida_ID = 0; raida_ID < 25; raida_ID++)
            {
                if (!continueExecution)
                {
                    Debug.Write("Stopping Execution");
                    return cu;
                }
                //  Console.WriteLine("Past Status for " + raida_ID + ", " + brokeCoin.pastStatus[raida_ID]);

                if (cu.getPastStatus(raida_ID).ToLower() != "pass")//will try to fix everything that is not perfect pass.
                {

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Out.WriteLine("");
                    Console.WriteLine("Attempting to fix RAIDA " + raida_ID);
                    pge.MajorProgressMessage = "Attempting to fix RAIDA " + raida_ID;
                    raida.OnLogRecieved(pge);
                    // CoreLogger.Log("Attempting to fix RAIDA " + raida_ID);
                    Console.Out.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;

                    fixer = new FixitHelper(raida_ID, brokeCoin.an.ToArray());

                    //trustedServerAns = new String[] { brokeCoin.ans[fixer.currentTriad[0]], brokeCoin.ans[fixer.currentTriad[1]], brokeCoin.ans[fixer.currentTriad[2]] };
                    corner = 1;
                    while (!fixer.finished)
                    {
                        if (!continueExecution)
                        {
                            Debug.Write("Stopping Execution");
                            return cu;
                        }
                        Console.WriteLine(" Using corner " + corner);
                        pge.MajorProgressMessage = " Using corner " + corner;
                        raida.OnLogRecieved(pge);
                        //   CoreLogger.Log(" Using corner " + corner);
                        fix_result = fixOneGuidCorner(raida_ID, brokeCoin, corner, fixer.currentTriad);
                        // Console.WriteLine(" fix_result: " + fix_result + " for corner " + corner);
                        if (fix_result.Contains("success"))
                        {
                            //Fixed. Do the fixed stuff
                            cu.setPastStatus("pass", raida_ID);
                            fixer.finished = true;
                            corner = 1;
                        }
                        else
                        {
                            //Still broken, do the broken stuff. 
                            corner++;
                            fixer.setCornerToCheck(corner);
                        }
                    }//End whild fixer not finnished
                }//end if RAIDA past status is passed and does not need to be fixed
            }//end for each AN

            for (int raida_ID = 24; raida_ID > 0; raida_ID--)
            {
                //  Console.WriteLine("Past Status for " + raida_ID + ", " + brokeCoin.pastStatus[raida_ID]);
                if (!continueExecution)
                {
                    return cu;
                }

                if (cu.getPastStatus(raida_ID).ToLower() != "pass")//will try to fix everything that is not perfect pass.
                {

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Out.WriteLine("");
                    Console.WriteLine("Attempting to fix RAIDA " + raida_ID);
                    pge.MajorProgressMessage = "Attempting to fix RAIDA " + raida_ID;
                    raida.OnLogRecieved(pge);
                    //  CoreLogger.Log("Attempting to fix RAIDA " + raida_ID);
                    Console.Out.WriteLine("");
                    Console.ForegroundColor = ConsoleColor.White;

                    fixer = new FixitHelper(raida_ID, brokeCoin.an.ToArray());

                    //trustedServerAns = new String[] { brokeCoin.ans[fixer.currentTriad[0]], brokeCoin.ans[fixer.currentTriad[1]], brokeCoin.ans[fixer.currentTriad[2]] };
                    corner = 1;
                    while (!fixer.finished)
                    {
                        Console.WriteLine(" Using corner " + corner);
                        pge.MajorProgressMessage = " Using corner " + corner;
                        raida.OnLogRecieved(pge);
                        //CoreLogger.Log(" Using corner " + corner);
                        fix_result = fixOneGuidCorner(raida_ID, brokeCoin, corner, fixer.currentTriad);
                        // Console.WriteLine(" fix_result: " + fix_result + " for corner " + corner);
                        if (fix_result.Contains("success"))
                        {
                            //Fixed. Do the fixed stuff
                            cu.setPastStatus("pass", raida_ID);
                            fixer.finished = true;
                            corner = 1;
                        }
                        else
                        {
                            //Still broken, do the broken stuff. 
                            corner++;
                            fixer.setCornerToCheck(corner);
                        }
                    }//End whild fixer not finnished
                }//end if RAIDA past status is passed and does not need to be fixed
            }//end for each AN
            DateTime after = DateTime.Now;
            TimeSpan ts = after.Subtract(before);
            Console.WriteLine("Time spent fixing RAIDA in milliseconds: " + ts.Milliseconds);
            pge.MajorProgressMessage = "Time spent fixing RAIDA in milliseconds: " + ts.Milliseconds;
            raida.OnLogRecieved(pge);
            //CoreLogger.Log("Time spent fixing RAIDA in milliseconds: " + ts.Milliseconds);

            cu.calculateHP();//how many fails did it get
                             //  cu.gradeCoin();// sets the grade and figures out what the file extension should be (bank, fracked, counterfeit, lost

            cu.grade();
            cu.calcExpirationDate();
            return cu;
        }// end fix coin
示例#19
0
        public async static Task ProcessNetworkCoins(int NetworkNumber)
        {
            IFileSystem FS = FileSystem;
            FileSystem.LoadFileSystem();
            //FileSystem.DetectPreProcessing();

            var predetectCoins = FS.LoadFolderCoins(FS.PreDetectFolder);
            predetectCoins = (from x in predetectCoins
                              where x.nn == NetworkNumber
                              select x).ToList();

            IFileSystem.predetectCoins = predetectCoins;

            RAIDA raida = (from x in networks
                           where x.NetworkNumber == NetworkNumber
                           select x).FirstOrDefault();

            // Process Coins in Lots of 200. Can be changed from Config File
            int LotCount = predetectCoins.Count() / Config.MultiDetectLoad;
            if (predetectCoins.Count() % Config.MultiDetectLoad > 0) LotCount++;
            ProgressChangedEventArgs pge = new ProgressChangedEventArgs();

            int CoinCount = 0;
            int totalCoinCount = predetectCoins.Count();
            for (int i = 0; i < LotCount; i++)
            {
                //Pick up 200 Coins and send them to RAIDA
                var coins = predetectCoins.Skip(i * Config.MultiDetectLoad).Take(200);
                raida.coins = coins;

                var tasks = raida.GetMultiDetectTasks(coins.ToArray(), Config.milliSecondsToTimeOut);
                try
                {
                    string requestFileName = Utils.RandomString(16).ToLower() + DateTime.Now.ToString("yyyyMMddHHmmss") + ".stack";
                    // Write Request To file before detect
                    FS.WriteCoinsToFile(coins, FS.RequestsFolder + requestFileName);
                    await Task.WhenAll(tasks.AsParallel().Select(async task => await task()));
                    int j = 0;
                    foreach (var coin in coins)
                    {
                        coin.pown = "";
                        for (int k = 0; k < CloudCoinCore.Config.NodeCount; k++)
                        {
                            coin.response[k] = raida.nodes[k].MultiResponse.responses[j];
                            coin.pown += coin.response[k].outcome.Substring(0, 1);
                        }
                        int countp = coin.response.Where(x => x.outcome == "pass").Count();
                        int countf = coin.response.Where(x => x.outcome == "fail").Count();
                        coin.PassCount = countp;
                        coin.FailCount = countf;
                        CoinCount++;


                        updateLog("No. " + CoinCount + ". Coin Deteced. S. No. - " + coin.sn + ". Pass Count - " + coin.PassCount + ". Fail Count  - " + coin.FailCount + ". Result - " + coin.DetectionResult + "." + coin.pown);
                        Debug.WriteLine("Coin Deteced. S. No. - " + coin.sn + ". Pass Count - " + coin.PassCount + ". Fail Count  - " + coin.FailCount + ". Result - " + coin.DetectionResult);
                        //coin.sortToFolder();
                        pge.MinorProgress = (CoinCount) * 100 / totalCoinCount;
                        Debug.WriteLine("Minor Progress- " + pge.MinorProgress);
                        raida.OnProgressChanged(pge);
                        j++;
                    }
                    pge.MinorProgress = (CoinCount - 1) * 100 / totalCoinCount;
                    Debug.WriteLine("Minor Progress- " + pge.MinorProgress);
                    raida.OnProgressChanged(pge);
                    FS.WriteCoin(coins, FS.DetectedFolder);
                    FS.RemoveCoins(coins, FS.PreDetectFolder);


                    //FS.WriteCoin(coins, FS.DetectedFolder);

                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }


            }
            pge.MinorProgress = 100;
            Debug.WriteLine("Minor Progress- " + pge.MinorProgress);
            raida.OnProgressChanged(pge);
            var detectedCoins = FS.LoadFolderCoins(FS.DetectedFolder);
            //detectedCoins.ForEach(x => x.pown= "ppppppppppppppppppppppppp");

            // Apply Sort to Folder to all detected coins at once.
            updateLog("Starting Sort.....");
            detectedCoins.ForEach(x => x.SortToFolder());
            updateLog("Ended Sort........");

            var passedCoins = (from x in detectedCoins
                               where x.folder == FS.BankFolder
                               select x).ToList();

            var failedCoins = (from x in detectedCoins
                               where x.folder == FS.CounterfeitFolder
                               select x).ToList();
            var lostCoins = (from x in detectedCoins
                             where x.folder == FS.LostFolder
                             select x).ToList();
            var suspectCoins = (from x in detectedCoins
                                where x.folder == FS.SuspectFolder
                                select x).ToList();

            Debug.WriteLine("Total Passed Coins - " + passedCoins.Count());
            Debug.WriteLine("Total Failed Coins - " + failedCoins.Count());
            updateLog("Coin Detection finished.");
            updateLog("Total Passed Coins - " + passedCoins.Count() + "");
            updateLog("Total Failed Coins - " + failedCoins.Count() + "");
            updateLog("Total Lost Coins - " + lostCoins.Count() + "");
            updateLog("Total Suspect Coins - " + suspectCoins.Count() + "");

            // Move Coins to their respective folders after sort
            FS.MoveCoins(passedCoins, FS.DetectedFolder, FS.BankFolder);

            //FS.WriteCoin(failedCoins, FS.CounterfeitFolder, true);
            FS.MoveCoins(lostCoins, FS.DetectedFolder, FS.LostFolder);
            FS.MoveCoins(suspectCoins, FS.DetectedFolder, FS.SuspectFolder);

            // Clean up Detected Folder
            FS.RemoveCoins(failedCoins, FS.DetectedFolder);
            FS.RemoveCoins(lostCoins, FS.DetectedFolder);
            FS.RemoveCoins(suspectCoins, FS.DetectedFolder);

            FS.MoveImportedFiles();

            //after = DateTime.Now;
            //ts = after.Subtract(before);

            //Debug.WriteLine("Detection Completed in - " + ts.TotalMilliseconds / 1000);
            //updateLog("Detection Completed in - " + ts.TotalMilliseconds / 1000);


        }
示例#20
0
        }//End multi detect

        //int[] nn, int[] sn, String[] an, String[] pan, int[] d, int timeout
        public async Task <MultiDetectResponse> MultiDetect()
        {
            /*PREPARE REQUEST*/
            try
            {
                var      raida   = RAIDA.GetInstance();
                int[]    nn      = raida.multiRequest.nn;
                int[]    sn      = raida.multiRequest.sn;
                String[] an      = raida.multiRequest.an[NodeNumber - 1];
                String[] pan     = raida.multiRequest.pan[NodeNumber - 1];
                int[]    d       = raida.multiRequest.d;
                int      timeout = raida.multiRequest.timeout;

                Response[] response = new Response[nn.Length];
                for (int i = 0; i < nn.Length; i++)
                {
                    response[i] = new Response();
                }

                //Create List of KeyValuePairs to use as the POST data
                List <KeyValuePair <string, string> > postVariables = new List <KeyValuePair <string, string> >();

                //Loop over String array and add all instances to our bodyPoperties
                for (int i = 0; i < nn.Length; i++)
                {
                    postVariables.Add(new KeyValuePair <string, string>("nns[]", nn[i].ToString()));
                    postVariables.Add(new KeyValuePair <string, string>("sns[]", sn[i].ToString()));
                    postVariables.Add(new KeyValuePair <string, string>("ans[]", an[i]));
                    postVariables.Add(new KeyValuePair <string, string>("pans[]", pan[i]));
                    postVariables.Add(new KeyValuePair <string, string>("denomination[]", d[i].ToString()));
                    // Debug.WriteLine("url is " + this.fullUrl + "detect?nns[]=" + nn[i] + "&sns[]=" + sn[i] + "&ans[]=" + an[i] + "&pans[]=" + pan[i] + "&denomination[]=" + d[i]);

                    response[i].fullRequest = this.FullUrl + "detect?nns[]=" + nn[i] + "&sns[]=" + sn[i] + "&ans[]=" + an[i] + "&pans[]=" + pan[i] + "&denomination[]=" + d[i];//Record what was sent
                }

                //convert postVariables to an object of FormUrlEncodedContent
                var      dataContent = new FormUrlEncodedContent(postVariables.ToArray());
                DateTime before      = DateTime.Now;
                DateTime after;
                TimeSpan ts = new TimeSpan();


                /*MAKE REQEST*/
                string totalResponse = "";
                var    client        = new HttpClient();
                client.Timeout = TimeSpan.FromMilliseconds(timeout);

                try
                {
                    //POST THE REQUEST AND FILL THE ANSER IN totalResponse
                    totalResponse = "";
                    HttpResponseMessage json;

                    using (client)
                    {
                        // Console.Write("postHtml await for response: ");
                        json = await client.PostAsync(FullUrl + "multi_detect", dataContent);

                        //Console.Write(".");
                        if (json.IsSuccessStatusCode)//200 status good
                        {
                            totalResponse = await json.Content.ReadAsStringAsync();

                            // Console.Out.WriteLine("RAIDA " + NodeNumber + " returned good: " + json.StatusCode);
                            //  Console.Out.WriteLine(totalResponse);
                        }
                        else //404 not found or 500 error.
                        {
                            Console.Out.WriteLine("RAIDA " + NodeNumber + " had an error: " + json.StatusCode);
                            after = DateTime.Now;
                            ts    = after.Subtract(before);//Start the timer
                            for (int i = 0; i < nn.Length; i++)
                            {
                                response[i].outcome      = "error";
                                response[i].fullResponse = json.StatusCode.ToString();
                                response[i].success      = false;
                                response[i].milliseconds = Convert.ToInt32(ts.Milliseconds);
                                FailsDetect = true;
                                //RAIDA_Status.failsDetect[RAIDANumber] = true;
                            }//end for every CloudCoin note
                            MultiResponse.responses = response;
                            return(MultiResponse);//END IF THE REQUEST GOT AN ERROR
                        } //end else 404 or 500
                    }     //end using
                }
                catch (TaskCanceledException ex)//This means it timed out
                {
                    // Console.WriteLine("T1:" + ex.Message);
                    after = DateTime.Now;
                    ts    = after.Subtract(before);//Start the timer
                    for (int i = 0; i < nn.Length; i++)
                    {
                        response[i].outcome      = "noresponse";
                        response[i].fullResponse = ex.Message;
                        response[i].success      = false;
                        response[i].milliseconds = Convert.ToInt32(ts.Milliseconds);
                        FailsDetect = true;
                        //RAIDA_Status.failsDetect[RAIDANumber] = true;
                    }//end for every CloudCoin note
                    MultiResponse.responses = response;

                    return(MultiResponse); //END IF THE REQUEST FAILED
                }
                catch (Exception ex)       //Request failed with some kind of error that did not provide a response.
                {
                    // Console.WriteLine("M1:" + ex.Message);
                    after = DateTime.Now;
                    ts    = after.Subtract(before);//Start the timer
                    for (int i = 0; i < nn.Length; i++)
                    {
                        response[i].outcome      = "error";
                        response[i].fullResponse = ex.Message;
                        response[i].success      = false;
                        response[i].milliseconds = Convert.ToInt32(ts.Milliseconds);
                        FailsDetect = true;
                        //RAIDA_Status.failsDetect[RAIDANumber] = true;
                    }//end for every CloudCoin note
                    MultiResponse.responses = response;
                    return(MultiResponse);//END IF THE REQUEST FAILED
                }//end catch request attmept


                /* PROCESS REQUEST*/
                after = DateTime.Now;
                ts    = after.Subtract(before); //Start the timer
                                                //Is the request a dud?
                if (totalResponse.Contains("dud"))
                {
                    //Mark all Responses as duds
                    for (int i = 0; i < nn.Length; i++)
                    {
                        response[i].fullResponse = totalResponse;
                        response[i].success      = false;
                        response[i].outcome      = "dud";
                        response[i].milliseconds = Convert.ToInt32(ts.Milliseconds);
                    } //end for each dud
                }     //end if dud
                else
                {
                    //Not a dud so break up parts into smaller pieces
                    //Remove leading "[{"
                    totalResponse = totalResponse.Remove(0, 2);
                    //Remove trailing "}]"
                    totalResponse = totalResponse.Remove(totalResponse.Length - 2, 2);
                    //Split by "},{"
                    string[] responseArray = Regex.Split(totalResponse, "},{");
                    //Check to see if the responseArray is the same length as the request detectResponse. They should be the same
                    if (response.Length != responseArray.Length)
                    {
                        //Mark all Responses as duds
                        for (int i = 0; i < nn.Length; i++)
                        {
                            response[i].fullResponse = totalResponse;
                            response[i].success      = false;
                            response[i].outcome      = "dud";
                            response[i].milliseconds = Convert.ToInt32(ts.Milliseconds);
                        } //end for each dud
                    }     //end if lenghts are not the same
                    else  //Lengths are the same so lets go through each one
                    {
                        for (int i = 0; i < nn.Length; i++)
                        {
                            if (responseArray[i].Contains("pass"))
                            {
                                response[i].fullResponse = responseArray[i];
                                response[i].outcome      = "pass";
                                response[i].success      = true;
                                response[i].milliseconds = Convert.ToInt32(ts.Milliseconds);
                            }
                            else if (responseArray[i].Contains("fail") && responseArray[i].Length < 200)//less than 200 incase there is a fail message inside errored page
                            {
                                response[i].fullResponse = responseArray[i];
                                response[i].outcome      = "fail";
                                response[i].success      = false;
                                response[i].milliseconds = Convert.ToInt32(ts.Milliseconds);
                            }
                            else
                            {
                                response[i].fullResponse = responseArray[i];
                                response[i].outcome      = "error";
                                response[i].success      = false;
                                response[i].milliseconds = Convert.ToInt32(ts.Milliseconds);
                            }
                        } //End for each response
                    }     //end if array lengths are the same
                }         //End Else not a dud
                 //Break the respons into sub responses.
                MultiDetectTime         = Convert.ToInt32(ts.Milliseconds);
                MultiResponse.responses = response;
                return(MultiResponse);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            return(null);
        }//End multi detect
示例#21
0
        public async static Task ProcessNetworkCoins(int NetworkNumber, bool ChangeANS = true)
        {
            IFileSystem FS = FileSystem;

            FileSystem.LoadFileSystem();
            FileSystem.DetectPreProcessing();

            var predetectCoins = FS.LoadFolderCoins(FS.PreDetectFolder);

            predetectCoins = (from x in predetectCoins
                              where x.nn == NetworkNumber
                              select x).ToList();

            IFileSystem.predetectCoins = predetectCoins;

            #region Check Existing coins and skip them

            IEnumerable <CloudCoin> bankCoins     = IFileSystem.bankCoins;
            IEnumerable <CloudCoin> frackedCoins1 = IFileSystem.frackedCoins;

            var bCoins = bankCoins.ToList();
            bCoins.AddRange(frackedCoins1);
            //bankCoins.ToList().AddRange(frackedCoins1);

            var totalBankCoins = bCoins;

            var snList = (from x in totalBankCoins
                          where x.nn == NetworkNumber
                          select x.sn).ToList();

            var newCoins      = from x in predetectCoins where !snList.Contains(x.sn) select x;
            var existingCoins = from x in predetectCoins where snList.Contains(x.sn) select x;

            foreach (var coin in existingCoins)
            {
                updateLog("Found coin SN:" + coin.sn + " in folders. Skipping detection of the coin SN:" + coin.sn);
                FS.MoveFile(FS.PreDetectFolder + coin.FileName + ".stack", FS.TrashFolder + coin.FileName + ".stack", IFileSystem.FileMoveOptions.Replace);
            }

            predetectCoins = newCoins.ToList();

            #endregion

            RAIDA raida = (from x in networks
                           where x.NetworkNumber == NetworkNumber
                           select x).FirstOrDefault();
            if (raida == null)
            {
                return;
            }
            // Process Coins in Lots of 200. Can be changed from Config File
            int LotCount = predetectCoins.Count() / Config.MultiDetectLoad;
            if (predetectCoins.Count() % Config.MultiDetectLoad > 0)
            {
                LotCount++;
            }
            ProgressChangedEventArgs pge = new ProgressChangedEventArgs();

            int CoinCount      = 0;
            int totalCoinCount = predetectCoins.Count();
            for (int i = 0; i < LotCount; i++)
            {
                //Pick up 200 Coins and send them to RAIDA
                var coins = predetectCoins.Skip(i * Config.MultiDetectLoad).Take(Config.MultiDetectLoad);
                try
                {
                    raida.coins = coins;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
                if (i == LotCount - 1)
                {
                    updateLog("\tDetecting Coins " + (i * CloudCoinCore.Config.MultiDetectLoad + 1) +
                              " to " + totalCoinCount);
                }
                else
                {
                    updateLog("\tDetecting Coins " + (i * CloudCoinCore.Config.MultiDetectLoad + 1) +
                              " to " + (i + 1) * CloudCoinCore.Config.MultiDetectLoad);
                }
                var tasks = raida.GetMultiDetectTasks(coins.ToArray(), Config.milliSecondsToTimeOut, ChangeANS);
                try
                {
                    string requestFileName = Utils.RandomString(16).ToLower() + DateTime.Now.ToString("yyyyMMddHHmmss") + ".stack";
                    // Write Request To file before detect
                    FS.WriteCoinsToFile(coins, FS.RequestsFolder + requestFileName);
                    await Task.WhenAll(tasks.AsParallel().Select(async task => await task()));

                    int j = 0;
                    foreach (var coin in coins)
                    {
                        coin.pown = "";
                        for (int k = 0; k < CloudCoinCore.Config.NodeCount; k++)
                        {
                            coin.response[k] = raida.nodes[k].MultiResponse.responses[j];
                            coin.pown       += coin.response[k].outcome.Substring(0, 1);
                        }
                        int countp = coin.response.Where(x => x.outcome == "pass").Count();
                        int countf = coin.response.Where(x => x.outcome == "fail").Count();
                        coin.PassCount = countp;
                        coin.FailCount = countf;
                        CoinCount++;


                        //    MainWindow.UpdateCELog("No. " + CoinCount + ". Coin Deteced. S. No. - " + coin.sn + ". Pass Count - " + coin.PassCount + ". Fail Count  - " + coin.FailCount + ". Result - " + coin.DetectionResult + "." + coin.pown);


                        pge.MinorProgress = (CoinCount) * 100 / totalCoinCount;
                        Debug.WriteLine("Minor Progress- " + pge.MinorProgress);
                        raida.OnProgressChanged(pge);
                        coin.doPostProcessing();
                        j++;
                    }
                    pge.MinorProgress = (CoinCount - 1) * 100 / totalCoinCount;
                    Debug.WriteLine("Minor Progress- " + pge.MinorProgress);
                    raida.OnProgressChanged(pge);
                    FS.WriteCoin(coins, FS.DetectedFolder, true);
                    FS.RemoveCoinsByFileName(coins, FS.PreDetectFolder);

                    // MainWindow.UpdateCELog(pge.MinorProgress + " % of Coins on Network " + NetworkNumber + " processed.");
                    //FS.WriteCoin(coins, FS.DetectedFolder);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }
            pge.MinorProgress = 100;
            Debug.WriteLine("Minor Progress- " + pge.MinorProgress);
            raida.OnProgressChanged(pge);
            var detectedCoins = FS.LoadFolderCoins(FS.DetectedFolder);
            //detectedCoins.ForEach(x => x.pown= "ppppppppppppppppppppppppp");

            // Apply Sort to Folder to all detected coins at once.
            updateLog("Starting Grading Coins..");
            //detectedCoins.ForEach(x => x.doPostProcessing());
            detectedCoins.ForEach(x => x.SortToFolder());
            updateLog("Grading Coins Completed.");

            // detectedCoins.ForEach(x => x.folder = FS.SuspectFolder);


            var passedCoins = (from x in detectedCoins
                               where x.folder == FS.BankFolder
                               select x).ToList();

            var frackedCoins = (from x in detectedCoins
                                where x.folder == FS.FrackedFolder
                                select x).ToList();

            var failedCoins = (from x in detectedCoins
                               where x.folder == FS.CounterfeitFolder
                               select x).ToList();
            var lostCoins = (from x in detectedCoins
                             where x.folder == FS.LostFolder
                             select x).ToList();
            var suspectCoins = (from x in detectedCoins
                                where x.folder == FS.SuspectFolder
                                select x).ToList();
            var dangerousCoins = (from x in detectedCoins
                                  where x.folder == FS.DangerousFolder
                                  select x).ToList();



            Debug.WriteLine("Total Passed Coins - " + (passedCoins.Count() + frackedCoins.Count()));
            Debug.WriteLine("Total Failed Coins - " + failedCoins.Count());

            // Move Coins to their respective folders after sort
            FS.MoveCoins(passedCoins, FS.DetectedFolder, FS.BankFolder);
            FS.MoveCoins(frackedCoins, FS.DetectedFolder, FS.FrackedFolder);

            if (failedCoins.Count() > 0)
            {
                FS.WriteCoin(failedCoins, FS.CounterfeitFolder, false, true);
            }
            FS.MoveCoinsByFileName(lostCoins, FS.DetectedFolder, FS.LostFolder);
            FS.MoveCoinsByFileName(suspectCoins, FS.DetectedFolder, FS.SuspectFolder);

            // Clean up Detected Folder
            FS.RemoveCoinsByFileName(failedCoins, FS.DetectedFolder);
            FS.RemoveCoinsByFileName(lostCoins, FS.DetectedFolder);
            FS.RemoveCoinsByFileName(suspectCoins, FS.DetectedFolder);

            FS.MoveImportedFiles();

            //after = DateTime.Now;
            //ts = after.Subtract(before);

            //Debug.WriteLine("Detection Completed in - " + ts.TotalMilliseconds / 1000);
            //updateLog("Detection Completed in - " + ts.TotalMilliseconds / 1000);

            updateLog("Detection and Import of the CloudCoins completed.");
            updateLog("Coin Detection finished.");
            updateLog("Total Passed Coins - " + (passedCoins.Count() + frackedCoins.Count()) + "");
            updateLog("Total Counterfeit Coins - " + failedCoins.Count() + "");
            updateLog("Total Lost Coins - " + lostCoins.Count() + "");
            updateLog("Total Suspect Coins - " + suspectCoins.Count() + "");
            updateLog("Total Dangerous Coins - " + dangerousCoins.Count() + "");
            updateLog("Total Skipped Coins - " + existingCoins.Count() + "");

            pge.MinorProgress = 100;
            Debug.WriteLine("Minor Progress- " + pge.MinorProgress);
        }
示例#22
0
        }//end record pown

        public void SortToFolder()
        {
            //figures out which folder to put it in.
            if (isPerfect())
            {
                folder = folder = RAIDA.GetInstance().FS.BankFolder;
                //folder = Folder.Bank;
                return;
            }//if is perfect

            if (isCounterfeit())
            {
                folder = RAIDA.GetInstance().FS.CounterfeitFolder;
                //folder = Folder.Counterfeit;
                return;
            }//if is counterfeit

            //--------------------------------------
            /*Now look  at fracked coins*/

            if (isGradablePass())
            {
                if (!isFracked())
                {
                    folder = RAIDA.GetInstance().FS.BankFolder;
                    return;
                }
                else
                {
                    if (isDangerous())
                    {
                        if (isFixable())
                        {
                            recordPown();
                            folder = RAIDA.GetInstance().FS.DangerousFolder;
                            return;
                        }
                        else
                        {
                            folder = RAIDA.GetInstance().FS.CounterfeitFolder;
                            return;
                        }
                    }
                    else
                    {
                        if (!isFixable())
                        {
                            folder = RAIDA.GetInstance().FS.CounterfeitFolder;
                            return;
                        }
                        else
                        {
                            folder = RAIDA.GetInstance().FS.FrackedFolder;
                            return;
                        }
                    }
                }
            }
            else
            {
                if (noResponses())
                {
                    folder = RAIDA.GetInstance().FS.LostFolder;
                    //folder = Folder.Lost;
                    return;
                }//end no responses
                else
                {
                    folder = RAIDA.GetInstance().FS.SuspectFolder;
                    //folder = Folder.Lost;
                    return;
                }
            }
        }//end sort folder