Ejemplo n.º 1
0
 public NewVersion(Types.Version version)
 {
     InitializeComponent();
     this.version = version;
     exec.downloadProgressChange += NewVersion_ProgressChange;
     exec.downloadProgressDone   += NewVersion_ProgressDone;
 }
Ejemplo n.º 2
0
        bool initialization(System.ComponentModel.DoWorkEventArgs e)
        {
            //check new version>
            WebClient client           = new WebClient();
            String    downloadedString = client.DownloadString("https://raw.githubusercontent.com/0x6b656e/SimpleWallet/master/version.json");

            Types.Version parse = JsonConvert.DeserializeObject <Types.Version>(downloadedString);
            if (Types.time < parse.time)
            {
                NewVersion nVer = new NewVersion(parse);
                nVer.ShowDialog();
                if (nVer.isFinished)
                {
                    return(false);
                }
            }


            api.checkConfig();
            currStatus = "Checking params...";
            //lbCurrentStatus.Invoke(new Action(() => lbCurrentStatus.Text = currStatus));
            bool downloadFile = exec.checkParamsFile(verifyingKey, provingKey);

            if (downloadFile)
            {
                pbProcess.Invoke(new Action(() => pbProcess.Visible = true));
                currStatus = "Downloading params";
                //lbCurrentStatus.Invoke(new Action(() => lbCurrentStatus.Text = currStatus));
                downloadFile = Task.Run(() => exec.downloadParams(verifyingKey, Types.DownloadFileType.VERIFYING)).Result;
                if (!downloadFile)
                {
                    veriStatus = true;
                }
                downloadFile |= Task.Run(() => exec.downloadParams(provingKey, Types.DownloadFileType.PROVING)).Result;
                if (downloadFile)
                {
                    checkParamsDone = false;
                }
                else
                {
                    provStatus = true;
                }
            }
            else
            {
                veriStatus      = true;
                provStatus      = true;
                checkParamsDone = true;
                if (start.isEnableAutoBackup())
                {
                    command += " -backupwallet";
                }
                Task.Run(() =>
                         api.startWallet(command));
            }
            Thread.Sleep(1000);
            int countdot = 0;

            while (true)
            {
                if (e.Cancel)
                {
                    break;
                }
                if (checkParamsDone)
                {
                    Dictionary <String, String> data = api.checkWallet();
                    if (Api.checkResult(data))
                    {
                        if (Api.getResult(data) == "success")
                        {
                            break;
                        }
                        else if (Api.getResult(data) == "fail")
                        {
                            currStatus = data["message"];
                        }
                        else
                        {
                            currStatus = data["message"];
                        }
                    }
                }
                else
                {
                    if (countdot < 3)
                    {
                        currStatus = "Downloading params";
                    }
                    else if (countdot < 6)
                    {
                        currStatus = "Downloading params.";
                    }
                    else if (countdot < 9)
                    {
                        currStatus = "Downloading params..";
                    }
                    else if (countdot < 12)
                    {
                        currStatus = "Downloading params...";
                    }
                    else
                    {
                        countdot = 0;
                    }
                }
                countdot++;

                Thread.Sleep(200);
            }

            return(true);
        }