Exemplo n.º 1
0
        /// <summary>
        /// 加载正则表达式配置文件
        /// </summary>
        private void LoadRegexJson()
        {
            try
            {
                StreamReader sr   = new StreamReader("EachListRegex.json", Encoding.Unicode);
                var          json = sr.ReadToEnd();
                sr.Dispose();

                RegexHelp.ListRegex = JsonHelp.DeserializeObject <List <EachListRegex> >(json);
            }
            catch (Exception e)
            {
                MessageBox.Show("加载配置文件失败!");
            }
        }
Exemplo n.º 2
0
        private void UpdateSoft()
        {
            try
            {
                var url  = XmlHelp.GetInnerTextByPath("Config:UpdateUrl");
                var json = HtmlHelp.Get(url);

                var result = JsonHelp.DeserializeObject <ResultEntity>(json);

                if (result.Code == "1")
                {
                    var url2 = XmlHelp.GetInnerTextByPath("Config:WebUrl");
                    var zip  = Path.GetFileName(result.FileName);
                    var b    = HtmlHelp.DownFile(url2 + result.FileName, zip, progressBar1);

                    if (!b)
                    {
                        throw new Exception();
                    }

                    //解压下载的文件
                    var aPath = Application.StartupPath + "/";
                    ZipHelp.ExtractToDirectory(zip, aPath + "NewPixiv");

                    //删除下载的压缩文件
                    File.Delete(aPath + zip);

                    //替换文件
                    ReplaceFile(aPath, aPath + "NewPixiv");

                    //删除解压后的文件
                    Directory.Delete(aPath + "NewPixiv", true);

                    //重新启动主程序
                    var mainPreocess = XmlHelp.GetInnerTextByPath("Config:MainProcess");
                    Process.Start(mainPreocess);
                }
                else
                {
                    MessageBox.Show(result.Message);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("更新文件失败!");
            }
        }
Exemplo n.º 3
0
        private void CheckUpdate()
        {
            try
            {
                var updateFile = XmlHelp.GetInnerTextByPath("Config:UpdateFileName");

                var ps = Process.GetProcessesByName(updateFile.Replace(".exe", ""));
                foreach (var p in ps)
                {
                    p.Kill();
                }
                if (File.Exists(updateFile))
                {
                    File.Delete(updateFile);
                }

                var url = XmlHelp.GetInnerTextByPath("Config:CheckVersionUrl");

                var json = HtmlHelp.Get(url);

                var result = JsonHelp.DeserializeObject <ResultEntity>(json);

                if (result.Code == "-1")
                {
                    MessageBox.Show(result.Message);
                }
                else if (result.Code == "1")
                {
                    UpdateDetailForm f = new UpdateDetailForm();
                    f.updateSoft   = result.UpdateSoft;
                    f.updateDetail = result.UpdateDetail;

                    f.Show();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("检查更新失败!");
                //MessageBox.Show(e.Message);
            }
        }