Ejemplo n.º 1
0
        private void StartPorcessing(string s2)
        {
            if (s2.Length > 5)
            {
                List<string> returns = new List<string>();
                if (s2[0] == '�')
                {
                    while (s2.Length > 0)
                    {
                        if (s2[0] == '�')
                        {
                            int length = int.Parse(s2.Substring(1, s2.IndexOf('�', 1) - 1));
                            string tmp = s2.Substring(s2.IndexOf('�', 1) + 1, length);
                            returns.Add(tmp.Substring(4));
                            s2 = s2.Substring(s2.IndexOf('�', 1) + length + 1);
                        }
                    }
                }
                else if (s2.Substring(0, 4) == "5:::")
                {
                    returns.Add(s2.Substring(4));
                }
                else
                {

                }

                foreach (string s in returns)
                {
                    ReceivedObject t = json.JsonDeserialize<ReceivedObject>(s);
                    if (s.Length > 13)
                    {
                        string tmpstring = s.Substring(9, s.IndexOf("\"", 9) - 9);
                        if (tmpstring.Contains("pong"))
                        {
                            if (OnPong != null)
                            {
                                OnPong();
                            }
                        }
                        if (tmpstring.Contains("result") && !tmpstring.Contains("old_results"))
                        {
                            Result tmp =  t.args[0] as Result;
                            ProcessResult(s);
                        }
                        else if (tmpstring.Contains("init"))
                        {
                            ProcessInit(s);
                        }
                        else if (tmpstring.Contains("history"))
                        {
                            ProcessHistory(s);
                        }
                        else if (tmpstring.Contains("chat"))
                        {
                            ProcessChat(s);
                        }
                        else if (tmpstring.Contains("set_hash"))
                        {
                            ProcessSetHash(s);
                        }
                        else if (tmpstring.Contains("old_results"))
                        {
                            ProcessOldResults(s);
                        }
                        else if (tmpstring.Contains("timeout"))
                        {
                            if (OnTimeout != null && !logginging)
                                OnTimeout();
                        }
                        else if (tmpstring.Contains("dismiss") && !logginging)
                        {
                            if (OnDismiss != null)
                                OnDismiss();
                        }
                        else if (tmpstring.Contains("details") && !logginging)
                        {
                            ProcessDetails(s);
                        }
                        else if (tmpstring.Contains("setup_ga") && !logginging)
                        {
                            ProcessSetupGa(s);
                        }
                        else if (tmpstring.Contains("ga_info") && !logginging)
                        {
                            ProcessGaInfo(s);
                        }
                        else if (tmpstring.Contains("ga_code_ok") && !logginging)
                        {
                            ProcessGaCode(s);
                        }
                        else if (tmpstring.Contains("ga_done") && !logginging)
                        {
                            if ( onGaDone != null)
                                onGaDone();
                        }
                        else if (tmpstring.Contains("ga_code_done") && !logginging)
                        {
                            if (onGaDone != null)
                                onGaDone();
                        }
                        else if (tmpstring.Contains("staked") && !logginging)
                        {
                            ProcessStake(s);
                        }

                        else //for everything that uses the various class as output
                        {
                            try
                            {
                                Various tmp = ProcessVarious(s);
                                switch (tmp.name)
                                {
                                    case "invest": Invest tmp2 = new Invest
                                    {
                                        Amount = decimal.Parse(tmp.args[0].ToString(), System.Globalization.CultureInfo.InvariantCulture),
                                        Percentage = decimal.Parse(tmp.args[1].ToString(), System.Globalization.CultureInfo.InvariantCulture),
                                        Profit = decimal.Parse(tmp.args[2].ToString(), System.Globalization.CultureInfo.InvariantCulture),
                                        Offsite = decimal.Parse(tmp.args[3].ToString(), System.Globalization.CultureInfo.InvariantCulture),

                                    }; this.Investment = tmp2.Amount; this.Percent = tmp2.Percentage; this.Invest_pft=tmp2.Profit; this.Offsite=tmp2.Offsite; if (onInvest != null && !logginging) onInvest(tmp2 ); break;
                                    case "invest_error": if (OnInvestError != null && !logginging) OnInvestError(tmp.args[0].ToString()); break;
                                    case "divest_error": if (OnDivestError != null && !logginging) OnDivestError(tmp.args[0].ToString()); break;
                                    case "offset": this.Offset = decimal.Parse(tmp.args[0].ToString(), System.Globalization.CultureInfo.InvariantCulture); if (this.OnOffset != null) OnOffset(this.Offset); break;
                                    case "wdaddr": if (OnWDAddress != null && !logginging) OnWDAddress(tmp.args[0].ToString()); break;
                                    case "balance": this.Balance = double.Parse(tmp.args[0].ToString(), System.Globalization.CultureInfo.InvariantCulture); if (OnBalance != null && !logginging) OnBalance(decimal.Parse(tmp.args[0].ToString(), System.Globalization.CultureInfo.InvariantCulture)); break;
                                    case "shash": this.shash = tmp.args[0].ToString(); if (OnSecretHash != null && !logginging) OnSecretHash(tmp.args[0].ToString()); break;
                                    case "seed": this.seed = tmp.args[0].ToString(); if (OnClientSeed != null && !logginging) OnClientSeed(tmp.args[0].ToString()); break;
                                    case "bad_seed": if (OnBadClientSeed != null && !logginging) OnBadClientSeed(tmp.args[0].ToString()); break;
                                    case "nonce": this.Nonce = int.Parse(tmp.args[0].ToString()); if (OnNonce != null && !logginging) OnNonce(int.Parse(tmp.args[0].ToString())); break;
                                    case "jderror": if (OnJDError != null && !logginging) OnJDError(tmp.args[0].ToString()); break;
                                    case "jdmsg": if (OnJDMessage != null && !logginging) OnJDMessage(tmp.args[0].ToString()); break;
                                    case "form_error": if (OnFormError != null && !logginging) OnFormError(tmp.args[0].ToString()); break;
                                    case "login_error": if (OnLoginError != null && !logginging) OnLoginError(tmp.args[0].ToString()); break;
                                    case "wins": this.Wins = long.Parse(tmp.args[0].ToString()); if (OnWins != null && !logginging) OnWins(long.Parse(tmp.args[0].ToString())); break;
                                    case "losses": this.Losses = long.Parse(tmp.args[0].ToString()); if (OnLossess != null && !logginging) OnLossess(long.Parse(tmp.args[0].ToString())); break;
                                    //case "details": if (OnDetails != null && !logginging) OnDetails(tmp); break;
                                    case "max_profit": this.MaxProfit = double.Parse(tmp.args[0].ToString(), System.Globalization.CultureInfo.InvariantCulture); if (OnMaxProfit != null && !logginging) OnMaxProfit(decimal.Parse(tmp.args[0].ToString(), System.Globalization.CultureInfo.InvariantCulture)); break;
                                    case "new_client_seed": this.shash = tmp.args[0].ToString(); if (OnNewClientSeed != null && !logginging) OnNewClientSeed(
                                        new SeedInfo
                                        {
                                            OldServerSeed = tmp.args[0].ToString(),
                                            OldServerHash = tmp.args[1].ToString(),
                                            OldClientSeed = tmp.args[2].ToString(),
                                            TotalRolls = tmp.args[3].ToString(),
                                            NewServerHash = tmp.args[4].ToString()
                                        }
                                        ); break;
                                    case "address": if (OnAddress != null && !logginging) OnAddress(new Address
                                    {
                                        DepositAddress = tmp.args[0].ToString(),
                                        ImageHTML= tmp.args[0].ToString(),
                                        Note = tmp.args[0].ToString(),
                                    }
                                    ); break;
                                    case "pong": if (OnPong != null && !logginging) OnPong(); break;
                                    //case "reload": Reconnect(); break;
                                }
                            }
                            catch (Exception E)
                            {
                                if (logging)
                                    writelog("Caught! " + E.Message);
                                throw E;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 void JD_onInvest(Invest InvestResult)
 {
     UpdateLable(lblInvestInvested, InvestResult.Amount.ToString());
     UpdateLable(lblInvestPercentage, InvestResult.Percentage.ToString());
     UpdateLable(lblMeInvested, InvestResult.Amount.ToString());
     UpdateLable(lblMeInvestProfit, InvestResult.Profit.ToString());
     UpdateLable(lblStatsINvestedOn, InvestResult.Amount.ToString());
     UpdateLable(lblStatsInvestedTotal, (InvestResult.Amount + InvestResult.Offsite).ToString());
     UpdateLable(lblStatsInvestProfit, InvestResult.Profit.ToString());
     UpdateLable(lblStatsInvestedOff, InvestResult.Offsite.ToString());
 }