Esempio n. 1
0
 public DerivedTable(MySQLData.DerivedTable table, string aliasName)
 {
     base.SchemaName = table.schemaName;
     base.Name = table.name;
     base.AliasName = aliasName;
     Query = table.Query;
 }
Esempio n. 2
0
 public Table(MySQLData.Table table, string aliasName)
 {
     SchemaName = table.schemaName;
     Name = table.name;
     AliasName = aliasName;
 }
Esempio n. 3
0
		private static void UpdateMySQL()
		{
			if (!CMOptions.ModuleEnabled || !CMOptions.MySQLEnabled || !CMOptions.MySQLInfo.IsValid())
			{
				if (_Connection != null)
				{
					_Connection.Dispose();
					_Connection = null;
				}

				return;
			}

			if (_Connection == null || _Connection.IsDisposed)
			{
				_Connection = null;
				return;
			}

			if (!_Connection.Connected)
			{
				_Connection.Dispose();
				_Connection = null;
				return;
			}

			using (_Connection)
			{
				#region Conquests
				CMOptions.ToConsole("Exporting conquests...");

				Conquest[] cList = ConquestRegistry.Values.Where(c => c != null && !c.Deleted).ToArray();

				_Connection.NonQuery(GetCreateQuery("conquests"));
				_Connection.Truncate("conquests");

				int cCount = 0;

				foreach (Conquest c in cList)
				{
					var sData = new MySQLData("id_con", c.UID.Value);

					using (var props = new PropertyList<Conquest>(c))
					{
						props.RemoveKeyRange("UID", "");

						int pc =
							props.Count(
								kv =>
								{
									CMOptions.ToConsole("Prop: {0} = {1}", kv.Key, kv.Value);
									
									return _Connection.Insert("conquests", new[] {sData, new MySQLData("key", kv.Key), new MySQLData("val", kv.Value)});
								});

						if (pc == props.Count)
						{
							++cCount;
						}
					}
				}

				CMOptions.ToConsole("Exported {0:#,0} conquests.", cCount);
				#endregion

				#region Profiles
				CMOptions.ToConsole("Exporting profiles...");

				ConquestProfile[] pList = Profiles.Values.Where(p => p != null && p.Owner != null).ToArray();

				_Connection.NonQuery(GetCreateQuery("profiles"));
				_Connection.Truncate("profiles");

				int pCount =
					pList.Count(
						p =>
						_Connection.Insert(
							"profiles",
							new[]
							{
								new MySQLData("id_owner", p.Owner.Serial.Value), new MySQLData("owner", p.Owner.RawName),
								new MySQLData("points", p.GetPointsTotal()), new MySQLData("credit", p.Credit)
							}));

				CMOptions.ToConsole("Exported {0:#,0} profiles.", pCount);
				#endregion

				#region States
				CMOptions.ToConsole("Exporting states...");

				_Connection.NonQuery(GetCreateQuery("states"));
				_Connection.Truncate("states");

				int sCount = 0;

				foreach (var p in pList)
				{
					foreach (var s in p)
					{
						var sData = new MySQLData("id_state", s.UID.Value);
						var cData = new MySQLData("id_con", s.Conquest.UID.Value);
						var oData = new MySQLData("id_owner", s.Owner.Serial.Value);

						using (var props = new PropertyList<ConquestState>(s))
						{
							props.Remove("UID");
							props.Remove("Conquest");
							props.Remove("Owner");
							props.Remove("ConquestExists");

							int pc =
								props.Count(
									kv =>
									_Connection.Insert(
										"states", new[] {sData, cData, oData, new MySQLData("key", kv.Key), new MySQLData("val", kv.Value)}));

							if (pc == props.Count)
							{
								++sCount;
							}
						}
					}
				}

				CMOptions.ToConsole("Exported {0:#,0} states.", sCount);
				#endregion
			}

			_Connection = null;
		}
Esempio n. 4
0
        private static void UpdateMySQL()
        {
            if (!CMOptions.ModuleEnabled || !CMOptions.MySQLEnabled || !CMOptions.MySQLInfo.IsValid())
            {
                if (_Connection != null)
                {
                    _Connection.Dispose();
                    _Connection = null;
                }

                return;
            }

            if (_Connection == null || _Connection.IsDisposed)
            {
                _Connection = null;
                return;
            }

            if (!_Connection.Connected)
            {
                _Connection.Dispose();
                _Connection = null;
                return;
            }

            using (_Connection)
            {
                #region Conquests
                CMOptions.ToConsole("Exporting conquests...");

                Conquest[] cList = ConquestRegistry.Values.Where(c => c != null && !c.Deleted).ToArray();

                _Connection.NonQuery(GetCreateQuery("conquests"));
                _Connection.Truncate("conquests");

                int cCount = 0;

                foreach (Conquest c in cList)
                {
                    var sData = new MySQLData("id_con", c.UID.Value);

                    using (var props = new PropertyList <Conquest>(c))
                    {
                        props.RemoveKeyRange("UID", "");

                        int pc =
                            props.Count(
                                kv =>
                        {
                            CMOptions.ToConsole("Prop: {0} = {1}", kv.Key, kv.Value);

                            return(_Connection.Insert("conquests", new[] { sData, new MySQLData("key", kv.Key), new MySQLData("val", kv.Value) }));
                        });

                        if (pc == props.Count)
                        {
                            ++cCount;
                        }
                    }
                }

                CMOptions.ToConsole("Exported {0:#,0} conquests.", cCount);
                #endregion

                #region Profiles
                CMOptions.ToConsole("Exporting profiles...");

                ConquestProfile[] pList = Profiles.Values.Where(p => p != null && p.Owner != null).ToArray();

                _Connection.NonQuery(GetCreateQuery("profiles"));
                _Connection.Truncate("profiles");

                int pCount =
                    pList.Count(
                        p =>
                        _Connection.Insert(
                            "profiles",
                            new[]
                {
                    new MySQLData("id_owner", p.Owner.Serial.Value), new MySQLData("owner", p.Owner.RawName),
                    new MySQLData("points", p.GetPointsTotal()), new MySQLData("credit", p.Credit)
                }));

                CMOptions.ToConsole("Exported {0:#,0} profiles.", pCount);
                #endregion

                #region States
                CMOptions.ToConsole("Exporting states...");

                _Connection.NonQuery(GetCreateQuery("states"));
                _Connection.Truncate("states");

                int sCount = 0;

                foreach (var p in pList)
                {
                    foreach (var s in p)
                    {
                        var sData = new MySQLData("id_state", s.UID.Value);
                        var cData = new MySQLData("id_con", s.Conquest.UID.Value);
                        var oData = new MySQLData("id_owner", s.Owner.Serial.Value);

                        using (var props = new PropertyList <ConquestState>(s))
                        {
                            props.Remove("UID");
                            props.Remove("Conquest");
                            props.Remove("Owner");
                            props.Remove("ConquestExists");

                            int pc =
                                props.Count(
                                    kv =>
                                    _Connection.Insert(
                                        "states", new[] { sData, cData, oData, new MySQLData("key", kv.Key), new MySQLData("val", kv.Value) }));

                            if (pc == props.Count)
                            {
                                ++sCount;
                            }
                        }
                    }
                }

                CMOptions.ToConsole("Exported {0:#,0} states.", sCount);
                #endregion
            }

            _Connection = null;
        }
Esempio n. 5
0
 public bool FindElement(MySQLData.Table tb)
 {
     return (tb.name == ElementNameValue);
 }