示例#1
0
        public static ArrayList GetWebBookMarks(string serverPath, string clientID, MySqlWrapper dbConn)
        {
            ArrayList webBookmarks = new ArrayList();

            try
            {
                string    sql       = "select bookmark_title,bookmark_url from ctool_bookmark where bookmark_ownerid = " + clientID;
                ArrayList recordset = dbConn.Execute(sql);
                foreach (ArrayList record in recordset)
                {
                    WebBookMark entry = new WebBookMark((string)record[0], (string)record[1]);
                    webBookmarks.Add(entry);
                }

                sql       = "select bookmark_title,bookmark_url from ctool_bookmark,ctool_bmtouser where bookmark_id = bmtouser_bookmark_id AND bmtouser_mid = " + clientID;
                recordset = dbConn.Execute(sql);
                foreach (ArrayList record in recordset)
                {
                    WebBookMark entry = new WebBookMark((string)record[0], (string)record[1]);
                    webBookmarks.Add(entry);
                }
            }
            catch (Exception ee)
            {
                //	MessageBox.Show(ee.Message);
            }
            return(webBookmarks);
        }
示例#2
0
 public static bool isUserChallenged(string channel, string name)
 {
     if (doesUserExist(channel, name))
     {
         string        fill  = string.Format("select Challenger from VIEWERS.{0} where Name = \"{1}\"", channel, name);
         List <string> query = MySqlWrapper.MakeQuery(fill, "Challenger");
         if (query.Count > 0)
         {
             string n = query[0];
             if (n == null || n.Equals(""))
             {
                 //User is not challenged
                 return(false);
             }
             else
             {
                 //User is challenged
                 return(true);
             }
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
示例#3
0
        public static ArrayList GetWebFiles(string serverPath, string clientId, MySqlWrapper dbConn)
        {
            ArrayList WebFiles = new ArrayList();

            try
            {
                string    sql       = "select Concat(uploads_id,uploads_url) as FilePath,uploads_title from ctool_uploads where uploads_ownerid= " + clientId;
                ArrayList recordset = dbConn.Execute(sql);
                foreach (ArrayList record in recordset)
                {
                    WebUploadedFiles file = new WebUploadedFiles((string)record[1], serverPath + record[0]);
                    WebFiles.Add(file);
                }

                sql       = "select Concat(uploads_id,uploads_url) as FilePath,uploads_title from ctool_uploads,ctool_uploadstouser where uploads_id = uploadstouser_uploads_id AND uploadstouser_mid = " + clientId;
                recordset = dbConn.Execute(sql);
                foreach (ArrayList record in recordset)
                {
                    WebUploadedFiles file = new WebUploadedFiles((string)record[1], serverPath + record[0]);
                    WebFiles.Add(file);
                }
            }
            catch (Exception ee)
            {
//				MessageBox.Show("We Integration " + ee.Message);
            }
            return(WebFiles);
        }
        public static string getPreis(int mahlzeitid, ISession s)
        {
            string preis = "0";

            if (s.GetString("role") != "" && s.GetString("role") != null)
            {
                if (s.GetString("role") == "Student")
                {
                    preis = MySqlWrapper.exexuteReaderPreis($@"SELECT p.Studentpreis
                                                                from Preise p 
                                                                WHERE p.fkMahlzeiten={mahlzeitid}", "Studentpreis");
                }
                else
                {
                    preis = MySqlWrapper.exexuteReaderPreis($@"SELECT p.`MA-Preis`
                                                                from Preise p 
                                                                WHERE p.fkMahlzeiten={mahlzeitid}", "MA-Preis");
                }
                return(preis);
            }
            preis = MySqlWrapper.exexuteReaderPreis($@"SELECT p.Gastpreis 
                                                                from Preise p 
                                                                WHERE p.fkMahlzeiten={mahlzeitid}", "Gastpreis");
            return(preis);
        }
        public static int getImageID(int mahlzeitid)
        {
            int imageId = (int)MySqlWrapper.exexuteScalar <int>($@"SELECT b.ID FROM Bilder as b
                                    JOIN MahlzeitenBilder as mb ON mb.IDBilder=b.ID
                                    JOIN Mahlzeiten as m ON mb.IDMahlzeiten=m.ID
                                    WHERE m.ID={mahlzeitid}");

            return(imageId);
        }
        public static string getImageCopyright(int mahlzeitid)
        {
            string imageId = MySqlWrapper.exexuteScalar <string>($@"SELECT b.Copyright FROM Bilder as b
                                    JOIN MahlzeitenBilder as mb ON mb.IDBilder=b.ID
                                    JOIN Mahlzeiten as m ON mb.IDMahlzeiten=m.ID
                                    WHERE m.ID={mahlzeitid}");

            return(imageId);
        }
示例#7
0
		public frmLogin( MySqlWrapper SqlObj ) {
			sql = SqlObj;

			InitializeComponent();

			this.Cursor = frmMain.ShaiyaCursor;
			if( Properties.Settings.Default.Username != string.Empty ) {
				txtUsername.Text = Crypter.Decrypt( Properties.Settings.Default.Username );
				txtPasswort.Text = Crypter.Decrypt( Properties.Settings.Default.Passwort );
			}
		}
示例#8
0
 public static int getTotalPoints(string channel, string name)
 {
     if (doesUserExist(channel, name))
     {
         string        sb    = string.Format("select TotalPoints from VIEWERS.{0} where Name = \"{1}\"", channel, name);
         List <string> query = MySqlWrapper.MakeQuery(sb, "TotalPoints");
         int           i;
         Int32.TryParse(query[0], out i);
         return(i);
     }
     return(-1);
 }
示例#9
0
        public frmLogin(MySqlWrapper SqlObj)
        {
            sql = SqlObj;

            InitializeComponent();

            if (Properties.Settings.Default.Username != string.Empty)
            {
                txtUsername.Text = Crypter.Decrypt(Properties.Settings.Default.Username);
                txtPasswort.Text = Crypter.Decrypt(Properties.Settings.Default.Password);
            }
        }
示例#10
0
 ///<summary>Adds user to database</summary>
 ///<para name="channel">Channel name</para>
 ///<para name="name">Username</para>
 ///<returns>Returns true if user is added to db or false is user already exists.</returns>
 public static bool addUser(string channel, string name)
 {
     if (!doesUserExist(channel, name))
     {
         string sb = string.Format("insert into VIEWERS.{0} (Name, Points, TotalPoints) values (\"{1}\", 0, 0)", channel, name);
         MySqlWrapper.MakeQuery(sb, "Points");
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#11
0
 public static bool setTotalPoints(string channel, string name, int points)
 {
     if (doesUserExist(channel, name))
     {
         string sb = string.Format("UPDATE VIEWERS.{0} SET TotalPoints = {1} WHERE Name = \"{2}\"", channel, points, name);
         MySqlWrapper.MakeQuery(sb, "TotalPoints");
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#12
0
        private void frmMain_Shown(object sender, EventArgs e)
        {
            mMysql = new MySqlWrapper("178.77.65.232", 3306, "insanero", "NNDRDFFB3xmXwK9q", "insanero");
            EMysqlConnectionError result = mMysql.Prepare();

            if (result != EMysqlConnectionError.None)
            {
                MessageBox.Show("Datenbanmk Verbindung failed: " + result.ToString());
                Close();
                return;
            }

            cmbType.SelectedIndex = 0;
        }
示例#13
0
        public static bool clearChallenger(string channel, string challenger, string challenged, int points)
        {
            if (doesUserExist(channel, challenged))
            {
                string sb = string.Format("UPDATE VIEWERS.{0} SET Challenger = \"{1}\" WHERE Name = \"{2}\"", channel, challenger, challenged);
                MySqlWrapper.MakeQuery(sb, "Challenger");

                string sb2 = string.Format("UPDATE VIEWERS.{0} SET ChallPoints = {1} WHERE Name = \"{2}\"", channel, points, challenged);
                MySqlWrapper.MakeQuery(sb2, "ChallPoints");
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#14
0
        override public bool AddToChannel(string channel)
        {
            // not sure what toStrng returns
            int channelIndex = ModuleManager.channels.FindIndex(x => x.Name == channel);

            // find out if channel exists and module is not added to it, if not added add it
            if (channelIndex != -1)
            {
                int moduleIndex = ModuleManager.channels[channelIndex].ActiveModules.FindIndex(x => x == moduleName);
                if (moduleIndex == -1)
                {
                    ModuleManager.channels[channelIndex].ActiveModules.Add(moduleName);
                    string sb = string.Format("use VIEWERS; CREATE TABLE `{0}` (`Name` text COLLATE utf8mb4_unicode_ci,`Points` int(11) DEFAULT 0,`TotalPoints` int(11) DEFAULT 0,`Challenger` text COLLATE utf8mb4_unicode_ci DEFAULT '', `ChallPoints` int(11) DEFAULT 0) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;", channel);
                    MySqlWrapper.MakeQuery(sb);
                    return(true);
                }
            }
            return(false);
        }
示例#15
0
        override public void HandleMessage(Message message)
        {
            String channel = message.channel;
            String msg     = message.msg;
            String sender  = message.sender;

            // Get the index of a channel
            int channelIndex = ModuleManager.channels.FindIndex(x => x.Name == channel);

            if (MySqlWrapper.checkForSQLInjection(channel) || MySqlWrapper.checkForSQLInjection(msg) || MySqlWrapper.checkForSQLInjection(sender))
            {
                Log.WriteLine(string.Format("Prevented sql injection. Channel: \t{0}\n \t{1}\n \t{2}\n ", channel, msg, sender));
                return;
            }

            string handlepoints          = "!" + ModuleManager.channels[channelIndex].pointsConfig.pointsName;
            string handlechallenge       = "!" + ModuleManager.channels[channelIndex].pointsConfig.challengeName;
            string handleacceptchallenge = "!" + ModuleManager.channels[channelIndex].pointsConfig.challengeAccept;
            string handleroulette        = "!" + ModuleManager.channels[channelIndex].pointsConfig.rouletteName;
            string handledonate          = "!" + ModuleManager.channels[channelIndex].pointsConfig.donateName;

            if (msg.StartsWith(handlepoints))
            {
                PointsCommands.HandleShowPoints(message, irc);
            }
            else if (msg.StartsWith(handlechallenge))
            {
                PointsCommands.HandleStartChallenge(message, irc);
            }
            else if (msg.StartsWith(handleacceptchallenge))
            {
                PointsCommands.HandleEndChallenge(channel, sender, msg, irc);
            }
            else if (msg.StartsWith(handleroulette))
            {
                PointsCommands.HandleRoulette(channel, sender, msg, irc);
            }
            if (msg.StartsWith(handledonate))
            {
                PointsCommands.HandleDonate(message, irc);
            }
        }
示例#16
0
        private void TestConnection()
        {
            Cursor = Cursors.WaitCursor;
            try
            {
                MySqlWrapper mySqlConnection = new MySqlWrapper(CreateConnectionString().ToString());

                pB_connectionStatus.Image = iL_connection.Images["connected"];
                l_status.Text             = "The connection was successfully established.";
                l_message.Text            = "";
            }
            catch (Exception ex)
            {
                pB_connectionStatus.Image = iL_connection.Images["disconnected"];
                l_status.Text             = "The connection could not be established.";
                l_message.Text            = ex.Message;
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            Cursor = Cursors.Default;
        }
示例#17
0
 ///<summary>Returns a challenger or empty string like "" if something went wrong.</summary>
 public static string getChallenger(string channel, string name)
 {
     if (isUserChallenged(channel, name))
     {
         string        sb    = string.Format("select Challenger from VIEWERS.{0} where Name = \"{1}\"", channel, name);
         List <string> query = MySqlWrapper.MakeQuery(sb, "Challenger");
         if (query.Count > 0)
         {
             return(query[0]);
         }
         else
         {
             return("");
         }
     }
     else
     {
         return("");
     }
 }
示例#18
0
        /// <summary>
        /// Retrieves Configuration data and establishes a database connection
        /// </summary>
        private void LoadConfig()
        {
            _config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
            if (!_config.ConnectionStrings.SectionInformation.IsProtected)
            {
                _config.ConnectionStrings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
            }

            string conStr = _config.ConnectionStrings.ConnectionStrings["ConnectionString"].ConnectionString;

            try
            {
                _mysql = new MySqlWrapper(conStr);
                DatabaseContainer.MySql = _mysql;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                VerifyPreferences();
            }
        }
示例#19
0
 public static int getChallPoints(string channel, string name)
 {
     if (isUserChallenged(channel, name))
     {
         string        sb    = string.Format("select ChallPoints from VIEWERS.{0} where Name = \"{1}\"", channel, name);
         List <string> query = MySqlWrapper.MakeQuery(sb, "ChallPoints");
         if (query.Count > 0)
         {
             int i = Int32.Parse(query[0]);
             return(i);
         }
         else
         {
             return(-1);
         }
     }
     else
     {
         return(-1);
     }
 }
示例#20
0
        private int InitSql()
        {
            if (IsSqlInit == true)
            {
                return(1);
            }

            MySql = new MySqlWrapper("blubb-gaming.de", 3306, "shaiya_forum", "alone4ever", "shaiya_forum");
            MysqlError error = MySql.Prepare();

            switch (error)
            {
            case MysqlError.None:
                break;

            default:
                System.Diagnostics.Debug.WriteLine("SqlInit Fehler: " + error);
                System.Windows.Forms.MessageBox.Show("SqlInit Fehler!\n\n" + error);
                return(-1);
            }

            ResultTable table = MySql.Query("SELECT userID FROM wcf1_user WHERE username = '******' AND password = '******'", ForumUsername.MysqlEscape(), this.GetForumPass(ForumUsername, ForumPassword).MysqlEscape());

            if (table.Rows.Count == 0)
            {
                return(0);
            }

            if (MySql.LastError != null)
            {
                System.Diagnostics.Debug.WriteLine(MySql.LastError);
                System.Windows.Forms.MessageBox.Show("SQL Fehler!\n\n" + MySql.LastError);
                return(-1);
            }

            ForumUserID = table.Rows[0]["userID"].GetInt32();

            IsSqlInit = true;
            return(1);
        }
示例#21
0
        ///<summary>Checks if user exits in database.</summary>
        ///<para name="channel">Channel name</para>
        ///<para name="name">Username</para>
        ///<returns>Returns true if user exists in db or false if user does not exist..</returns>
        public static bool doesUserExist(string channel, string name)
        {
            string        fill  = string.Format("select Name from VIEWERS.{0} where Name = \"{1}\"", channel, name);
            List <string> query = MySqlWrapper.MakeQuery(fill, "Name");

            if (query.Count > 0)
            {
                string n = query[0];
                if (!name.Equals(""))
                {
                    //User exist
                    return(true);
                }
                else
                {
                    //User does not exist
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
示例#22
0
        public static void Main(string[] args)
        {
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
#endif
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);

            try {
                mThread   = Thread.CurrentThread;
                mProcess  = Process.GetCurrentProcess();
                mAssembly = Assembly.GetEntryAssembly();
                if (mThread != null)
                {
                    mThread.Name = "Core Thread";
                }

                Timer.TimerThread ttObj = new Timer.TimerThread();
                mTimerThread      = new Thread(new ThreadStart(ttObj.TimerMain));
                mTimerThread.Name = "Timer Thread";

                int width = Math.Min(100, Console.LargestWindowWidth - 2);
                Console.CursorVisible = false;
                Console.Clear();
                Console.WindowLeft = Console.WindowTop = 0;
                if (Console.WindowWidth < width)
                {
                    Console.WindowWidth = width;
                }

                LogoPrinter.PrefixColor = EConsoleColor.Blue;
                LogoPrinter.SufixColor  = EConsoleColor.Blue;
                LogoPrinter.TextColor   = EConsoleColor.Gray;
                LogoPrinter.PrintLogo();

                Version ver = mAssembly.GetName().Version;
                CConsole.StatusLine("Shaiya.Extended Server - Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);

                mConsoleEventHandler = new ConsoleEventHandler(OnConsoleEvent);
                SetConsoleCtrlHandler(mConsoleEventHandler, true);

                mAppConf = new ApplicationSettings();
                mAppConf.ReadAll();

                Stopwatch watch = Stopwatch.StartNew();
                CConsole.Info("Connecting to SQL Server {0}...", mAppConf.Network["DB Server"]);
                mDatabase = new MySqlWrapper(mAppConf.Network["DB Server"], int.Parse(mAppConf.Network["DB Port"]), mAppConf.Network["DB User"], mAppConf.Network["DB Password"], mAppConf.Network["DB Database"]);
                MysqlError conRes = mDatabase.Prepare();
                if (conRes != MysqlError.None)
                {
                    CConsole.WriteLine(EConsoleColor.Error, " failed!");
                    throw new Exception("Failed to open Database Connection! Type: " + conRes.ToString());
                }
                watch.Stop();
                CConsole.WriteLine(EConsoleColor.Status, " done! Needed {0:F2} sec", watch.Elapsed.TotalSeconds);
                watch = null;

                ScriptDatabase.Initialize(@"Scripts\ScriptList.xml");
                ScriptCompiler.Compile(AppDomain.CurrentDomain.BaseDirectory + Path.Combine(Settings.Default.MainConfDir, Settings.Default.ScriptAssemblies), true, true);

                World.Load();

                // testing CallMethod
                ScriptCompiler.CallMethod("Initialize");

                SocketPool.Create();
                mSocketConnector = new SocketConnector(mAppConf.Network["Server IP"], mAppConf.Network.GetInt("Server Port"));
                PacketHandlers.Initialize();

                // start Timer Thread
                mTimerThread.Start();

                NetState.Initialize();

                // finished Loading
                Events.InvokeServerStarted();


                DateTime    now, last = DateTime.Now;
                const int   sampleInterval = 100;
                const float ticksPerSecond = (float)(TimeSpan.TicksPerSecond * sampleInterval);
                int         sample         = 0;

                while (mSignal.WaitOne())
                {
                    Timer.Slice();
                    mSocketConnector.Slice();

                    NetState.FlushAll();
                    NetState.ProcessDisposedQueue();

                    if (Slice != null)
                    {
                        Slice();
                    }

                    // just for Diagnostics
                    if ((++sample % sampleInterval) == 0)
                    {
                        now = DateTime.Now;
                        mCyclesPerSecond[mCycleIndex++ % mCyclesPerSecond.Length] = ticksPerSecond / (now.Ticks - last.Ticks);
                        last = now;
                    }
                }
            } catch (Exception e) {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }
        }
示例#23
0
 public static List <string> zutatenListe(int id)
 {
     return(MySqlWrapper.exexuteColumn($@"SELECT z.`Name` FROM MahlzeitenZutaten AS mz 
                         JOIN Zutaten AS z ON z.ID=mz.IDZutaten 
                         WHERE mz.IDMahlzeiten={id}", "Name"));
 }
示例#24
0
 public WebPolls(MySqlWrapper dbConn)
 {
     dbCon = dbConn;
 }
示例#25
0
 public WebEvaluations(MySqlWrapper dbConn)
 {
     dbCon = dbConn;
 }
示例#26
0
        public static ArrayList GetWebPresentations(string serverPath, string clientID, MySqlWrapper dbConn)
        {
            ArrayList WebPresentations = new ArrayList();

            try
            {
                string    sql       = "select presentation_title,Concat(presentation_id,presentation_url) from ctool_presentation where presentation_ownerid = " + clientID;
                ArrayList recordset = dbConn.Execute(sql);
                foreach (ArrayList record in recordset)
                {
                    WebPresentationEntry entry = new WebPresentationEntry((string)record[0], serverPath + record[1]);
                    WebPresentations.Add(entry);
                }

                sql = "select presentation_title,Concat(presentation_id,presentation_url),pretouser_presentation_id from ctool_presentation,ctool_pretouser WHERE presentation_id = pretouser_presentation_id  AND pretouser_mid = " + clientID;

                recordset = dbConn.Execute(sql);
                foreach (ArrayList record in recordset)
                {
                    WebPresentationEntry entry = new WebPresentationEntry((string)record[0], serverPath + record[1]);
                    WebPresentations.Add(entry);
                }
            }
            catch (Exception ee)
            {
                //		MessageBox.Show(ee.Message);
            }
            return(WebPresentations);
        }
示例#27
0
        /// <summary>
        /// Retrieves Configuration data and establishes a database connection
        /// </summary>
        private void LoadConfig()
        {
            _config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
            if (!_config.ConnectionStrings.SectionInformation.IsProtected)
                _config.ConnectionStrings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");

            string conStr = _config.ConnectionStrings.ConnectionStrings["ConnectionString"].ConnectionString;
            try
            {
                _mysql = new MySqlWrapper(conStr);
                DatabaseContainer.MySql = _mysql;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                VerifyPreferences();
            }
        }
示例#28
0
        private void LoadConfig()
        {
            try
            {
                // open app.config to gaher database connection string
                _config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);

                // protect string section if not already protected
                if (!_config.ConnectionStrings.SectionInformation.IsProtected)
                {
                    // Protect section so it's not saved in plain text
                    _config.ConnectionStrings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
                    _config.Save();
                }

                if (!_config.AppSettings.SectionInformation.IsProtected)
                {
                    _config.AppSettings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
                    _config.Save();
                }
                // extract database connection string from app.config
                string connectionString = _config.ConnectionStrings.ConnectionStrings["ConnectionString"].ConnectionString;

                //_deniedGroups = (StringCollection)_config.AppSettings.Settings["DeniedGroups"];


                foreach (string str in _config.AppSettings.Settings["DeniedGroups"].Value.Split(new char[] { ';' }))
                {
                    _deniedGroups.Add(str);
                }

                // instantiate database wrapper (with connection)
                _mysql = new MySqlWrapper(connectionString);
                Log("Database connection established.");
            }
            catch (MySqlException msex)
            {
                // Display error Message
                if (Thread.CurrentThread.CurrentUICulture.Name == "en")
                {
                    MessageBox.Show("A database connection error occured. Please contact your administrator.",
                                    "Database connection error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Bei der Verbindung mit der Datenbank trat ein Fehler auf. Bitte kontaktieren Sie den Administrator.",
                                    "Fehler bei der Datenbank Verbindung",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }


                Debug.WriteLine(msex.ToString());

                // kill the app by all means necessary
                this.Close();
            }
            catch (ConfigurationErrorsException ex)
            {
                Debug.WriteLine(ex.ToString());
                // Display error Message
                if (Thread.CurrentThread.CurrentUICulture.Name == "en")
                {
                    MessageBox.Show("A configuration exception occured. Please contact your administrator.",
                                    "Configuration error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Beim Laden der Konfigurationsdatei trat ein Fehler auf. Bitte kontaktieren Sie den Administrator.",
                                    "Fehler beim Laden der Konfiguration",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }

                // kill the app by all means necessary
                this.Close();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());

                if (Thread.CurrentThread.CurrentUICulture.Name == "en")
                {
                    MessageBox.Show("An error occured while loading the form. Please contact your administrator.",
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Beim Laden der Anwendung trat ein Fehler auf. Bitte kontaktieren Sie den Administrator.",
                                    "Fehler beim Laden der Anwendung",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }

                // kill the app by all means necessary
                this.Close();
            }
        }
示例#29
0
        private void LoadConfig()
        {
            try
            {
                // open app.config to gaher database connection string
                _config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);

                // protect string section if not already protected
                if (!_config.ConnectionStrings.SectionInformation.IsProtected)
                {
                    // Protect section so it's not saved in plain text
                    _config.ConnectionStrings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
                    _config.Save();
                }

                if(!_config.AppSettings.SectionInformation.IsProtected)
                {
                    _config.AppSettings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
                    _config.Save();
                }
                // extract database connection string from app.config
                string connectionString = _config.ConnectionStrings.ConnectionStrings["ConnectionString"].ConnectionString;

                //_deniedGroups = (StringCollection)_config.AppSettings.Settings["DeniedGroups"];

                foreach (string str in _config.AppSettings.Settings["DeniedGroups"].Value.Split(new char[] { ';' }))
                    _deniedGroups.Add(str);

                // instantiate database wrapper (with connection)
                _mysql = new MySqlWrapper(connectionString);
                Log("Database connection established.");
            }
            catch (MySqlException msex)
            {
                // Display error Message
                if(Thread.CurrentThread.CurrentUICulture.Name == "en")
                MessageBox.Show("A database connection error occured. Please contact your administrator.",
                                "Database connection error",
                                 MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);
                else
                MessageBox.Show("Bei der Verbindung mit der Datenbank trat ein Fehler auf. Bitte kontaktieren Sie den Administrator.",
                                "Fehler bei der Datenbank Verbindung",
                                 MessageBoxButtons.OK,
                                 MessageBoxIcon.Error);

                Debug.WriteLine(msex.ToString());

                // kill the app by all means necessary
                this.Close();
            }
            catch (ConfigurationErrorsException ex)
            {
                Debug.WriteLine(ex.ToString());
                // Display error Message
                if (Thread.CurrentThread.CurrentUICulture.Name == "en")
                    MessageBox.Show("A configuration exception occured. Please contact your administrator.",
                                    "Configuration error",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                else
                    MessageBox.Show("Beim Laden der Konfigurationsdatei trat ein Fehler auf. Bitte kontaktieren Sie den Administrator.",
                                    "Fehler beim Laden der Konfiguration",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);

                // kill the app by all means necessary
                this.Close();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());

                if (Thread.CurrentThread.CurrentUICulture.Name == "en")
                    MessageBox.Show("An error occured while loading the form. Please contact your administrator.",
                                    "Error",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                else
                    MessageBox.Show("Beim Laden der Anwendung trat ein Fehler auf. Bitte kontaktieren Sie den Administrator.",
                                    "Fehler beim Laden der Anwendung",
                                     MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);

                // kill the app by all means necessary
                this.Close();
            }
        }
示例#30
0
		private int InitSql() {
			if( IsSqlInit == true )
				return 1;

			MySql = new MySqlWrapper( "blubb-gaming.de", 3306, "shaiya_forum", "alone4ever", "shaiya_forum" );
			MysqlError error = MySql.Prepare();
			switch( error ) {
				case MysqlError.None:
					break;
				default:
					System.Diagnostics.Debug.WriteLine( "SqlInit Fehler: " + error );
					System.Windows.Forms.MessageBox.Show( "SqlInit Fehler!\n\n" + error );
					return -1;
			}

			ResultTable table = MySql.Query( "SELECT userID FROM wcf1_user WHERE username = '******' AND password = '******'", ForumUsername.MysqlEscape(), this.GetForumPass( ForumUsername, ForumPassword ).MysqlEscape() );
			if( table.Rows.Count == 0 )
				return 0;

			if( MySql.LastError != null ) {
				System.Diagnostics.Debug.WriteLine( MySql.LastError );
				System.Windows.Forms.MessageBox.Show( "SQL Fehler!\n\n" + MySql.LastError );
				return -1;
			}

			ForumUserID = table.Rows[ 0 ][ "userID" ].GetInt32();

			IsSqlInit = true;
			return 1;
		}
        private void TestConnection()
        {
            Cursor = Cursors.WaitCursor;
            try
            {
                MySqlWrapper mySqlConnection = new MySqlWrapper(CreateConnectionString().ToString());

                pB_connectionStatus.Image = iL_connection.Images["connected"];
                l_status.Text = "The connection was successfully established.";
                l_message.Text = "";
            }
            catch(Exception ex)
            {
                pB_connectionStatus.Image = iL_connection.Images["disconnected"];
                l_status.Text = "The connection could not be established.";
                l_message.Text = ex.Message;
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            Cursor = Cursors.Default;
        }