Esempio n. 1
0
        }//end fixit

        /**
         * Method GET TICKET
         * Returns an ticket from a trusted server
         * @param nn  int that is the coin's Network Number
         * @param sn  int that is the coin's Serial Number
         * @param an String that is the coin's Authenticity Number (GUID)
         * @param pan String that is the Proposed Authenticity Number to replace the AN.
         * @param d int that is the Denomination of the Coin
         * @return Response object.
         */
        public async Task <Response> GetTicket(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);

                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);
        }     //end get ticket
Esempio n. 2
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
Esempio n. 3
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
        }//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
Esempio n. 6
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
Esempio n. 7
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