// 設定ファイルを更新する処理 // アップデートがある場合は0を返します // アップデートがない場合は1を返します private static int UpdateSettingFile(VRChatOpenBrowser c) { try { string uri = "https://raw.githubusercontent.com/YukiYukiVirtual/OpenBrowserServer/master/setting.yaml#" + DateTime.Now.ToString(); System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; string responseBody = client.GetStringAsync(uri).Result; File.WriteAllText("setting.yaml", responseBody); int firstLineEnd = responseBody.IndexOf("\r\n"); string version_latest = responseBody.Substring(2, firstLineEnd - 2); // "# v1.2.3".IndexOf("v") if (version_latest.Equals(version_local)) { return(1); } else { string msg = "更新があります。\n" + "現在のバージョン: " + version_local + "\n" + "最新バージョン: " + version_latest + "\n\n" + "プログラムを終了しますか?\n" + "(ダウンロードページを開くので手動で更新してください)"; DialogResult result = MessageBox.Show(msg, "Check Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { cmdstart("."); // フォルダを開く // ダウンロードページを開く OpenBrowser("https://yukiyukivirtual.booth.pm/items/2539784"); // アイコン、サーバーも止めて、プログラムを終了する c.ExitAll(); } } } catch (HttpRequestException e) { Logger.WriteLog(e); } return(0); }
public static void Main() { // 多重起動抑止処理 System.Threading.Mutex mutex = new System.Threading.Mutex(false, "VRChatOpenBrowser"); if (!mutex.WaitOne(0, false)) { MessageBox.Show("すでに起動しています。2つ同時には起動できません。", "多重起動禁止"); return; } // ログ開始 Logger.StartBlock(Logger.LogType.Session); Logger.TimeLog(); Logger.WriteLog(Logger.LogType.Version, "Version: " + version_local); Logger.EndBlock(); // Formアプリとしてインスタンス化 VRChatOpenBrowser inst = new VRChatOpenBrowser(); // 設定ファイル更新 UpdateSettingFile(inst); // 設定クラスをインスタンス化 settings = new Settings("setting.yaml"); // Boothで買ってほしい気持ち #if BOOTH { } #else { OpenBrowser("https://yukiyukivirtual.booth.pm/items/2539784"); } #endif // サーバーを起動する StartServer(); Application.Run(); }