Пример #1
0
        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();

        }
Пример #2
0
        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"));
        }
Пример #3
0
        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);
        }
Пример #4
0
 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");
            }
        }
Пример #6
0
        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);
        }
Пример #7
0
        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!");
        }
Пример #8
0
        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;           
        }
Пример #9
0
        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;
            }
        }
Пример #10
0
 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");
 }
Пример #11
0
 /// <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;
 }
Пример #12
0
 internal static DamageFX Parse(IniParser parser)
 {
     return(parser.ParseNamedBlock(
                (x, name) => x.SetNameAndInstanceId("DamageFX", name),
                FieldParseTable));
 }
Пример #13
0
 internal static FloodMember Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #14
0
 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");
 }
Пример #15
0
 internal static CivilianSpawnCollideModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #16
0
        /// <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);
            }
        }
Пример #17
0
 internal static ParalyzeNugget Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #18
0
        //        string req2 =
        //" { " +
        //"   \"Method\":\"GetFuellingPointConfig\" " +
        //" } ";
        //        "Method":"Preset"
        //,"Transaction":

        static UTAPI()
        {
            ReadCodes();
            iniFile = new IniParser("groups.ini");
        }
Пример #19
0
 internal static new DevastateSpecialPowerModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #20
0
 internal static FXListDieModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #21
0
 internal static SpawnAndFadeNugget Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #22
0
 internal static EvaSideSound Parse(IniParser parser)
 {
     return(parser.ParseBlock(FieldParseTable));
 }
Пример #23
0
 static rustpp()
 {
     string path = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "rust++.cfg"));
         config = new IniParser (@path);
 }
Пример #24
0
 internal static SlavedUpdateModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #25
0
        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();
        }
Пример #26
0
        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();
        }
Пример #27
0
 internal static EvaEvent Parse(IniParser parser)
 {
     return(parser.ParseNamedBlock(
                (x, name) => x.SetNameAndInstanceId("EvaEvent", name),
                FieldParseTable));
 }
Пример #28
0
 internal static BridgeTowerBehaviorModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #29
0
        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();
        }
Пример #30
0
 internal static VolumeSliderMultiplier Parse(IniParser parser) => parser.ParseAttributeList(FieldParseTable);
Пример #31
0
 internal static AISideInfo Parse(IniParser parser)
 {
     return(parser.ParseNamedBlock(
                (x, name) => x.Name = name,
                FieldParseTable));
 }
Пример #32
0
 internal static DefaultProductionExitUpdateModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #33
0
        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");
        }
Пример #34
0
 internal static LuaEventNugget Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #35
0
        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;
        }
Пример #36
0
        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);
            }
        }
Пример #37
0
 /// <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(';');
 }
Пример #38
0
        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!");
        }
Пример #39
0
        public void GetBPData(string content)
		{
			mIni = new IniParser(content, true);
		}
Пример #40
0
 internal static AIStructure Parse(IniParser parser)
 {
     return(parser.ParseNamedBlock(
                (x, name) => x.Key = name,
                FieldParseTable));
 }
Пример #41
0
        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();
            }
        }
Пример #42
0
 internal static AISkirmishBuildList Parse(IniParser parser)
 {
     return(parser.ParseNamedBlock(
                (x, name) => x.Name = name,
                FieldParseTable));
 }
Пример #43
0
 public string GetProperty(string strPropertyName)
 {
     IniParser parser = new IniParser(this.ServerDirectory + @"\server.properties");
     return parser.GetSetting("ROOT", strPropertyName);
 }
Пример #44
0
 internal static AISkillSet Parse(IniParser parser)
 {
     return(parser.ParseBlock(FieldParseTable));
 }
Пример #45
0
 internal static OpenGateNugget Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #46
0
 internal static void Parse(IniParser parser, AIData value) => parser.ParseBlockContent(value, FieldParseTable);
Пример #47
0
        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!");
        }
Пример #48
0
 internal static BezierProjectileBehaviorData Parse(IniParser parser) => parser.ParseBlock(BezierProjectileFieldParseTable);
Пример #49
0
 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;
     }
 }
Пример #50
0
 internal static TerrainScorchFXNuggetData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);
Пример #51
0
        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", "&#x3;" + colors[18] + "*** Attempting to connect to $server ($serverip) on port $port");
                        im.MessageSettings[1] = NewMessageFormat("Server Disconnect", "&#x3;" + colors[19] + "*** Server disconnected on $server");
                        im.MessageSettings[2] = NewMessageFormat("Server Reconnect", "&#x3;" + colors[11] + "*** Attempting to re-connect to $server");
                        im.MessageSettings[3] = NewMessageFormat("Channel Invite", "&#x3;" + colors[22] + "* $nick invites you to $channel");
                        im.MessageSettings[4] = NewMessageFormat("Ctcp Reply", "&#x3;" + colors[27] + "[$nick $ctcp Reply] : $reply");
                        im.MessageSettings[5] = NewMessageFormat("Ctcp Send", "&#x3;" + colors[26] + "--> [$nick] $ctcp");
                        im.MessageSettings[6] = NewMessageFormat("Ctcp Request", "&#x3;" + colors[11] + "[$nick] $ctcp");
                        im.MessageSettings[7] = NewMessageFormat("Channel Mode", "&#x3;" + colors[7] + "* $nick sets mode $mode $modeparam for $channel");
                        im.MessageSettings[8] = NewMessageFormat("Server Mode", "&#x3;" + colors[16] + "* Your mode is now $mode");
                        im.MessageSettings[9] = NewMessageFormat("Server Notice", "&#x3;" + colors[24] + "*** $server $message");
                        im.MessageSettings[10] = NewMessageFormat("Server Message", "&#x3;" + colors[11] + "-$server- $message");
                        im.MessageSettings[11] = NewMessageFormat("User Notice", "&#x3;" + colors[3] + "--$nick-- $message");
                        im.MessageSettings[12] = NewMessageFormat("Channel Message", "&#x3;" + colors[0] + "<$color$status$nick&#x3;> $message");
                        im.MessageSettings[13] = NewMessageFormat("Self Channel Message", "&#x3;" + colors[2] + "<$nick&#x3;> $message");
                        im.MessageSettings[14] = NewMessageFormat("Channel Action", "&#x3;" + colors[1] + "* $nick $message");
                        im.MessageSettings[15] = NewMessageFormat("Self Channel Action", "&#x3;" + colors[2] + "* $nick $message");
                        im.MessageSettings[16] = NewMessageFormat("Channel Join", "&#x3;" + colors[5] + "* $nick ($host)$account has joined channel $channel");
                        im.MessageSettings[17] = NewMessageFormat("Self Channel Join", "&#x3;" + colors[5] + "* You have joined $channel");
                        im.MessageSettings[18] = NewMessageFormat("Channel Part", "&#x3;" + colors[4] + "* $nick ($host) has left $channel $reason");
                        im.MessageSettings[19] = NewMessageFormat("Self Channel Part", "&#x3;" + colors[4] + "* You have left $channel - You will be missed &#x3;10 $reason");
                        im.MessageSettings[20] = NewMessageFormat("Server Quit", "&#x3;" + colors[21] + "* $nick ($host) Quit ($reason)");
                        im.MessageSettings[21] = NewMessageFormat("Channel Nick Change", "&#x3;" + colors[20] + "* $nick is now known as $newnick");
                        im.MessageSettings[22] = NewMessageFormat("Self Nick Change", "&#x3;" + colors[20] + "* You are now known as $newnick");
                        im.MessageSettings[23] = NewMessageFormat("Channel Kick", "&#x3;" + colors[6] + "* $kickee was kicked by $nick($host) &#x3;3 - Reason ($reason)");
                        im.MessageSettings[24] = NewMessageFormat("Self Channel Kick", "&#x3;" + colors[6] + "* You were kicked from $channel by $kicker (&#x3;3$reason)");
                        im.MessageSettings[25] = NewMessageFormat("Private Message", "&#x3;" + colors[0] + "<$nick> $message");
                        im.MessageSettings[26] = NewMessageFormat("Self Private Message", "&#x3;" + colors[2] + "<$nick>&#x3;1 $message");
                        im.MessageSettings[27] = NewMessageFormat("Private Action", "&#x3;" + colors[1] + "* $nick $message");
                        im.MessageSettings[28] = NewMessageFormat("Self Private Action", "&#x3;" + colors[1] + "* $nick $message");
                        im.MessageSettings[29] = NewMessageFormat("DCC Chat Action", "&#x3;" + colors[1] + "* $nick $message");
                        im.MessageSettings[30] = NewMessageFormat("Self DCC Chat Action", "&#x3;" + colors[1] + "* $nick $message");
                        im.MessageSettings[31] = NewMessageFormat("DCC Chat Message", "&#x3;" + colors[0] + "<$nick> $message");
                        im.MessageSettings[32] = NewMessageFormat("Self DCC Chat Message", "&#x3;" + colors[2] + "<$nick> $message");
                        im.MessageSettings[33] = NewMessageFormat("DCC Chat Request", "&#x3;" + colors[11] + "* $nick ($host) is requesting a DCC Chat");
                        im.MessageSettings[34] = NewMessageFormat("DCC File Send", "&#x3;" + colors[11] + "* $nick ($host) is trying to send you a file ($file) [$filesize bytes]");
                        im.MessageSettings[35] = NewMessageFormat("Channel Topic Change", "&#x3;" + colors[8] + "* $nick changes topic to: $topic");
                        im.MessageSettings[36] = NewMessageFormat("Channel Topic Text", "&#x3;" + colors[8] + " Topic: $topic");
                        im.MessageSettings[37] = NewMessageFormat("Server MOTD", "&#x3;" + colors[10] + "$message");
                        im.MessageSettings[38] = NewMessageFormat("Channel Notice", "&#x3;" + colors[3] + "-$nick:$status$channel- $message");
                        im.MessageSettings[39] = NewMessageFormat("Channel Other", "&#x3;" + colors[9] + "$message");
                        im.MessageSettings[40] = NewMessageFormat("User Echo", "&#x3;" + colors[15] + "$message");
                        im.MessageSettings[41] = NewMessageFormat("Server Error", "&#x3;" + colors[17] + "ERROR: $message");
                        im.MessageSettings[42] = NewMessageFormat("User Whois", "&#x3;" + colors[14] + "->> $nick $data");
                        im.MessageSettings[43] = NewMessageFormat("User Error", "&#x3;" + colors[12] + "ERROR: $message");
                        im.MessageSettings[44] = NewMessageFormat("DCC Chat Connect", "&#x3;" + colors[18] + "* DCC Chat Connection Established with $nick");
                        im.MessageSettings[45] = NewMessageFormat("DCC Chat Disconnect", "&#x3;" + colors[19] + "* DCC Chat Disconnected from $nick");
                        im.MessageSettings[46] = NewMessageFormat("DCC Chat Outgoing", "&#x3;" + colors[11] + "* DCC Chat Requested with $nick");
                        im.MessageSettings[47] = NewMessageFormat("DCC Chat Timeout", "&#x3;" + colors[11] + "* DCC Chat with $nick timed out");
                        im.MessageSettings[48] = NewMessageFormat("Self Notice", "&#x3;" + 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);
                        }
                    }

                }

            }
        }
Пример #52
0
        /// <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\">&lt;Nachname&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(person.LastName));

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Vorname&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(person.FirstName));

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Ausweisnummer&gt;</text:placeholder>");
                if (person.TableNo.HasValue)
                {
                    replaceSt.Add(SafeStringParser.safeParseToStr(person.TableNo));
                }
                else
                {
                    return;
                }

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Datum&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(DateTime.Now));
            }
            else
            {
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Nachname&gt;</text:placeholder>");
                replaceSt.Add("");

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Vorname&gt;</text:placeholder>");
                replaceSt.Add("");

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Ausweisnummer&gt;</text:placeholder>");
                replaceSt.Add("");

                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Datum&gt;</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);
            }
        }
Пример #53
0
        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();
        }
Пример #54
0
        /// <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\">&lt;Nachdruck&gt;</text:placeholder>");
            if (reprint)
            {
                replaceSt.Add(SafeStringParser.safeParseToStr(IniParser.GetSetting("DOCUMENTS", "reprint")));
            }
            else
            {
                replaceSt.Add("");
            }

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kassenabschlussdatum&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(report.CashClosure.ClosureDate));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kassenabschlussnummer&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(report.CashClosure.CashClosureID));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Einnahmen&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Revenue, true));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Ausgaben&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToMoney(report.CashClosure.Expense, true));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Saldo&gt;</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);
            }
        }
Пример #55
0
 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);
 }
Пример #56
0
        /// <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\">&lt;Vorname&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.FirstName));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Nachname&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.LastName));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Strasse&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.Street));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;PLZ&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.ZipCode));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Ort&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.City));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Geburtstag&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.DateOfBirth));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Staatsangehoerigkeit&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.Nationality));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Geburtsland&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.CountryOfBirth));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Familienstand&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.FamilyState.Name));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Vorname_Partner&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalFirstName));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Nachname_Partner&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalLastName));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Geburtstag_Partner&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalBirthday));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Staatsangehoerigkeit_Partner&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.MaritalNationality));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Datum&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(DateTime.Now));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Gueltigkeitsende&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.ValidityEnd));
            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;KNR&gt;</text:placeholder>");
            replaceSt.Add(SafeStringParser.safeParseToStr(person.TableNo));

            toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Erfasser&gt;</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\">&lt;Kind_Index_" + childIndex + "&gt;</text:placeholder>");
                replaceSt.Add("#" + childIndex);
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Vorname_" + childIndex + "&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(child.FirstName));
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Nachname_" + childIndex + "&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(child.LastName));
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Geburtstag_" + childIndex + "&gt;</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\">&lt;Kind_Index_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Vorname_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Nachname_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Kind_Geburtstag_" + i + "&gt;</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\">&lt;Einkunft_" + revenueIndex + "&gt;</text:placeholder>");
                replaceSt.Add(revenue.RevenueType.Name + ": " + revenue.Description);
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Bescheid_" + revenueIndex + "&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(revenue.StartDate));
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Bewilligt_" + revenueIndex + "&gt;</text:placeholder>");
                replaceSt.Add(SafeStringParser.safeParseToStr(revenue.EndDate));
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Hoehe_" + revenueIndex + "&gt;</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\">&lt;Einkunft_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Bescheid_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Bewilligt_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
                toReplace.Add("<text:placeholder text:placeholder-type=\"text\">&lt;Hoehe_" + i + "&gt;</text:placeholder>");
                replaceSt.Add("");
            }

            string tmpFilePath;
            bool   success = LibreOffice.replaceXMLstringInODT(path, toReplace, replaceSt, out tmpFilePath);

            if (success)
            {
                LibreOffice.openWithWriter(tmpFilePath, true, true);
            }
        }
Пример #57
0
 public override void Initialize()
 {
     Config = new IniParser(Path.Combine(ModuleFolder, "GlitchFix.cfg"));
     Fougerite.Hooks.OnEntityDeployed += EntityDeployed;
 }
Пример #58
0
        /// <summary>
        /// Druck des Caritas-Formulars
        /// </summary>
        public static void printCaritasForm()
        {
            string path = IniParser.GetSetting("DOCUMENTS", "path") + "\\CaritasDienste.odt";

            LibreOffice.openWithWriter(path, true, false);
        }
Пример #59
0
        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");
            }
        }
Пример #60
0
 internal static W3dDebrisDrawModuleData Parse(IniParser parser) => parser.ParseBlock(FieldParseTable);