private void frmMain_Load(object sender, EventArgs e) { dataGridView1.DataSource = null; DataSet ds = YAMS.Database.ReturnLogRows(); dataGridView1.DataSource = ds.Tables[0]; this.checkBox1.Checked = YAMS.Util.HasJRE(); this.checkBox2.Checked = YAMS.Util.HasJDK(); this.textBox1.Text = YAMS.Util.JavaPath(); this.textBox2.Text = YAMS.Util.JavaPath("jdk"); FileSystemWatcher watcher = new FileSystemWatcher(); watcher.Path = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName; watcher.Filter = "*.sdf"; //watcher.NotifyFilter = NotifyFilters.LastWrite; watcher.Changed += new FileSystemEventHandler(OnChanged); watcher.EnableRaisingEvents = true; IniParser parser = new IniParser(@"server.properties"); txtIniCheck.Text = parser.GetSetting("ROOT", "level-name"); parser.AddSetting("ROOT", "level-name", "world"); parser.SaveSettings(); }
public MCServer(int intServerID) { this.ServerID = intServerID; //Set this first so that we can use it right away this.ServerDirectory = Core.StoragePath + this.ServerID.ToString() + @"\"; //If server is a pre-0.2.3 then we need to move everything back to default layout to support a lot of bukkit plugins if (Directory.Exists(Core.StoragePath + this.ServerID.ToString() + "\\config\\")) { //This is our old config and working dir, so we need everything out of it moved into the main dir try { Util.Copy(Core.StoragePath + this.ServerID.ToString() + "\\config\\", this.ServerDirectory); Directory.Delete(Core.StoragePath + this.ServerID.ToString() + "\\config\\", true); //We also need to amend the properties file to include the new world path IniParser parser = new IniParser(this.ServerDirectory + @"\server.properties"); parser.AddSetting("ROOT", "level-name", "world"); parser.SaveSettings("#Minecraft server properties\r\n#Generated by YAMS " + DateTime.Now.ToString() + "\r\n"); } catch(Exception e) { Database.AddLog("Unable to move config directory, this will have to be done manually to avoid losing settings: " + e.Message, "app", "error"); } } //Set this here to catch any old references to it. this.strWorkingDir = this.ServerDirectory; this.bolEnableJavaOptimisations = Convert.ToBoolean(Database.GetSetting(this.ServerID, "ServerEnableOptimisations")); this.intAssignedMem = Convert.ToInt32(Database.GetSetting(this.ServerID, "ServerAssignedMemory")); this.ServerTitle = Convert.ToString(Database.GetSetting(this.ServerID, "ServerTitle")); this.ServerType = Convert.ToString(Database.GetSetting(this.ServerID, "ServerType")); this.LogonMode = Convert.ToString(Database.GetSetting(this.ServerID, "ServerLogonMode")); this.Port = Convert.ToInt32(this.GetProperty("server-port")); }
private void AppStartup(object sender, StartupEventArgs eventArgs) { string iniFilePath = !string.IsNullOrEmpty(EntryDirectory) ? Path.Combine(EntryDirectory, Path.GetFileNameWithoutExtension(EntryPath) + "-settings.ini") : "settings.ini"; IniParser = new IniParser(iniFilePath); LoadConfig(); if (checkAppLocalePresence) CheckAppLocalePresence(); ProcessStartupArguments(eventArgs.Args); }
private string Get_Value(string file_name, string section, string key) { try { IniParser myIniParser = new IniParser(file_name); string value = myIniParser.IniReadValue(section, key); if (value == null) return "!missing_ini_key: " + key + "!"; return value; } catch (Exception e) { return "err: " + e.Message; } }
public void ReceiveLeatherConfiguration(LeatherConfig config) { string cfgPath = Path.Combine (config.ConfigDirectoryPath, "LimitedSleepers.cfg"); if (File.Exists (cfgPath)) { IniParser parser = new IniParser (cfgPath); String lifeStr = parser.GetSetting ("General", "SleeperLifeInMinutes"); int.TryParse (lifeStr, out this.sleeperLifeInMinutes); ConsoleSystem.Log ("Config parsed- sleeper life is "+this.sleeperLifeInMinutes+" minutes."); } else { ConsoleSystem.Log ("Could not locate LimitedSleepers.cfg"); } }
public LoadOut(string name) { path = Path.Combine(Singleton<Rust.Util>.Instance.GetLoadoutFolder(), name + ".ini"); bool nu = false; if (!File.Exists(path)) { File.AppendAllText(path, ""); nu = true; } IniParser ini = new IniParser(path); Name = ini.Name; if (!nu) { itemCount = Int32.Parse(ini.GetSetting("Def", "itemCount")); OwnerUse = ini.GetBoolSetting("Def", "ownerCanUse"); ModeratorUse = ini.GetBoolSetting("Def", "modCanUse"); NormalUse = ini.GetBoolSetting("Def", "normalCanUse"); } else { itemCount = 0; OwnerUse = true; NormalUse = true; ModeratorUse = true; } items = new Dictionary<int, LoadOutItem>(30); if (itemCount != 0) { for (int i = 0; i < itemCount; i++) { string namee = ini.GetSetting(i.ToString(), "Name"); int amount; if (!Int32.TryParse(ini.GetSetting(i.ToString(), "Amount"), out amount)) amount = Int32.MaxValue; LoadOutItem current = new LoadOutItem(namee, amount); items.Add(i, current); } } if (Server.GetInstance().LoadOuts.ContainsKey(Name)) Server.GetInstance().LoadOuts.Remove(Name); Server.GetInstance().LoadOuts.Add(Name, this); }
public static void Init(string DirectoryConfigPath) { Contract.Requires(!string.IsNullOrEmpty(DirectoryConfigPath)); Contract.Ensures(FougeriteDirectoryConfig != null); Contract.Ensures(FougeriteConfig != null); if (File.Exists(DirectoryConfigPath)) { FougeriteDirectoryConfig = new IniParser(DirectoryConfigPath); Debug.Log("DirectoryConfig " + DirectoryConfigPath + " loaded!"); } else Debug.Log("DirectoryConfig " + DirectoryConfigPath + " NOT loaded!"); string ConfigPath = Path.Combine(GetPublicFolder(), "Fougerite.cfg"); if (File.Exists(ConfigPath)) { FougeriteConfig = new IniParser(ConfigPath); Debug.Log("Config " + ConfigPath + " loaded!"); } else Debug.Log("Config " + ConfigPath + " NOT loaded!"); }
public bool ToIni(string inifilename = "DataStore") { string inipath = Path.Combine(Config.GetPublicFolder(), inifilename.RemoveChars(new char[] { '.', '/', '\\', '%', '$' }).RemoveWhiteSpaces() + ".ini"); File.WriteAllText(inipath, ""); IniParser ini = new IniParser(inipath); ini.Save(); foreach (string section in this.datastore.Keys) { Hashtable ht = (Hashtable)this.datastore[section]; foreach (object setting in ht.Keys) { try { string key = "NullReference"; string val = "NullReference"; if (setting != null) { if (setting.GetType().GetMethod("ToString", Type.EmptyTypes) == null) { key = "type:" + setting.GetType().ToString(); } else { key = setting.ToString(); } } if (ht[setting] != null) { if (ht[setting].GetType().GetMethod("ToString", Type.EmptyTypes) == null) { val = "type:" + ht[setting].GetType().ToString(); } else { val = ht[setting].ToString(); } } ini.AddSetting(section, key, val); } catch (Exception ex) { Logger.LogException(ex); } } } ini.Save(); return true; }
public void LoadFromFile(String file) { IniParser parser = new IniParser(file); String res = parser.GetSetting("Video", "Water").ToLower(); switch (res) { case "verylow": Water = VideoQuality.LOW; break; case "low": Water = VideoQuality.LOW; break; case "medium": Water = VideoQuality.MEDIUM; break; case "high": Water = VideoQuality.HIGH; break; case "ultra": Water = VideoQuality.ULTRA; break; } }
public void CreateDefaultSettingsFile() { StreamWriter writer = new StreamWriter(m_settingsPath); writer.Close(); IniParser iniParser = new IniParser(m_settingsPath); iniParser.AddSetting("NewTaskHotkey", "Ctrl", "false"); iniParser.AddSetting("NewTaskHotkey", "Alt", "true"); iniParser.AddSetting("NewTaskHotkey", "Win", "false"); iniParser.AddSetting("NewTaskHotkey", "Shift", "false"); iniParser.AddSetting("NewTaskHotkey", "Key", "N"); iniParser.AddSetting("General", "startwithwindows", "true"); iniParser.AddSetting("General", "autoupdate", "true"); iniParser.AddSetting("General", "playsound", "true"); iniParser.AddSetting("CultureInfo", "name", "lt-Lt"); iniParser.AddSetting("RemindMeLater", "Default", RemindLaterValue.Round(10.0m/60.0m).ToString()); iniParser.AddSetting("Skin", "code", BlackSkin.SKIN_UNIQUE_CODE); iniParser.AddSetting("Skin", "themename", _defaultThemeName); iniParser.AddSetting("Sync", "enable", "false"); iniParser.AddSetting("Sync", "ID", ""); iniParser.AddSetting("Sync", "interval", "30"); iniParser.SaveSettings(); m_log.Info("New settings file was created successfully"); }
/// <summary> /// Parses CompilingMusicSettings.ini into the global variable "settings". /// </summary> private void loadSettings() { FileInfo settingInfo = new FileInfo(userDir + "\\Visual Studio 2010\\Addins\\CompilingMusicSettings.ini"); if (settingLastModified == settingInfo.LastWriteTime) return; parser = new IniParser(userDir + "\\Visual Studio 2010\\Addins\\CompilingMusicSettings.ini"); settings.bassUser = parser.GetSetting("bass", "email"); settings.bassCode = parser.GetSetting("bass", "code"); settings.setMode = Boolean.Parse(parser.GetSetting("options", "setMode")); settings.setDirectory = parser.GetSetting("options", "setDirectory"); settings.randomCompileDirectory = parser.GetSetting("options", "randomCompileDirectory"); settings.randomFailDirectory = parser.GetSetting("options", "randomFailDirectory"); settings.randomSuccessDirectory = parser.GetSetting("options", "randomSuccessDirectory"); settings.STFU = Boolean.Parse(parser.GetSetting("options", "STFU")); settingLastModified = settingInfo.LastWriteTime; }
internal static DamageFX Parse(IniParser parser) { return(parser.ParseNamedBlock( (x, name) => x.SetNameAndInstanceId("DamageFX", name), FieldParseTable)); }
internal static FloodMember Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
public void SaveProperty(string strPropertyName, string strPropertyValue) { //If there is already a partially updated file, we want to put this value in the new file string strPathToRead; if (File.Exists(this.ServerDirectory + @"\server.properties.UPDATE")) strPathToRead = this.ServerDirectory + @"\server.properties.UPDATE"; else strPathToRead = this.ServerDirectory + @"\server.properties"; IniParser parser = new IniParser(strPathToRead); parser.AddSetting("ROOT", strPropertyName, strPropertyValue); parser.SaveSettings(this.ServerDirectory + @"\server.properties.UPDATE", "#Minecraft server properties\r\n#Generated by YAMS " + DateTime.Now.ToString() + "\r\n"); }
internal static CivilianSpawnCollideModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
/// <summary> /// Aktiviert oder deaktiviert einen Benutzer /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToggleUserActivateStateButton_Click(object sender, RoutedEventArgs e) { try { UserAccount currentUserAccount = UserDataGrid.SelectedItem as UserAccount; if (currentUserAccount != null) { if (currentUserAccount.IsAdmin && currentUserAccount.IsActive && UserAccount.GetUserAccounts().Where(u => u.IsAdmin).ToList().Count <= 1) { throw new Exception(IniParser.GetSetting("ERRORMSG", "deactivateAdmin")); } if (UserSession.userAccountID.Equals(currentUserAccount.UserAccountID)) { throw new Exception(IniParser.GetSetting("ERRORMSG", "selfDeactivation")); } var state = currentUserAccount.IsActive; var message = string.Format(IniParser.GetSetting("USER", "confirmationFormatString"), currentUserAccount.Username, ((state) ? IniParser.GetSetting("FILTER", "inactive") : IniParser.GetSetting("FILTER", "active"))); var dialogResult = MessageBox.Show(message, IniParser.GetSetting("USER", "confirmationNeeded"), MessageBoxButton.OKCancel, MessageBoxImage.Question); if (dialogResult == MessageBoxResult.OK) { if (state) { UserAccount.Deactivate(currentUserAccount.UserAccountID); } else { UserAccount.Activate(currentUserAccount.UserAccountID); } this.userAccounts = UserAccount.GetUserAccounts(); if (this.userAccounts != null) { this.userAccounts.OrderByDescending(u => u.IsActive); } if (this.parentToolbar.searchPanel.searchBox.Text == IniParser.GetSetting("APPSETTINGS", "search")) { processKeyUp(""); } else { processKeyUp(this.parentToolbar.searchPanel.searchBox.Text); } } } } catch (Exception ex) { MessageBoxEnhanced.Error(ex.Message); } }
internal static ParalyzeNugget Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
// string req2 = //" { " + //" \"Method\":\"GetFuellingPointConfig\" " + //" } "; // "Method":"Preset" //,"Transaction": static UTAPI() { ReadCodes(); iniFile = new IniParser("groups.ini"); }
internal static new DevastateSpecialPowerModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
internal static FXListDieModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
internal static SpawnAndFadeNugget Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
internal static EvaSideSound Parse(IniParser parser) { return(parser.ParseBlock(FieldParseTable)); }
static rustpp() { string path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "rust++.cfg")); config = new IniParser (@path); }
internal static SlavedUpdateModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
public void Items() { string path = Path.Combine(GetPublicFolder(), "Items.ini"); if (!File.Exists(path)) File.AppendAllText(path, ""); IniParser ini = new IniParser(path); foreach (ItemDefinition item in ItemManager.itemList) { ini.AddSetting(item.displayName.english, "itemid", item.itemid.ToString()); ini.AddSetting(item.displayName.english, "category", item.category.ToString()); ini.AddSetting(item.displayName.english, "shortname", item.shortname); ini.AddSetting(item.displayName.english, "description", item.displayDescription.english); } ini.Save(); }
public void ParseDatabase() { try { WebClient GetData = new WebClient(); if (!File.Exists(cd + "\\Common\\AppData\\Modules\\UIWeather\\Database.ini")) { GetData.DownloadFile(new Uri("https://github.com/Material-Desktop-CobaltUI/raw/master/Common/Database/Weather/Database.ini"), cd + "\\Common\\AppData\\Modules\\UIWeather\\Database.ini"); } else { File.Move(cd + "\\Common\\AppData\\Modules\\UIWeather\\Database.ini", cd + "\\Common\\AppData\\Modules\\UIWeather\\Database.ini.old"); GetData.DownloadFile(new Uri("https://github.com/Material-Desktop-CobaltUI/raw/master/Common/Database/Weather/Database.ini"), cd + "\\Common\\AppData\\Modules\\UIWeather\\Database.ini"); } } catch (Exception ex) { LblFooter.Text = "Failed to download database..."; MessageBox.Show("Failed to download the database." + Environment.NewLine + Environment.NewLine + ex, "UIWeather: Database error", MessageBoxButtons.OK, MessageBoxIcon.Error); } try { IniParser parser = new IniParser(cd + "\\Common\\AppData\\Modules\\UIWeather\\Database.ini"); //Normal Conditions parser.GetSetting("normal_conditions", "clearnight"); parser.GetSetting("normal_conditions", "sunny"); parser.GetSetting("normal_conditions", "partlycloudyday"); parser.GetSetting("normal_conditions", "partlycloudynight"); parser.GetSetting("normal_conditions", "overcast"); parser.GetSetting("normal_conditions", "cloudy"); parser.GetSetting("normal_conditions", "clearnight"); //Fog & mist parser.GetSetting("fog_mist", "mist"); parser.GetSetting("fog_mist", "fog"); parser.GetSetting("fog_mist", "freezingfog"); //Rain parser.GetSetting("rain", "rainday"); parser.GetSetting("rain", "rainnight"); parser.GetSetting("rain", "rain"); parser.GetSetting("rain", "heavyrain"); parser.GetSetting("rain", "heavyrainday"); parser.GetSetting("rain", "heavyrainnight"); parser.GetSetting("rain", "freezingrain"); parser.GetSetting("rain", "freezingdrizzle"); parser.GetSetting("rain", "rainthunder"); //Sleet parser.GetSetting("sleet", "sleetday"); parser.GetSetting("sleet", "sleetnight"); parser.GetSetting("sleet", "lightsleet"); //Snow parser.GetSetting("snow", "snowday"); parser.GetSetting("snow", "snownight"); parser.GetSetting("snow", "lightsnow"); parser.GetSetting("snow", "heavysnow"); parser.GetSetting("snow", "blizzard"); //windy parser.GetSetting("windy", "wind"); } catch (Exception ex) { LblFooter.Text = "Failed to parse database..."; MessageBox.Show("Failed to parse the database." + Environment.NewLine + Environment.NewLine + ex, "UIWeather: Database error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Conditions = new string[] { "Sunny.png", "ModRain.png", "Overcast.png", "Clear.png", "Cloudy.png", "Fog.png", "FreezingRain.png", "HeavyRain.png", "HeavySleet.png", "HeavySnow.png", "Mist.png", "Blizzard.png", "Wind.png", "ModSnow.png", "PartlyCloudyDay.png", "PartlyCloudyNight.png", "PartCloudRainThunderDay.png", "PartCloudRainThunderNight.png", }; PrgWait.Value = 15; GetIcons(); Random rand; rand = new Random(); int randomIndex = rand.Next(Conditions.Length); string FinalCondition = Conditions[randomIndex]; PcxLogo.BackgroundImage = Image.FromFile(cd + "\\Common\\AppData\\Modules\\UIWeather\\Icons\\" + FinalCondition); PrgWait.Value = 50; ShowWeather(); }
internal static EvaEvent Parse(IniParser parser) { return(parser.ParseNamedBlock( (x, name) => x.SetNameAndInstanceId("EvaEvent", name), FieldParseTable)); }
internal static BridgeTowerBehaviorModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
private void savePrefs() { IniParser parser = new IniParser(@"CP1252Fixer.ini"); for (int i = 0; i < CMOptions.Length; ++i) { parser.AddSetting("options", CMOptions[i].text, (CMOptions[i].active ? "true" : "false")); } parser.SaveSettings(); }
internal static VolumeSliderMultiplier Parse(IniParser parser) => parser.ParseAttributeList(FieldParseTable);
internal static AISideInfo Parse(IniParser parser) { return(parser.ParseNamedBlock( (x, name) => x.Name = name, FieldParseTable)); }
internal static DefaultProductionExitUpdateModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
public void SaveSettingsToFile() { IniParser parser = new IniParser(m_settingsPath); parser.DeleteSetting("NewTaskHotkey", "alt"); parser.DeleteSetting("NewTaskHotkey", "ctrl"); parser.DeleteSetting("NewTaskHotkey", "shift"); parser.DeleteSetting("NewTaskHotkey", "win"); parser.DeleteSetting("NewTaskHotkey", "key"); parser.DeleteSetting("general", "startwithwindows"); parser.DeleteSetting("general", "autoupdate"); parser.DeleteSetting("general", "playsound"); parser.DeleteSetting("CultureInfo", "name"); parser.DeleteSetting("RemindMeLater", "default"); parser.DeleteSetting("skin", "code"); parser.DeleteSetting("skin", "themename"); parser.DeleteSetting("sync", "id"); parser.DeleteSetting("sync", "interval"); parser.DeleteSetting("sync", "enable"); parser.AddSetting("NewTaskHotkey", "alt", StaticData.Settings.NewTaskHotkey.Alt.ToString()); parser.AddSetting("NewTaskHotkey", "ctrl", StaticData.Settings.NewTaskHotkey.Ctrl.ToString()); parser.AddSetting("NewTaskHotkey", "shift", StaticData.Settings.NewTaskHotkey.Shift.ToString()); parser.AddSetting("NewTaskHotkey", "win", StaticData.Settings.NewTaskHotkey.Win.ToString()); parser.AddSetting("NewTaskHotkey", "key", StaticData.Settings.NewTaskHotkey.Key); parser.AddSetting("General", "startwithwindows", StaticData.Settings.StartWithWindows.ToString()); parser.AddSetting("General", "autoupdate", StaticData.Settings.CheckUpdates.ToString()); parser.AddSetting("General", "playsound", StaticData.Settings.PlaySound.ToString()); parser.AddSetting("CultureInfo", "name", StaticData.Settings.CultureData.CultureInfo.Name.ToString()); parser.AddSetting("RemindMeLater", "default", RemindLaterValue.Round(StaticData.Settings.RemindMeLaterDecimalValue).ToString()); parser.AddSetting("skin", "code", StaticData.Settings.SkinsUniqueCodes.SelectedSkin); parser.AddSetting("skin", "themename", StaticData.Settings.ThemeUniqueCode); parser.AddSetting("sync", "id", StaticData.Settings.Sync.Id); parser.AddSetting("sync", "interval", StaticData.Settings.Sync.Interval.ToString()); parser.AddSetting("sync", "enable", StaticData.Settings.Sync.Enable.ToString()); parser.SaveSettings(); m_log.Info("Settings were saved successfully"); }
internal static LuaEventNugget Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
private static bool SetHandlers(ref ILoaderConfigHandler configStore, ref IStatusHandler statusHandler) { string reportStoreType = ""; string reportStoreConnectionString = ""; string configStoreName = ""; string configStoreConnectionString = ""; try { IniParser ini = new IniParser("conf.ini"); reportStoreType = ini.GetSetting("STATUS_REPORT", "REPORT_TO"); reportStoreConnectionString = ini.GetSetting("STATUS_REPORT", "REPORT_CONNECTION"); configStoreName = ini.GetSetting("CONFIG_STORE", "TYPE"); configStoreConnectionString = ini.GetSetting("CONFIG_STORE", "CONNECTION"); } catch (System.IO.FileNotFoundException ex) { Console.WriteLine(ex.Message); return false; } //Setup property store //Currently we hardcode this to SQL Server, the infrastructure to reflect on it is in place configStore = new Aih.DataLoader.ConfigHandlers.SQLServerLoaderConfigHandler(configStoreConnectionString); //Setup where to report status to //Currently we hardcode this to SQL Server, the infrastructure to reflect on it is in place statusHandler = new Aih.DataLoader.StatusHandlers.SQLServerStatusHandler(reportStoreConnectionString); return true; }
private void BanCheater(Fougerite.Player player, string StringLog) { try { IniParser iniBansIP; string ConfigFile = Path.Combine(ModuleFolder, "BansIP.ini"); if (File.Exists(ConfigFile)) iniBansIP = new IniParser(ConfigFile); else { Logger.LogError("BansIP.ini does not exist!"); return; } IniParser iniBansID; ConfigFile = Path.Combine(ModuleFolder, "BansID.ini"); if (File.Exists(ConfigFile)) iniBansID = new IniParser(ConfigFile); else { Logger.LogError("BansID.ini does not exist!"); return; } string Date = DateTime.Now.ToShortDateString(); string Time = DateTime.Now.ToShortTimeString(); string BanMessage = "Nickname: " + player.Name + ", Date: " + Date + ", Time: " + Time + ", Reason: " + StringLog + ", Ping: " + player.Ping; iniBansIP.AddSetting("Ips", player.IP, BanMessage); iniBansID.AddSetting("Ids", player.SteamID, BanMessage); iniBansIP.Save(); iniBansID.Save(); player.MessageFrom(EchoBotName, "[color#FF2222]You have been banned."); Log("BAN: " + player.Name + " " + ". " + StringLog + ". Ping: " + player.Ping); player.Disconnect(); } catch (Exception ex) { Logger.LogException(ex); } }
/// <summary> /// Loads a random set file from the folder defined in settings and parses it into the global variable "currentSet". /// </summary> public void setRandomSet() { currentSet = new Set(); string[] files = Directory.GetFiles(settings.setDirectory,"*.ini"); string selectedSet = files[rnd.Next(0, files.Length)]; parser = new IniParser(selectedSet); currentSet.basePath = parser.GetSetting("Set", "BasePath"); currentSet.compileSong = parser.GetSetting("Set", "CompileSong").Split(';'); currentSet.successSong = parser.GetSetting("Set", "SuccessSong").Split(';'); currentSet.failSong = parser.GetSetting("Set", "FailSong").Split(';'); }
public override void Initialize() { Logger.LogDebug(ConsolePrefix + " Loading..."); string ConfigFile = Path.Combine(ModuleFolder, "Anticheat.cfg"); if(File.Exists(ConfigFile)) INIConfig = new IniParser(ConfigFile); else { Logger.LogError("Anticheat.cfg does not exist. Can't load module."); return; } DS = DataStore.GetInstance(); DS.Flush("loginCooldown"); ConfigInit(); TimersInit(); Hooks.OnEntityDecay += EntityDecay; Hooks.OnDoorUse += DoorUse; Hooks.OnEntityHurt += EntityHurt; Hooks.OnPlayerConnected += PlayerConnect; Hooks.OnPlayerDisconnected += PlayerDisconnect; Hooks.OnPlayerHurt += PlayerHurt; Hooks.OnPlayerSpawned += PlayerSpawned; if (AntiAIM_Enabled) Hooks.OnPlayerKilled += PlayerKilled; Hooks.OnServerShutdown += ServerShutdown; Hooks.OnShowTalker += ShowTalker; Hooks.OnChat += Chat; Logger.LogDebug(ConsolePrefix + " Loaded!"); }
public void GetBPData(string content) { mIni = new IniParser(content, true); }
internal static AIStructure Parse(IniParser parser) { return(parser.ParseNamedBlock( (x, name) => x.Key = name, FieldParseTable)); }
private void ServerExited(object sender, EventArgs e) { DateTime datTimeStamp = DateTime.Now; Database.AddLog(datTimeStamp, "Server Exited", "server", "warn", false, this.ServerID); this.Running = false; Util.RemovePID(this.PID); //Close firewall if (Database.GetSetting("EnableOpenFirewall", "YAMS") == "true") Networking.CloseFirewallPort(this.Port); if (Database.GetSetting("EnablePortForwarding", "YAMS") == "true") Networking.CloseUPnP(this.Port); //Server has stopped, so clear out any entries in the user list this.Players.Clear(); //Did the server stop safely? if (!this.SafeStop) { System.Threading.Thread.Sleep(10000); if (this.AgreeEULA) { //It's the EULA message, let's clear it. string strPathToRead = this.ServerDirectory + @"\eula.txt"; IniParser parser = new IniParser(strPathToRead); parser.AddSetting("ROOT", "eula", "true"); parser.SaveSettings(this.ServerDirectory + @"\eula.txt", "#Minecraft EULA file\r\n#Generated by YAMS " + DateTime.Now.ToString() + "\r\n"); } this.Start(); } }
internal static AISkirmishBuildList Parse(IniParser parser) { return(parser.ParseNamedBlock( (x, name) => x.Name = name, FieldParseTable)); }
public string GetProperty(string strPropertyName) { IniParser parser = new IniParser(this.ServerDirectory + @"\server.properties"); return parser.GetSetting("ROOT", strPropertyName); }
internal static AISkillSet Parse(IniParser parser) { return(parser.ParseBlock(FieldParseTable)); }
internal static OpenGateNugget Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
internal static void Parse(IniParser parser, AIData value) => parser.ParseBlockContent(value, FieldParseTable);
private void PlayerConnect(Fougerite.Player player) { try { try { if (AntiSpeedHack_Enabled) { DS.Add("lastCoords", player.SteamID.ToString(), player.Location); DS.Add("AntiSpeedHack", player.SteamID.ToString(), 0); } } catch (Exception ex) { Logger.LogError(ConsolePrefix + " DS fill fail"); Logger.LogException(ex); } try { IniParser iniBansIP; string ConfigFile = Path.Combine(ModuleFolder, "BansIP.ini"); if (File.Exists(ConfigFile)) iniBansIP = new IniParser(ConfigFile); else { Logger.LogError("BansIP.ini does not exist!"); return; } string IpBanned = iniBansIP.GetSetting("Ips", player.IP); if (!string.IsNullOrEmpty(IpBanned)) { player.MessageFrom(EchoBotName, "[color#FF2222]You have been banned."); Logger.LogDebug(ConsolePrefix + " " + player.Name + " banned by IP!"); player.Disconnect(); return; } IniParser iniBansID; ConfigFile = Path.Combine(ModuleFolder, "BansID.ini"); if (File.Exists(ConfigFile)) iniBansID = new IniParser(ConfigFile); else { Logger.LogError("BansID.ini does not exist!"); return; } string IdBanned = iniBansID.GetSetting("Ids", player.SteamID); if (!string.IsNullOrEmpty(IdBanned)) { player.MessageFrom(EchoBotName, "[color#FF2222]You have been banned."); Logger.LogDebug(ConsolePrefix + " " + player.Name + " banned by ID!"); player.Disconnect(); return; } } catch (Exception ex) { Logger.LogError(ConsolePrefix + " Bans check fail"); Logger.LogException(ex); } } catch (Exception ex) { Logger.LogException(ex); } try { if (NamesRestrict_Enabled) { var name = player.Name; var len = player.Name.Length; try { if (len > NamesRestrict_MaxLength) { player.MessageFrom(EchoBotName, "[color#FF2222]You have too many characters in your name. Please Change it. Maximum is " + NamesRestrict_MaxLength); Log("Nick: " + player.Name + ". Too many chars in name."); player.Disconnect(); return; } if (len < NamesRestrict_MinLength) { player.MessageFrom(EchoBotName, "[color#FF2222]You have not enough characters in your name. Please Change it. Minimum is " + NamesRestrict_MinLength); Log("Nick: " + player.Name + ". Low length of name."); player.Disconnect(); return; } } catch (Exception ex) { Logger.LogError(ConsolePrefix + " NameLenght fail"); Logger.LogException(ex); } try { foreach (char Symbol in player.Name) if (NamesRestrict_AllowedChars.IndexOf(Symbol) == -1) { player.MessageFrom(EchoBotName, "[color#FF2222]You have invalid characters in your name"); Log("Nick: " + player.Name + ". Banned chars in name."); player.Disconnect(); return; } } catch (Exception ex) { Logger.LogError(ConsolePrefix + " Name Symbols fail"); Logger.LogException(ex); } try { for (var i = 0; i < BannedNames.Length; i++) { if (player.Name.ToLower() == BannedNames[i].ToLower()) { player.MessageFrom(EchoBotName, "[color#FF2222]This name isn't allowed. Please change your name."); Log("Nick: " + player.Name + ". Banned name."); player.Disconnect(); return; } } } catch (Exception ex) { Logger.LogError(ConsolePrefix + " BannedNames fail"); Logger.LogException(ex); } try { if (NamesRestrict_BindName) { IniParser BoundNames; if (File.Exists(Path.Combine(ModuleFolder, "BoundNames.ini"))) BoundNames = new IniParser(Path.Combine(ModuleFolder, "BoundNames.ini")); else { Logger.LogError(Path.Combine(ModuleFolder, "BoundNames.ini") + " does not exist!"); return; } var Name = player.Name.ToLower(); string ID = BoundNames.GetSetting("Names", Name); if ((player.Admin && NamesRestrict_AdminsOnly) || !NamesRestrict_AdminsOnly) { if (string.IsNullOrEmpty(ID)) { player.MessageFrom(EchoBotName, "[color#22AAFF]Nick " + player.Name + " was bound to your SteamID."); BoundNames.AddSetting("Names", Name, player.SteamID); BoundNames.Save(); } else if (ID != player.SteamID) { player.MessageFrom(EchoBotName, "[color#FF2222]This nickname doesn't belong to you."); Log("Nick: " + player.Name + ". Nick stealer."); player.Disconnect(); return; } } } } catch (Exception ex) { Logger.LogError(ConsolePrefix + " BindName fail"); Logger.LogException(ex); } } } catch (Exception ex) { Logger.LogError(ConsolePrefix + " NickRestrict check fail"); Logger.LogException(ex); } try { if (RelogCooldown) { var Time = Environment.TickCount; object ObjCooldown = DS.Get("loginCooldown", player.SteamID.ToString()); if (ObjCooldown == null) return; int Disconnected = (int) ObjCooldown; if (Time <= Cooldown * 1000 + Disconnected) { var Remaining = ((Cooldown * 1000 - (Time - Disconnected)) / 1000).ToString("F2"); player.MessageFrom(EchoBotName, "[color#FF2222]You must wait " + Cooldown + " seconds before reconnecting. Remaining: " + Remaining + " seconds."); Logger.LogDebug(ConsolePrefix + " " + player.Name + " connect cooldown " + Cooldown + " sec!"); player.Disconnect(); return; } if (Time > Cooldown * 1000 + Disconnected) DS.Remove("loginCooldown", player.SteamID.ToString()); } } catch (Exception ex) { Logger.LogError(ConsolePrefix + " Cooldown check fail"); Logger.LogException(ex); } Logger.LogDebug(ConsolePrefix + " " + player.Name + " Connected!"); }
internal static BezierProjectileBehaviorData Parse(IniParser parser) => parser.ParseBlock(BezierProjectileFieldParseTable);
public string GetProperty(string strPropertyName) { try { IniParser parser = new IniParser(this.ServerDirectory + @"\server.properties"); return parser.GetSetting("ROOT", strPropertyName); } catch (Exception e) { Database.AddLog("Cannot get property \"" + strPropertyName + "\" for server " + this.ServerTitle, "server", "error", false, this.ServerID); return null; } }
internal static TerrainScorchFXNuggetData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
private void buttonImportTheme_Click(object sender, EventArgs e) { //this will load an icechat 7 theme //do it the same way as icechat 7 did, from the clipboard OpenFileDialog ofd = new OpenFileDialog(); ofd.DefaultExt = ".ini"; ofd.CheckFileExists = true; ofd.CheckPathExists = true; ofd.AddExtension = true; ofd.AutoUpgradeEnabled = true; ofd.Filter = "Monody INI Setting (*.ini)|*.ini"; ofd.Title = "Locate the Monody.ini settings file?"; string directory = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Monody"; //check if the folder exists if (File.Exists(directory + Path.DirectorySeparatorChar + "icechat.ini")) ofd.InitialDirectory = directory; else ofd.InitialDirectory = Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData); if (ofd.ShowDialog() == DialogResult.OK) { //make sure it is icechat.ini System.Diagnostics.Debug.WriteLine(ofd.FileName); if (Path.GetFileName(ofd.FileName).ToLower().Equals("icechat.ini")) { IniParser parser = new IniParser(ofd.FileName); string[] themes = parser.EnumSectionTheme("Color Themes"); foreach (string theme in themes) { string name = theme.Substring(0, theme.IndexOf((char)255)); string value = theme.Substring(theme.IndexOf((char)255) + 1); string[] colors = value.Split(','); if (name == "Default") name = "DefaultIce7"; IceChatColors ic = new IceChatColors(); ic.ChannelAdminColor = Convert.ToInt32(colors[38]); ic.ChannelBackColor = Convert.ToInt32(colors[43]); ic.ChannelListBackColor = Convert.ToInt32(colors[63]); ic.ChannelListForeColor = Convert.ToInt32(colors[86]); ic.ChannelOwnerColor = Convert.ToInt32(colors[39]); ic.ChannelRegularColor = Convert.ToInt32(colors[34]); ic.ChannelVoiceColor = Convert.ToInt32(colors[35]); ic.ChannelHalfOpColor = Convert.ToInt32(colors[36]); ic.ChannelOpColor = Convert.ToInt32(colors[37]); ic.ConsoleBackColor = Convert.ToInt32(colors[42]); ic.InputboxBackColor = Convert.ToInt32(colors[52]); ic.InputboxForeColor = Convert.ToInt32(colors[25]); ic.NickListBackColor = Convert.ToInt32(colors[53]); ic.PanelHeaderBG1 = Convert.ToInt32(colors[70]); ic.PanelHeaderBG2 = Convert.ToInt32(colors[71]); ic.PanelHeaderForeColor = Convert.ToInt32(colors[88]); ic.QueryBackColor = Convert.ToInt32(colors[44]); ic.RandomizeNickColors = false; ic.ServerListBackColor = Convert.ToInt32(colors[54]); ic.StatusbarBackColor = Convert.ToInt32(colors[90]); ic.StatusbarForeColor = Convert.ToInt32(colors[89]); ic.TabBarChannelJoin = Convert.ToInt32(colors[30]); ic.TabBarChannelPart = Convert.ToInt32(colors[31]); ic.TabBarCurrent = Convert.ToInt32(colors[28]); ic.TabBarDefault = Convert.ToInt32(colors[28]); ic.TabBarNewMessage = Convert.ToInt32(colors[29]); ic.TabBarOtherMessage = Convert.ToInt32(colors[32]); ic.TabBarServerMessage = Convert.ToInt32(colors[32]); ic.TabBarServerQuit = Convert.ToInt32(colors[32]); ic.TabBarNewAction = Convert.ToInt32(colors[29]); ic.TabBarServerNotice = Convert.ToInt32(colors[32]); ic.TabBarBuddyNotice = Convert.ToInt32(colors[32]); ic.ToolbarBackColor = Convert.ToInt32(colors[68]); ic.UnreadTextMarkerColor = Convert.ToInt32(colors[67]); XmlSerializer serializerC = new XmlSerializer(typeof(IceChatColors)); string themeFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Colors-" + name + ".xml"; TextWriter textWriterC = new StreamWriter(themeFile); serializerC.Serialize(textWriterC, ic); textWriterC.Close(); textWriterC.Dispose(); IceChatMessageFormat im = new IceChatMessageFormat(); im.MessageSettings = new ServerMessageFormatItem[49]; im.MessageSettings[0] = NewMessageFormat("Server Connect", "" + colors[18] + "*** Attempting to connect to $server ($serverip) on port $port"); im.MessageSettings[1] = NewMessageFormat("Server Disconnect", "" + colors[19] + "*** Server disconnected on $server"); im.MessageSettings[2] = NewMessageFormat("Server Reconnect", "" + colors[11] + "*** Attempting to re-connect to $server"); im.MessageSettings[3] = NewMessageFormat("Channel Invite", "" + colors[22] + "* $nick invites you to $channel"); im.MessageSettings[4] = NewMessageFormat("Ctcp Reply", "" + colors[27] + "[$nick $ctcp Reply] : $reply"); im.MessageSettings[5] = NewMessageFormat("Ctcp Send", "" + colors[26] + "--> [$nick] $ctcp"); im.MessageSettings[6] = NewMessageFormat("Ctcp Request", "" + colors[11] + "[$nick] $ctcp"); im.MessageSettings[7] = NewMessageFormat("Channel Mode", "" + colors[7] + "* $nick sets mode $mode $modeparam for $channel"); im.MessageSettings[8] = NewMessageFormat("Server Mode", "" + colors[16] + "* Your mode is now $mode"); im.MessageSettings[9] = NewMessageFormat("Server Notice", "" + colors[24] + "*** $server $message"); im.MessageSettings[10] = NewMessageFormat("Server Message", "" + colors[11] + "-$server- $message"); im.MessageSettings[11] = NewMessageFormat("User Notice", "" + colors[3] + "--$nick-- $message"); im.MessageSettings[12] = NewMessageFormat("Channel Message", "" + colors[0] + "<$color$status$nick> $message"); im.MessageSettings[13] = NewMessageFormat("Self Channel Message", "" + colors[2] + "<$nick> $message"); im.MessageSettings[14] = NewMessageFormat("Channel Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[15] = NewMessageFormat("Self Channel Action", "" + colors[2] + "* $nick $message"); im.MessageSettings[16] = NewMessageFormat("Channel Join", "" + colors[5] + "* $nick ($host)$account has joined channel $channel"); im.MessageSettings[17] = NewMessageFormat("Self Channel Join", "" + colors[5] + "* You have joined $channel"); im.MessageSettings[18] = NewMessageFormat("Channel Part", "" + colors[4] + "* $nick ($host) has left $channel $reason"); im.MessageSettings[19] = NewMessageFormat("Self Channel Part", "" + colors[4] + "* You have left $channel - You will be missed 10 $reason"); im.MessageSettings[20] = NewMessageFormat("Server Quit", "" + colors[21] + "* $nick ($host) Quit ($reason)"); im.MessageSettings[21] = NewMessageFormat("Channel Nick Change", "" + colors[20] + "* $nick is now known as $newnick"); im.MessageSettings[22] = NewMessageFormat("Self Nick Change", "" + colors[20] + "* You are now known as $newnick"); im.MessageSettings[23] = NewMessageFormat("Channel Kick", "" + colors[6] + "* $kickee was kicked by $nick($host) 3 - Reason ($reason)"); im.MessageSettings[24] = NewMessageFormat("Self Channel Kick", "" + colors[6] + "* You were kicked from $channel by $kicker (3$reason)"); im.MessageSettings[25] = NewMessageFormat("Private Message", "" + colors[0] + "<$nick> $message"); im.MessageSettings[26] = NewMessageFormat("Self Private Message", "" + colors[2] + "<$nick>1 $message"); im.MessageSettings[27] = NewMessageFormat("Private Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[28] = NewMessageFormat("Self Private Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[29] = NewMessageFormat("DCC Chat Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[30] = NewMessageFormat("Self DCC Chat Action", "" + colors[1] + "* $nick $message"); im.MessageSettings[31] = NewMessageFormat("DCC Chat Message", "" + colors[0] + "<$nick> $message"); im.MessageSettings[32] = NewMessageFormat("Self DCC Chat Message", "" + colors[2] + "<$nick> $message"); im.MessageSettings[33] = NewMessageFormat("DCC Chat Request", "" + colors[11] + "* $nick ($host) is requesting a DCC Chat"); im.MessageSettings[34] = NewMessageFormat("DCC File Send", "" + colors[11] + "* $nick ($host) is trying to send you a file ($file) [$filesize bytes]"); im.MessageSettings[35] = NewMessageFormat("Channel Topic Change", "" + colors[8] + "* $nick changes topic to: $topic"); im.MessageSettings[36] = NewMessageFormat("Channel Topic Text", "" + colors[8] + " Topic: $topic"); im.MessageSettings[37] = NewMessageFormat("Server MOTD", "" + colors[10] + "$message"); im.MessageSettings[38] = NewMessageFormat("Channel Notice", "" + colors[3] + "-$nick:$status$channel- $message"); im.MessageSettings[39] = NewMessageFormat("Channel Other", "" + colors[9] + "$message"); im.MessageSettings[40] = NewMessageFormat("User Echo", "" + colors[15] + "$message"); im.MessageSettings[41] = NewMessageFormat("Server Error", "" + colors[17] + "ERROR: $message"); im.MessageSettings[42] = NewMessageFormat("User Whois", "" + colors[14] + "->> $nick $data"); im.MessageSettings[43] = NewMessageFormat("User Error", "" + colors[12] + "ERROR: $message"); im.MessageSettings[44] = NewMessageFormat("DCC Chat Connect", "" + colors[18] + "* DCC Chat Connection Established with $nick"); im.MessageSettings[45] = NewMessageFormat("DCC Chat Disconnect", "" + colors[19] + "* DCC Chat Disconnected from $nick"); im.MessageSettings[46] = NewMessageFormat("DCC Chat Outgoing", "" + colors[11] + "* DCC Chat Requested with $nick"); im.MessageSettings[47] = NewMessageFormat("DCC Chat Timeout", "" + colors[11] + "* DCC Chat with $nick timed out"); im.MessageSettings[48] = NewMessageFormat("Self Notice", "" + colors[24] + "--> $nick - $message"); //check if we have this theme already... bool themeFound = false; foreach (ComboItem checkTheme in comboTheme.Items) { if (checkTheme.ThemeName.ToLower().Equals(name.ToLower())) themeFound = true; } if (themeFound == false) { XmlSerializer serializerIM = new XmlSerializer(typeof(IceChatMessageFormat)); string messFile = FormMain.Instance.CurrentFolder + System.IO.Path.DirectorySeparatorChar + "Messages-" + name + ".xml"; TextWriter textWriterIM = new StreamWriter(messFile); serializerIM.Serialize(textWriterIM, im); textWriterIM.Close(); textWriterIM.Dispose(); ComboItem item = new ComboItem(); item.ThemeName = name; item.ThemeType = "XML"; comboTheme.Items.Add(item); } } } } }
/// <summary> /// Druck des Haftungsausschlusses /// </summary> /// <param name="personID">ID der Person</param> public static void printClientDisclaimer(int?personID = null) { if (!LibreOffice.isLibreOfficeInstalled()) { string warning = IniParser.GetSetting("ERRORMSG", "libre"); MessageBoxEnhanced.Error(warning); } string currentDir = System.IO.Directory.GetCurrentDirectory(); string path = IniParser.GetSetting("DOCUMENTS", "path").Replace("%PROGRAMPATH%", currentDir) + "\\" + IniParser.GetSetting("DOCUMENTS", "disclaimer"); List <string> toReplace = new List <string>(); List <string> replaceSt = new List <string>(); if (personID.HasValue) { Person person; try { person = Person.GetPersons(personID).FirstOrDefault(); } catch { return; } toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachname></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.LastName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Vorname></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.FirstName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Ausweisnummer></text:placeholder>"); if (person.TableNo.HasValue) { replaceSt.Add(SafeStringParser.safeParseToStr(person.TableNo)); } else { return; } toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Datum></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(DateTime.Now)); } else { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachname></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Vorname></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Ausweisnummer></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Datum></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:span text:style-name=\"T3\">, </text:span>"); replaceSt.Add(""); } string tmpFilePath; bool success = LibreOffice.replaceXMLstringInODT(path, toReplace, replaceSt, out tmpFilePath); if (success) { LibreOffice.openWithWriter(tmpFilePath, true, true); } }
public void ToIni() { IniParser ini = new IniParser(path); ini.AddSetting("Def", "itemCount", itemCount.ToString()); ini.AddSetting("Def", "ownerCanUse", OwnerUse.ToString()); ini.AddSetting("Def", "modCanUse", ModeratorUse.ToString()); ini.AddSetting("Def", "normalCanUse", NormalUse.ToString()); for (int i = 0; i < itemCount; i++) { ini.AddSetting(i.ToString(), "Name", items[i].Name); ini.AddSetting(i.ToString(), "Amount", items[i].Amount.ToString()); } ini.Save(); }
/// <summary> /// Druck des Kassenabschlussberichts /// </summary> /// <param name="cashClosureID">Kassenabschluss-ID</param> /// <param name="reprint">Nachdruck</param> public static void printCashClosureReport(int cashClosureID, bool reprint) { if (!LibreOffice.isLibreOfficeInstalled()) { string warning = IniParser.GetSetting("ERRORMSG", "libre"); MessageBoxEnhanced.Error(warning); } CashClosureReport report; try { var reports = CashClosureReport.GetCashClosureReports(null, cashClosureID); report = reports.FirstOrDefault(); } catch { return; } string currentDir = System.IO.Directory.GetCurrentDirectory(); string path = IniParser.GetSetting("DOCUMENTS", "path").Replace("%PROGRAMPATH%", currentDir) + "\\" + IniParser.GetSetting("DOCUMENTS", "cashClosureReport"); List <string> toReplace = new List <string>(); List <string> replaceSt = new List <string>(); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachdruck></text:placeholder>"); if (reprint) { replaceSt.Add(SafeStringParser.safeParseToStr(IniParser.GetSetting("DOCUMENTS", "reprint"))); } else { replaceSt.Add(""); } toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kassenabschlussdatum></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(report.CashClosure.ClosureDate)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kassenabschlussnummer></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(report.CashClosure.CashClosureID)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Einnahmen></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Revenue, true)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Ausgaben></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Expense, true)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Saldo></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Sum, true)); string tmpFilePath; bool success = LibreOffice.replaceXMLstringInODT(path, toReplace, replaceSt, out tmpFilePath); if (success) { LibreOffice.openWithWriter(tmpFilePath, true, true); } }
public string GetProperty(string strPropertyName) { //File.WriteAllText(Core.RootFolder + @"\log.err", "Try to get property: " + strPropertyName + " from file: " + this.ServerDirectory + @"\server.properties"); IniParser parser = new IniParser(this.ServerDirectory + @"\server.properties"); return parser.GetSetting("ROOT", strPropertyName); }
/// <summary> /// Druck des Aufnahmeformulars /// </summary> /// <param name="personID">ID der Person</param> public static void printClientEnrolmentForm(int personID) { if (!LibreOffice.isLibreOfficeInstalled()) { string warning = IniParser.GetSetting("ERRORMSG", "libre"); MessageBoxEnhanced.Error(warning); } Person person; try { var persons = Person.GetPersons(personID).ToList(); person = persons.FirstOrDefault(); } catch { return; } string currentDir = System.IO.Directory.GetCurrentDirectory(); string path = IniParser.GetSetting("DOCUMENTS", "path").Replace("%PROGRAMPATH%", currentDir) + "\\" + IniParser.GetSetting("DOCUMENTS", "enrolmentForm"); List <string> toReplace = new List <string>(); List <string> replaceSt = new List <string>(); int rowsChildren = 6; int rowsRevenues = 8; if (person == null) { return; } toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Vorname></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.FirstName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachname></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.LastName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Strasse></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.Street)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><PLZ></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.ZipCode)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Ort></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.City)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Geburtstag></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.DateOfBirth)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Staatsangehoerigkeit></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.Nationality)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Geburtsland></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.CountryOfBirth)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Familienstand></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.FamilyState.Name)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Vorname_Partner></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalFirstName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Nachname_Partner></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalLastName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Geburtstag_Partner></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalBirthday)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Staatsangehoerigkeit_Partner></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalNationality)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Datum></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(DateTime.Now)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Gueltigkeitsende></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.ValidityEnd)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><KNR></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(person.TableNo)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Erfasser></text:placeholder>"); if (person.UserAccount != null) { replaceSt.Add(SafeStringParser.safeParseToStr(person.UserAccount.Username)); } else { replaceSt.Add(""); } // fülle Kinder IEnumerable <Child> children = Child.GetChildren(null, person.PersonID); int childIndex = 1; foreach (var child in children) { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Index_" + childIndex + "></text:placeholder>"); replaceSt.Add("#" + childIndex); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Vorname_" + childIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(child.FirstName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Nachname_" + childIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(child.LastName)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Geburtstag_" + childIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(child.DateOfBirth)); childIndex++; } // Sorge dafür, dass die übrigen Zeilen beim Druck leer sind for (int i = childIndex; i <= rowsChildren; i++) { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Index_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Vorname_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Nachname_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Kind_Geburtstag_" + i + "></text:placeholder>"); replaceSt.Add(""); } // fülle Einkünfte IEnumerable <Revenue> revenues = Revenue.GetRevenues(null, person.PersonID); int revenueIndex = 1; foreach (var revenue in revenues) { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Einkunft_" + revenueIndex + "></text:placeholder>"); replaceSt.Add(revenue.RevenueType.Name + ": " + revenue.Description); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Bescheid_" + revenueIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(revenue.StartDate)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Bewilligt_" + revenueIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToStr(revenue.EndDate)); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Hoehe_" + revenueIndex + "></text:placeholder>"); replaceSt.Add(SafeStringParser.safeParseToMoney(revenue.Amount, true)); revenueIndex++; } // Sorge dafür, dass die übrigen Zeilen beim Druck leer sind for (int i = revenueIndex; i <= rowsRevenues; i++) { toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Einkunft_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Bescheid_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Bewilligt_" + i + "></text:placeholder>"); replaceSt.Add(""); toReplace.Add("<text:placeholder text:placeholder-type=\"text\"><Hoehe_" + i + "></text:placeholder>"); replaceSt.Add(""); } string tmpFilePath; bool success = LibreOffice.replaceXMLstringInODT(path, toReplace, replaceSt, out tmpFilePath); if (success) { LibreOffice.openWithWriter(tmpFilePath, true, true); } }
public override void Initialize() { Config = new IniParser(Path.Combine(ModuleFolder, "GlitchFix.cfg")); Fougerite.Hooks.OnEntityDeployed += EntityDeployed; }
/// <summary> /// Druck des Caritas-Formulars /// </summary> public static void printCaritasForm() { string path = IniParser.GetSetting("DOCUMENTS", "path") + "\\CaritasDienste.odt"; LibreOffice.openWithWriter(path, true, false); }
private void loadPrefs() { if (!File.Exists("CP1252Fixer.ini")) { System.IO.FileStream fs = System.IO.File.Create("CP1252Fixer.ini"); fs.Close(); return; // just make the file for saving to later, and keep defaults } IniParser parser = new IniParser(@"CP1252Fixer.ini"); for (int i = 0; i < CMOptions.Length; ++i) { String on = parser.GetSetting("options", CMOptions[i].text.ToUpper()); setOption(ref CMOptions[i], on == "TRUE"); } }
internal static W3dDebrisDrawModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);