Browse Source

中控稳定版v1.0

1062167724@qq.com 6 years ago
parent
commit
cf5121ed07

+ 0 - 81
parkMonitor/DataBase/DBConnection.cs

@@ -1,81 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using MySql.Data.MySqlClient;
-using System.Configuration;
-
-namespace parkMonitor.DataBase
-{
-    public class DBConnection
-    {
-        /// <summary>
-        /// 连接字符串
-        /// </summary>
-        public static string localStr = "SqlConnectionLocation";
-        public static string remoteStr = "SqlConnectionStr";
-        public static string localConf, remoteConf;
-        public static string localIP, remoteIP;
-        public static void Init()
-        {
-            try
-            {
-                localConf = ConfigurationManager.AppSettings[localStr];
-                remoteConf = ConfigurationManager.AppSettings[remoteStr];
-                localIP = ConfigurationManager.AppSettings["localDBIP"];
-                remoteIP = ConfigurationManager.AppSettings["remoteDBIP"];
-            }
-            catch
-            {
-                Console.WriteLine("配置文件有误");
-            }
-        }
-        /// <summary>
-        /// 连接句柄
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <returns></returns>
-        //public MySqlConnection getConn(string connectionStr)
-        //{
-        //    MySqlConnection con = null;
-        //    try
-        //    {
-        //        if (connectionStr == localStr)
-        //        {
-        //            con = new MySqlConnection(localConf);
-        //        }
-        //        else if (connectionStr == remoteStr)
-        //        {
-        //            con = new MySqlConnection(remoteConf);
-        //        }
-        //        return con;
-        //    }
-        //    catch { }
-        //    return null;
-        //}
-        /// <summary>
-        /// 预处理句柄
-        /// </summary>
-        /// <param name="sql"></param>
-        /// <param name="con"></param>
-        /// <returns></returns>
-        public MySqlCommand getComm(string sql, MySqlConnection con)
-        {
-            MySqlCommand cmd = null;
-            try
-            {
-                cmd = new MySqlCommand(sql, con);
-            }
-            catch (MySqlException)
-            {
-                Console.WriteLine("数据库连接异常");
-            }
-            catch
-            {
-                Console.WriteLine("sql语句异常");
-            }
-            return cmd;
-        }
-    }
-}

+ 0 - 166
parkMonitor/DataBase/DBConnectionPool.cs

@@ -1,166 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using MySql.Data.MySqlClient;
-using System.Collections;
-using System.Configuration;
-
-namespace parkMonitor.DataBase
-{
-    /// <summary>
-    /// 数据库连接池
-    /// </summary>
-    class DBConnectionPool
-    {
-        private static DBConnectionPool connectionPool = null;//池管理对象
-        private static Object objlock = typeof(DBConnectionPool);//池管理对象实例
-        private int Min_Pool_Size { get; set; }//最小连接数
-        private int Max_Pool_Size { get; set; }//最大连接数
-        private int useCount = 0;//已经使用连接数
-        private ArrayList pool = null;//连接保存的集合
-        private static string connectionStr = "";//连接字符串
-
-        public DBConnectionPool(string connectionString)
-        {
-            try
-            {
-                Min_Pool_Size = Convert.ToInt32(ConfigurationManager.AppSettings["Min_Pool_Size"]);
-                Max_Pool_Size = Convert.ToInt32(ConfigurationManager.AppSettings["Max_Pool_Size"]);
-            }
-            catch { }
-            connectionStr = connectionString;
-            pool = new ArrayList();
-            for (int i = 0; i < 10; i++)
-            {
-                MySqlConnection conn = null;
-                conn = CreateConnection(conn);
-                if (conn != null)
-                {
-                    pool.Add(conn);
-                }
-            }
-        }
-        /// <summary>
-        /// 创建获取池对象
-        /// </summary>
-        /// <returns></returns>
-        public static DBConnectionPool getPool(string connectionString)
-        {
-            lock (objlock)
-            {
-                if (connectionPool == null)
-                {
-                    connectionPool = new DBConnectionPool(connectionString);
-                }
-                return connectionPool;
-            }
-        }
-        /// <summary>
-        /// 获取池连接
-        /// </summary>
-        /// <returns></returns>
-        public MySqlConnection getConnection()
-        {
-            lock (pool)
-            {
-                MySqlConnection conn = null;
-                if (pool.Count > 0)
-                {
-                    //取第一个可用连接
-                    conn = (MySqlConnection)pool[0];
-                    //可用连接中移除
-                    pool.RemoveAt(0);
-                    //创建不成功
-                    if (!isUseful(conn))
-                    {
-                        useCount--;
-                        conn = getConnection();
-                    }
-                }
-                else
-                {
-                    //可使用连接小于连接数
-                    if (useCount <= Min_Pool_Size)
-                    {
-                        try
-                        {
-                            conn = CreateConnection(conn);
-                        }
-                        catch (Exception)
-                        {
-                        }
-                    }
-                }
-                if (conn == null)
-                {
-                    //达到最大连接数递归调用获取连接否则创建新连接
-                    if (useCount <= Min_Pool_Size)
-                    {
-                        conn = getConnection();
-                    }
-                    else
-                    {
-                        conn = CreateConnection(conn);
-                    }
-                }
-                return conn;
-            }
-        }
-        /// <summary>
-        /// 创建连接
-        /// </summary>
-        /// <param name="temp"></param>
-        /// <returns></returns>
-        private MySqlConnection CreateConnection(MySqlConnection temp)
-        {
-            MySqlConnection conn = new MySqlConnection(connectionStr);
-            conn.Open();
-            if (useCount < Max_Pool_Size)
-            {
-                useCount++;
-                temp = conn;
-                return temp;
-            }
-            return null;
-        }
-        /// <summary>
-        /// 连接是否创建成功可用
-        /// </summary>
-        /// <param name="conn"></param>
-        /// <returns></returns>
-        private bool isUseful(MySqlConnection conn)
-        {
-            bool result = true;
-            if (conn != null)
-            {
-                string sql = "select garageFreeSpace from garage where garageID = '1'";
-                MySqlCommand cmd = new MySqlCommand(sql, conn);
-                try
-                {
-                    cmd.ExecuteScalar().ToString();
-                }
-                catch
-                {
-                    result = false;
-                }
-            }
-            return result;
-        }
-        /// <summary>
-        /// 释放连接,回到连接池
-        /// </summary>
-        /// <param name="conn"></param>
-        public void ConnectionClose(MySqlConnection conn)
-        {
-            lock (pool)
-            {
-                if (conn != null)
-                {
-                    pool.Add(conn);
-                }
-            }
-        }
-    }
-}

+ 0 - 553
parkMonitor/DataBase/DBOperation.cs

@@ -1,553 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using MySql.Data.MySqlClient;
-using parkMonitor.server.CoreThread;
-
-namespace parkMonitor.DataBase
-{
-    public class DBOperation
-    {
-        /// <summary>
-        /// 查询车库表获得剩余车位数
-        /// </summary>
-        /// <param name="connectionStr">定义本地远端数据库的字符串</param>
-        /// <param name="garageID">车库ID</param>
-        /// <returns>获得的空闲车位总数</returns>
-        public int getGarageFreeSpace(string connectionStr, int garageID)
-        {
-            MySqlDataReader reader = null;
-            int garageFreeSpace = 0;
-            string sql = "select * from garage where garageID = '" + garageID + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                garageFreeSpace = reader.GetInt32("garageFreeSpace");
-                return garageFreeSpace;
-            }
-            else
-            {
-                Console.WriteLine("车位剩余数查无结果");
-            }
-            oper.DBClose(reader);
-            return 0;
-        }
-
-        /// <summary>
-        /// 查询空闲车位位置
-        /// </summary>
-        /// <param name="connectionStr">定义本地远端数据库的字符串</param>
-        /// <param name="garageID">车库ID</param>
-        /// <returns>获得空闲车位具体信息</returns>
-        public Dictionary<int, Parking_Space> GetParkingSpace(string connectionStr, int garageID)
-        {
-            Dictionary<int, Parking_Space> lps = new Dictionary<int, Parking_Space>();
-            MySqlDataReader reader = null;
-            string sql = "select * from parkingspace where parkingSpaceState = 0 and garageID = '" + garageID + "' ";
-            Operation oper = new Operation(connectionStr, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0)
-            {
-                for (int i = 1; i <= count && reader.Read(); i++)
-                {
-                    Parking_Space ps = new Parking_Space();
-                    ps.parkingSpaceID = reader.GetInt32("parkingSpaceID");
-                    ps.parkingSpaceX = reader.GetInt32("parkingSpaceX");
-                    ps.parkingSpaceY = reader.GetInt32("parkingSpaceY");
-                    ps.parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
-                    ps.garageID = garageID;
-                    lps.Add(ps.parkingSpaceID, (Parking_Space)ps.Clone());
-                }
-                return lps;
-            }
-            else
-            {
-                Console.WriteLine("空闲车位查无结果"); 
-            }
-            oper.DBClose(reader);
-            return null;
-        }
-
-        /// <summary>
-        /// 查询所有车位位置及状态
-        /// </summary>
-        /// <param name="connectionStr">定义本地远端数据库的字符串</param>
-        /// <param name="garageID">车库ID</param>
-        /// <returns>获得所有车位具体信息</returns>
-        public Dictionary<int, Parking_Space> GetAllParkingSpace(string connectionStr, int garageID)
-        {
-            Dictionary<int, Parking_Space> lps = new Dictionary<int, Parking_Space>();
-            MySqlDataReader reader = null;
-            string sql = "select * from parkingspace where garageID = '" + garageID + "' ";
-            Operation oper = new Operation(connectionStr, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0)
-            {
-                for (int i = 1; i <= count && reader.Read(); i++)
-                {
-                    Parking_Space ps = new Parking_Space();
-                    ps.parkingSpaceID = reader.GetInt32("parkingSpaceID");
-                    ps.parkingSpaceX = reader.GetInt32("parkingSpaceX");
-                    ps.parkingSpaceY = reader.GetInt32("parkingSpaceY");
-                    ps.parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
-                    ps.parkingSpaceState = reader.GetInt32("parkingSpaceState");
-                    ps.garageID = garageID;
-                    lps.Add(ps.parkingSpaceID, (Parking_Space)ps.Clone());
-                }
-                return lps;
-            }
-            else
-            {
-                Console.WriteLine("所有车位查无结果");
-            }
-            oper.DBClose(reader);
-            return null;
-        }
-
-        /// <summary>
-        /// 数据插入云记录表,并返回停车记录id
-        /// </summary>
-        /// <param name="connectionStr">定义本地远端数据库的字符串</param>
-        /// <param name="userID">用户ID</param>
-        /// <param name="numberPlate">号牌</param>
-        /// <param name="parkingSpaceID">车位DI</param>
-        /// <param name="garageID">车库ID</param>
-        /// <param name="parkingRecordsState">停车记录车辆状态</param>
-        /// <param name="realParkTime">停车时间</param>
-        /// <returns></returns>
-        public int InsertToParkingRecords(string connectionStr, int userID, string numberPlate, int parkingSpaceID, int garageID, int parkingRecordsState, string realParkTime)
-        {
-            string sql = "insert into parkingrecords(userID,numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime) values('" + userID + "','" + numberPlate + "','" + parkingSpaceID + "','" + garageID + "','" + parkingRecordsState + "','" + realParkTime + "')";
-            int parkingRecordsID = 0;
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getInsert();
-            parkingRecordsID = oper.getInsertId();
-
-            return parkingRecordsID;
-        }
-
-        /// <summary>
-        /// 根据车牌号更新车辆表
-        /// </summary>
-        /// <param name="connectionStr">定义本地远端数据库的字符串</param>
-        /// <param name="numberPlate">号牌</param>
-        /// <param name="vehiclepParkState">车辆状态</param>
-        /// <param name="scanEntryTime">停车开始时间</param>
-        /// <param name="parkingRecordsID">停车记录ID</param>
-        /// <param name="parkingSpaceID">车位ID</param>
-        /// <param name="vehicleTypeConfirm">车辆类型确认</param>
-        /// <param name="frontWheelbase">前轮距</param>
-        /// <param name="rearWheelbase">后轮距</param>
-        public void UpdateVehicle(string connectionStr, string numberPlate, int vehiclepParkState, string scanEntryTime, int parkingRecordsID, int parkingSpaceID, int vehicleTypeConfirm, int frontWheelbase, int rearWheelbase)
-        {
-            string sql = "update vehicle set vehiclepParkState = '" + vehiclepParkState + "',scanEntryTime = '" + scanEntryTime + "',parkingRecordsID = '" + parkingRecordsID + "',parkingSpaceID = '" + parkingSpaceID + "',vehicleTypeConfirm = '" + vehicleTypeConfirm + "',frontwheelbase = '" + frontWheelbase + "',rearwheelbase = '" + rearWheelbase + "' where numberPlate = '" + numberPlate + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getUpdate();
-
-        }
-
-        /// <summary>
-        /// 更新车库表剩余车位数
-        /// </summary>
-        /// <param name="connectionStr">定义本地远端数据库的字符串</param>
-        /// <param name="garageFreeSpace">空闲总车位数</param>
-        /// <param name="garageID">车库ID</param>
-        public void UpdateGarageFreeSpace(string connectionStr, int garageFreeSpace, int garageID)
-        {
-            string sql = "update garage set garageFreeSpace = '" + garageFreeSpace + "' where garageID = '" + garageID + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getUpdate();
-
-        }
-
-        /// <summary>
-        /// 根据车牌号更新车辆状态
-        /// </summary>
-        /// <param name="connectionStr">定义本地远端数据库的字符串</param>
-        /// <param name="numberPlate">号牌</param>
-        /// <param name="vehiclepParkState">车辆停车状态</param>
-        public void UpdateVehicleParkState(string connectionStr, string numberPlate, int vehiclepParkState)
-        {
-            string sql = "update vehicle set vehiclepParkState = '" + vehiclepParkState + "'where numberPlate = '" + numberPlate + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getUpdate();
-
-        }
-
-        /// <summary>
-        /// 更新车位状态
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="parkingSpaceID"></param>
-        /// <param name="parkingSpaceState"></param>
-        public void UpdateParkingSpaceState(string connectionStr, int parkingSpaceID, int parkingSpaceState)
-        {
-            string sql = "update parkingspace set parkingSpaceState = '" + parkingSpaceState + "'where parkingSpaceID = '" + parkingSpaceID + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getUpdate();
-
-        }
-
-        /// <summary>
-        /// 更新停车记录表
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="parkingRecordsState"></param>
-        /// <param name="realGetTime"></param>
-        /// <param name="parkingRecordsID"></param>
-        public void UpdateParkingRecords(string connectionStr, int parkingRecordsState, string realGetTime, int parkingRecordsID)
-        {
-            string sql = "update parkingrecords set parkingRecordsState = '" + parkingRecordsState + "',realGetTime = '" + realGetTime + "'where parkingRecordsID = '" + parkingRecordsID + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getUpdate();
-
-        }
-
-        /// <summary>
-        /// 插入消息推送表
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="userID"></param>
-        /// <param name="context"></param>
-        /// <param name="messageType"></param>
-        public void InsertToMessageQueue(string connectionStr, int userID, string context, int messageType)
-        {
-            string sql = "insert into messagequeue(userID,context,messageType) values('" + userID + "','" + context + "','" + messageType + "')";
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getInsert();
-
-        }
-
-        /// <summary>
-        /// 根据车牌查询得到车库id和车位id以及轮距
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="numberPlate"></param>
-        /// <returns></returns>
-        public Vehicle GetVehicle(string connectionStr, string numberPlate)
-        {
-            Vehicle v = new Vehicle();
-            MySqlDataReader reader = null;
-            string sql = "select * from vehicle where numberPlate = '" + numberPlate + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                int parkingSpaceID = reader.GetInt32("parkingSpaceID");
-                int garageID = reader.GetInt32("garageID");
-                int frontwheelbase = reader.GetInt32("frontwheelbase");
-                int rearwheelbase = reader.GetInt32("rearwheelbase");
-                v.parkingRecordsID = reader.GetInt32("parkingRecordsID");
-                v.parkingSpaceID = parkingSpaceID;
-                v.garageID = garageID;
-                v.frontwheelbase = frontwheelbase;
-                v.rearwheelbase = rearwheelbase;
-                return v;
-            }
-            else
-            {
-                Console.WriteLine("云端车辆查无结果");
-            }
-            oper.DBClose(reader);
-            return null;
-        }
-
-        /// <summary>
-        /// 根据车位id获得x,y,z
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="parkingSpaceID"></param>
-        /// <returns></returns>
-        public Parking_Space GetFetchingSpace(string connectionStr, int parkingSpaceID)
-        {
-            Parking_Space ps = new Parking_Space();
-            MySqlDataReader reader = null;
-            string sql = "select * from parkingspace where parkingSpaceID = '" + parkingSpaceID + " '";
-            Operation oper = new Operation(connectionStr, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                ps.parkingSpaceID = parkingSpaceID;
-                ps.parkingSpaceX = reader.GetInt32("parkingSpaceX");
-                ps.parkingSpaceY = reader.GetInt32("parkingSpaceY");
-                ps.parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
-                return ps;
-            }
-            else
-            {
-                Console.WriteLine("车位xyz查无结果");
-            }
-            oper.DBClose(reader);
-            return null;
-        }
-
-        /// <summary>
-        /// 查询手机号是否被注册
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="tel"></param>
-        /// <returns></returns>
-        public bool IsTelRegister(string connectionStr, string tel)
-        {
-            bool isTelRegister = false;
-            MySqlDataReader reader = null;
-            string sql = "select * from user where userTelephone = '" + tel + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0)
-            {
-                isTelRegister = true;
-            }
-            else
-            {
-                isTelRegister = false;
-            }
-            oper.DBClose(reader);
-            return isTelRegister;
-        }
-
-        /// <summary>
-        /// 注册信息写入数据库,返回注册成功信息
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="tel"></param>
-        /// <param name="password"></param>
-        /// <returns></returns>
-        public int InsertUser(string connectionStr, string tel, string password)
-        {
-            string sql = "insert into user(userTelephone,userPassword,userLevel) values('" + tel + "','" + password + "',1)";
-            int userID = 0;
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getInsert();
-            userID = oper.getInsertId();
-
-            return userID;
-        }
-
-        /// <summary>
-        /// 根据电话号码查询userID
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="tel"></param>
-        /// <returns></returns>
-        public int GetUserID(string connectionStr, string tel)
-        {
-            int userID = 0;
-            MySqlDataReader reader = null;
-            string sql = "select userID from user where userTelephone = '" + tel + "'";
-            int count = 0;
-            Operation oper = new Operation(connectionStr, sql);
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                userID = reader.GetInt32("userID");
-                return userID;
-            }
-            else
-            {
-                Console.WriteLine("userID查无结果");
-            }
-            oper.DBClose(reader);
-            return 0;
-        }
-
-        /// <summary>
-        /// 查询停车记录id
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="numberPlate"></param>
-        /// <returns></returns>
-        public int GetParkingRecordsID(string connectionStr, string numberPlate)
-        {
-            int parkingRecordsID = 0;
-            MySqlDataReader reader = null;
-            string sql = "select parkingRecordsID from parkingrecords where numberPlate = '" + numberPlate + "' and parkingRecordsState = 3";
-            int count = 0;
-            Operation oper = new Operation(connectionStr, sql);
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                parkingRecordsID = reader.GetInt32("parkingRecordsID");
-                return parkingRecordsID;
-            }
-            else
-            {
-                Console.WriteLine("停车记录id查无结果");
-            }
-            oper.DBClose(reader);
-            return 0;
-        }
-
-        /// <summary>
-        /// 车库有无此车
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="numberPlate"></param>
-        /// <param name="garageID"></param>
-        /// <returns></returns>
-        public bool IsNumberPlate(string connectionStr, string numberPlate, int garageID)
-        {
-            bool isNumberPlate = true;
-            MySqlDataReader reader = null;
-            string sql = "select * from parkingrecords where numberPlate = '" + numberPlate + "' and parkingRecordsState = 3 and garageID = '" + garageID + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                isNumberPlate = true;
-            }
-            else
-            {
-                isNumberPlate = false;
-            }
-            oper.DBClose(reader);
-            return isNumberPlate;
-        }
-
-        /// <summary>
-        /// 数据插入本地记录表,并返回停车记录id
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="parkingStatus"></param>
-        /// <param name="userID"></param>
-        /// <param name="numberPlate"></param>
-        /// <param name="parkingSpaceID"></param>
-        /// <param name="garageID"></param>
-        /// <param name="parkingRecordsState"></param>
-        /// <param name="realParkTime"></param>
-        /// <param name="frontWheelbase"></param>
-        /// <param name="rearWheelbase"></param>
-        /// <returns></returns>
-        public int InsertToLocalParkingRecords(string connectionStr, int parkingStatus, int userID, string numberPlate, int parkingSpaceID, int garageID, int parkingRecordsState, string realParkTime, int frontWheelbase, int rearWheelbase)
-        {
-            string sql = "insert into parkingrecords(parkingStatus,userID,numberPlate,parkingSpaceID,garageID,parkingRecordsState,realParkTime,frontWheelbase,rearWheelbase) values('" + parkingStatus + "','" + userID + "','" + numberPlate + "','" + parkingSpaceID + "','" + garageID + "','" + parkingRecordsState + "','" + realParkTime + "','" + frontWheelbase + "','" + rearWheelbase + "')";
-            int parkingRecordsID = 0;
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getInsert();
-            parkingRecordsID = oper.getInsertId();
-
-            return parkingRecordsID;
-        }
-
-        /// <summary>
-        /// 更新本地停车记录表
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="parkingStatus"></param>
-        /// <param name="parkingRecordsState"></param>
-        /// <param name="realGetTime"></param>
-        /// <param name="parkingRecordsID"></param>
-        public void UpdateParkingRecords(string connectionStr, int parkingStatus, int parkingRecordsState, string realGetTime, int parkingRecordsID)
-        {
-            string sql = "update parkingrecords set parkingStatus = '" + parkingStatus + "', parkingRecordsState = '" + parkingRecordsState + "',realGetTime = '" + realGetTime + "'where parkingRecordsID = '" + parkingRecordsID + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getUpdate();
-
-        }
-
-        /// <summary>
-        /// 插入车辆表
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="numberPlate"></param>
-        /// <param name="vehiclepParkState"></param>
-        /// <param name="parkingRecordsID"></param>
-        /// <param name="parkingSpaceID"></param>
-        /// <param name="vehicleTypeConfirm"></param>
-        public void InsertVehicle(string connectionStr, string numberPlate, int vehiclepParkState, int parkingRecordsID, int parkingSpaceID, int vehicleTypeConfirm)
-        {
-            string sql = "insert into vehicle(numberPlate,vehiclepParkState,parkingRecordsID,parkingSpaceID,vehicleTypeConfirm) values('" + numberPlate + "','" + vehiclepParkState + "','" + parkingRecordsID + "','" + parkingSpaceID + "','" + vehicleTypeConfirm + "')";
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getInsert();
-
-        }
-
-        /// <summary>
-        /// 判断车辆表中是否存在该车辆号牌
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="numberPlate"></param>
-        /// <returns></returns>
-        public bool IsNumberPlateFromVehicle(string connectionStr, string numberPlate)
-        {
-            bool isNumberPlateFromVehicle = true;
-            string sql = "select * from vehicle where numberPlate = '" + numberPlate + "' and vehiclepParkState = 1";
-            MySqlDataReader reader = null;
-            Operation oper = new Operation(connectionStr, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                isNumberPlateFromVehicle = true;
-            }
-            else
-            {
-                isNumberPlateFromVehicle = false;
-            }
-            oper.DBClose(reader);
-            return isNumberPlateFromVehicle;
-        }
-
-        /// <summary>
-        /// 根据车牌号更新本地车辆表
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="numberPlate"></param>
-        /// <param name="vehiclepParkState"></param>
-        /// <param name="parkingRecordsID"></param>
-        /// <param name="parkingSpaceID"></param>
-        /// <param name="vehicleTypeConfirm"></param>
-        public void UpdateLocalVehicle(string connectionStr, string numberPlate, int vehiclepParkState, int parkingRecordsID, int parkingSpaceID, int vehicleTypeConfirm)
-        {
-            string sql = "update vehicle set vehiclepParkState = '" + vehiclepParkState + "',parkingRecordsID = '" + parkingRecordsID + "',parkingSpaceID = '" + parkingSpaceID + "',vehicleTypeConfirm = '" + vehicleTypeConfirm + "' where numberPlate = '" + numberPlate + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            oper.getUpdate();
-
-        }
-
-        /// <summary>
-        /// 根据车牌查询得到车库id和车位id以及轮距
-        /// </summary>
-        /// <param name="connectionStr"></param>
-        /// <param name="numberPlate"></param>
-        /// <param name="garageID"></param>
-        /// <returns></returns>
-        public Vehicle GetLocalVehicle(string connectionStr, string numberPlate, int garageID)
-        {
-            Vehicle v = new Vehicle();
-            MySqlDataReader reader = null;
-            string sql = "select * from parkingrecords where numberPlate = '" + numberPlate + "' and parkingRecordsState = 3 and garageID = '" + garageID + "'";
-            Operation oper = new Operation(connectionStr, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                int parkingSpaceID = reader.GetInt32("parkingSpaceID");
-                int frontwheelbase = reader.GetInt32("frontwheelbase");
-                int rearwheelbase = reader.GetInt32("rearwheelbase");
-                v.parkingSpaceID = parkingSpaceID;
-                v.garageID = garageID;
-                v.frontwheelbase = frontwheelbase;
-                v.rearwheelbase = rearwheelbase;
-                return v;
-            }
-            else
-            {
-                Console.WriteLine("本地车辆查无结果");
-            }
-            oper.DBClose(reader);
-            return null;
-        }
-
-    }
-}

+ 0 - 305
parkMonitor/DataBase/IDBOperation.cs

@@ -1,305 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Data;
-using MySql.Data.MySqlClient;
-using parkMonitor.tools;
-using parkMonitor.server.uiLogServer;
-using parkMonitor.LOG;
-
-namespace parkMonitor.DataBase
-{
-    interface IDBOperation
-    {
-        MySqlDataReader getResultSet(ref int count);
-        void getInsert();
-        void getUpdate();
-        void getDelete();
-    }
-    public class Operation : IDBOperation
-    {
-        /// <summary>
-        /// 数据库连接异常
-        /// </summary>
-        public static bool malfunctionRemote = false;
-        public static bool malfunctionLocal = false;
-        private int count = 0;
-        DBConnection connection = null;
-        MySqlConnection con = null;
-        MySqlCommand cmd = null;
-        MySqlDataReader reader = null;
-        public Operation(string connectionStr, string sql)
-        {
-            connection = new DBConnection();
-            con = DBConnectionPool.getPool(connectionStr).getConnection();
-            cmd = connection.getComm(sql, con);
-        }
-
-        /// <summary>
-        /// 数据库查询
-        /// </summary>
-        /// <param name="sql"></param>
-        /// <returns></returns>
-        public MySqlDataReader getResultSet(ref int count)
-        {
-            TryOpen(con);
-            TryExecute(true, ref count);
-            return reader;
-        }
-        /// <summary>
-        /// 数据库插入
-        /// </summary>
-        public void getInsert()
-        {
-            TryOpen(con);
-            TryExecute(false, ref this.count);
-        }
-        /// <summary>
-        /// 数据库更新
-        /// </summary>
-        public void getUpdate()
-        {
-            TryOpen(con);
-            TryExecute(false, ref this.count);
-        }
-        /// <summary>
-        /// 数据库删除
-        /// </summary>
-        public void getDelete()
-        {
-            TryOpen(con);
-            TryExecute(false, ref this.count);
-        }
-        /// <summary>
-        /// 获得插入记录ID
-        /// </summary>
-        /// <returns></returns>
-        public int getInsertId()
-        {
-            int insertID = 0;
-            try
-            {
-                insertID = Convert.ToInt32(cmd.LastInsertedId);
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine("插入数据库失败");
-                Console.WriteLine(ex.Message);
-            }
-            finally
-            {
-                DBClose();
-            }
-            return insertID;
-        }
-
-        /// <summary>
-        /// 尝试与数据库连接
-        /// </summary>
-        public static void TryOpen(MySqlConnection conn)
-        {
-            MyTimer mt = new MyTimer();
-            mt.StartTiming();
-            int count = 0;
-            if (conn == null)
-            {
-                UILogServer.ins.error("传入非法数据库连接对象,请检查后手动重置数据库状态");
-                Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "传入非法数据库连接对象");
-                Operation.malfunctionRemote = true;
-                Operation.malfunctionLocal = true;
-            }
-            else
-            {
-                while (conn != null && conn.State != ConnectionState.Open)
-                {
-                    mt.EndTiming();
-                    if (mt.IsLonger(45, 1, false, out count) && count >= 2)
-                    {
-                        if (conn.DataSource == DBConnection.remoteIP)
-                        {
-                            if (count == 2)
-                            {
-                                UILogServer.ins.error("暂时无法连接远端数据库, 请检查网络连接后点击“控制面板-启动远端DB”恢复。");
-                                Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "与远端DB失去连接");
-                            }
-                            Operation.malfunctionRemote = true;
-                        }
-                        else if (conn.DataSource == DBConnection.localIP)
-                        {
-                            if (count == 2)
-                            {
-                                UILogServer.ins.error("暂时无法连接本地数据库,请检查网络连接后点击“控制面板-启动本地DB”恢复。");
-                                Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "与本地DB失去连接");
-                            }
-                            Operation.malfunctionLocal = true;
-                        }
-                    }
-                    try
-                    {
-                        conn.Open();
-                    }
-                    catch (Exception e) { UILogServer.ins.error(e.StackTrace); }
-                }
-            }
-        }
-
-        public static bool MyTransaction(MySqlConnection conn, string sql, out int returnedValue)
-        {
-            List<string> strs = new List<string>();
-            strs.Add(sql);
-            return MyTransaction(conn, strs, out returnedValue);
-        }
-
-        public static bool MyTransaction(MySqlConnection conn, List<string> sqls, out int returnedValue)
-        {
-            MySqlTransaction transaction = conn.BeginTransaction();
-            MySqlCommand cmd = conn.CreateCommand();
-            cmd.Transaction = transaction;
-            returnedValue = 0;
-            try
-            {
-                for (int i = 0; i < sqls.Count; i++)
-                {
-                    cmd.CommandText = sqls[i];
-                    cmd.ExecuteNonQuery();
-                    returnedValue = Convert.ToInt32(cmd.LastInsertedId);
-                }
-                transaction.Commit();
-                cmd.Dispose();
-                //conn.Close();
-                //conn.Dispose();
-                DBConnectionPool.getPool(DBConnection.remoteConf).ConnectionClose(conn);
-                return true;
-            }
-            catch
-            {
-                try
-                {
-                    transaction.Rollback();
-                }
-                catch { return false; }
-                UILogServer.ins.error("数据库操作失败,事务回滚");
-                if (cmd != null) { cmd.Dispose(); }
-                if (conn != null)
-                {
-                    //conn.Close(); 
-                    //conn.Dispose();
-                    DBConnectionPool.getPool(DBConnection.remoteConf).ConnectionClose(conn);
-                }
-            }
-            return false;
-        }
-
-        /// <summary>
-        /// 尝试执行sql语句
-        /// </summary>
-        /// <param name="isSearch">是否查询</param>
-        /// <param name="count">获得数据条数</param>
-        public void TryExecute(bool isSearch, ref int count)
-        {
-            MyTimer mt = new MyTimer();
-            mt.StartTiming();
-            int counter = 0;
-            while (true)
-            {
-                mt.EndTiming();
-                if (mt.IsLonger(30, 1, false, out counter) && counter >= 1)
-                {
-                    if (con.DataSource == DBConnection.remoteIP)
-                    {
-                        if (counter == 1)
-                        {
-                            UILogServer.ins.error("数据库操作异常,暂停处理自动命令。回滚后点击“启动远端DB”恢复");
-                            Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "操作远端DB异常");
-                        }
-                        Operation.malfunctionRemote = true;
-                    }
-                    else if (con.DataSource == DBConnection.localIP)
-                    {
-                        if (counter == 1)
-                        {
-                            UILogServer.ins.error("数据库操作异常,暂停处理自动命令。回滚后点击“启动本地DB”恢复");
-                            Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "操作本地DB异常");
-                        }
-                        Operation.malfunctionLocal = true;
-                    }
-                    break;
-                }
-                try
-                {
-                    //非查询,在内部关闭
-                    if (!isSearch)
-                    {
-                        cmd.ExecuteNonQuery();
-                        DBClose();
-                        break;
-                    }
-                    //查询,在上层关闭
-                    else
-                    {
-                        reader = cmd.ExecuteReader();
-                        while (reader.Read())
-                        {
-                            if (reader.HasRows)
-                            {
-                                count++;
-                            }
-                        }
-                        reader.Close();
-                        reader.Dispose();
-                        if (count > 0)
-                        {
-                            reader = cmd.ExecuteReader();
-                        }
-                        break;
-                    }
-                }
-                catch (Exception)
-                {
-                    DBClose();
-                }
-            }
-        }
-
-        public static void DBClose(MySqlConnection conn, MySqlCommand cmd, MySqlDataReader reader)
-        {
-            if (reader != null)
-            {
-                reader.Close();
-                reader.Dispose();
-            }
-            if (cmd != null)
-            {
-                cmd.Dispose();
-            }
-            if (conn != null)
-            {
-                DBConnectionPool.getPool(DBConnection.remoteConf).ConnectionClose(conn);
-            }
-        }
-
-        /// <summary>
-        /// 关闭连接
-        /// </summary>
-        public void DBClose()
-        {
-            DBClose(con, cmd, reader);
-        }
-
-        /// <summary>
-        /// 关闭连接
-        /// </summary>
-        /// <param name="reader">需要释放的reader</param>
-        public void DBClose(MySqlDataReader reader)
-        {
-            if (reader != null)
-            {
-                reader.Close();
-                reader.Dispose();
-            }
-            DBClose();
-        }
-    }
-}

+ 0 - 20
parkMonitor/DataBase/Vehicle.cs

@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace parkMonitor.DataBase
-{
-    /// <summary>
-    /// 车辆表数据结构
-    /// </summary>
-    public class Vehicle
-    {
-        public int parkingSpaceID { get; set; }
-        public int garageID { get; set; }
-        public int frontwheelbase { get; set; }
-        public int rearwheelbase { get; set; }
-        public int parkingRecordsID { get; set; }
-    }
-}

+ 8 - 3
parkMonitor/Database2/AbstractCommand.cs

@@ -37,6 +37,7 @@ namespace parkMonitor.Database2
             catch (Exception ex) {
                 Console.WriteLine(ex.Message);
                 Console.WriteLine("MySqlCommand异常");
+                throw ex;
             }
             return cmd;
         }
@@ -51,6 +52,7 @@ namespace parkMonitor.Database2
             {
                 Console.WriteLine(ex.Message);
                 Console.WriteLine("MySqlCommand异常");
+                throw ex;
             }
             return cmd;
         }
@@ -79,6 +81,7 @@ namespace parkMonitor.Database2
             {
                 Console.WriteLine(ex.Message);
                 Console.WriteLine("ExecuteReader执行异常");
+                throw ex;
             }
             return result;
         }
@@ -101,6 +104,7 @@ namespace parkMonitor.Database2
             {
                 Console.WriteLine(ex.Message);
                 Console.WriteLine("ExecuteNonQuery执行异常");
+                throw ex;
             }
             return result;
         }
@@ -124,10 +128,10 @@ namespace parkMonitor.Database2
                 Console.WriteLine("ExecuteScalar执行异常");
                 if(conn != null)
                 {
-                    conn.Dispose();
-                    ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
-
+                    conn.Dispose();                   
                 }
+                ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
+                throw ex;
             }
             return result;
         }
@@ -204,6 +208,7 @@ namespace parkMonitor.Database2
                 }
                 flag = false;
                 Console.WriteLine(e.Message + "事务操作失败");
+                throw e;
             }
             finally
             {

+ 16 - 10
parkMonitor/Database2/ConnectionPoolManager.cs

@@ -15,6 +15,8 @@ namespace parkMonitor.Database2
     class ConnectionPoolManager
     {
         //public static BlockingQueue bq = new BlockingQueue();
+        public static bool malfunctionRemote = false;
+        public static bool malfunctionLocal = false;
         /// <summary>
         /// 连接字符串
         /// </summary>
@@ -51,7 +53,7 @@ namespace parkMonitor.Database2
             for (int i = 0; i < max; i++)
             {
                 Connection conn = DatabaseConnPoolFactory.CreateConnection(connectionString);
-                if (conn.mySqlConnFlag)
+                if (conn!=null&&conn.mySqlConnFlag)
                 {
                     bq.Enqueue(conn);
                     Console.WriteLine("连接成功入队");
@@ -66,12 +68,11 @@ namespace parkMonitor.Database2
         public static Connection GetConnection(BlockingQueue bq)
         {
             Connection connection = (Connection)bq.Dequeue();
-            if (!CheckConnection(connection, bq))
+            if (connection!=null&&!CheckConnection(connection, bq))
             {
-                connection.mySqlConnFlag = false;
+                connection.mySqlConnFlag = false;                
                 while (!connection.mySqlConnFlag)
                 {
-
                     connection.Dispose();
                     AddConnToPooling(1, remoteConf);
                     connection = (Connection)bq.Dequeue();
@@ -95,7 +96,6 @@ namespace parkMonitor.Database2
                 connection = (Connection)conn;
             }
             Console.WriteLine("连接成功出队");
-            Console.WriteLine("输入参数连接池个数:" + bq.Count());
             return connection;
         }
         /// <summary>
@@ -104,7 +104,10 @@ namespace parkMonitor.Database2
         /// <param name="conn"></param>
         public static void RemoveConnection(Connection conn)
         {
-            conn.Dispose();
+            if (conn != null)
+            {
+                conn.Dispose();
+            }
         }
         /// <summary>
         /// 定时重置连接
@@ -162,7 +165,7 @@ namespace parkMonitor.Database2
         /// <param name="bq"></param>
         public static void ReleaseConnection(Connection conn, BlockingQueue bq)
         {
-            Connection temp = null;
+            //Connection temp = null;
             //for (int i = 0; i < bq.Count(); i++)
             //{
             //    temp = (Connection)bq.Dequeue();
@@ -191,12 +194,15 @@ namespace parkMonitor.Database2
                     isUseful = true;
                     Console.WriteLine("连接测试正常");
                 }
-                ReleaseConnection(conn, bq);
-                Console.WriteLine("连接检测成功,重新入队");
+                //ReleaseConnection(conn, bq);
+                //Console.WriteLine("连接检测成功,重新入队");
             }
             catch (Exception ex)
             {
-                conn.Dispose();
+                if (conn != null)
+                {
+                    conn.Dispose();
+                }
                 AddConnToPooling(1,remoteConf);
                 Console.WriteLine("连接检测失败,重新添加一个连接入队");
                 isUseful = false;

+ 23 - 9
parkMonitor/Database2/DBAccess.cs

@@ -46,21 +46,35 @@ namespace parkMonitor.Database2
         public object GetResult()
         {
             object result = null;
-            AbstractCommand abscommand = SimpleCommandFactory.CreateCommandAndExcute(commType);
-            abscommand.sql = sql;
-            abscommand.conn = conn;
-            result = abscommand.ExecuteSqlCommand();
+            try
+            {
+                AbstractCommand abscommand = SimpleCommandFactory.CreateCommandAndExcute(commType);
+                abscommand.sql = sql;
+                abscommand.conn = conn;
+                result = abscommand.ExecuteSqlCommand();
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
             return result;
         }
 
         public TransactionResult DealTransaction(List<string> strs)
         {
             TransactionResult result = null;
-            TransactionCommand abscommand = (TransactionCommand) SimpleCommandFactory.CreateCommandAndExcute(commType);
-            abscommand.strs = strs;
-            abscommand.conn = conn;
-            abscommand.sql = sql;
-            result = (TransactionResult)abscommand.ExecuteSqlCommand();
+            try
+            {
+                TransactionCommand abscommand = (TransactionCommand)SimpleCommandFactory.CreateCommandAndExcute(commType);
+                abscommand.strs = strs;
+                abscommand.conn = conn;
+                abscommand.sql = sql;
+                result = (TransactionResult)abscommand.ExecuteSqlCommand();
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
             return result;
         }
     }

+ 106 - 162
parkMonitor/Database2/DBOperation.cs

@@ -33,10 +33,10 @@ namespace parkMonitor.Database2
             }
             else
             {
-                DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
-                object result = access.GetResult();
                 try
                 {
+                    DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
+                    object result = access.GetResult();
                     reader = (MySqlDataReader)result;
                     while (reader.Read())
                     {
@@ -54,7 +54,10 @@ namespace parkMonitor.Database2
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message + "查询剩余车位异常");
-                    conn.Dispose();
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
                 finally
@@ -63,7 +66,7 @@ namespace parkMonitor.Database2
                     {
                         reader.Close();
                         reader.Dispose();
-                    }                    
+                    }
                 }
             }
             return garageFreeSpace; ;
@@ -86,10 +89,10 @@ namespace parkMonitor.Database2
             }
             else
             {
-                DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
-                object result = access.GetResult();
                 try
                 {
+                    DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
+                    object result = access.GetResult();
                     reader = (MySqlDataReader)result;
                     while (reader.Read())
                     {
@@ -111,7 +114,10 @@ namespace parkMonitor.Database2
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message + "查询车位表异常");
-                    conn.Dispose();
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
                 finally
@@ -120,7 +126,7 @@ namespace parkMonitor.Database2
                     {
                         reader.Close();
                         reader.Dispose();
-                    }                   
+                    }
                 }
             }
             return null;
@@ -143,10 +149,10 @@ namespace parkMonitor.Database2
             }
             else
             {
-                DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
-                object result = access.GetResult();
                 try
                 {
+                    DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
+                    object result = access.GetResult();
                     reader = (MySqlDataReader)result;
                     while (reader.Read())
                     {
@@ -160,7 +166,7 @@ namespace parkMonitor.Database2
                             v.parkingSpaceID = parkingSpaceID;
                             v.garageID = garageID;
                             v.frontwheelbase = frontwheelbase;
-                            v.rearwheelbase = rearwheelbase;                           
+                            v.rearwheelbase = rearwheelbase;
                         }
                     }
                     ConnectionPoolManager.ReleaseConnection(conn, bq);
@@ -169,7 +175,10 @@ namespace parkMonitor.Database2
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message + "查询车辆表异常");
-                    conn.Dispose();
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
                 finally
@@ -178,7 +187,7 @@ namespace parkMonitor.Database2
                     {
                         reader.Close();
                         reader.Dispose();
-                    }                   
+                    }
                 }
             }
             return null;
@@ -201,10 +210,10 @@ namespace parkMonitor.Database2
             }
             else
             {
-                DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
-                object result = access.GetResult();
                 try
                 {
+                    DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
+                    object result = access.GetResult();
                     reader = (MySqlDataReader)result;
                     while (reader.Read())
                     {
@@ -213,7 +222,7 @@ namespace parkMonitor.Database2
                             ps.parkingSpaceID = parkingSpaceID;
                             ps.parkingSpaceX = reader.GetInt32("parkingSpaceX");
                             ps.parkingSpaceY = reader.GetInt32("parkingSpaceY");
-                            ps.parkingSpaceZ = reader.GetInt32("parkingSpaceZ");                            
+                            ps.parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
                         }
                     }
                     ConnectionPoolManager.ReleaseConnection(conn, bq);
@@ -222,7 +231,10 @@ namespace parkMonitor.Database2
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message + "查询车位表获取x,y,z异常");
-                    conn.Dispose();
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
                 finally
@@ -231,7 +243,7 @@ namespace parkMonitor.Database2
                     {
                         reader.Close();
                         reader.Dispose();
-                    }                    
+                    }
                 }
             }
             return null;
@@ -253,10 +265,10 @@ namespace parkMonitor.Database2
             }
             else
             {
-                DBAccess access = new DBAccess(sql, conn, CommandTypes.SCALARCOMMAND);
-                object result = access.GetResult();
                 try
                 {
+                    DBAccess access = new DBAccess(sql, conn, CommandTypes.SCALARCOMMAND);
+                    object result = access.GetResult();
                     int count = (int)result;
                     if (count > 0)
                     {
@@ -271,7 +283,10 @@ namespace parkMonitor.Database2
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message + "检测电话号码注册异常");
-                    conn.Dispose();
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
             }
@@ -295,10 +310,10 @@ namespace parkMonitor.Database2
             }
             else
             {
-                DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
-                object result = access.GetResult();
                 try
                 {
+                    DBAccess access = new DBAccess(sql, conn, CommandTypes.QUERYCOMMAND);
+                    object result = access.GetResult();
                     reader = (MySqlDataReader)result;
                     while (reader.Read())
                     {
@@ -316,7 +331,10 @@ namespace parkMonitor.Database2
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message + "查询停车记录id异常");
-                    conn.Dispose();
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
                 finally
@@ -325,7 +343,7 @@ namespace parkMonitor.Database2
                     {
                         reader.Close();
                         reader.Dispose();
-                    }                   
+                    }
                 }
             }
             return parkingRecordsID;
@@ -349,10 +367,10 @@ namespace parkMonitor.Database2
             }
             else
             {
-                DBAccess access = new DBAccess(sql, conn, CommandTypes.SCALARCOMMAND);
-                object result = access.GetResult();
                 try
                 {
+                    DBAccess access = new DBAccess(sql, conn, CommandTypes.SCALARCOMMAND);
+                    object result = access.GetResult();
                     int count = (int)result;
                     if (count > 0)
                     {
@@ -367,7 +385,10 @@ namespace parkMonitor.Database2
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message + "检测车库中车辆异常");
-                    conn.Dispose();
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
             }
@@ -390,10 +411,10 @@ namespace parkMonitor.Database2
             }
             else
             {
-                DBAccess access = new DBAccess(sql, conn, CommandTypes.SCALARCOMMAND);
-                object result = access.GetResult();
                 try
                 {
+                    DBAccess access = new DBAccess(sql, conn, CommandTypes.SCALARCOMMAND);
+                    object result = access.GetResult();
                     int count = (int)result;
                     if (count > 0)
                     {
@@ -408,7 +429,10 @@ namespace parkMonitor.Database2
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message + "检测车辆表车辆号牌异常");
-                    conn.Dispose();
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
             }
@@ -438,8 +462,11 @@ namespace parkMonitor.Database2
                 }
                 catch (Exception ex)
                 {
-                    Console.WriteLine(ex.Message+"更新车辆状态失败");
-                    conn.Dispose();
+                    Console.WriteLine(ex.Message + "更新车辆状态失败");
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
             }
@@ -468,8 +495,11 @@ namespace parkMonitor.Database2
                 }
                 catch (Exception ex)
                 {
-                    Console.WriteLine(ex.Message+"更新车位状态失败");
-                    conn.Dispose();
+                    Console.WriteLine(ex.Message + "更新车位状态失败");
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
             }
@@ -490,17 +520,20 @@ namespace parkMonitor.Database2
             }
             else
             {
-                DBAccess access = new DBAccess(null, conn, CommandTypes.TRANSACTIONCOMMAND);
-                TransactionResult transactionResult = access.DealTransaction(strs);
                 try
                 {
+                    DBAccess access = new DBAccess(null, conn, CommandTypes.TRANSACTIONCOMMAND);
+                    TransactionResult transactionResult = access.DealTransaction(strs);
                     parkingRecordsID = transactionResult.result;
                     ConnectionPoolManager.ReleaseConnection(conn, bq);
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.Message + "停车记录ID获取失败");
-                    conn.Dispose();
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
             }
@@ -538,122 +571,17 @@ namespace parkMonitor.Database2
                 }
                 catch (Exception ex)
                 {
-                    Console.WriteLine(ex.Message+"更新事务失败");
-                    conn.Dispose();
+                    Console.WriteLine(ex.Message + "更新事务失败");
+                    if (conn != null)
+                    {
+                        conn.Dispose();
+                    }
                     ConnectionPoolManager.AddConnToPooling(1, ConnectionPoolManager.remoteConf);
                 }
             }
             return flag;
         }
 
-        ///// <summary>
-        ///// 插入停车记录表事务
-        ///// </summary>
-        ///// <param name="bq"></param>
-        ///// <param name="strs"></param>
-        ///// <returns></returns>
-        //public static int InsertParkingRecords(BlockingQueue bq, List<string> strs)
-        //{
-        //    Connection conn = ConnectionPoolManager.GetConnection(bq);
-        //    object result = null;
-        //    MySqlCommand myCommand = conn.mySqlConnection.CreateCommand();
-        //    MySqlTransaction myTrans;
-        //    myTrans = conn.mySqlConnection.BeginTransaction();
-        //    myCommand.Connection = conn.mySqlConnection;
-        //    myCommand.Transaction = myTrans;
-        //    try
-        //    {
-        //        for (int i = 0; i < strs.Count(); i++)
-        //        {
-        //            myCommand.CommandText = strs[i];
-        //            myCommand.ExecuteNonQuery();
-        //            result = Convert.ToInt32(myCommand.LastInsertedId);
-        //        }
-        //        myTrans.Commit();
-        //    }
-        //    catch (Exception e)
-        //    {
-        //        try
-        //        {
-        //            myTrans.Rollback();
-        //        }
-        //        catch (MySqlException ex)
-        //        {
-        //            if (myTrans.Connection != null)
-        //            {
-        //                Console.WriteLine(ex.Message + "事务回滚失败");
-        //            }
-        //        }
-        //        Console.WriteLine(e.Message + "事务操作失败");
-        //    }
-        //    finally
-        //    {
-        //        myCommand.Dispose();
-        //        myTrans.Dispose();
-        //        //ConnectionPoolManager.ReleaseConnection(conn);
-        //    }
-        //    int parkingRecordsID = 0;
-        //    try
-        //    {
-        //        parkingRecordsID = (int)result;
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        Console.WriteLine(ex.Message + "停车记录ID获取失败");
-        //    }
-        //    finally
-        //    {
-        //        ConnectionPoolManager.ReleaseConnection(conn, bq);
-        //    }
-        //    return parkingRecordsID;
-        //}
-        ///// <summary>
-        ///// 更新数据库事务
-        ///// </summary>
-        ///// <param name="bq"></param>
-        ///// <param name="strs"></param>
-        //public static object UpdateTransaction(BlockingQueue bq, List<string> strs)
-        //{
-        //    Connection conn = ConnectionPoolManager.GetConnection(bq);
-        //    object result = false;
-        //    MySqlCommand myCommand = conn.mySqlConnection.CreateCommand();
-        //    MySqlTransaction myTrans;
-        //    myTrans = conn.mySqlConnection.BeginTransaction();
-        //    myCommand.Connection = conn.mySqlConnection;
-        //    myCommand.Transaction = myTrans;
-        //    try
-        //    {
-        //        for (int i = 0; i < strs.Count(); i++)
-        //        {
-        //            myCommand.CommandText = strs[i];
-        //            myCommand.ExecuteNonQuery();
-        //            result = true;
-        //        }
-        //        myTrans.Commit();
-        //    }
-        //    catch (Exception e)
-        //    {
-        //        try
-        //        {
-        //            myTrans.Rollback();
-        //        }
-        //        catch (MySqlException ex)
-        //        {
-        //            if (myTrans.Connection != null)
-        //            {
-        //                Console.WriteLine(ex.Message + "事务回滚失败");
-        //            }
-        //        }
-        //        Console.WriteLine(e.Message + "事务操作失败");
-        //    }
-        //    finally
-        //    {
-        //        myCommand.Dispose();
-        //        myTrans.Dispose();
-        //        ConnectionPoolManager.ReleaseConnection(conn,bq);
-        //    }
-        //    return result;
-        //}
 
         private static Connection CreateConnAndGetValidConn(BlockingQueue bq)
         {
@@ -689,23 +617,39 @@ namespace parkMonitor.Database2
             dba.commType = CommandTypes.QUERYCOMMAND;
             if (dba.conn != null)
             {
-                result = dba.GetResult();
-
-            }
-            MySqlDataReader rdr = (MySqlDataReader)result;
-            while (rdr.Read())
-            {
-                killidlist.Add((string)rdr[0]);
+                try
+                {
+                    result = dba.GetResult();
+                    if (result != null)
+                    {
+                        MySqlDataReader rdr = (MySqlDataReader)result;
+                        while (rdr.Read())
+                        {
+                            killidlist.Add((string)rdr[0]);
+                        }
+                        rdr.Close();
+                        foreach (string str in killidlist)
+                        {
+                            //Console.WriteLine(str);
+                            dba.sql = str;
+                            dba.commType = CommandTypes.NOQUERYCOMMAND;
+                            dba.GetResult();
+                        }                        
+                    }
+                    if (dba.conn != null)
+                    {
+                        dba.conn.Dispose();
+                    }
+                }
+                catch (Exception)
+                {
+                    Console.WriteLine("连接为空,kill失败");
+                }
             }
-            rdr.Close();
-            foreach (string str in killidlist)
+            else
             {
-                //Console.WriteLine(str);
-                dba.sql = str;
-                dba.commType = CommandTypes.NOQUERYCOMMAND;
-                dba.GetResult();
+                Console.WriteLine("连接为空,kill失败");
             }
-            dba.conn.Dispose();
         }
 
     }

+ 0 - 309
parkMonitor/Database2/DBOperation2.cs

@@ -1,309 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using MySql.Data.MySqlClient;
-using parkMonitor.tools;
-using parkMonitor.server.CoreThread;
-
-namespace parkMonitor.Database2
-{
-    class DBOperation2
-    {
-        /// <summary>
-        /// 查询车库表获得剩余车位数
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="garageID"></param>
-        /// <returns></returns>
-        public int getGarageFreeSpace(BlockingQueue bq, int garageID)
-        {
-            MySqlDataReader reader = null;
-            int garageFreeSpace = 0;
-            string sql = "select * from garage where garageID = '" + garageID + "'";
-            Operation oper = new Operation(bq, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                garageFreeSpace = reader.GetInt32("garageFreeSpace");
-                return garageFreeSpace;
-            }
-            else
-            {
-                Console.WriteLine("车位剩余数查无结果");
-            }
-            oper.DBClose(null, null, reader);
-            return 0;
-        }
-        /// <summary>
-        /// 查询所有车位位置及状态
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="garageID"></param>
-        /// <returns></returns>
-        public Dictionary<int, Parking_Space> GetAllParkingSpace(BlockingQueue bq, int garageID)
-        {
-            Dictionary<int, Parking_Space> lps = new Dictionary<int, Parking_Space>();
-            MySqlDataReader reader = null;
-            string sql = "select * from parkingspace where garageID = '" + garageID + "' ";
-            Operation oper = new Operation(bq, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0)
-            {
-                for (int i = 1; i <= count && reader.Read(); i++)
-                {
-                    Parking_Space ps = new Parking_Space();
-                    ps.parkingSpaceID = reader.GetInt32("parkingSpaceID");
-                    ps.parkingSpaceX = reader.GetInt32("parkingSpaceX");
-                    ps.parkingSpaceY = reader.GetInt32("parkingSpaceY");
-                    ps.parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
-                    ps.parkingSpaceState = reader.GetInt32("parkingSpaceState");
-                    ps.garageID = garageID;
-                    lps.Add(ps.parkingSpaceID, (Parking_Space)ps.Clone());
-                }
-                return lps;
-            }
-            else
-            {
-                Console.WriteLine("所有车位查无结果");
-            }
-            oper.DBClose(null, null, reader);
-            return null;
-        }
-        /// <summary>
-        /// 根据车牌查询得到车库id和车位id以及轮距
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="numberPlate"></param>
-        /// <returns></returns>
-        public Vehicle GetVehicle(BlockingQueue bq, string numberPlate)
-        {
-            Vehicle v = new Vehicle();
-            MySqlDataReader reader = null;
-            string sql = "select * from vehicle where numberPlate = '" + numberPlate + "'";
-            Operation oper = new Operation(bq, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                int parkingSpaceID = reader.GetInt32("parkingSpaceID");
-                int garageID = reader.GetInt32("garageID");
-                int frontwheelbase = reader.GetInt32("frontwheelbase");
-                int rearwheelbase = reader.GetInt32("rearwheelbase");
-                v.parkingRecordsID = reader.GetInt32("parkingRecordsID");
-                v.parkingSpaceID = parkingSpaceID;
-                v.garageID = garageID;
-                v.frontwheelbase = frontwheelbase;
-                v.rearwheelbase = rearwheelbase;
-                return v;
-            }
-            else
-            {
-                Console.WriteLine("云端车辆查无结果");
-            }
-            oper.DBClose(null, null, reader);
-            return null;
-        }
-        /// <summary>
-        /// 根据车位id获得x,y,z
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="parkingSpaceID"></param>
-        /// <returns></returns>
-        public Parking_Space GetFetchingSpace(BlockingQueue bq, int parkingSpaceID)
-        {
-            Parking_Space ps = new Parking_Space();
-            MySqlDataReader reader = null;
-            string sql = "select * from parkingspace where parkingSpaceID = '" + parkingSpaceID + " '";
-            Operation oper = new Operation(bq, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                ps.parkingSpaceID = parkingSpaceID;
-                ps.parkingSpaceX = reader.GetInt32("parkingSpaceX");
-                ps.parkingSpaceY = reader.GetInt32("parkingSpaceY");
-                ps.parkingSpaceZ = reader.GetInt32("parkingSpaceZ");
-                return ps;
-            }
-            else
-            {
-                Console.WriteLine("车位xyz查无结果");
-            }
-            oper.DBClose(null, null, reader);
-            return null;
-        }
-        /// <summary>
-        /// 查询手机号是否被注册
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="tel"></param>
-        /// <returns></returns>
-        public bool IsTelRegister(BlockingQueue bq, string tel)
-        {
-            bool isTelRegister = false;
-            MySqlDataReader reader = null;
-            string sql = "select * from user where userTelephone = '" + tel + "'";
-            Operation oper = new Operation(bq, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0)
-            {
-                isTelRegister = true;
-            }
-            else
-            {
-                isTelRegister = false;
-            }
-            oper.DBClose(null, null, reader);
-            return isTelRegister;
-        }
-        /// <summary>
-        /// 注册信息写入数据库,返回注册成功信息
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="tel"></param>
-        /// <param name="password"></param>
-        /// <returns></returns>
-        public int InsertUser(BlockingQueue bq, string tel, string password)
-        {
-            string sql = "insert into user(userTelephone,userPassword,userLevel) values('" + tel + "','" + password + "',1)";
-            int userID = 0;
-            Operation oper = new Operation(bq, sql);
-            oper.getInsert();
-            userID = oper.getInsertId();
-            return userID;
-        }
-        /// <summary>
-        /// 根据电话号码查询userID
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="tel"></param>
-        /// <returns></returns>
-        public int GetUserID(BlockingQueue bq, string tel)
-        {
-            int userID = 0;
-            MySqlDataReader reader = null;
-            string sql = "select userID from user where userTelephone = '" + tel + "'";
-            int count = 0;
-            Operation oper = new Operation(bq, sql);
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                userID = reader.GetInt32("userID");
-                return userID;
-            }
-            else
-            {
-                Console.WriteLine("userID查无结果");
-            }
-            oper.DBClose(null, null, reader);
-            return 0;
-        }
-        /// <summary>
-        /// 查询停车记录id
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="numberPlate"></param>
-        /// <returns></returns>
-        public int GetParkingRecordsID(BlockingQueue bq, string numberPlate)
-        {
-            int parkingRecordsID = 0;
-            MySqlDataReader reader = null;
-            string sql = "select parkingRecordsID from parkingrecords where numberPlate = '" + numberPlate + "' and parkingRecordsState = 3";
-            int count = 0;
-            Operation oper = new Operation(bq, sql);
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                parkingRecordsID = reader.GetInt32("parkingRecordsID");
-                return parkingRecordsID;
-            }
-            else
-            {
-                Console.WriteLine("停车记录id查无结果");
-            }
-            oper.DBClose(null, null, reader);
-            return 0;
-        }
-
-        /// <summary>
-        /// 车库有无此车
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="numberPlate"></param>
-        /// <param name="garageID"></param>
-        /// <returns></returns>
-        public bool IsNumberPlate(BlockingQueue bq, string numberPlate, int garageID)
-        {
-            bool isNumberPlate = true;
-            MySqlDataReader reader = null;
-            string sql = "select * from parkingrecords where numberPlate = '" + numberPlate + "' and parkingRecordsState = 3 and garageID = '" + garageID + "'";
-            Operation oper = new Operation(bq, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                isNumberPlate = true;
-            }
-            else
-            {
-                isNumberPlate = false;
-            }
-            oper.DBClose(null, null, reader);
-            return isNumberPlate;
-        }
-        /// <summary>
-        /// 判断车辆表中是否存在该车辆号牌
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="numberPlate"></param>
-        /// <returns></returns>
-        public bool IsNumberPlateFromVehicle(BlockingQueue bq, string numberPlate)
-        {
-            bool isNumberPlateFromVehicle = true;
-            string sql = "select * from vehicle where numberPlate = '" + numberPlate + "' and vehiclepParkState = 1";
-            MySqlDataReader reader = null;
-            Operation oper = new Operation(bq, sql);
-            int count = 0;
-            reader = oper.getResultSet(ref count);
-            if (count > 0 && reader.Read())
-            {
-                isNumberPlateFromVehicle = true;
-            }
-            else
-            {
-                isNumberPlateFromVehicle = false;
-            }
-            oper.DBClose(null, null, reader);
-            return isNumberPlateFromVehicle;
-        }
-        /// <summary>
-        /// 根据车牌号更新车辆状态
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="numberPlate"></param>
-        /// <param name="vehiclepParkState"></param>
-        public void UpdateVehicleParkState(BlockingQueue bq, string numberPlate, int vehiclepParkState)
-        {
-            string sql = "update vehicle set vehiclepParkState = '" + vehiclepParkState + "'where numberPlate = '" + numberPlate + "'";
-            Operation oper = new Operation(bq, sql);
-            oper.getUpdate();
-        }
-        /// <summary>
-        /// 更新车位状态
-        /// </summary>
-        /// <param name="bq"></param>
-        /// <param name="parkingSpaceID"></param>
-        /// <param name="parkingSpaceState"></param>
-        public void UpdateParkingSpaceState(BlockingQueue bq, int parkingSpaceID, int parkingSpaceState)
-        {
-            string sql = "update parkingspace set parkingSpaceState = '" + parkingSpaceState + "'where parkingSpaceID = '" + parkingSpaceID + "'";
-            Operation oper = new Operation(bq, sql);
-            oper.getUpdate();
-        }
-    }
-}

+ 0 - 223
parkMonitor/Database2/IDBOperation.cs

@@ -1,223 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using MySql.Data.MySqlClient;
-using parkMonitor.tools;
-using parkMonitor.server.uiLogServer;
-using parkMonitor.LOG;
-using parkMonitor.server.CoreThread;
-using parkMonitor.entity;
-
-namespace parkMonitor.Database2
-{
-    interface IDBOperation
-    {
-        MySqlDataReader getResultSet(ref int count);
-        void getInsert();
-        void getUpdate();
-        void getDelete();
-    }
-    public class Operation : IDBOperation
-    {
-        /// <summary>
-        /// 数据库连接异常
-        /// </summary>
-        public static bool malfunctionRemote = false;
-        public static bool malfunctionLocal = false;
-        private int count = 0;
-        Connection connection = null;
-        MySqlCommand cmd = null;
-        MySqlDataReader reader = null;
-        public Operation(BlockingQueue bq, string sql)
-        {
-            connection = ConnectionPoolManager.GetConnection(bq);
-            cmd = DatabaseConnPoolFactory.CreateCommand(sql, connection);
-        }
-        /// <summary>
-        /// 数据库查询
-        /// </summary>
-        /// <param name="sql"></param>
-        /// <returns></returns>
-        public MySqlDataReader getResultSet(ref int count)
-        {
-            TryExecute(true, ref count);
-            return reader;
-        }
-        /// <summary>
-        /// 数据库插入
-        /// </summary>
-        public void getInsert()
-        {
-            TryExecute(false, ref this.count);
-        }
-        /// <summary>
-        /// 数据库更新
-        /// </summary>
-        public void getUpdate()
-        {
-            TryExecute(false, ref this.count);
-        }
-        /// <summary>
-        /// 数据库删除
-        /// </summary>
-        public void getDelete()
-        {
-            TryExecute(false, ref this.count);
-        }
-        /// <summary>
-        /// 获得插入记录ID
-        /// </summary>
-        /// <returns></returns>
-        public int getInsertId()
-        {
-            int insertID = 0;
-            try
-            {
-                insertID = Convert.ToInt32(cmd.LastInsertedId);
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine("插入数据库失败");
-                Console.WriteLine(ex.Message);
-            }
-            finally
-            {
-                DBClose(connection, cmd, reader);
-                //ConnectionPoolManager.ReleaseConnection(connection);
-            }
-            return insertID;
-        }
-
-        public void TryExecute(bool isSearch, ref int count)
-        {
-            MyTimer mt = new MyTimer();
-            mt.StartTiming();
-            int counter = 0;
-            while (true)
-            {
-                mt.EndTiming();
-                if (mt.IsLonger(30, 1, false, out counter) && counter >= 1)
-                {
-                    if (connection.mySqlConnection.DataSource == ConnectionPoolManager.remoteIP)
-                    {
-                        if (counter == 1)
-                        {
-                            UILogServer.ins.error("数据库操作异常,暂停处理自动命令。回滚后点击“启动远端DB”恢复");
-                            Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "操作远端DB异常");
-                        }
-                        Operation.malfunctionRemote = true;
-                    }
-                    else if (connection.mySqlConnection.DataSource == ConnectionPoolManager.localIP)
-                    {
-                        if (counter == 1)
-                        {
-                            UILogServer.ins.error("数据库操作异常,暂停处理自动命令。回滚后点击“启动本地DB”恢复");
-                            Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "操作本地DB异常");
-                        }
-                        Operation.malfunctionLocal = true;
-                    }
-                    break;
-                }
-                try
-                {
-                    //非查询,在内部关闭
-                    if (!isSearch)
-                    {
-                        cmd.ExecuteNonQuery();
-                        //DBClose(connection,cmd,null);
-                        break;
-                    }
-                    //查询,在上层关闭
-                    else
-                    {
-                        reader = cmd.ExecuteReader();
-                        while (reader.Read())
-                        {
-                            if (reader.HasRows)
-                            {
-                                count++;
-                            }
-                        }
-                        reader.Close();
-                        reader.Dispose();
-                        if (count > 0)
-                        {
-                            reader = cmd.ExecuteReader();
-                        }
-                        break;
-                    }
-                }
-                catch (Exception ex)
-                {
-                    Console.WriteLine(ex.Message);
-                    DBClose(connection,cmd,reader);
-                }
-                finally
-                {
-                    DBClose(connection, cmd, null);
-                }
-            }
-        }
-        public static bool MyTransaction(BlockingQueue bq,string sql, out int returnedValue)
-        {
-            List<string> strs = new List<string>();
-            strs.Add(sql);
-            return MyTransaction(bq,strs, out returnedValue);
-        }
-
-        public static bool MyTransaction(BlockingQueue bq,List<string> sqls, out int returnedValue)
-        {
-            Connection conn = ConnectionPoolManager.GetConnection(bq);
-            MySqlTransaction transaction = conn.mySqlConnection.BeginTransaction();
-            MySqlCommand cmd = conn.mySqlConnection.CreateCommand();
-            cmd.Transaction = transaction;
-            returnedValue = 0;
-            try
-            {
-                for (int i = 0; i < sqls.Count; i++)
-                {
-                    cmd.CommandText = sqls[i];
-                    cmd.ExecuteNonQuery();
-                    returnedValue = Convert.ToInt32(cmd.LastInsertedId);
-                }
-                transaction.Commit();
-                cmd.Dispose();
-                ConnectionPoolManager.ReleaseConnection(conn, EntityForCore.remoteBQ);
-                return true;
-            }
-            catch
-            {
-                try
-                {
-                    transaction.Rollback();
-                }
-                catch { return false; }
-                UILogServer.ins.error("数据库操作失败,事务回滚");
-                if (cmd != null) { cmd.Dispose(); }
-                if (conn != null)
-                {
-                    ConnectionPoolManager.ReleaseConnection(conn, EntityForCore.remoteBQ);
-                }
-            }
-            return false;
-        }
-        public void DBClose(Connection conn, MySqlCommand cmd, MySqlDataReader reader)
-        {
-            if (reader != null)
-            {
-                reader.Close();
-                reader.Dispose();
-            }
-            if (cmd != null)
-            {
-                cmd.Dispose();
-            }
-            if (conn != null)
-            {
-                ConnectionPoolManager.ReleaseConnection(conn, EntityForCore.remoteBQ);
-            }
-        }
-    }
-}

+ 0 - 1
parkMonitor/bll/MainBll.cs

@@ -8,7 +8,6 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using MySql.Data.MySqlClient;
-using parkMonitor.DataBase;
 using System.Threading;
 using parkMonitor.LOG;
 using parkMonitor.Database2;

+ 14 - 1
parkMonitor/controlPanel/ControlPanel.Designer.cs

@@ -34,11 +34,12 @@
             this.btn_remoteDB = new System.Windows.Forms.Button();
             this.btn_localDB = new System.Windows.Forms.Button();
             this.btn_reInit = new System.Windows.Forms.Button();
+            this.btn_pause = new System.Windows.Forms.Button();
             this.SuspendLayout();
             // 
             // btn_refresh
             // 
-            this.btn_refresh.Font = new System.Drawing.Font("宋体", 10F);
+            this.btn_refresh.Font = new System.Drawing.Font("SimSun", 10F);
             this.btn_refresh.Location = new System.Drawing.Point(43, 182);
             this.btn_refresh.Name = "btn_refresh";
             this.btn_refresh.Size = new System.Drawing.Size(57, 30);
@@ -93,11 +94,22 @@
             this.btn_reInit.UseVisualStyleBackColor = true;
             this.btn_reInit.Click += new System.EventHandler(this.btn_reInit_Click);
             // 
+            // btn_pause
+            // 
+            this.btn_pause.Location = new System.Drawing.Point(151, 79);
+            this.btn_pause.Name = "btn_pause";
+            this.btn_pause.Size = new System.Drawing.Size(75, 23);
+            this.btn_pause.TabIndex = 9;
+            this.btn_pause.Text = "暂停处理";
+            this.btn_pause.UseVisualStyleBackColor = true;
+            this.btn_pause.Click += new System.EventHandler(this.btn_pause_Click);
+            // 
             // ControlPanel
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(369, 242);
+            this.Controls.Add(this.btn_pause);
             this.Controls.Add(this.btn_reInit);
             this.Controls.Add(this.btn_localDB);
             this.Controls.Add(this.btn_remoteDB);
@@ -118,5 +130,6 @@
         private System.Windows.Forms.Button btn_remoteDB;
         private System.Windows.Forms.Button btn_localDB;
         private System.Windows.Forms.Button btn_reInit;
+        private System.Windows.Forms.Button btn_pause;
     }
 }

+ 37 - 33
parkMonitor/controlPanel/ControlPanel.cs

@@ -1,5 +1,4 @@
 using MySql.Data.MySqlClient;
-using parkMonitor.DataBase;
 using parkMonitor.entity;
 using parkMonitor.server.CoreThread;
 using System;
@@ -81,42 +80,42 @@ namespace parkMonitor.controlPanel
 
         private void btn_remoteDB_Click(object sender, EventArgs e)
         {
-            bool initState = false;
-            if (Operation.malfunctionRemote)
-            {
-                using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
-                //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
-                {
-                    Operation.TryOpen(conn);
-                    initState = conn.Ping();
-                    Operation.DBClose(conn,null,null);
-                }
-                if (initState)
-                {
-                    Operation.malfunctionRemote = false;
-                    MessageBox.Show("远端数据库已成功复位");
-                }
-            }
+            //bool initState = false;
+            //if (ConnectionPoolManager.malfunctionRemote)
+            //{
+            //    using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+            //    //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+            //    {
+            //        Operation.TryOpen(conn);
+            //        initState = conn.Ping();
+            //        Operation.DBClose(conn,null,null);
+            //    }
+            //    if (initState)
+            //    {
+            //        Operation.malfunctionRemote = false;
+            //        MessageBox.Show("远端数据库已成功复位");
+            //    }
+            //}
         }
 
         private void btn_localDB_Click(object sender, EventArgs e)
         {
-            bool initState = false;
-            if (Operation.malfunctionLocal)
-            {
-                using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
-                //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
-                {
-                    Operation.TryOpen(conn);
-                    initState = conn.Ping();
-                    Operation.DBClose(conn, null, null);
-                }
-                if (initState)
-                {
-                    Operation.malfunctionLocal = false;
-                    MessageBox.Show("本地数据库已成功复位");
-                }
-            }
+            //bool initState = false;
+            //if (ConnectionPoolManager.malfunctionLocal)
+            //{
+            //    using (MySqlConnection conn = DBConnectionPool.getPool(DBConnection.remoteConf).getConnection())
+            //    //using (MySqlConnection conn = new MySqlConnection(DBConnection.remoteConf))
+            //    {
+            //        Operation.TryOpen(conn);
+            //        initState = conn.Ping();
+            //        Operation.DBClose(conn, null, null);
+            //    }
+            //    if (initState)
+            //    {
+            //        Operation.malfunctionLocal = false;
+            //        MessageBox.Show("本地数据库已成功复位");
+            //    }
+            //}
         }
 
         private void btn_reInit_Click(object sender, EventArgs e)
@@ -124,5 +123,10 @@ namespace parkMonitor.controlPanel
             InitWin iw = new InitWin();
             iw.ShowDialog();
         }
+
+        private void btn_pause_Click(object sender, EventArgs e)
+        {
+            EntityForCore.ins.globalStatus = false;
+        }
     }
 }

+ 0 - 140
parkMonitor/manualParking/ManualParking.Designer.cs

@@ -1,140 +0,0 @@
-namespace parkMonitor.manualParking
-{
-    partial class ManualParking
-    {
-        /// <summary>
-        /// Required designer variable.
-        /// </summary>
-        private System.ComponentModel.IContainer components = null;
-
-        /// <summary>
-        /// Clean up any resources being used.
-        /// </summary>
-        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
-        #region Windows Form Designer generated code
-
-        /// <summary>
-        /// Required method for Designer support - do not modify
-        /// the contents of this method with the code editor.
-        /// </summary>
-        private void InitializeComponent()
-        {
-            this.label1 = new System.Windows.Forms.Label();
-            this.tel = new System.Windows.Forms.TextBox();
-            this.label2 = new System.Windows.Forms.Label();
-            this.store = new System.Windows.Forms.Button();
-            this.fetch = new System.Windows.Forms.Button();
-            this.label3 = new System.Windows.Forms.Label();
-            this.numberPlate = new System.Windows.Forms.TextBox();
-            this.selectGarage = new System.Windows.Forms.TextBox();
-            this.SuspendLayout();
-            // 
-            // label1
-            // 
-            this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(36, 42);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(41, 12);
-            this.label1.TabIndex = 0;
-            this.label1.Text = "电话:";
-            // 
-            // tel
-            // 
-            this.tel.Location = new System.Drawing.Point(102, 33);
-            this.tel.Name = "tel";
-            this.tel.Size = new System.Drawing.Size(112, 21);
-            this.tel.TabIndex = 1;
-            // 
-            // label2
-            // 
-            this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(36, 121);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(41, 12);
-            this.label2.TabIndex = 2;
-            this.label2.Text = "车库:";
-            // 
-            // store
-            // 
-            this.store.Location = new System.Drawing.Point(41, 221);
-            this.store.Name = "store";
-            this.store.Size = new System.Drawing.Size(75, 23);
-            this.store.TabIndex = 4;
-            this.store.Text = "停车";
-            this.store.UseVisualStyleBackColor = true;
-            this.store.Click += new System.EventHandler(this.store_Click);
-            // 
-            // fetch
-            // 
-            this.fetch.Location = new System.Drawing.Point(175, 221);
-            this.fetch.Name = "fetch";
-            this.fetch.Size = new System.Drawing.Size(75, 23);
-            this.fetch.TabIndex = 5;
-            this.fetch.Text = "取车";
-            this.fetch.UseVisualStyleBackColor = true;
-            this.fetch.Click += new System.EventHandler(this.fetch_Click);
-            // 
-            // label3
-            // 
-            this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(36, 85);
-            this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(41, 12);
-            this.label3.TabIndex = 6;
-            this.label3.Text = "号牌:";
-            // 
-            // numberPlate
-            // 
-            this.numberPlate.Location = new System.Drawing.Point(102, 76);
-            this.numberPlate.Name = "numberPlate";
-            this.numberPlate.Size = new System.Drawing.Size(112, 21);
-            this.numberPlate.TabIndex = 7;
-            // 
-            // selectGarage
-            // 
-            this.selectGarage.Location = new System.Drawing.Point(102, 121);
-            this.selectGarage.Name = "selectGarage";
-            this.selectGarage.Size = new System.Drawing.Size(112, 21);
-            this.selectGarage.TabIndex = 8;
-            // 
-            // ManualParking
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(387, 334);
-            this.Controls.Add(this.selectGarage);
-            this.Controls.Add(this.numberPlate);
-            this.Controls.Add(this.label3);
-            this.Controls.Add(this.fetch);
-            this.Controls.Add(this.store);
-            this.Controls.Add(this.label2);
-            this.Controls.Add(this.tel);
-            this.Controls.Add(this.label1);
-            this.Name = "ManualParking";
-            this.Text = "ManualParking";
-            this.ResumeLayout(false);
-            this.PerformLayout();
-
-        }
-
-        #endregion
-
-        private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.TextBox tel;
-        private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.Button store;
-        private System.Windows.Forms.Button fetch;
-        private System.Windows.Forms.Label label3;
-        private System.Windows.Forms.TextBox numberPlate;
-        private System.Windows.Forms.TextBox selectGarage;
-    }
-}

+ 0 - 108
parkMonitor/manualParking/ManualParking.cs

@@ -1,108 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using parkMonitor.entity;
-using parkMonitor.server.CoreThread;
-using parkMonitor.model;
-using parkMonitor.DataBase;
-
-namespace parkMonitor.manualParking
-{
-    public partial class ManualParking : Form
-    {
-        Command storeCmd = new Command();
-        IEquipments qt = EquipmentSimpleFactory.ins.FindEquipment(EquipmentName.Queue);
-        DBOperation oper = new DBOperation();
-
-        string numberRecord = "";
-        string connectionStr = "SqlConnectionLocation";
-        public ManualParking()
-        {
-            InitializeComponent();
-        }
-
-        private void store_Click(object sender, EventArgs e)
-        {
-            storeCmd.manual = true;
-            storeCmd.commandType = 's';
-            storeCmd.userID = oper.GetUserID(connectionStr,tel.Text).ToString();
-            storeCmd.LicenseNum = numberPlate.Text;
-            try
-            {
-                storeCmd.garageID = Convert.ToInt32(selectGarage.Text);
-            }
-            catch { MessageBox.Show("非法车库号,请重新输入"); return; }
-            int garageFreeSpace = 0;
-            bool isTelRegister = oper.IsTelRegister(connectionStr,tel.Text);
-            if (isTelRegister == false)
-            {
-                MessageBox.Show("该号码未被注册,请先注册");
-            }
-            else if (storeCmd.garageID != 0)
-            {
-                garageFreeSpace = oper.getGarageFreeSpace(connectionStr,storeCmd.garageID);
-                if (garageFreeSpace > 0)
-                {
-                    if (storeCmd.userID != "" && storeCmd.LicenseNum != numberRecord)
-                    {
-                        qt.SetMessage((Command)storeCmd.Clone());
-                        MessageBox.Show("发送成功");
-                        numberRecord = storeCmd.LicenseNum;
-                    }
-                    else
-                    {
-                        MessageBox.Show("不要重复发送指令");
-                    }
-                }
-                else
-                {
-                    MessageBox.Show("该车库没有剩余车位");
-                }
-            }
-        }
-
-        private void fetch_Click(object sender, EventArgs e)
-        {
-            storeCmd.manual = true;
-            storeCmd.commandType = 'f';
-            storeCmd.userID = oper.GetUserID(connectionStr,tel.Text).ToString();
-            storeCmd.LicenseNum = numberPlate.Text;
-            storeCmd.TimeRecord = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-            try
-            {
-                storeCmd.garageID = Convert.ToInt32(selectGarage.Text);
-            }
-            catch { MessageBox.Show("非法车库号,请重新输入"); return; }
-            bool isTelRegister = oper.IsTelRegister(connectionStr,tel.Text);
-            bool isNumberPlate = oper.IsNumberPlate(connectionStr,storeCmd.LicenseNum, storeCmd.garageID);
-            if (isTelRegister == false)
-            {
-                MessageBox.Show("该号码未被注册,请先注册");
-            }
-            else if (isNumberPlate == false)
-            {
-                MessageBox.Show("车库中查无此车");
-            }
-            else
-            {
-                storeCmd.parkingRecordsID = oper.GetParkingRecordsID(connectionStr,storeCmd.LicenseNum);
-                if (storeCmd.userID != "" && storeCmd.LicenseNum != "" && storeCmd.parkingRecordsID != 0)
-                {
-                    qt.SetMessage((Command)storeCmd.Clone());
-                    MessageBox.Show("发送成功");
-                    this.Close();
-                }
-                else
-                {
-                    MessageBox.Show("电话号码或号牌错误");
-                }
-            }
-        }
-    }
-}

+ 0 - 120
parkMonitor/manualParking/ManualParking.resx

@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
-  <!-- 
-    Microsoft ResX Schema 
-    
-    Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
-    associated with the data types.
-    
-    Example:
-    
-    ... ado.net/XML headers & schema ...
-    <resheader name="resmimetype">text/microsoft-resx</resheader>
-    <resheader name="version">2.0</resheader>
-    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
-    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
-    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
-    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
-    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
-        <value>[base64 mime encoded serialized .NET Framework object]</value>
-    </data>
-    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
-        <comment>This is a comment</comment>
-    </data>
-                
-    There are any number of "resheader" rows that contain simple 
-    name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
-    mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
-    extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
-    read any of the formats listed below.
-    
-    mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
-            : and then encoded with base64 encoding.
-    
-    mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
-            : and then encoded with base64 encoding.
-
-    mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
-            : using a System.ComponentModel.TypeConverter
-            : and then encoded with base64 encoding.
-    -->
-  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
-    <xsd:element name="root" msdata:IsDataSet="true">
-      <xsd:complexType>
-        <xsd:choice maxOccurs="unbounded">
-          <xsd:element name="metadata">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" />
-              </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string" />
-              <xsd:attribute name="type" type="xsd:string" />
-              <xsd:attribute name="mimetype" type="xsd:string" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="assembly">
-            <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string" />
-              <xsd:attribute name="name" type="xsd:string" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="data">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="resheader">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" />
-            </xsd:complexType>
-          </xsd:element>
-        </xsd:choice>
-      </xsd:complexType>
-    </xsd:element>
-  </xsd:schema>
-  <resheader name="resmimetype">
-    <value>text/microsoft-resx</value>
-  </resheader>
-  <resheader name="version">
-    <value>2.0</value>
-  </resheader>
-  <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-</root>

+ 0 - 186
parkMonitor/manualParking/ManualParkingSimul.cs

@@ -1,186 +0,0 @@
-using parkMonitor.entity;
-using parkMonitor.model;
-using parkMonitor.server.uiLogServer;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using parkMonitor.DataBase;
-using parkMonitor.LOG;
-
-namespace parkMonitor
-{
-    public class ManualParkingSimul
-    {
-        public static ManualParkingSimul ins;
-        private const string userId = "18202736439";
-        private const string garageId = "1";
-        private const string header = "鄂A";
-        private const int licInterval = 5000;//90秒
-        private Random rnd;
-        private Dictionary<int, CarStatusStru> numStatusMap = new Dictionary<int, CarStatusStru>();
-        Command executableCmd = new Command();
-        IEquipments queue;
-        DBOperation oper = new DBOperation();
-
-        public ManualParkingSimul()
-        {
-            Task.Factory.StartNew(() =>
-            {
-                for (int i = 0; i < 10; i++)
-                {
-                    numStatusMap.Add(i, new CarStatusStru(header + (i * 11111).ToString("D5"), 0));
-                }
-                while (queue == null)
-                {
-                    queue = EquipmentSimpleFactory.ins.FindEquipment(EquipmentName.Queue);
-                }
-            }).Wait();
-            Task.Factory.StartNew(() =>
-            {
-                Run();
-            });
-        }
-
-        public void Store(string lic)
-        {
-            string connectionStr = "SqlConnectionLocation";
-            executableCmd.manual = true;
-            executableCmd.commandType = 's';
-            executableCmd.userID = oper.GetUserID(connectionStr, userId).ToString();
-            executableCmd.LicenseNum = lic;
-            executableCmd.TimeRecord = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-            try
-            {
-                executableCmd.garageID = Convert.ToInt32(garageId);
-            }
-            catch { UILogServer.ins.error("非法车库号,请重新输入"); Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "非法车库号,请重新输入"); return; }
-            int garageFreeSpace = 0;
-            bool isTelRegister = oper.IsTelRegister(connectionStr, userId);
-            if (isTelRegister == false)
-            {
-                UILogServer.ins.error(lic+"停车,该号码未被注册,请先注册");
-                Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, lic + "停车,号码未被注册");
-            }
-            else if (executableCmd.garageID != 0)
-            {
-                garageFreeSpace = oper.getGarageFreeSpace(connectionStr, executableCmd.garageID);
-                if (garageFreeSpace > 0)
-                {
-                    if (executableCmd.userID != "" && executableCmd.LicenseNum != "")
-                    {
-                        queue.SetMessage((Command)executableCmd.Clone());
-                        //UILogServer.ins.info("发送成功");
-                    }
-                }
-                else
-                {
-                    UILogServer.ins.error(lic+"该车库没有剩余车位");
-                    Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, lic + "该车库没有剩余车位");
-                }
-            }
-        }
-
-        public void Fetch(string lic)
-        {
-            string connectionStr = "SqlConnectionLocation";
-            executableCmd.manual = true;
-            executableCmd.commandType = 'f';
-            executableCmd.userID = oper.GetUserID(connectionStr, userId).ToString();
-            executableCmd.LicenseNum = lic;
-            executableCmd.TimeRecord = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-            try
-            {
-                executableCmd.garageID = Convert.ToInt32(garageId);
-            }
-            catch { UILogServer.ins.error("非法车库号,请重新输入"); Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "非法车库号"); return; }
-            bool isTelRegister = oper.IsTelRegister(connectionStr, userId);
-            bool isNumberPlate = oper.IsNumberPlate(connectionStr, executableCmd.LicenseNum, executableCmd.garageID);
-            if (isTelRegister == false)
-            {
-                UILogServer.ins.error(lic+"取车该号码未被注册,请先注册");
-                Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, lic + "取车该号码未被注册");
-            }
-            else if (isNumberPlate == false)
-            {
-                UILogServer.ins.error(lic+"车库中查无此车");
-                Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, lic + "车库中查无此车");
-            }
-            else
-            {
-                executableCmd.parkingRecordsID = oper.GetParkingRecordsID(connectionStr, executableCmd.LicenseNum);
-                if (executableCmd.userID != "" && executableCmd.LicenseNum != "" && executableCmd.parkingRecordsID != 0)
-                {
-                    queue.SetMessage((Command)executableCmd.Clone());
-                    //UILogServer.ins.info("发送成功");
-                }
-                else
-                {
-                    UILogServer.ins.error("电话号码或号牌错误");
-                    Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "电话号码或号牌错误");
-                }
-            }
-
-        }
-
-        public void Run()
-        {
-            while (true)
-            {
-                rnd = new Random(DateTime.Now.Millisecond);
-                if (numStatusMap.Count > 0)
-                {
-                    int index = -1, status = -1, count = numStatusMap.Count;
-                    do
-                    {
-                        index = rnd.Next(0, numStatusMap.Count);
-                        status = numStatusMap[index].status;
-                    } while (count-- > 0 && status != 0 && status != 1);
-                    if (status == 0)
-                    {
-                        Store(numStatusMap[index].licNum);
-                        numStatusMap[index].status = 2;
-                    }
-                    else if (status == 1)
-                    {
-                        Fetch(numStatusMap[index].licNum);
-                        numStatusMap[index].status = 3;
-                    }
-
-                }
-                Thread.Sleep(licInterval);
-            }
-        }
-
-        public void Update(int index)
-        {
-            int status = numStatusMap[index].status;
-            if (status == 2)
-            {
-                numStatusMap[index].status = 1;
-            }
-            else if (status == 3)
-            {
-                numStatusMap[index].status = 0;
-            }
-        }
-    }
-    class CarStatusStru
-    {
-        public string licNum { get; set; }
-        public int status { get; set; }
-        public CarStatusStru()
-        {
-            licNum = "";
-            status = 0;
-        }
-        public CarStatusStru(string str, int stat)
-        {
-            licNum = str;
-            status = stat;
-        }
-    }
-
-}

+ 0 - 127
parkMonitor/manualParking/Register.Designer.cs

@@ -1,127 +0,0 @@
-namespace parkMonitor.manualParking
-{
-    partial class Register
-    {
-        /// <summary>
-        /// Required designer variable.
-        /// </summary>
-        private System.ComponentModel.IContainer components = null;
-
-        /// <summary>
-        /// Clean up any resources being used.
-        /// </summary>
-        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing && (components != null))
-            {
-                components.Dispose();
-            }
-            base.Dispose(disposing);
-        }
-
-        #region Windows Form Designer generated code
-
-        /// <summary>
-        /// Required method for Designer support - do not modify
-        /// the contents of this method with the code editor.
-        /// </summary>
-        private void InitializeComponent()
-        {
-            this.label1 = new System.Windows.Forms.Label();
-            this.label2 = new System.Windows.Forms.Label();
-            this.label3 = new System.Windows.Forms.Label();
-            this.textBox1 = new System.Windows.Forms.TextBox();
-            this.textBox2 = new System.Windows.Forms.TextBox();
-            this.textBox3 = new System.Windows.Forms.TextBox();
-            this.register_now = new System.Windows.Forms.Button();
-            this.SuspendLayout();
-            // 
-            // label1
-            // 
-            this.label1.AutoSize = true;
-            this.label1.Location = new System.Drawing.Point(38, 33);
-            this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(41, 12);
-            this.label1.TabIndex = 0;
-            this.label1.Text = "电话:";
-            // 
-            // label2
-            // 
-            this.label2.AutoSize = true;
-            this.label2.Location = new System.Drawing.Point(38, 92);
-            this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(41, 12);
-            this.label2.TabIndex = 1;
-            this.label2.Text = "密码:";
-            // 
-            // label3
-            // 
-            this.label3.AutoSize = true;
-            this.label3.Location = new System.Drawing.Point(38, 153);
-            this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(65, 12);
-            this.label3.TabIndex = 2;
-            this.label3.Text = "确认密码:";
-            // 
-            // textBox1
-            // 
-            this.textBox1.Location = new System.Drawing.Point(150, 33);
-            this.textBox1.Name = "textBox1";
-            this.textBox1.Size = new System.Drawing.Size(100, 21);
-            this.textBox1.TabIndex = 3;
-            // 
-            // textBox2
-            // 
-            this.textBox2.Location = new System.Drawing.Point(150, 92);
-            this.textBox2.Name = "textBox2";
-            this.textBox2.Size = new System.Drawing.Size(100, 21);
-            this.textBox2.TabIndex = 4;
-            // 
-            // textBox3
-            // 
-            this.textBox3.Location = new System.Drawing.Point(150, 153);
-            this.textBox3.Name = "textBox3";
-            this.textBox3.Size = new System.Drawing.Size(100, 21);
-            this.textBox3.TabIndex = 5;
-            // 
-            // register_now
-            // 
-            this.register_now.Location = new System.Drawing.Point(121, 243);
-            this.register_now.Name = "register_now";
-            this.register_now.Size = new System.Drawing.Size(75, 23);
-            this.register_now.TabIndex = 6;
-            this.register_now.Text = "注册";
-            this.register_now.UseVisualStyleBackColor = true;
-            this.register_now.Click += new System.EventHandler(this.register_now_Click);
-            // 
-            // Register
-            // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(396, 313);
-            this.Controls.Add(this.register_now);
-            this.Controls.Add(this.textBox3);
-            this.Controls.Add(this.textBox2);
-            this.Controls.Add(this.textBox1);
-            this.Controls.Add(this.label3);
-            this.Controls.Add(this.label2);
-            this.Controls.Add(this.label1);
-            this.Name = "Register";
-            this.Text = "Register";
-            this.ResumeLayout(false);
-            this.PerformLayout();
-
-        }
-
-        #endregion
-
-        private System.Windows.Forms.Label label1;
-        private System.Windows.Forms.Label label2;
-        private System.Windows.Forms.Label label3;
-        private System.Windows.Forms.TextBox textBox1;
-        private System.Windows.Forms.TextBox textBox2;
-        private System.Windows.Forms.TextBox textBox3;
-        private System.Windows.Forms.Button register_now;
-    }
-}

+ 0 - 77
parkMonitor/manualParking/Register.cs

@@ -1,77 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using System.Security.Cryptography;
-using parkMonitor.DataBase;
-
-namespace parkMonitor.manualParking
-{
-    public partial class Register : Form
-    {
-        public Register()
-        {
-            InitializeComponent();           
-        }
-
-        private void register_now_Click(object sender, EventArgs e)
-        {
-            int flag = 0;
-            string tel = this.textBox1.Text;
-            if (tel.Length != 11)
-            {
-                MessageBox.Show("电话号码不合法");
-            }
-            else
-            {
-                flag = flag + 1;
-            }
-            byte[] passwordText = Encoding.Default.GetBytes(this.textBox2.Text.Trim());
-            MD5 md5 = new MD5CryptoServiceProvider();
-            byte[] passwordMD5 = md5.ComputeHash(passwordText);
-            string password = BitConverter.ToString(passwordMD5).Replace("-", "");
-            if ((passwordText.Length < 6 || passwordText.Length > 20) && flag >= 1)
-            {
-                MessageBox.Show("密码格式不正确,请填写6-20位数字或字母");
-            }
-            else
-            {
-                flag = flag + 1;
-            }
-            byte[] passwordSureText = Encoding.Default.GetBytes(this.textBox3.Text.Trim());
-            byte[] passwordSureMD5 = md5.ComputeHash(passwordSureText);
-            string passwordSure = BitConverter.ToString(passwordSureMD5).Replace("-", "");
-            if (!password.Equals(passwordSure) && flag >= 2)
-            {
-                MessageBox.Show("两次密码不一样");
-            }
-            else
-            {
-                flag = flag + 1;
-            }
-            //DBLocationOperator locationOper = new DBLocationOperator();
-            DBOperation oper = new DBOperation();
-            string connectionStr = "SqlConnectionLocation";
-            bool isTelRegister = oper.IsTelRegister(connectionStr,tel);
-            if (isTelRegister&&flag >= 3)
-            {
-                MessageBox.Show("此电话号码已被注册");
-            }
-            else
-            {
-                flag = flag + 1;               
-            }
-            int userID = oper.InsertUser(connectionStr,tel, password);
-            if (userID!=0&&flag >= 4)
-            {
-                MessageBox.Show("注册成功");
-                this.Close(); 
-            }
-        }
-    }
-}

+ 0 - 120
parkMonitor/manualParking/Register.resx

@@ -1,120 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<root>
-  <!-- 
-    Microsoft ResX Schema 
-    
-    Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
-    associated with the data types.
-    
-    Example:
-    
-    ... ado.net/XML headers & schema ...
-    <resheader name="resmimetype">text/microsoft-resx</resheader>
-    <resheader name="version">2.0</resheader>
-    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
-    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
-    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
-    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
-    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
-        <value>[base64 mime encoded serialized .NET Framework object]</value>
-    </data>
-    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
-        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
-        <comment>This is a comment</comment>
-    </data>
-                
-    There are any number of "resheader" rows that contain simple 
-    name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
-    mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
-    extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
-    read any of the formats listed below.
-    
-    mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
-            : and then encoded with base64 encoding.
-    
-    mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
-            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
-            : and then encoded with base64 encoding.
-
-    mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
-            : using a System.ComponentModel.TypeConverter
-            : and then encoded with base64 encoding.
-    -->
-  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
-    <xsd:element name="root" msdata:IsDataSet="true">
-      <xsd:complexType>
-        <xsd:choice maxOccurs="unbounded">
-          <xsd:element name="metadata">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" />
-              </xsd:sequence>
-              <xsd:attribute name="name" use="required" type="xsd:string" />
-              <xsd:attribute name="type" type="xsd:string" />
-              <xsd:attribute name="mimetype" type="xsd:string" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="assembly">
-            <xsd:complexType>
-              <xsd:attribute name="alias" type="xsd:string" />
-              <xsd:attribute name="name" type="xsd:string" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="data">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
-              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
-              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
-              <xsd:attribute ref="xml:space" />
-            </xsd:complexType>
-          </xsd:element>
-          <xsd:element name="resheader">
-            <xsd:complexType>
-              <xsd:sequence>
-                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-              </xsd:sequence>
-              <xsd:attribute name="name" type="xsd:string" use="required" />
-            </xsd:complexType>
-          </xsd:element>
-        </xsd:choice>
-      </xsd:complexType>
-    </xsd:element>
-  </xsd:schema>
-  <resheader name="resmimetype">
-    <value>text/microsoft-resx</value>
-  </resheader>
-  <resheader name="version">
-    <value>2.0</value>
-  </resheader>
-  <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-  <resheader name="writer">
-    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-  </resheader>
-</root>

+ 0 - 26
parkMonitor/parkMonitor.csproj

@@ -119,15 +119,8 @@
     <Compile Include="Database2\DatabaseConnPoolFactory.cs" />
     <Compile Include="Database2\DBAccess.cs" />
     <Compile Include="Database2\DBOperation.cs" />
-    <Compile Include="Database2\DBOperation2.cs" />
-    <Compile Include="Database2\IDBOperation.cs" />
     <Compile Include="Database2\SimpleCommandFactory.cs" />
     <Compile Include="Database2\Vehicle.cs" />
-    <Compile Include="DataBase\DBConnection.cs" />
-    <Compile Include="DataBase\DBConnectionPool.cs" />
-    <Compile Include="DataBase\DBOperation.cs" />
-    <Compile Include="DataBase\IDBOperation.cs" />
-    <Compile Include="DataBase\Vehicle.cs" />
     <Compile Include="DBLocation\DBLocation.cs" />
     <Compile Include="DBLocation\IDBLocation.cs" />
     <Compile Include="DB\DBOperation.cs" />
@@ -145,19 +138,6 @@
     <Compile Include="LOG\Log.cs" />
     <Compile Include="LOG\LogManager.cs" />
     <Compile Include="LOG\LogTest.cs" />
-    <Compile Include="manualParking\ManualParking.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="manualParking\ManualParking.Designer.cs">
-      <DependentUpon>ManualParking.cs</DependentUpon>
-    </Compile>
-    <Compile Include="manualParking\ManualParkingSimul.cs" />
-    <Compile Include="manualParking\Register.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="manualParking\Register.Designer.cs">
-      <DependentUpon>Register.cs</DependentUpon>
-    </Compile>
     <Compile Include="model\EquipmentName.cs" />
     <Compile Include="model\EquipmentsSection.cs" />
     <Compile Include="sdk\superscene\TimeTest.cs" />
@@ -508,12 +488,6 @@
     <EmbeddedResource Include="controlPanel\InitWin.resx">
       <DependentUpon>InitWin.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="manualParking\ManualParking.resx">
-      <DependentUpon>ManualParking.cs</DependentUpon>
-    </EmbeddedResource>
-    <EmbeddedResource Include="manualParking\Register.resx">
-      <DependentUpon>Register.cs</DependentUpon>
-    </EmbeddedResource>
     <EmbeddedResource Include="Properties\Resources.resx">
       <Generator>ResXFileCodeGenerator</Generator>
       <LastGenOutput>Resources.Designer.cs</LastGenOutput>

+ 5 - 2
parkMonitor/server/CoreThread/CoreThreadTest2.cs

@@ -150,7 +150,7 @@ namespace parkMonitor.server.CoreThread
                             if (queueCmd != null)
                             {
                                 //远端或本地异常,遇到相应指令则退回
-                                if ((!queueCmd.manual && Operation.malfunctionRemote) || (queueCmd.manual && Operation.malfunctionLocal))
+                                if ((!queueCmd.manual && ConnectionPoolManager.malfunctionRemote) || (queueCmd.manual && ConnectionPoolManager.malfunctionLocal))
                                 {
                                     queueCmd.returnedCount = 1;
                                     queuingThread.SetMessage((Command)queueCmd.Clone());
@@ -182,11 +182,14 @@ namespace parkMonitor.server.CoreThread
                         }
                         queueCmdRecord = (Command)queueCmd.Clone();
                     }
+                    Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "准备,等待机械手线程个数:" + Robot.robot1.waitCount);
                     Task.Factory.StartNew(() =>
                     {
+                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "开始");
                         SimpleCMDFactory simpleCMDFactory = new SimpleCMDFactory();
                         AbstractCmd abstractCmd = simpleCMDFactory.createCmd(queueCmd);
                         abstractCmd.executeCmd(queueCmd);
+                        Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "完成");
                     });
 
                 }
@@ -287,7 +290,7 @@ namespace parkMonitor.server.CoreThread
         private void CheckRemotePool(object o)
         {
             ConnectionPoolManager.CheckConnPooling(3, 10, ConnectionPoolManager.remoteConf, EntityForCore.remoteBQ);
-            DBOperation.KillTimeOutConnection(ConnectionPoolManager.remoteConf, 3600, EntityForCore.remoteBQ);
+            DBOperation.KillTimeOutConnection(null, 3600, EntityForCore.remoteBQ);
         }
         private void CheckLocalPool(object o)
         {

+ 49 - 9
parkMonitor/server/CoreThread/QueuingThread.cs

@@ -11,7 +11,7 @@ using System.Configuration;
 using parkMonitor.tools;
 using parkMonitor.server.uiLogServer;
 using parkMonitor.LOG;
-using parkMonitor.DataBase;
+using parkMonitor.Database2;
 
 namespace parkMonitor.server.CoreThread
 {
@@ -103,7 +103,7 @@ namespace parkMonitor.server.CoreThread
                     if (cmd.commandType == 'p')
                     {
                         DateTime dt = new DateTime();
-                        if(webMsg.bookTime == null)
+                        if (webMsg.bookTime == null)
                         {
                             cmd.TimeRecord = "";
                         }
@@ -176,6 +176,7 @@ namespace parkMonitor.server.CoreThread
         private void Run()
         {
             NumberMachineNode temp = null;
+            NumberMachineMessage numMsg = null;
             while (!isClosing)
             {
                 lock (LicenseQueue)
@@ -183,7 +184,11 @@ namespace parkMonitor.server.CoreThread
                     //本地号牌已使用,则接收新的号牌消息
                     if (numMachineHandle != null && !NumMachineNodeValidation(license))
                     {
-                        license = ((NumberMachineMessage)numMachineHandle.GetMessage()).aNode;
+                        while (numMsg == null)
+                        {
+                            numMsg = ((NumberMachineMessage)numMachineHandle.GetMessage());
+                        }
+                        license = numMsg.aNode;
                         //无重复则匹配指令,匹配失败则入号牌队列,并将号牌机线程获得的Node中ip标记为已使用
                         if (NumMachineNodeValidation(license))
                         {
@@ -209,7 +214,6 @@ namespace parkMonitor.server.CoreThread
                             LicenseQueue.Enqueue(temp);
                         }
                     }
-
                 }
 
                 //队列业务逻辑
@@ -249,7 +253,7 @@ namespace parkMonitor.server.CoreThread
                 if (cmd != null)
                 {
                     TimeSpan ts = DateTime.Now - DateTime.Parse(cmd.TimeRecord);
-                    if (ts.TotalMinutes>= bookTime)
+                    if (ts.TotalMinutes >= bookTime)
                     {
                         //超时则释放车位,丢出指令
                         UILogServer.ins.warn("预约指令 " + cmd.LicenseNum + " 已存在超过" + bookTime + "分钟 ,强制出队");
@@ -279,7 +283,7 @@ namespace parkMonitor.server.CoreThread
                 //Console.WriteLine("指令已扫描时间:" + userTimeSpan.TotalSeconds);
                 if (userTimeSpan.TotalMinutes >= userTime)
                 {
-                    UILogServer.ins.warn("用户指令 " + cmd.LicenseNum + " 已存在超过" + String.Format("{0:F1}", userTimeSpan.TotalMinutes) + "分钟 ,强制出队");
+                    UILogServer.ins.warn("用户" + cmd.userID + "指令 " + cmd.LicenseNum + " 已存在超过" + String.Format("{0:F1}", userTimeSpan.TotalMinutes) + "分钟 ,强制出队");
                     Log.WriteLog(LogType.NOT_DATABASE, LogFile.ERROR, "用户指令 " + cmd.LicenseNum + " 已存在超过" + String.Format("{0:F1}", userTimeSpan.TotalMinutes) + "分钟 ,强制出队");
                     //cmd.LicenseNum = "";
                     cmd.commandType = 'e';
@@ -419,7 +423,7 @@ namespace parkMonitor.server.CoreThread
                 while (FetchCmdQueue.Count != 0 && fetch-- > 0)
                 {
                     cmd = FetchCmdQueue.Dequeue();
-                    if ((cmd.manual && Operation.malfunctionLocal) || (!cmd.manual && Operation.malfunctionRemote))
+                    if ((cmd.manual && ConnectionPoolManager.malfunctionLocal) || (!cmd.manual && ConnectionPoolManager.malfunctionRemote))
                     {
                         FetchCmdQueue.Enqueue(cmd);
                     }
@@ -436,7 +440,7 @@ namespace parkMonitor.server.CoreThread
                 if (ValidStoreCmdQueue.Count != 0)
                 {
                     cmd = ValidStoreCmdQueue.Dequeue();
-                    if ((cmd.manual && Operation.malfunctionLocal) || (!cmd.manual && Operation.malfunctionRemote))
+                    if ((cmd.manual && ConnectionPoolManager.malfunctionLocal) || (!cmd.manual && ConnectionPoolManager.malfunctionRemote))
                     {
                         ValidStoreCmdQueue.Enqueue(cmd);
                     }
@@ -450,11 +454,47 @@ namespace parkMonitor.server.CoreThread
             }
         }
 
+        private string QueueDisplay(Queue<Command> queue)
+        {
+            string temp = "[";
+            if (queue != null && queue.Count != 0)
+            {
+                Command cmd = null;
+                for (int i = 0; i < queue.Count; i++)
+                {
+                    cmd = queue.Dequeue();
+                    temp += cmd.LicenseNum + ",";
+                    queue.Enqueue(cmd);
+                }
+            }
+            return temp + "]";
+        }
+        private string QueueDisplay(Queue<NumberMachineNode> queue)
+        {
+            string temp = "[";
+            if (queue != null && queue.Count != 0)
+            {
+                NumberMachineNode node = null;
+                for (int i = 0; i < queue.Count; i++)
+                {
+                    node = queue.Dequeue();
+                    temp += node.LicenseNum + ",";
+                    queue.Enqueue(node);
+                }
+            }
+            return temp + "]";
+        }
+
         /// <summary>
         /// 获取一个停取车指令
         /// </summary>
         public AbstractMessage GetMessage()
         {
+            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "号牌队列:" + QueueDisplay(LicenseQueue));
+            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "停指队列:" + QueueDisplay(StoreCmdQueue));
+            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "取指队列:" + QueueDisplay(FetchCmdQueue));
+            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "合法停指队列:" + QueueDisplay(ValidStoreCmdQueue));
+            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "预约队列:" + QueueDisplay(BookParkingQueue));
             lock (ExecutableCmdQueue)
             {
                 return (Command)ExecutableCmdQueue.Dequeue();
@@ -508,7 +548,7 @@ namespace parkMonitor.server.CoreThread
                     }
                     else
                     {
-                        if (!Operation.malfunctionLocal)
+                        if (!ConnectionPoolManager.malfunctionLocal)
                         {
                             if (command.commandType.Equals('f'))
                             {

+ 5 - 0
parkMonitor/server/CoreThread/SpaceManager.cs

@@ -116,6 +116,7 @@ namespace parkMonitor.server.CoreThread
                     }
                     Dictionary<int, Parking_Space>.Enumerator enumer = parkingSpaceStatusMap.GetEnumerator();
                     Parking_Space temp = null;
+                    string log = "[";
                     while (enumer.MoveNext())
                     {
                         if (enumer.Current.Value != null)
@@ -123,6 +124,8 @@ namespace parkMonitor.server.CoreThread
                             if (enumer.Current.Value.parkingSpaceState == 0)
                             {
                                 lps.Add(enumer.Current.Key, enumer.Current.Value);
+                                //输出空闲车位
+                                log += enumer.Current.Key.ToString() + ",";
                             }
                             else if (enumer.Current.Value.parkingSpaceState == 2 && enumer.Current.Value.licence == queueCmd.LicenseNum)
                             {
@@ -130,6 +133,7 @@ namespace parkMonitor.server.CoreThread
                             }
                         }
                     }
+                    Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, log+"]");
                     if (temp != null && !booking)
                     {
                         //分配已预约的车位后将该车位置为占用
@@ -188,6 +192,7 @@ namespace parkMonitor.server.CoreThread
                 if (parkingSpaceStatusMap[parkingSpaceID].parkingSpaceState != status)
                 {
                     parkingSpaceStatusMap[parkingSpaceID].parkingSpaceState = status;
+                    Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "车位ID:" + parkingSpaceStatusMap[parkingSpaceID].parkingSpaceID + "置为" + status);
                     //清空该车位号牌
                     if (status == 0)
                     {

+ 1 - 1
parkMonitor/server/NumMachine/ParkingSimul.cs

@@ -1,4 +1,4 @@
-using parkMonitor.DataBase;
+
 using parkMonitor.entity;
 using parkMonitor.LOG;
 using parkMonitor.model;

+ 4 - 6
parkMonitor/view/menuBox/MenuBox.xaml.cs

@@ -1,8 +1,6 @@
 using parkMonitor.controlPanel;
-using parkMonitor.DataBase;
 using parkMonitor.entity;
 using parkMonitor.LOG;
-using parkMonitor.manualParking;
 using parkMonitor.model;
 using parkMonitor.server.uiLogServer;
 using parkMonitor.tools;
@@ -96,10 +94,10 @@ namespace parkMonitor.view.util
         /// <summary>菜单-启动Web服务器</summary>
         private void muRunWebServer_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
         {
-            Register register = new Register();
-            register.ShowDialog();
-            ManualParking mp = new ManualParking();
-            mp.ShowDialog();
+            //Register register = new Register();
+            //register.ShowDialog();
+            //ManualParking mp = new ManualParking();
+            //mp.ShowDialog();
         }
 
         /// <summary>菜单-启动号牌机</summary>

+ 42 - 1
预约笔记.txt

@@ -1 +1,42 @@
-预约停车,提前分配车位到截止时间。在此之前匹配上则将该车位给予该车辆。
+预约停车,提前分配车位到截止时间。在此之前匹配上则将该车位给予该车辆。
+
+Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "号牌队列:" + QueueDisplay(LicenseQueue));
+            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "停指队列:" + QueueDisplay(StoreCmdQueue));
+            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "取指队列:" + QueueDisplay(FetchCmdQueue));
+            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "合法停指队列:" + QueueDisplay(ValidStoreCmdQueue));
+            Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "预约队列:" + QueueDisplay(BookParkingQueue));
+			
+        private string QueueDisplay(Queue<Command> queue)
+        {
+            string temp = "[";
+            if (queue != null && queue.Count != 0)
+            {
+                Command cmd = null;
+                for (int i = 0; i < queue.Count; i++)
+                {
+                    cmd = queue.Dequeue();
+                    temp += cmd.LicenseNum + ",";
+                    queue.Enqueue(cmd);
+                }
+            }
+            return temp + "]";
+        }
+        private string QueueDisplay(Queue<NumberMachineNode> queue)
+        {
+            string temp = "[";
+            if (queue != null && queue.Count != 0)
+            {
+                NumberMachineNode node = null;
+                for (int i = 0; i < queue.Count; i++)
+                {
+                    node = queue.Dequeue();
+                    temp += node.LicenseNum + ",";
+                    queue.Enqueue(node);
+                }
+            }
+            return temp + "]";
+        }
+		
+		Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "准备,等待机械手线程个数:" + Robot.robot1.waitCount);
+		Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "开始");
+		Log.WriteLog(LogType.NOT_DATABASE, LogFile.LOG, "线程创建:" + queueCmd.LicenseNum + "完成");