Beispiel #1
0
        public static void lintels()
        {
            SqlWrapper    ms    = new SqlWrapper();
            List <lintel> doors = new List <lintel>();
            lintel        ll;

            ms.SqlRead("SELECT * FROM doors");

            #region MySql
            if (ms.ismysql)
            {
                while (ms.myreader.Read())
                {
                    ll        = new lintel();
                    ll.ID     = ms.myreader.GetInt32("ID");
                    ll.X      = ms.myreader.GetFloat("X");
                    ll.Y      = ms.myreader.GetFloat("Y");
                    ll.Z      = ms.myreader.GetFloat("Z");
                    ll.HZ     = ms.myreader.GetFloat("HZ");
                    ll.frompf = ms.myreader.GetInt32("playfield");
                    ll.topf   = ms.myreader.GetInt32("toplayfield");
                    ll.toid   = ms.myreader.GetInt32("toid");
                    ll.proxy  = ms.myreader.GetInt32("proxy");
                    doors.Add(ll);
                }
                ms.myreader.Close();
                ms.mcc.Close();
                ms.mcc.Dispose();
            }
            #endregion

            #region MsSql
            if (ms.ismssql)
            {
                while (ms.sqlreader.Read())
                {
                    ll        = new lintel();
                    ll.ID     = ms.sqlreader.GetInt32(0);
                    ll.X      = ms.sqlreader.GetFloat(1);
                    ll.Y      = ms.sqlreader.GetFloat(2);
                    ll.Z      = ms.sqlreader.GetFloat(3);
                    ll.HZ     = ms.sqlreader.GetFloat(4);
                    ll.frompf = ms.sqlreader.GetInt32(5);
                    ll.topf   = ms.sqlreader.GetInt32(6);
                    ll.toid   = ms.sqlreader.GetInt32(7);
                    ll.proxy  = ms.sqlreader.GetInt32(8);
                    doors.Add(ll);
                }
                ms.sqlreader.Close();
                ms.sqlcc.Close();
                ms.sqlcc.Dispose();
            }
            #endregion

            #region PostgreSql
            if (ms.isnpgsql)
            {
                while (ms.npgreader.Read())
                {
                    ll        = new lintel();
                    ll.ID     = ms.npgreader.GetInt32(0);
                    ll.X      = ms.npgreader.GetFloat(1);
                    ll.Y      = ms.npgreader.GetFloat(2);
                    ll.Z      = ms.npgreader.GetFloat(3);
                    ll.HZ     = ms.npgreader.GetFloat(4);
                    ll.frompf = ms.npgreader.GetInt32(5);
                    ll.topf   = ms.npgreader.GetInt32(6);
                    ll.toid   = ms.npgreader.GetInt32(7);
                    ll.proxy  = ms.npgreader.GetInt32(8);
                    doors.Add(ll);
                }
                ms.npgreader.Close();
                ms.npgcc.Close();
                ms.npgcc.Dispose();
            }
            #endregion

            bool found;
            foreach (lintel l1 in doors)
            {
                found = false;
                foreach (lintel l2 in doors)
                {
                    if (l1.ID != l2.ID)
                    {
                        if (l1.topf != 0)
                        {
                            if ((l1.frompf == l2.topf) && (l1.topf == l2.frompf))
                            {
                                found   = true;
                                l1.toid = l2.ID;
                                ms.SqlUpdate(
                                    "UPDATE doors set toid=" + l2.ID.ToString() + " where id=" + l1.ID.ToString());
                                Console.WriteLine(l1.ID.ToString());
                            }
                            else if ((l1.topf == l2.frompf) && (l2.topf == 0))
                            {
                                l1.toid = l2.ID;
                                ms.SqlUpdate(
                                    "UPDATE doors set toid=" + l2.ID.ToString() + " where id=" + l1.ID.ToString());
                                Console.WriteLine(l1.ID.ToString());
                            }
                        }
                    }
                }
                if (!found)
                {
                    ms.SqlUpdate("UPDATE doors SET proxy=1 where ID=" + l1.ID.ToString());
                }
            }
        }
        public static void lintels()
        {
            SqlWrapper ms = new SqlWrapper();
            List<lintel> doors = new List<lintel>();
            lintel ll;
            ms.SqlRead("SELECT * FROM doors");

            #region MySql
            if (ms.ismysql)
            {
                while (ms.myreader.Read())
                {
                    ll = new lintel();
                    ll.ID = ms.myreader.GetInt32("ID");
                    ll.X = ms.myreader.GetFloat("X");
                    ll.Y = ms.myreader.GetFloat("Y");
                    ll.Z = ms.myreader.GetFloat("Z");
                    ll.HZ = ms.myreader.GetFloat("HZ");
                    ll.frompf = ms.myreader.GetInt32("playfield");
                    ll.topf = ms.myreader.GetInt32("toplayfield");
                    ll.toid = ms.myreader.GetInt32("toid");
                    ll.proxy = ms.myreader.GetInt32("proxy");
                    doors.Add(ll);
                }
                ms.myreader.Close();
                ms.mcc.Close();
                ms.mcc.Dispose();
            }
            #endregion

            #region MsSql
            if (ms.ismssql)
            {
                while (ms.sqlreader.Read())
                {
                    ll = new lintel();
                    ll.ID = ms.sqlreader.GetInt32(0);
                    ll.X = ms.sqlreader.GetFloat(1);
                    ll.Y = ms.sqlreader.GetFloat(2);
                    ll.Z = ms.sqlreader.GetFloat(3);
                    ll.HZ = ms.sqlreader.GetFloat(4);
                    ll.frompf = ms.sqlreader.GetInt32(5);
                    ll.topf = ms.sqlreader.GetInt32(6);
                    ll.toid = ms.sqlreader.GetInt32(7);
                    ll.proxy = ms.sqlreader.GetInt32(8);
                    doors.Add(ll);
                }
                ms.sqlreader.Close();
                ms.sqlcc.Close();
                ms.sqlcc.Dispose();
            }
            #endregion

            #region PostgreSql
            if (ms.isnpgsql)
            {
                while (ms.npgreader.Read())
                {
                    ll = new lintel();
                    ll.ID = ms.npgreader.GetInt32(0);
                    ll.X = ms.npgreader.GetFloat(1);
                    ll.Y = ms.npgreader.GetFloat(2);
                    ll.Z = ms.npgreader.GetFloat(3);
                    ll.HZ = ms.npgreader.GetFloat(4);
                    ll.frompf = ms.npgreader.GetInt32(5);
                    ll.topf = ms.npgreader.GetInt32(6);
                    ll.toid = ms.npgreader.GetInt32(7);
                    ll.proxy = ms.npgreader.GetInt32(8);
                    doors.Add(ll);
                }
                ms.npgreader.Close();
                ms.npgcc.Close();
                ms.npgcc.Dispose();
            }
            #endregion

            bool found;
            foreach (lintel l1 in doors)
            {
                found = false;
                foreach (lintel l2 in doors)
                {
                    if (l1.ID != l2.ID)
                    {
                        if (l1.topf != 0)
                        {
                            if ((l1.frompf == l2.topf) && (l1.topf == l2.frompf))
                            {
                                found = true;
                                l1.toid = l2.ID;
                                ms.SqlUpdate(
                                    "UPDATE doors set toid=" + l2.ID.ToString() + " where id=" + l1.ID.ToString());
                                Console.WriteLine(l1.ID.ToString());
                            }
                            else if ((l1.topf == l2.frompf) && (l2.topf == 0))
                            {
                                l1.toid = l2.ID;
                                ms.SqlUpdate(
                                    "UPDATE doors set toid=" + l2.ID.ToString() + " where id=" + l1.ID.ToString());
                                Console.WriteLine(l1.ID.ToString());
                            }
                        }
                    }
                }
                if (!found)
                {
                    ms.SqlUpdate("UPDATE doors SET proxy=1 where ID=" + l1.ID.ToString());
                }
            }
        }