private void assert_parses(string val, Conf obj) { var assertions = obj.ToHash(); var territory_name = assertions.DeleteOrUseDefault("with_territory", Context.DefaultTerritoryName); var number = Context.Parse(val, (string) territory_name); Assert.That(number,Is.TypeOf<Number>()); Assert.That(new { country_code = number.CountryCode, national_string = number.NationalString }.ToHash(), Is.EquivalentTo(assertions)); }
public async Task <bool> ExecuteAsync(TelegramBotClient botClient, Update update) { if (update.Message.ReplyToMessage == null || update.Message.ReplyToMessage.ForwardFrom == null) { return(false); } UnbanUser(update.Message.ReplyToMessage.ForwardFrom.Id); _ = await Conf.SaveConf(false, true).ConfigureAwait(false); _ = await botClient.SendTextMessageAsync( update.Message.From.Id, Vars.CurrentLang.Message_UserPardoned, ParseMode.Markdown, false, Vars.CurrentConf.DisableNotifications, update.Message.MessageId).ConfigureAwait(false); return(true); }
private void LoadConfiguration(Config config) { if (config == null) { config = Conf.Get(Conf.Names.NetworkingConfig); } if (String.IsNullOrEmpty(name)) { // Whats a good default value ? name = config.GetOption(Conf.Names.ServiceName, String.Empty); } // Check to see if our enabled status hasn't changed if (enabled != config.GetOption(Conf.Names.ServiceEnabled, enabled)) { enabled = config.GetOption(Conf.Names.ServiceEnabled, enabled); if (enabled) { try { Publish(); } catch (ClientException) { Log.Error("Could not start avahi"); return; } } else { Unpublish(); } Logger.Log.Info("Zeroconf: Index sharing is {0}", enabled ? "enabled" : "disabled"); } // Handle index name changes if (String.Compare(name, config.GetOption(Conf.Names.ServiceName, name)) != 0) { Update(); } }
bool _cacheRefresh;//�L���b�V�����| public Cache(Kernel kernel, Logger logger, Conf conf) : base(logger) { this.logger = logger; //_oneOption = oneOption; _conf = conf; _useCache = (bool)conf.Get("useCache"); if (!_useCache) { return; } _expires = (int)conf.Get("expires"); _maxSize = (int)conf.Get("maxSize"); _diskSize = (int)conf.Get("diskSize"); _memorySize = (int)conf.Get("memorySize"); //�L���b�V���Ώۃ��X�g _cacheTargetHost = new CacheTarget((Dat)conf.Get("cacheHost"), (int)conf.Get("enableHost")); _cacheTargetExt = new CacheTarget((Dat)conf.Get("cacheExt"), (int)conf.Get("enableExt")); //�f�B�X�N�L���b�V�� var cacheDir = (string)conf.Get("cacheDir");//�L���b�V����ۑ�����f�B���N�g�� if (cacheDir == "" || !Directory.Exists(cacheDir)) { logger.Set(LogKind.Error, null, 15, string.Format("dir = {0}", cacheDir)); _diskSize = 0; } if (_diskSize != 0) { _diskCache = new DiskCache(cacheDir, logger); } if (_memorySize != 0)//�������L���b�V�� { _memoryCache = new MemoryCache(logger); } }
// MainWindow Constructor public MainWindow() : base(Gtk.WindowType.Toplevel) { Build (); entry_dvd.Changed += OnEntry_dvdChanged; // Adds "*.dvd" fillter to FileChooserDialog FileFilter filter = new FileFilter(); filter.Name="*.dvd"; filter.AddPattern("*.dvd"); filechooserbutton.AddFilter(filter); UnixUserInfo user = UnixUserInfo.GetRealUser(); // Checks existing of configuration file and loads configuration of the programm if (!Directory.Exists(user.HomeDirectory + "/.linxbox360burner")) Directory.CreateDirectory(user.HomeDirectory + "/.linxbox360burner"); if (!File.Exists(user.HomeDirectory + "/.linxbox360burner/conf")) { config = new Conf(); config.Commit(); } else { config = new Conf(user.HomeDirectory + "/.linxbox360burner/conf"); } if (config.dvdrwremember) entry_dvd.Text = config.dvdrw; dvddrive = new DVDdrive (entry_dvd.Text); dvddrive.GetMediaInfo(); Gnome.Vfs.Vfs.Initialize(); vm = Gnome.Vfs.VolumeMonitor.Get(); vm.VolumeMounted += delegate(object o, Gnome.Vfs.VolumeMountedArgs args) { DriveStateChanged(); }; vm.VolumeUnmounted += delegate(object o, Gnome.Vfs.VolumeUnmountedArgs args) { DriveStateChanged(); }; }
public async Task <bool> Process() { Log("Application version: " + Vars.AppVer.ToString(), "CMD"); Log("Checking for updates...", "CMD"); var Latest = Conf.CheckForUpdates(); if (Conf.IsNewerVersionAvailable(Latest)) { Log("Newer version found: " + Latest.Latest + ", main changes:\n" + Latest.Details, "CMD"); Log("Updating...", "CMD"); Log("Starting update download... (pmcenter_update.zip)", "CMD"); var Downloader = new WebClient(); await Downloader.DownloadFileTaskAsync( new Uri(Vars.UpdateArchiveURL), Path.Combine(Vars.AppDirectory, "pmcenter_update.zip")); Log("Download complete. Extracting...", "CMD"); using (ZipArchive Zip = ZipFile.OpenRead(Path.Combine(Vars.AppDirectory, "pmcenter_update.zip"))) { foreach (ZipArchiveEntry Entry in Zip.Entries) { Log("Extracting: " + Path.Combine(Vars.AppDirectory, Entry.FullName), "CMD"); Entry.ExtractToFile(Path.Combine(Vars.AppDirectory, Entry.FullName), true); } } Log("Starting language file update...", "CMD"); await Downloader.DownloadFileTaskAsync( new Uri(Vars.CurrentConf.LangURL), Path.Combine(Vars.AppDirectory, "pmcenter_locale.json") ); Log("Cleaning up temporary files...", "CMD"); File.Delete(Path.Combine(Vars.AppDirectory, "pmcenter_update.zip")); Log("Update complete.", "CMD"); } else { Log("No newer version found.\nCurrently installed version: " + Vars.AppVer.ToString() + "\nThe latest version is: " + Latest.Latest, "CMD"); } return(true); }
/// <summary> /// 在应用程序由最终用户正常启动时进行调用。 /// 将在启动应用程序以打开特定文件等情况下使用。 /// </summary> /// <param name="e">有关启动请求和过程的详细信息。</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { var rootFrame = Window.Current.Content as Frame; Conf.Log("logs may not appear as soon as they're logged, refer to the timestamp as standard.", LogLevel.Warning); // read settings Conf.Log("reading settings..."); _ = Conf.Read(); Conf.Log("settings read successfully.", LogLevel.Complete); // 不要在窗口已包含内容时重复应用程序初始化, // 只需确保窗口处于活动状态 if (rootFrame == null) { // 创建要充当导航上下文的框架,并导航到第一页 rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: 从之前挂起的应用程序加载状态 } // 将框架放在当前窗口中 Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // 当导航堆栈尚未还原时,导航到第一页, // 并通过将所需信息作为导航参数传入来配置 // 参数 rootFrame.Navigate(typeof(MainPage), e.Arguments); } // 确保当前窗口处于活动状态 Window.Current.Activate(); } }
public override async void Start() { Log("插件启动中"); var loadWindow = new Windows.LoadingWindowLight(); try { loadWindow.IsOpen = true; loadWindow.ProgressBar.Value = 30; Conf.Delay(10); ALog("正在检查配置"); await Conf.InitiateAsync(); loadWindow.ProgressBar.Value = 60; Conf.Delay(10); ALog("配置初始化成功"); ALog("正在启用播放器"); TTSPlayer.Init(); loadWindow.ProgressBar.Value = 80; Conf.Delay(10); if (Vars.CurrentConf.AutoUpdate) { ALog("正在启动更新检查"); Thread updateChecker = new Thread(() => UpdateThread()); updateChecker.Start(); } loadWindow.ProgressBar.Value = 100; Conf.Delay(10); loadWindow.IsOpen = false; Log("启动成功"); IsEnabled = true; if ((Vars.ManagementWindow != null) && !Vars.ManagementWindow.WindowDisposed) { Vars.ManagementWindow.Dispatcher.Invoke(() => { Vars.ManagementWindow.CheckBox_IsPluginActive.IsChecked = true; }); } base.Start(); } catch (Exception ex) { loadWindow.IsOpen = false; Log($"启动过程中出错: {ex}"); Windows.AsyncDialog.Open("启动失败,更多信息请查看日志(首页)。\n请在反馈错误时附加日志信息。\n\n如您在后期继续使用时遇到问题,请尝试重新启动弹幕姬。", "Re: TTSCat", MessageBoxIcon.Error); Log("启动失败"); } }
public static void BeforeClass() { TestUtil.CopyLangTxt();//BJD.Lang.txt //named.caのコピー var src = string.Format("{0}\\DnsServerTest\\named.ca", TestUtil.ProjectDirectory()); var dst = string.Format("{0}\\BJD\\out\\named.ca", TestUtil.ProjectDirectory()); File.Copy(src, dst, true); //設定ファイルの退避と上書き _op = new TmpOption("DnsServerTest", "DnsServerTest.ini"); OneBind oneBind = new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Udp); Kernel kernel = new Kernel(); var option = kernel.ListOption.Get("Dns"); Conf conf = new Conf(option); //サーバ起動 _sv = new Server(kernel, conf, oneBind); _sv.Start(); }
public static DataTable getPbProvider(int type = 0) { object o = Cache.GetCache("pbProvider"); if (o == null) { string sql = ""; if (type == 0) { sql = Conf.getXMLSelectSql(SQLPath.MainSQL, "pbProvider"); } DataTable dt = DataFactory.openCon().Ado.GetDataTable(sql); Cache.SetCache("pbProvider", dt); return(dt); } else { return((DataTable)o); } }
public void OnApplicationStart() { config = Conf.CreateConfig(ConfigType.YAML, BeatSaber.UserDataPath, "Particular"); try { HarmonyInstance harmony = HarmonyInstance.Create("com.jackbaron.beatsaber.particular"); harmony.PatchAll(Assembly.GetExecutingAssembly()); } catch (Exception e) { log.Error( "This plugin requires Harmony. Make sure you installed the plugin properly, " + "as the Harmony DLL should have been installed with it." ); log.Critical(e); } BSMLSettings.instance.AddSettingsMenu("Particular", "Particular.Settings.ParticularSettings.bsml", ParticularSettings.instance); }
public static void BeforeClass() { //設定ファイルの退避と上書き _op = new TmpOption("WebApiServerTest", "WebApiServerTest.ini"); //MailBoxのみ初期化する特別なテスト用Kernelコンストラクタ var kernel = new Kernel("MailBox"); var option = kernel.ListOption.Get("WebApi"); var conf = new Conf(option); //メールボックスの初期化 MailBoxBackup(); MailBoxSetup(); //サーバ起動 _v4Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Tcp)); _v4Sv.Start(); _v6Sv = new Server(kernel, conf, new OneBind(new Ip(IpKind.V6Localhost), ProtocolKind.Tcp)); _v6Sv.Start(); }
public void Option及びServerインスタンスの生成() { var kernel = new Kernel(); const string currentDir = @"C:\tmp2\bjd5\BJD\out"; var sut = new ListPlugin(string.Format("{0}\\bin\\plugins", currentDir)); foreach (var onePlugin in sut) { //Optionインスタンス生成 var oneOption = onePlugin.CreateOption(kernel, "Option", "nameTag"); Assert.NotNull(oneOption); //Serverインスタンス生成 var conf = new Conf(oneOption); var oneBind = new OneBind(new Ip(IpKind.V4Localhost), ProtocolKind.Tcp); var oneServer = onePlugin.CreateServer(kernel, conf, oneBind); Assert.NotNull(oneServer); } }
public int ReplaceTeam(string LianSai_a, string LianSai_b, int i) { string sql = null; int iLianSaiID1 = Conf.GetteamKeyID(LianSai_a); int iLianSaiID2 = Conf.GetteamKeyID(LianSai_b); if (iLianSaiID1 == -1 && iLianSaiID2 == -1) { if (LianSai_a == LianSai_b) { Conf.teamKey.Add(LianSai_a, i); sql += "INSERT INTO qdt (qd,val) VALUES ('" + LianSai_a + "'," + i.ToString() + ")"; } else { Conf.teamKey.Add(LianSai_a, i); Conf.teamKey.Add(LianSai_b, i); sql += "INSERT INTO qdt (qd,val) VALUES ('" + LianSai_a + "'," + i.ToString() + ");"; sql += "INSERT INTO qdt (qd,val) VALUES ('" + LianSai_b + "'," + i.ToString() + ")"; } } else { if (iLianSaiID1 > -1 && iLianSaiID2 == -1) { Conf.teamKey.Add(LianSai_b, iLianSaiID1); sql += "INSERT INTO qdt (qd,val) VALUES ('" + LianSai_b + "'," + iLianSaiID1.ToString() + ")"; } else if (iLianSaiID1 == -1 && iLianSaiID2 > -1) { Conf.teamKey.Add(LianSai_a, iLianSaiID2); sql += "INSERT INTO qdt (qd,val) VALUES ('" + LianSai_a + "'," + iLianSaiID2.ToString() + ")"; } } if (sql != null) { database.ExecuteSQLiteTran(sql); } return(1); }
private static void ReadSectionXml(string section) { Log.Level = LogLevel.Always; // shhhh... silence Config config = null; try { config = Conf.Load(section); } catch { System.Environment.Exit(ERROR_CONFIG_LOAD); } if (config == null) { System.Environment.Exit(ERROR_CONFIG_NO_SECTION); } try { if (!Conf.ReadSectionXml(config, Console.In)) { System.Environment.Exit(ERROR_CONFIG_BAD); } } catch (System.Xml.XmlException) { System.Environment.Exit(ERROR_CONFIG_XML); } catch (Exception) { System.Environment.Exit(ERROR_CONFIG_BAD); } //Console.WriteLine ("Successfully read config for {0}", section); //Conf.WriteSectionXml (config, Console.Out); //Console.WriteLine (); try { Conf.Save(config); } catch { System.Environment.Exit(ERROR_CONFIG_SAVE); } System.Environment.Exit(0); }
public void multipleを超えたリクエストは破棄される事をcountで確認する() { const int multiple = 5; const int port = 8889; const string address = "127.0.0.1"; var ip = new Ip(address); var oneBind = new OneBind(ip, ProtocolKind.Tcp); Conf conf = TestUtil.CreateConf("OptionSample"); conf.Set("port", port); conf.Set("multiple", multiple); conf.Set("acl", new Dat(new CtrlType[0])); conf.Set("enableAcl", 1); conf.Set("timeOut", 3); var myServer = new MyServer(conf, oneBind); myServer.Start(); var ar = new List <MyClient>(); for (int i = 0; i < 20; i++) { var myClient = new MyClient(address, port); myClient.Connet(); ar.Add(myClient); } Thread.Sleep(100); //multiple以上は接続できない Assert.That(myServer.Count(), Is.EqualTo(multiple)); myServer.Stop(); myServer.Dispose(); foreach (var c in ar) { c.Dispose(); } }
private void SaveGoogleSettings() { Config google_config = Conf.Get("GoogleBackends"); google_config.SetOption("GMailSearchFolder",main.GMailSearchFolder.Text); string username = main.GoogleUsername.Text.Trim(); if (username != String.Empty) { username = username + "@gmail.com"; google_config.SetOption("GMailUsername",username); } if (main.IsGoogleAppsAccount.Checked) { google_config.SetOption("GoogleAppsAccountName",main.GoogleAppsAccountName.Text); } else { google_config.SetOption("GoogleAppsAccountName",String.Empty); } if (main.OptionStorePasswordConf.Checked) { google_config.SetOption("GMailPasswordSource","conf-file"); google_config.SetOption("GMailPassword",main.GooglePassword.Text); } else if (main.OptionStorePasswordKWallet.Checked && !String.IsNullOrEmpty(username)) { try { KdeUtils.StorePasswordKDEWallet("beagle",username,main.GooglePassword.Text); google_config.SetOption("GMailPasswordSource","kdewallet"); } catch (ArgumentException e) { QMessageBox.Warning(this,"KDEWallet",e.Message); } } Conf.Save(google_config); }
/////////////////////////////////////////////////////////////////////////////////////////////// // EventHandler void MainForm_Load(object sender, EventArgs e) { Conf.Load(); initializeControl(); Synth.Playbacking += (IntPtr data, IntPtr evt) => { return(Synth.HandleEvent(data, evt)); }; Synth.Started += () => { Log.Info("Started called."); Invoke((MethodInvoker)(() => { Text = $"MidiPlayer: {Synth.MidiFilePath.ToFileName()} {Synth.SoundFontPath.ToFileName()}"; listView.Items.Clear(); Enumerable.Range(0, Synth.TrackCount).ToList().ForEach(x => { listView.Items.Add(new ListViewItem(new string[] { " ●", "--", "--", "--", "--", "--" })); }); })); }; Synth.Ended += () => { Log.Info("Ended called."); if (!playList.Ready) { Synth.Stop(); Synth.Start(); } else { Synth.Stop(); Synth.MidiFilePath = playList.Next; Synth.Start(); } }; Synth.Updated += (object sender, PropertyChangedEventArgs e) => { var _track = (Synth.Track)sender; Invoke(updateList(_track)); }; }
private static void ManageOneByConfFile(string op) { var conf = new Conf(); var serviceName = conf.ServiceName; var sc = SvcUtils.GetServiceController(serviceName); var status = (sc == null) ? "not installed" : sc.Status.ToString().ToLower(); if (op == "check" || op == "status") { conf.ShowConfig(); Console.WriteLine($"\r\nService status: {status}"); return; } if (op == "install") { if (sc != null) { Libs.Abort($"Service \"{serviceName}\" is already installed!"); } SvcUtils.InstallService(conf); return; } if (op == "log") { LoggingSvc(conf, status); return; } // op: start|stop|restart|remove if (sc == null) { Libs.Abort($"Service \"{serviceName}\" is not installed!"); } sc.Operate(op); }
public void run(IMahuaApi api) { this.api = api; object portV = Conf.getConfig("global.config", "port"); int port = 10268; if (portV != null) { try { port = int.Parse(portV.ToString()); } catch (Exception e) { } } Log.addLog("UDP服务已启动,端口:" + port); int recv; byte[] bytes = new byte[1024]; IPEndPoint ip = new IPEndPoint(IPAddress.Any, port); Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); server.Bind(ip); while (true) { IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0); EndPoint Remote = (EndPoint)(sender); recv = server.ReceiveFrom(bytes, ref Remote); string data = System.Text.Encoding.UTF8.GetString(bytes, 0, recv); int ac = CQAPI.getAuthCode(); CQAPI.xtAddLog(ac, LogType.status.DEBUG, "UDP获取数据", "获取数据:" + data); try { this.parseUdpData(data); } catch (Exception e) { CQAPI.xtAddLog(ac, LogType.status.INFO, "UDP解析警告", e.Message); } } }
public string Grouping([FromQuery(Name = "Id")] string Id) { string text = System.IO.File.ReadAllText(Location.ConfLocation); Conf conf = JsonConvert.DeserializeObject <Conf>(text); RawData main = new RawData(); main.Load(conf.RawDataPath + "\\" + Id + "\\main.csv"); TransformedData transformedData = TransformedData.ConvertRawtoTransformed(main); string content = ""; foreach (string[] line in transformedData.Table) { content += string.Join(";", line) + Environment.NewLine; } System.IO.File.WriteAllText(conf.TransformedDataPath + "\\" + Id + "\\main.csv", content); return("ok"); }
public static string SetSvcDescription(Conf conf) { var cwd = Path.GetFullPath("."); var description = $"{conf.Description} @<{cwd}>"; var scArgs = $"description \"{conf.ServiceName}\" \"{description}\""; Libs.Exec("sc", scArgs); try { var mngObj = GetServiceManagementObjectByName(conf.ServiceName); if (mngObj == null || mngObj["Description"].ToString() != description) { return("unknown"); } return(null); } catch (Exception ex) { return(ex.ToString()); } }
public string TrainRegressor([FromQuery(Name = "Id")] string Id, [FromQuery(Name = "Hash")] string Hash) { string text = System.IO.File.ReadAllText(Location.ConfLocation); Conf conf = JsonConvert.DeserializeObject <Conf>(text); Regressor regressor = new Regressor(); regressor.LoadByHash(Hash); string trainerDir = conf.TrainerDir; string Trainercmd = "python main.py "; Trainercmd += Id; Trainercmd += " "; Trainercmd += regressor.RegressorId; Trainercmd += " "; Trainercmd += regressor.Filter.Replace("\"", "\\\""); Command.runCmd(trainerDir, Trainercmd); return("ok"); }
ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; //获取本地应用设置容器(单例) public SettingPage() { this.InitializeComponent(); //下拉框初始化 combox1.Items.Add(new KeyValuePair <string, int>("1 分钟", 1)); combox1.Items.Add(new KeyValuePair <string, int>("5 分钟", 5)); combox1.Items.Add(new KeyValuePair <string, int>("10 分钟", 10)); combox1.Items.Add(new KeyValuePair <string, int>("15 分钟", 15)); combox1.Items.Add(new KeyValuePair <string, int>("30 分钟", 30)); combox1.Items.Add(new KeyValuePair <string, int>("60 分钟", 60)); com_lock.Items.Add(new KeyValuePair <string, int>("仅更换壁纸", 0)); com_lock.Items.Add(new KeyValuePair <string, int>("仅更换锁屏", 1)); com_lock.Items.Add(new KeyValuePair <string, int>("同时更换壁纸和锁屏", 2)); //值填充 Conf c = new Conf(); combox1.SelectedValue = c.time; switch (c.mode) { case "Top_50": radiobutton1.IsChecked = true; break; case "You_Like": radiobutton2.IsChecked = true; break; default: radiobutton1.IsChecked = true; break; } com_lock.SelectedValue = c.lockscr; textbox1.Text = c.account; passwordbox1.Password = c.password; }
static void Main() { Conf conf = new Conf(); try { conf.Load(); } catch (ConfException error) { Log.Error("Bad conf: {0}", error.Message); return; } Pullenti_.Init(conf.langs, conf.analyzers); using (Server server = new Server()) { server.Start(conf.host, conf.port); // maybe better to handle ctrl-c Thread.Sleep(Timeout.Infinite); } }
static async Task Main() { _conf = Deserialize <Conf>(GetEnvValue("CONF")); if (!string.IsNullOrWhiteSpace(_conf.ScKey)) { _scClient = new HttpClient(); } Console.WriteLine("ActionActivator开始运行..."); foreach (Activator act in _conf.Acts) { string owner = act.User; Console.WriteLine($"共 {_conf.Acts.Length} 个账号,正在运行{owner}..."); using var client = new HttpClient(); client.DefaultRequestHeaders.Add("User-Agent", owner); client.DefaultRequestHeaders.Add("Authorization", $"token {act.Token}"); foreach (Repo repo in act.Repos) { string badInfo = null; try { var httpResponseMessage = await client.PutAsync($"https://api.github.com/repos/{owner}/{repo.Name}/actions/workflows/{repo.WorkflowFileName}/enable", null); if (httpResponseMessage.StatusCode != HttpStatusCode.NoContent) {//请求失败 badInfo = $"请求失败. code: {httpResponseMessage.StatusCode}, msg: {await httpResponseMessage.Content.ReadAsStringAsync()}"; } } catch (Exception ex) { badInfo = $"ex: {ex.Message}"; } await Notify($"{repo.Name}...{badInfo ?? "ok"}", badInfo != null); } } Console.WriteLine("ActionActivator运行完毕"); }
public async Task <bool> ExecuteAsync(TelegramBotClient botClient, Update update) { // errors are handled by global error handler // notify user _ = await botClient.SendTextMessageAsync( update.Message.From.Id, Vars.CurrentLang.Message_SwitchingLang, ParseMode.Markdown, false, Vars.CurrentConf.DisableNotifications, update.Message.MessageId).ConfigureAwait(false); // download file var langUrl = update.Message.Text.Split(" ")[1]; Vars.CurrentConf.LangURL = langUrl; // save conf _ = await Conf.SaveConf(isAutoSave : true); await DownloadFileAsync( new Uri(langUrl), Path.Combine(Vars.AppDirectory, "pmcenter_locale.json") ).ConfigureAwait(false); // reload configurations _ = await Conf.ReadConf().ConfigureAwait(false); _ = await Lang.ReadLang().ConfigureAwait(false); // notify user _ = await botClient.SendTextMessageAsync( update.Message.From.Id, Vars.CurrentLang.Message_LangSwitched, ParseMode.Markdown, false, Vars.CurrentConf.DisableNotifications, update.Message.MessageId).ConfigureAwait(false); return(true); }
public void TcpObjTest(string key, string val) { var conf = new Conf(option); var request = new Request(null, null); var header = new Header(); var tcpObj = new SockTcp(new Kernel(), new Ip("0.0.0.0"), 88, 1, null); tcpObj.LocalAddress = new IPEndPoint((new Ip("127.0.0.1")).IPAddress, 80); tcpObj.RemoteAddress = new IPEndPoint((new Ip("10.0.0.100")).IPAddress, 5000); const string fileName = ""; var env = new Env(_kernel, conf, request, header, tcpObj, fileName); foreach (var e in env) { if (e.Key == key) { Assert.AreEqual(e.Val, val); return; } } Assert.AreEqual(key, ""); }
public MainPage() { this.InitializeComponent(); c = new Conf(); top50 = new PixivTop50(); like = new PixivLike(); timer = new DispatcherTimer(); timer.Interval = TimeSpan.FromMinutes(c.time); timer.Tick += Timer_Tick; timer.Start(); li_uptimer = new DispatcherTimer(); li_uptimer.Interval = TimeSpan.FromHours(1); li_uptimer.Tick += Li_uptimer_Tick; li_uptimer.Start(); if (c.lastImg != null) { ImageBrush br = new ImageBrush(); br.Stretch = Stretch.UniformToFill; br.AlignmentX = AlignmentX.Left; br.AlignmentY = AlignmentY.Top; br.ImageSource = new BitmapImage(new Uri("ms-appdata:///local/" + c.lastImg.imgId)); gr.Background = br; } else { ImageBrush br = new ImageBrush(); br.Stretch = Stretch.UniformToFill; br.AlignmentX = AlignmentX.Left; br.AlignmentY = AlignmentY.Top; br.ImageSource = new BitmapImage(new Uri("ms-appx:///Res/62258773_p0.png")); gr.Background = br; } main.Navigate(typeof(ShowPage)); }
private static void CheckStage1() { if (Op == "create") { CreateProject(); } Conf = new Conf(true); if (Op == "test-worker") { TestWorker(); } Sc = SvcUtils.GetServiceController(Conf.ServiceName); Status = (Sc == null) ? "not installed" : Sc.Status.ToString().ToLower(); if (Op == "check" || Op == "status") { Conf.ShowConfig(); Exit($"\r\nService status: {Status}"); } if (Op == "install" && Sc != null) { Abort($"Service \"{Conf.ServiceName}\" is already installed!"); } if (Op != "install" && Sc == null) { Abort($"Service \"{Conf.ServiceName}\" is not installed!"); } if (Op == "log" && Status != "running") { Abort($"Service \"{Conf.ServiceName}\" is not running"); } }
private async void Button_Delete_Click(object sender, RoutedEventArgs e) { var temp = new List <string>(); temp.AddRange(ListView_EndPoints.SelectedItems.Select(s => (string)s)); if (temp.Count == 0) { return; } var dialog = new ContentDialog() { Title = resourceLoader.GetString("Prompt_DeleteAPIEndPointConfirmation_Title"), Content = resourceLoader.GetString("Prompt_DeleteAPIEndPointConfirmation_Content").Replace("%1", temp.Count.ToString()), DefaultButton = ContentDialogButton.Secondary, PrimaryButtonText = resourceLoader.GetString("Prompt_DeleteAPIEndPointConfirmation_Yes"), SecondaryButtonText = resourceLoader.GetString("Prompt_DeleteAPIEndPointConfirmation_No") }; var result = await dialog.ShowAsync(); if (result == ContentDialogResult.Secondary) { return; } foreach (var item in temp) { // search for corresponding item foreach (var ep in Conf.CurrentConf.ApiEndPoints2) { if (ep.Address == item) { Conf.CurrentConf.ApiEndPoints2.Remove(ep); break; } } ListView_EndPoints.Items.Remove(item); Conf.Log($"deleted endpoint {item}.", LogLevel.Complete); } }
public static void Init() { Display.Header(); #region Configuration Conf = new Conf(); if (!Conf.Ok) { Display.Show(ShowType.Error, "Failed to load configurations, aborting..."); Console.ReadKey(); } Display.Show(ShowType.Status, "All configurations loaded!"); #endregion #region Database DatabaseRo.Configure(Conf.Inter.Database); #endregion LoginThread = new Thread(delegate() { Display.Show(ShowType.Status, "Login-Server Online!"); LoginServer = new Server((ushort)6900, 1000, ServerType.LOGIN); }); LoginThread.Start(); CharThread = new Thread(delegate() { Display.Show(ShowType.Status, "Char-Server Online!"); CharServer = new Server((ushort)6121, 1000, ServerType.CHAR); }); CharThread.Start(); System.Threading.Tasks.Task.Delay(-1).Wait(); }
public optionsForm(Conf Conf) { this.Conf = Conf; InitializeComponent(); }
private void assert_does_not_parse(string val, Conf obj=null) { var assertions = obj.ToHash(); var territoryName = assertions.DeleteOrUseDefault("with_territory", Context.DefaultTerritoryName); Assert.Throws<FailedToParseNumberException>(() => Context.Parse(val, (string) territoryName),"expected " +val+ " not to parse for territory "+territoryName); }
/** * Créé un modèle Jeu à partir d'un fichier de configuation */ public Jeu(Conf configuration) { _Config = configuration; _participant = new Participant (); newGame (); refreshConfigFiles (); }
/* Charge la configuration du fichier vers le jeu actuel */ public void loadConfig(string path) { _Config = getConfigFile (path); }
/** * Créé un modèle Jeu avec des valeurs par défaut */ public Jeu() { _Config = new Conf (); _participant = new Participant (); newGame (); refreshConfigFiles (); loadAppConfig (Application.dataPath + "/app.conf"); //Charge la dernière configuration sélectionnée avant de quitter l'application if (!_AppConfig.LastConfName.Equals ("") && File.Exists (Application.dataPath + "/" + _AppConfig.LastConfName + ".xml")) { loadConfig (Application.dataPath + "/" + _AppConfig.LastConfName + ".xml"); } else { _AppConfig.LastConfName = ""; } }