internal static void Load() { try { if (string.IsNullOrEmpty(Settings.PathToSkyrim)) { return; } string path = $"{Settings.PathToSkyrim}\\version.json"; if (File.Exists(path)) { lock (sync) model = JsonConvert.DeserializeObject <ModVersionModel>(File.ReadAllText(path)); } else { model = new ModVersionModel(); } } catch (Exception e) { Logger.Error("Version_Load", e); model = new ModVersionModel(); } ExperimentalFunctions.Use("ModVerLoad", () => { if (model == null) { model = new ModVersionModel(); } }); }
private async void MainBtn_Click(object sender, EventArgs e) { if (blockMainBtn) { return; } blockMainBtn = true; switch (mainButton.ButtonStatus) { case MainButtonStatus.Play: await Play(); break; case MainButtonStatus.Update: if (ExperimentalFunctions.HasExperimentalFunctions()) { await UpdateClientNew(); } else { await UpdateClientOld(); } break; case MainButtonStatus.Retry: await CheckClientUpdates(); break; } blockMainBtn = false; }
public static void Init(Version version) { try { StringBuilder uriString = new StringBuilder(); uriString.Append("pack://*****:*****@sentry.skyrez.su/4"); options.Release = version.ToString(); options.BeforeSend = SentryEvent; }); string tmpPath = Settings.PathToLocalTmp; if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } YandexMetricaFolder.SetCurrent(tmpPath); ExperimentalFunctions.IfUse("SetVers", () => { Version nv = new Version(version.Major, version.Minor, version.Build, version.Revision + 100); YandexMetrica.Config.CustomAppVersion = nv; }, () => { YandexMetrica.Config.CustomAppVersion = version; }); }
public static void Init(Version version) { try { string tmpPath = DefaultPaths.PathToLocalTmp; IO.CreateDirectory(tmpPath); YandexMetricaFolder.SetCurrent(tmpPath); ExperimentalFunctions.IfUse("SetVers", () => { Version nv = new Version(version.Major, version.Minor, version.Build, version.Revision + 100); YandexMetrica.Config.CustomAppVersion = nv; }, () => { YandexMetrica.Config.CustomAppVersion = version; }); } catch { } }
private async void Wind_Loaded(object sender, RoutedEventArgs e) { try { if (Settings.ExperimentalFunctions == null) { MessageBoxResult result = MessageBox.Show(Res.ExperimentalFeaturesText.Replace(@"\n", "\n"), Res.ExperimentalFeatures, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { Settings.ExperimentalFunctions = true; } else { Settings.ExperimentalFunctions = false; } Settings.Save(); } } catch (Exception er) { Logger.Error("ExpFunc", er); } Mods.Init(); if (ExperimentalFunctions.HasExperimentalFunctions()) { if (!Mods.ExistMod("SkyMPCore")) { MessageBox.Show("All files will be reinstalled", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation, MessageBoxResult.OK); GameCleaner.Clear(); } await CheckGameNew(); } else { await CheckGameOld(); } SetBackgroundServerList(); FillServerList(); Authorization_SignIn(); }
public void TestVectorUdf() { Func <Int32Array, StringArray, StringArray> udf1Func = (ages, names) => (StringArray)ToArrowArray( Enumerable.Range(0, names.Length) .Select(i => $"{names.GetString(i)} is {ages.GetValue(i) ?? 0}") .ToArray()); // Single UDF. Func <Column, Column, Column> udf1 = ExperimentalFunctions.VectorUdf(udf1Func); { Row[] rows = _df.Select(udf1(_df["age"], _df["name"])).Collect().ToArray(); Assert.Equal(3, rows.Length); Assert.Equal("Michael is 0", rows[0].GetAs <string>(0)); Assert.Equal("Andy is 30", rows[1].GetAs <string>(0)); Assert.Equal("Justin is 19", rows[2].GetAs <string>(0)); } // Chained UDFs. Func <Column, Column> udf2 = ExperimentalFunctions.VectorUdf <StringArray, StringArray>( (strings) => (StringArray)ToArrowArray( Enumerable.Range(0, strings.Length) .Select(i => $"hello {strings.GetString(i)}!") .ToArray())); { Row[] rows = _df .Select(udf2(udf1(_df["age"], _df["name"]))) .Collect() .ToArray(); Assert.Equal(3, rows.Length); Assert.Equal("hello Michael is 0!", rows[0].GetAs <string>(0)); Assert.Equal("hello Andy is 30!", rows[1].GetAs <string>(0)); Assert.Equal("hello Justin is 19!", rows[2].GetAs <string>(0)); } // Multiple UDFs: { Row[] rows = _df .Select(udf1(_df["age"], _df["name"]), udf2(_df["name"])) .Collect() .ToArray(); Assert.Equal(3, rows.Length); Assert.Equal("Michael is 0", rows[0].GetAs <string>(0)); Assert.Equal("hello Michael!", rows[0].GetAs <string>(1)); Assert.Equal("Andy is 30", rows[1].GetAs <string>(0)); Assert.Equal("hello Andy!", rows[1].GetAs <string>(1)); Assert.Equal("Justin is 19", rows[2].GetAs <string>(0)); Assert.Equal("hello Justin!", rows[2].GetAs <string>(1)); } // Register UDF { _df.CreateOrReplaceTempView("people"); _spark.Udf().RegisterVector("udf1", udf1Func); Row[] rows = _spark.Sql("SELECT udf1(age, name) FROM people") .Collect() .ToArray(); Assert.Equal(3, rows.Length); Assert.Equal("Michael is 0", rows[0].GetAs <string>(0)); Assert.Equal("Andy is 30", rows[1].GetAs <string>(0)); Assert.Equal("Justin is 19", rows[2].GetAs <string>(0)); } }
private bool HandleCmdArgs() { string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { bool eUpdate = false; int trying = 0; try { switch (args[1]) { case EndUpdate: eUpdate = true; Thread.Sleep(250); try { if (File.Exists($"{args[2]}.update.exe")) { File.SetAttributes($"{args[2]}.update.exe", FileAttributes.Normal); File.Delete($"{args[2]}.update.exe"); } } catch (IOException io) //фикс ошибки занятого файла, он должен освободится через какое то время { trying++; if (trying < 5) { goto case EndUpdate; } else { throw new TimeoutException("Timeout \"EndUpdate\"", io); } } break; case BeginUpdate: Thread.Sleep(250); try { File.Copy(FullPathToSelfExe, $"{args[2]}.exe", true); File.SetAttributes($"{args[2]}.exe", FileAttributes.Normal); } catch (IOException io) //фикс ошибки занятого файла, он должен освободится через какое то время { trying++; if (trying < 5) { goto case BeginUpdate; } else { throw new TimeoutException("Timeout \"BeginUpdate\"", io); } } Process.Start($"{args[2]}.exe", $"{EndUpdate} {args[2]}"); goto default; case "repair": Settings.Reset(); break; case "repair-client": try { ModVersion.Reset(); } catch (Exception e) { MessageBox.Show($"{e.Message}", $"{Res.Error}"); } goto default; case "clear-client": try { ExperimentalFunctions.IfUse("Cleaner", () => { Mods.Init(); Mods.DisableAll(true); }, () => GameCleaner.Clear()); } catch (Exception e) { MessageBox.Show($"{e.Message}", $"{Res.Error}"); } goto default; case "clear-full-client": try { ExperimentalFunctions.IfUse("Cleaner", () => { Mods.Init(); Mods.DisableAll(true); }, () => GameCleaner.Clear(true)); } catch (Exception e) { MessageBox.Show($"{e.Message}", $"{Res.Error}"); } goto default; default: ExitApp(); return(false); } } catch (UnauthorizedAccessException e) { if (!eUpdate) { MessageBox.Show($"{Res.ErrorEndSelfUpdate}\n{e.Message}", $"{Res.Error}"); return(false); } } catch (Exception e) { Logger.Error("HandleCmdArgs", e); return(false); } } return(true); }
private async Task <bool> SetMods(string adress) { string path = Settings.PathToLocalSkyrim + "Plugins.txt"; string content = ""; #if (DEBUG) bool d = true; #else bool d = false; #endif if (d || (NetworkSettings.EnableModLoader && ExperimentalFunctions.HasExperimentalFunctions())) { try { Mods.DisableAll(); ServerModsManifest mods = Mods.CheckCore(await GetManifest(adress)); Dictionary <string, List <(string, uint)> > needMods = GetMods(mods); foreach (KeyValuePair <string, List <(string, uint)> > mod in needMods) { if (!Mods.ExistMod(mod.Key) || !Mods.CheckMod(mod.Key, mod.Value)) { string tmpPath = Mods.GetTmpPath(); string desPath = tmpPath + "\\Data\\"; IO.CreateDirectory(desPath); string mainFile = null; foreach (var file in mod.Value) { await DownloadMod(desPath + file.Item1, adress, file.Item1); if (mods.LoadOrder.Contains(file.Item1)) { mainFile = file.Item1; } } Mods.AddMod(mod.Key, "", tmpPath, true, mainFile); } Mods.EnableMod(Path.GetFileNameWithoutExtension(mod.Key)); } foreach (var item in mods.LoadOrder) { content += $"*{item}\n"; } } catch (WebException) { if (NetworkSettings.CompatibilityMode) { NotifyController.Show(PopupNotify.Normal, Res.Attempt, "Вероятно целевой сервер устер, используется режим совместимости"); if (Mods.ExistMod("Farm")) { Mods.OldModeEnable(); } await Task.Delay(3000); content = @"*FarmSystem.esp"; } else { NotifyController.Show(PopupNotify.Error, Res.Attempt, "Возможно целевой сервер устарел, так как не ответил на запрос"); return(false); } } catch (FileNotFoundException) { NotifyController.Show(PopupNotify.Error, Res.Error, "Один или несколько модов не удалось загрузить с сервера"); return(false); } catch (Exception e) { Logger.Error("EnablerMods", e); NotifyController.Show(e); return(false); } } else { content = @"*FarmSystem.esp"; } try { if (!Directory.Exists(Settings.PathToLocalSkyrim)) { Directory.CreateDirectory(Settings.PathToLocalSkyrim); } if (File.Exists(path) && File.GetAttributes(path) != FileAttributes.Normal) { File.SetAttributes(path, FileAttributes.Normal); } File.WriteAllText(path, content); } catch (UnauthorizedAccessException) { FileAttributes attr = new FileInfo(path).Attributes; Logger.Error("Write_Plugin_UAException", new UnauthorizedAccessException($"UnAuthorizedAccessException: Unable to access file. Attributes: {attr}")); } catch (Exception e) { Logger.Error("Write_Plugin_txt", e); } return(true); }
private async Task Play() { if (!File.Exists($"{Settings.PathToSkyrim}\\skse64_loader.exe")) { await Task.Run(() => ExperimentalFunctions.IfUse("ModsInit", () => CheckGameNew().Wait(), () => CheckGameOld().Wait())); return; } if (serverList.SelectedItem == null) { NotifyController.Show(PopupNotify.Error, Res.Warning, Res.SelectServer); return; } string adressData; try { if (Directory.Exists(Path.GetDirectoryName(Settings.PathToSkympClientSettings)) && File.Exists(Settings.PathToSkympClientSettings)) { File.SetAttributes(Settings.PathToSkympClientSettings, FileAttributes.Normal); } SetServer(); string adress = ((ServerModel)serverList.SelectedItem).Address; adressData = ((ServerModel)serverList.SelectedItem).AddressData; object gameData = await Account.GetSession(adress); if (gameData == null) { return; } SetSession(gameData); } catch (JsonSerializationException) { NotifyController.Show(PopupNotify.Error, Res.Error, Res.ErrorReadSkyMPSettings); return; } catch (JsonReaderException) { NotifyController.Show(PopupNotify.Error, Res.Error, Res.ErrorReadSkyMPSettings); return; } catch (UnauthorizedAccessException) { FileAttributes attr = new FileInfo(Settings.PathToSkympClientSettings).Attributes; Logger.Error("Play_UAException", new UnauthorizedAccessException($"UnAuthorizedAccessException: Unable to access file. Attributes: {attr}")); NotifyController.Show(PopupNotify.Error, Res.Error, "UnAuthorizedAccessException: Unable to access file"); return; } catch (Exception e) { Logger.Error("Play", e); NotifyController.Show(PopupNotify.Error, Res.Error, e.Message); return; } if (!await SetMods(adressData)) { return; } try { Hide(); bool crash = await GameLauncher.StartGame(); Show(); if (crash) { YandexMetrica.ReportEvent("CrashDetected"); await Task.Delay(500); await ReportDmp(); } } catch { YandexMetrica.ReportEvent("HasNotAccess"); Close(); } }