Beispiel #1
0
        public string checkAppUpdate()
        {
            try
            {
                string    url       = "https://raw.githubusercontent.com/DearUnknown/PGLToolUpdate/master/PGLToolUpdate/VersionV1.0/checkUpdate.txt";
                WebClient webClient = new WebClient();
                webClient.DownloadFile(url, "Update/versionCheckUpdate.txt");

                FileStream   aFile = new FileStream("Update/versionCheckUpdate.txt", FileMode.Open);
                StreamReader sr    = new StreamReader(aFile);

                string line = sr.ReadLine();
                sr.Close();
                aFile.Close();
                File.Delete("Update/versionCheckUpdate.txt");
                if (line.Equals(GlobalConstants.APPVERSION))
                {
                    return("");
                }
                else
                {
                    return(line);
                }
            }
            catch (Exception e)
            {
                BugBox bb = new BugBox(e.ToString());
                bb.ShowDialog();
                return("");
            }
        }
Beispiel #2
0
        public ArrayList checkDataUpdate(string newVersion)
        {
            ArrayList gitVersions = new ArrayList();

            try
            {
                string    url       = "https://raw.githubusercontent.com/DearUnknown/PGLToolUpdate/master/PGLToolUpdate/Data/checkUpdate.txt";
                WebClient webClient = new WebClient();
                webClient.DownloadFile(url, "Update/dataCheckUpdate.txt");

                FileStream   aFile = new FileStream("Update/dataCheckUpdate.txt", FileMode.Open);
                StreamReader sr    = new StreamReader(aFile);

                for (int i = 0; i < GlobalConstants.GENERATION.Count; i++)
                {
                    gitVersions.Add(sr.ReadLine());
                }

                sr.Close();
                aFile.Close();
                File.Delete("Update/dataCheckUpdate.txt");

                if (!newVersion.Equals(""))
                {
                    int i;
                    for (i = 0; i < GlobalConstants.GENERATION.Count; i++)
                    {
                        if (gitVersions[i].ToString().Equals(newVersion))
                        {
                            break;
                        }
                    }
                    if (i == GlobalConstants.GENERATION.Count)
                    {
                        gitVersions.Clear();
                        return(gitVersions);
                    }
                }

                for (int i = 0; i < GlobalConstants.GENERATION.Count; i++)
                {
                    string localName = GlobalConstants.MOSTRECENTFILES[i].ToString().Split('/')[2];
                    long   localDate = long.Parse(localName.Split('-')[1] + localName.Split('-')[2]);
                    string gitName   = gitVersions[i].ToString().Split('/')[2];
                    long   gitDate   = long.Parse(gitName.Split('-')[1] + gitName.Split('-')[2]);
                    if (localDate > gitDate)
                    {
                        gitVersions.Clear();
                        return(gitVersions);
                    }
                    else if (localDate == gitDate)
                    {
                        gitVersions[i] = "";
                    }
                }

                return(gitVersions);
            }
            catch (Exception e)
            {
                BugBox bb = new BugBox(e.ToString());
                bb.ShowDialog();
                gitVersions.Clear();
                return(gitVersions);
            }
        }
Beispiel #3
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;
            }
        }