Exemple #1
0
 private void UpdateRight()         //检查更新
 {
     #if DEBUG
     return;
     #endif
     if (File.Exists("UpdateBash.bat"))
     {
         File.Delete("UpdateBash.bat");
         if (File.Exists("run.vbs"))
         {
             File.Delete("run.vbs");
         }
         this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
         {
             SSMessageHelper.noNo = true;
             ButtonHelper.SetIcon(SSMessageHelper.Icon, "");
             SSMessageHelper.Title    = "更新完成";
             SSMessageHelper.Says     = "我们成功更新了 SSTB !开始体验全新的功能吧!";
             SSMessageBox MB          = new SSMessageBox();
             this.IsMaskVisible       = true;
             MB.WindowStartupLocation = WindowStartupLocation.CenterOwner;
             MB.Owner = this;
             MB.ShowDialog();
             this.IsMaskVisible = false;
         });
     }
     error.logWriter("检查更新……", false);
     string GetJson;
     String saysuri = "https://stapxs.neocities.org/SSTB-NowVersion.txt";
     try
     {
         ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
         GetJson = HttpUitls.Get(saysuri, "DEFALT");
     }
     catch (Exception ex)
     {
         error.logWriter("检查更新错误 :" + ex, false);
         return;
     }
     if (String.IsNullOrWhiteSpace(GetJson))
     {
         return;
     }
     JObject obj = JObject.Parse(GetJson);
     if (int.Parse(obj["Version"].ToString()) != nUpdateVersion)
     {
         this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
         {
             SSMessageHelper.noNo = true;
             ButtonHelper.SetIcon(SSMessageHelper.Icon, "");
             SSMessageHelper.Title    = "发现更新";
             SSMessageHelper.Says     = "我们检查到了版本更新,但是由于更新文件版本不符,我们无法确认更新的可用性,请手动确认版本更新。\n(当前软件内更新文件标记版本为 " + nUpdateVersion + " ,获取到的更新文件标记版本为 " + obj["Version"].ToString() + " )";
             SSMessageBox MB          = new SSMessageBox();
             this.IsMaskVisible       = true;
             MB.WindowStartupLocation = WindowStartupLocation.CenterOwner;
             MB.Owner = this;
             MB.ShowDialog();
             this.IsMaskVisible = false;
         });
     }
     else
     {
         if (!obj["MainVersion"].ToString().Equals(stVersion))
         {
             this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate()
             {
                 SSMessageHelper.noNo = false;
                 ButtonHelper.SetIcon(SSMessageHelper.Icon, "");
                 SSMessageHelper.bOKtext  = "在线更新";
                 SSMessageHelper.bNOtext  = "知道了";
                 SSMessageHelper.Title    = "发现更新";
                 SSMessageHelper.Says     = "我们检查到了版本更新,最新版本为:" + obj["MainVersion"].ToString() + ",更新时间:" + obj["Time"].ToString() + ",选择在线更新将从GitHub在线下载。\n( GitHub 有约1小时的CDN缓存延时,建议在更新时间一小时后更新 )\n更新日志如下:\n" + obj["Logs"].ToString();
                 SSMessageBox MB          = new SSMessageBox();
                 this.IsMaskVisible       = true;
                 MB.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                 MB.Owner = this;
                 MB.ShowDialog();
                 this.IsMaskVisible      = false;
                 SSMessageHelper.bOKtext = "好的";
                 if (SSMessageHelper.buttonOK)
                 {
                     Updater UP               = new Updater();
                     UP.ParentWindow          = this;
                     UP.url                   = obj["Url"].ToString();
                     this.IsMaskVisible       = true;
                     UP.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                     UP.Owner                 = this;
                     UP.ShowDialog();
                     this.IsMaskVisible = false;
                     if (UpdateFin == true)
                     {
                         string where = Directory.GetCurrentDirectory();
                         where        = where + @"\run.vbs";
                         System.Diagnostics.Process process;
                         process = System.Diagnostics.Process.Start(@where);
                         Application.Current.Shutdown();
                     }
                 }
             });
         }
     }
     error.logWriter("检查更新完成。", false);
 }
Exemple #2
0
        private void WContentRendered(object sender, EventArgs e)
        {
            if (SetVerErr)
            {
                SetVerErr            = false;
                SSMessageHelper.noNo = false;
                ButtonHelper.SetIcon(SSMessageHelper.Icon, "");
                SSMessageHelper.Title = "设置文件版本不符";
                SSMessageHelper.Says  = "我们发现设置文件版本不符,将对设置文件进行重写。选择取消将退出程序。";
                SSMessageBox MB = new SSMessageBox();
                this.IsMaskVisible       = true;
                MB.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                MB.Owner = this;
                MB.ShowDialog();
                this.IsMaskVisible = false;
                error.logWriter("设置文件版本不符", false);
                if (SSMessageHelper.buttonNO)
                {
                    Application.Current.Shutdown();
                }
                else
                {
                    File.Delete("SSTB/Setup.json");
                    Settings = Set.newSetup();
                }
            }
            if (!Directory.Exists("SSTB/Files"))
            {
                Directory.CreateDirectory("SSTB/Files");
            }
            if (!File.Exists("SSTB/Files/jrrp.dat"))
            {
                try
                {
                    File.AppendAllText("SSTB/Files/jrrp.dat", System.DateTime.Now.ToString("yyyy-MM"));
                }
                catch { }
            }
            string temp;

            using (StreamReader sr = new StreamReader("SSTB/Files/jrrp.dat", Encoding.Default))
            {
                temp = sr.ReadLine();
            }
            if (!temp.Equals(System.DateTime.Now.ToString("yyyy-MM-dd")))
            {
                try
                {
                    File.Delete("SSTB/Files/jrrp.dat");
                    File.AppendAllText("SSTB/Files/jrrp.dat", System.DateTime.Now.ToString("yyyy-MM-dd"));
                }
                catch { }
                Random random = new Random();

                int      all      = 11 + 1;
                string[] sayslist = new string[all];
                sayslist[0]  = "今天也要加油啦!";
                sayslist[1]  = "你好世界。";
                sayslist[2]  = "不挖坑,毋宁死!";
                sayslist[3]  = "人生如梦……TMD怎么还不醒啊喂!";
                sayslist[4]  = "有点自信吧,即使在深渊之中。";
                sayslist[5]  = "山城无处不飞花。";
                sayslist[6]  = "旅者的努力,或许就是为了那期待的,远处的一片风景。";
                sayslist[7]  = "现在做的事情,可能就是为了将来能在别人面前装个逼吧。";
                sayslist[8]  = "感谢遇到你。";
                sayslist[9]  = "既然身边每个人都在为之努力,那你为什么不加油呢?";
                sayslist[10] = "人类这么优秀,一定做得到的!";
                sayslist[11] = "遇到困难的话就一鼓作气冲好了,总之,生活不是游戏。(这话好像在哪听过)";

                int    num    = random.Next(0, 100);
                string say    = "欢迎使用林槐工具箱!今天的人品是 " + num + " ,";
                int    numsay = random.Next(0, all - 1);
                say = say + sayslist[numsay];
                if (numsay == 0 || numsay == 4 || numsay == 8 || numsay == 9 || numsay == 11)
                {
                    SSMessageHelper.bOKtext = "谢谢";
                }
                SSMessageHelper.noNo = true;
                ButtonHelper.SetIcon(SSMessageHelper.Icon, "");
                SSMessageHelper.Title = "欢迎!";
                SSMessageHelper.Says  = say;
                SSMessageBox MB = new SSMessageBox();
                this.IsMaskVisible       = true;
                MB.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                MB.Owner = this;
                MB.ShowDialog();
                this.IsMaskVisible      = false;
                SSMessageHelper.bOKtext = "好的";
            }
        }