Ejemplo n.º 1
0
        private static void NewServerSqlData(int ServerId, string ServerName)
        {
            var db = DManager.QueryFirstRow("SELECT 1 FROM channels WHERE ServerId = '{0}'", ServerId);

            if (db.IsNull())
            {
                DManager.Insert("`channels`(ServerId, ServerName, Channel, Password, Language)", ServerId, ServerName, IRCConfig.List[ServerName].MasterChannel, IRCConfig.List[ServerName].MasterChannelPassword, sLManager.Locale);
            }

            db = DManager.QueryFirstRow("SELECT 1 FROM schumix WHERE ServerId = '{0}'", ServerId);
            if (db.IsNull())
            {
                foreach (var function in Enum.GetNames(typeof(IFunctions)))
                {
                    if (function == IFunctions.Mantisbt.ToString() || function == IFunctions.Wordpress.ToString() ||
                        function == IFunctions.Svn.ToString() || function == IFunctions.Git.ToString() ||
                        function == IFunctions.Hg.ToString())
                    {
                        DManager.Insert("`schumix`(ServerId, ServerName, FunctionName, FunctionStatus)", ServerId, ServerName, function.ToLower(), Off);
                    }
                    else
                    {
                        DManager.Insert("`schumix`(ServerId, ServerName, FunctionName, FunctionStatus)", ServerId, ServerName, function.ToLower(), On);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private static void IsAllSchumixFunction(int ServerId, string ServerName)
 {
     foreach (var function in Enum.GetNames(typeof(IFunctions)))
     {
         var db = DManager.QueryFirstRow("SELECT 1 FROM schumix WHERE ServerId = '{0}' And FunctionName = '{1}'", ServerId, function.ToLower());
         if (db.IsNull())
         {
             if (function == IFunctions.Mantisbt.ToString() || function == IFunctions.Wordpress.ToString() ||
                 function == IFunctions.Svn.ToString() || function == IFunctions.Git.ToString() ||
                 function == IFunctions.Hg.ToString())
             {
                 DManager.Insert("`schumix`(ServerId, ServerName, FunctionName, FunctionStatus)", ServerId, ServerName, function.ToLower(), Off);
             }
             else
             {
                 DManager.Insert("`schumix`(ServerId, ServerName, FunctionName, FunctionStatus)", ServerId, ServerName, function.ToLower(), On);
             }
         }
     }
 }
Ejemplo n.º 3
0
        public static void SqlInfoReConfig()
        {
            foreach (var sn in IRCConfig.List)
            {
                DManager.Update("channels", string.Format("ServerName = '{0}'", sn.Key), string.Format("ServerId = '{0}'", sn.Value.ServerId));
                DManager.Update("schumix", string.Format("ServerName = '{0}'", sn.Key), string.Format("ServerId = '{0}'", sn.Value.ServerId));
                DManager.Update("hlmessage", string.Format("ServerName = '{0}'", sn.Key), string.Format("ServerId = '{0}'", sn.Value.ServerId));
                DManager.Update("admins", string.Format("ServerName = '{0}'", sn.Key), string.Format("ServerId = '{0}'", sn.Value.ServerId));
                DManager.Update("ignore_addons", string.Format("ServerName = '{0}'", sn.Key), string.Format("ServerId = '{0}'", sn.Value.ServerId));
                DManager.Update("ignore_channels", string.Format("ServerName = '{0}'", sn.Key), string.Format("ServerId = '{0}'", sn.Value.ServerId));
                DManager.Update("ignore_commands", string.Format("ServerName = '{0}'", sn.Key), string.Format("ServerId = '{0}'", sn.Value.ServerId));
                DManager.Update("ignore_irc_commands", string.Format("ServerName = '{0}'", sn.Key), string.Format("ServerId = '{0}'", sn.Value.ServerId));
                DManager.Update("ignore_nicks", string.Format("ServerName = '{0}'", sn.Key), string.Format("ServerId = '{0}'", sn.Value.ServerId));

                var db1 = DManager.Query("SELECT Id, ServerName FROM channels WHERE ServerId = '{0}'", sn.Value.ServerId);
                if (!db1.IsNull())
                {
                    foreach (DataRow row in db1.Rows)
                    {
                        bool ignore = false;
                        int  id     = row["Id"].ToInt32();
                        var  db3    = DManager.Query("SELECT Id, Channel FROM channels WHERE ServerName = '{0}' And Channel = '{1}' ORDER BY Id ASC", row["ServerName"].ToString(), IRCConfig.List[row["ServerName"].ToString()].MasterChannel);
                        if (!db3.IsNull())
                        {
                            int id2 = 0;
                            var db4 = DManager.QueryFirstRow("SELECT Id FROM channels WHERE ServerName = '{0}' ORDER BY Id ASC", row["ServerName"].ToString());

                            if (!db4.IsNull())
                            {
                                id2 = db4["Id"].ToInt32();
                            }

                            foreach (DataRow row2 in db3.Rows)
                            {
                                if (id2 != row2["Id"].ToInt32() && row2["Channel"].ToString() == IRCConfig.List[row["ServerName"].ToString()].MasterChannel)
                                {
                                    ignore = true;
                                    break;
                                }
                            }
                        }

                        var db2 = DManager.QueryFirstRow("SELECT Id, ServerName, Channel FROM channels WHERE ServerName = '{0}' ORDER BY Id ASC", row["ServerName"].ToString());

                        if (!db2.IsNull())
                        {
                            if (id == db2["Id"].ToInt32() && !ignore)
                            {
                                string channel    = db2["Channel"].ToString();
                                string servername = db2["ServerName"].ToString();
                                DManager.Update("channels", string.Format("Channel = '{0}'", IRCConfig.List[servername].MasterChannel), string.Format("Channel = '{0}' And ServerName = '{1}'", channel, servername));
                                DManager.Update("channels", string.Format("Password = '******'", IRCConfig.List[servername].MasterChannelPassword.Length > 0 ? IRCConfig.List[servername].MasterChannelPassword : string.Empty), string.Format("Channel = '{0}' And ServerName = '{1}'", channel, servername));
                                Log.Notice("SchumixBase", sLConsole.GetString("{0} master channel is updated to: {1}"), servername, IRCConfig.List[servername].MasterChannel);
                            }
                            else if (id == db2["Id"].ToInt32() && ignore)
                            {
                                Log.Warning("SchumixBase", sLConsole.GetString("The master channel already exist on the database, named by default!"));
                            }
                        }
                    }
                }

                NewServerSqlData(sn.Value.ServerId, sn.Key);
                IsAllSchumixFunction(sn.Value.ServerId, sn.Key);
                IsAllChannelFunction(sn.Value.ServerId);

                var db = DManager.Query("SELECT FunctionName, FunctionStatus FROM schumix WHERE ServerName = '{0}'", sn.Key);
                if (!db.IsNull())
                {
                    var list = new Dictionary <string, string>();

                    foreach (DataRow row in db.Rows)
                    {
                        string name   = row["FunctionName"].ToString();
                        string status = row["FunctionStatus"].ToString();
                        list.Add(name.ToLower(), status.ToLower());
                    }

                    IFunctionsClass.ServerList.Add(sn.Key, new IFunctionsClassBase(list));
                }
                else
                {
                    Log.Error("SchumixBase", sLConsole.GetString("FunctionReload: Failre request!"));
                }
            }
        }