示例#1
0
        //thread starts
        private void startUpdate(object sender, DoWorkEventArgs e)
        {
            int finished = 0;

            try
            {
                for (int i = 0; i < GlobalConstants.GENERATION.Count; i++)
                {
                    foreach (TreeNode season in treeView1.Nodes[i].Nodes)
                    {
                        if (season.Checked)
                        {
                            UpdateBySqls ubs = new UpdateBySqls("Data/" + GlobalConstants.GENERATION[i] + "/" + season.Text);
                            for (int j = 0; j < 6; j++)
                            {
                                myWebClient.DownloadFile(url + "/" + GlobalConstants.GENERATION[i] + "/" + season.Text + "/" + j + ".txt", "Update/" + j + ".txt");
                                ubs.setTable(j, "Update/" + j + ".txt");
                                File.Delete("Update/" + j + ".txt");
                                finished++;
                                bkWorker.ReportProgress(finished * 100 / total, true);
                            }
                        }
                    }
                }
            }
            catch { }
        }
示例#2
0
        //thread starts
        private void startUpdate(object sender, DoWorkEventArgs e)
        {
            try
            {
                string fetchMessage;

                int done = 0;
                for (int i = 0; i < treeView1.Nodes.Count; i++)
                {
                    if (generationTotal[i] == 0)
                    {
                        continue;
                    }

                    int[] blankTable = (int[])newTables[i];
                    int   index      = 0;

                    if (radioButton2.Checked)
                    {
                        UpdateBySqls ubs         = new UpdateBySqls(gitTasks[i].ToString());
                        string       url         = "https://raw.githubusercontent.com/DearUnknown/PGLToolUpdate/master/PGLToolUpdate/" + gitTasks[i].ToString();
                        WebClient    myWebClient = new WebClient();
                        for (int j = 0; j < treeView1.Nodes[i].Nodes.Count; j++)
                        {
                            while (blankTable[index] == 0)
                            {
                                index++;
                            }
                            if (treeView1.Nodes[i].Nodes[j].Checked)
                            {
                                try
                                {
                                    myWebClient.DownloadFile(url + "/" + index + ".txt", "Update/" + index + ".txt");
                                }
                                catch (Exception e0)
                                {
                                    BugBox bb = new BugBox(url + "/" + index + ".txt\r\n" + "Update/" + index + ".txt\r\n" + e0.ToString());
                                    bb.ShowDialog();
                                }
                                ubs.setTable(index, "Update/" + index + ".txt");
                                File.Delete("Update/" + index + ".txt");
                            }
                            index++;
                        }

                        for (int j = 0; j < GlobalConstants.GENERATION.Count; j++)
                        {
                            if (gitVersions[j].ToString().Equals(gitTasks[i].ToString()))
                            {
                                Config.setConfig("MostRecentFile" + (j + 1).ToString(), gitTasks[i].ToString());
                            }
                        }

                        continue;
                    }

                    Fetch fetch = (Fetch)fetchTasks[i];
                    if (fetch.serverStatus == -1)
                    {
                        bkWorker.ReportProgress(1, "无法连接PGL服务器,请确认服务器是否在维护\r\n");
                        errorExists = true;
                        return;
                    }
                    fetch.updateInitial(done, total, bkWorker, pkIdList);

                    for (int j = 0; j < treeView1.Nodes[i].Nodes.Count; j++)
                    {
                        while (blankTable[index] == 0)
                        {
                            index++;
                        }
                        if (treeView1.Nodes[i].Nodes[j].Checked)
                        {
                            stopwatch.Restart();
                            fetchMessage = fetch.getSeasonPokemonDetail(index);
                            stopwatch.Stop();
                            timeSpan = stopwatch.Elapsed;
                            bkWorker.ReportProgress(1, fetchMessage + "用时" + ((int)timeSpan.TotalSeconds) / 60 + "分" + ((int)timeSpan.TotalSeconds) % 60 + "秒\r\n");
                        }
                        index++;
                    }
                    done += generationTotal[i];
                    Config.setConfig("MostRecentFile" + fetch.generationId, fetch.mostUpdated);
                }
            }
            catch (Exception ex)
            {
                bkWorker.ReportProgress(1, ex.ToString() + "\r\n");
                errorExists = true;
            }
        }