Пример #1
0
		}//end get ticket


		public void 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 };
			Task.WaitAll(taskList.ToArray(), millisecondsToTimeout);
			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
Пример #2
0
        }//end delete coin

        public CoinUtils fixCoin(CloudCoin brokeCoin, int millisecondsToTimeout)
        {
            CoinUtils cu = new CoinUtils(brokeCoin);

            /*0. RESET TICKETS IN RAIDA STATUS TO EMPTY*/
            RAIDA_Status.resetTickets();

            /*0. RESET THE DETECTION to TRUE if it is a new COIN */
            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++)
            {
                //Check to see if the coin has been marked counterfeit and should be moved to trash
                // Console.Out.WriteLine("The folder is " + cu.getFolder().ToLower());
                if (cu.cc.pown == "fffffffffffffffffffffffff")
                {
                    cu.setFolder("counterfeit");
                    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.
                {
                    cu.cc.an[raida_ID]      = cu.generatePan();     //Assign the AN a new PAN for security.
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write("  Attempting to fix RAIDA " + raida_ID + " ");
                    CoreLogger.Log("  Attempting to fix RAIDA " + raida_ID);
                    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.finnished)
                    {
                        Console.Write(" Using corner " + corner + " ");
                        CoreLogger.Log(" Using corner " + corner + " ");
                        fix_result = fixOneGuidCorner(raida_ID, brokeCoin, corner, fixer.currentTriad, millisecondsToTimeout);
                        // 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.finnished = true;
                            corner          = 1;
                        }
                        else if (fix_result.Contains("counterfeit"))
                        {
                            for (int j = 0; j < 25; j++)
                            {
                                cu.setPastStatus("fail", j);
                            }                                                            //Set all status to fail so the coin will be moved to counterfeit.
                            cu.setFolder("counterfeit");
                            fixer.finnished = true;
                            return(cu);
                        }
                        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 > -1; raida_ID--)
            {
                //  Console.WriteLine("Past Status for " + raida_ID + ", " + brokeCoin.pastStatus[raida_ID]);
                // Console.WriteLine("Pown is " + cu.cc.pown);
                if (cu.getPastStatus(raida_ID).ToLower() != "pass") //will try to fix everything that is not perfect pass.
                {
                    cu.cc.an[raida_ID]      = cu.generatePan();     //Assign the AN a new PAN for security.
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write("  Attempting to fix RAIDA " + raida_ID + " ");
                    CoreLogger.Log("  Attempting to fix RAIDA " + raida_ID);
                    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.finnished)
                    {
                        Console.Write(" Using corner " + corner + " ");
                        CoreLogger.Log(" Using corner " + corner + " ");
                        fix_result = fixOneGuidCorner(raida_ID, brokeCoin, corner, fixer.currentTriad, millisecondsToTimeout);
                        // 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.finnished = true;
                            corner          = 1;
                        }
                        else if (fix_result.Contains("counterfeit"))
                        {
                            for (int j = 0; j < 25; j++)
                            {
                                cu.setPastStatus("fail", j);
                            }                                                            //Set all status to fail so the coin will be moved to counterfeit.
                            cu.setFolder("counterfeit");
                            fixer.finnished = true;
                            return(cu);
                        }
                        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);
            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
Пример #3
0
        }     // End print welcome

        public static bool echoRaida()
        {
            RAIDA_Status.resetEcho();
            RAIDA raida1 = new RAIDA(5000);

            Response[] results    = raida1.echoAll(5000);
            int        totalReady = 0;

            Console.Out.WriteLine("");
            //For every RAIDA check its results
            int longestCountryName = 15;

            Console.Out.WriteLine();
            for (int i = 0; i < 25; i++)
            {
                int    padding = longestCountryName - countries[i].Length;
                string strPad  = "";
                for (int j = 0; j < padding; j++)
                {
                    strPad += " ";
                }//end for padding
                // Console.Out.Write(RAIDA_Status.failsEcho[i]);
                if (RAIDA_Status.failsEcho[i])
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Out.Write(strPad + countries[i]);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Out.Write(strPad + countries[i]);
                    totalReady++;
                }
                if (i == 4 || i == 9 || i == 14 || i == 19)
                {
                    Console.WriteLine();
                }
            }//end for
            Console.ForegroundColor = ConsoleColor.White;
            Console.Out.WriteLine("");
            Console.Out.WriteLine("");
            Console.Out.Write("  RAIDA Health: " + totalReady + " / 25: ");//"RAIDA Health: " + totalReady );

            //Check if enough are good
            if (totalReady < 16)//
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Out.WriteLine("  Not enough RAIDA servers can be contacted to import new coins."); // );
                Console.Out.WriteLine("  Is your device connected to the Internet?");                      // );
                Console.Out.WriteLine("  Is a router blocking your connection?");                          // );
                Console.ForegroundColor = ConsoleColor.White;
                return(false);
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.Out.WriteLine("The RAIDA is ready for counterfeit detection.");// );
                Console.ForegroundColor = ConsoleColor.White;
                return(true);
            } //end if enough RAIDA
        }     //End echo