|
@@ -3,15 +3,14 @@ using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
-using parkMonitor.DB;
|
|
|
using parkMonitor.LOG;
|
|
|
using parkMonitor.entity;
|
|
|
using parkMonitor.model;
|
|
|
using System.Configuration;
|
|
|
using System.Threading;
|
|
|
using parkMonitor.server.uiLogServer;
|
|
|
-using parkMonitor.DBLocation;
|
|
|
using parkMonitor.tools;
|
|
|
+using parkMonitor.DataBase;
|
|
|
|
|
|
namespace parkMonitor.server.CoreThread
|
|
|
{
|
|
@@ -37,7 +36,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
public int rearWheelbase_address { get; set; }
|
|
|
|
|
|
//instances
|
|
|
- public DBLocationOperator locationOper { get; set; }
|
|
|
+ //public DBLocationOperator locationOper { get; set; }
|
|
|
public IEquipments PLC { set; get; }
|
|
|
public IEquipments queuingThread { set; get; }
|
|
|
public DBOperation oper { set; get; }
|
|
@@ -73,7 +72,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
aps = new AllotParkingSpace();
|
|
|
Robot.robot1.parking_start_addr = parking_startRobot_address;
|
|
|
Robot.robot1.fetching_start_addr = fetching_startRobot_address;
|
|
|
- locationOper = new DBLocationOperator();
|
|
|
+ //locationOper = new DBLocationOperator();
|
|
|
}
|
|
|
public abstract void executeCmd(Command queueCmd);
|
|
|
public bool WaitForRobotResource(int robotID)
|
|
@@ -147,6 +146,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
/// <param name="isParking"></param>
|
|
|
public void Rollback(Command queueCmd, int parkingSpaceID, bool parkingSpaceUpdated, bool isParking)
|
|
|
{
|
|
|
+ string connectionStr = null;
|
|
|
//命令回退
|
|
|
queueCmd.returnedCount += 1;
|
|
|
queuingThread.SetMessage(queueCmd);
|
|
@@ -154,44 +154,46 @@ namespace parkMonitor.server.CoreThread
|
|
|
//复位车辆状态;若已更新过车位则还需复位总车位数,车位状态
|
|
|
if (!queueCmd.manual)
|
|
|
{
|
|
|
- int freeSpaceCount = oper.getGarageFreeSpace(queueCmd.garageID);
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
+ int freeSpaceCount = oper.getGarageFreeSpace(connectionStr,queueCmd.garageID);
|
|
|
if (isParking)
|
|
|
{
|
|
|
- oper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
|
|
|
+ oper.UpdateVehicleParkState(connectionStr,queueCmd.LicenseNum, 0);
|
|
|
if (parkingSpaceUpdated)
|
|
|
{
|
|
|
freeSpaceCount = freeSpaceCount + 1;
|
|
|
- oper.UpdateGarageFreeSpace(freeSpaceCount, queueCmd.garageID);
|
|
|
- oper.UpdateParkingSpaceState(parkingSpaceID, 0);
|
|
|
+ oper.UpdateGarageFreeSpace(connectionStr,freeSpaceCount, queueCmd.garageID);
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 0);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
- oper.UpdateVehicleParkState(queueCmd.LicenseNum, 1);
|
|
|
+ {
|
|
|
+ oper.UpdateVehicleParkState(connectionStr,queueCmd.LicenseNum, 1);
|
|
|
if (parkingSpaceUpdated)
|
|
|
{
|
|
|
freeSpaceCount = freeSpaceCount - 1;
|
|
|
- oper.UpdateGarageFreeSpace(freeSpaceCount, queueCmd.garageID);
|
|
|
- oper.UpdateParkingSpaceState(parkingSpaceID, 1);
|
|
|
+ oper.UpdateGarageFreeSpace(connectionStr,freeSpaceCount, queueCmd.garageID);
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
if (isParking)
|
|
|
{
|
|
|
- locationOper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
|
|
|
+ oper.UpdateVehicleParkState(connectionStr,queueCmd.LicenseNum, 0);
|
|
|
if (parkingSpaceUpdated)
|
|
|
{
|
|
|
- locationOper.UpdateParkingSpaceState(parkingSpaceID, 0);
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 0);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- locationOper.UpdateVehicleParkState(queueCmd.LicenseNum, 1);
|
|
|
+ oper.UpdateVehicleParkState(connectionStr,queueCmd.LicenseNum, 1);
|
|
|
if (parkingSpaceUpdated)
|
|
|
{
|
|
|
- locationOper.UpdateParkingSpaceState(parkingSpaceID, 1);
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -254,6 +256,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
/// <returns></returns>
|
|
|
private Parking_Space WaitForParkingSpaceResource(Command queueCmd)
|
|
|
{
|
|
|
+ string connectionStr = null;
|
|
|
//中心点
|
|
|
cEntrance.parkingEntX = parkingEntX;
|
|
|
cEntrance.parkingEntY = parkingEntY;
|
|
@@ -265,11 +268,13 @@ namespace parkMonitor.server.CoreThread
|
|
|
{
|
|
|
if (!queueCmd.manual)
|
|
|
{
|
|
|
- ppp = aps.MallocParkingSpace(cEntrance, oper, queueCmd);//自动
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
+ ppp = aps.MallocParkingSpace(cEntrance, connectionStr, queueCmd);//自动
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ppp = aps.MallocParkingSpace(cEntrance, locationOper, queueCmd);//手动
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
+ ppp = aps.MallocParkingSpace(cEntrance, connectionStr, queueCmd);//手动
|
|
|
}
|
|
|
if (ppp != null)
|
|
|
{
|
|
@@ -390,6 +395,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
/// </summary>
|
|
|
private bool WaitForStoreCompletionSignal(Command queueCmd, ref int parkingSpaceID, ref bool robotError, int status)
|
|
|
{
|
|
|
+ string connectionStr = null;
|
|
|
PLCMessage PLCMsg = null;
|
|
|
MyTimer mt = new MyTimer();
|
|
|
mt.StartTiming();
|
|
@@ -411,11 +417,13 @@ namespace parkMonitor.server.CoreThread
|
|
|
queuingThread.SetMessage(queueCmd);
|
|
|
if (!queueCmd.manual)
|
|
|
{
|
|
|
- oper.UpdateParkingSpaceState(parkingSpaceID, 0);
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- locationOper.UpdateParkingSpaceState(parkingSpaceID, 0);
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 0);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -484,6 +492,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
/// <param name="queueCmd"></param>
|
|
|
public override void executeCmd(Command queueCmd)
|
|
|
{
|
|
|
+ string connectionStr = null;
|
|
|
bool disappeared = false;
|
|
|
bool stopChecking = false;
|
|
|
bool robotError = false;
|
|
@@ -557,21 +566,23 @@ namespace parkMonitor.server.CoreThread
|
|
|
int parkingSpaceZ = ppp.parkingSpaceZ;
|
|
|
if (!queueCmd.manual)
|
|
|
{
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
//更新云端车位表车位状态
|
|
|
- oper.UpdateParkingSpaceState(parkingSpaceID, 1);
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 1);
|
|
|
//更新车库表剩余车位数
|
|
|
- int freeSpaceCount = oper.getGarageFreeSpace(garageID);
|
|
|
+ int freeSpaceCount = oper.getGarageFreeSpace(connectionStr, garageID);
|
|
|
freeSpaceCount = freeSpaceCount - 1;
|
|
|
- oper.UpdateGarageFreeSpace(freeSpaceCount, garageID);
|
|
|
+ oper.UpdateGarageFreeSpace(connectionStr, freeSpaceCount, garageID);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
//更新本地车位表车位状态
|
|
|
- locationOper.UpdateParkingSpaceState(parkingSpaceID, 1);
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 1);
|
|
|
//更新车库表剩余车位数
|
|
|
- int freeSpaceCount = locationOper.getGarageFreeSpace(garageID);
|
|
|
+ int freeSpaceCount = oper.getGarageFreeSpace(connectionStr,garageID);
|
|
|
freeSpaceCount = freeSpaceCount - 1;
|
|
|
- locationOper.UpdateGarageFreeSpace(freeSpaceCount, garageID);
|
|
|
+ oper.UpdateGarageFreeSpace(connectionStr,freeSpaceCount, garageID);
|
|
|
}
|
|
|
//号牌失效,数据库回滚
|
|
|
if (disappeared)
|
|
@@ -579,11 +590,13 @@ namespace parkMonitor.server.CoreThread
|
|
|
NumReset(queueCmd);
|
|
|
if (!queueCmd.manual)
|
|
|
{
|
|
|
- oper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
+ oper.UpdateVehicleParkState(connectionStr,queueCmd.LicenseNum, 0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- locationOper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
+ oper.UpdateVehicleParkState(connectionStr,queueCmd.LicenseNum, 0);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
@@ -657,20 +670,22 @@ namespace parkMonitor.server.CoreThread
|
|
|
//正常写入数据库
|
|
|
if (userID != 0)
|
|
|
{
|
|
|
- if (queueCmd.manual == false)
|
|
|
+ if (!queueCmd.manual)
|
|
|
{
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
//更新云端数据库
|
|
|
//插入停车记录表
|
|
|
- int parkingRecordsID = oper.InsertToParkingRecords(userID, numberPlate, parkingSpaceID, garageID, 3, realParkTime);
|
|
|
+ int parkingRecordsID = oper.InsertToParkingRecords(connectionStr,userID, numberPlate, parkingSpaceID, garageID, 3, realParkTime);
|
|
|
//车辆表更新车辆信息
|
|
|
- oper.UpdateVehicle(numberPlate, 1, realParkTime, parkingRecordsID, parkingSpaceID, 1, frontWheelbase, rearWheelbase);
|
|
|
+ oper.UpdateVehicle(connectionStr,numberPlate, 1, realParkTime, parkingRecordsID, parkingSpaceID, 1, frontWheelbase, rearWheelbase);
|
|
|
//插入消息队列表
|
|
|
- oper.InsertToMessageQueue(userID, "停车成功", 1);
|
|
|
+ oper.InsertToMessageQueue(connectionStr,userID, "停车成功", 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
//插入停车记录表
|
|
|
- int parkingRecordsID = locationOper.InsertToParkingRecords(1, userID, numberPlate, parkingSpaceID, garageID, 3, realParkTime, frontWheelbase, rearWheelbase);
|
|
|
+ int parkingRecordsID = oper.InsertToLocalParkingRecords(connectionStr,1, userID, numberPlate, parkingSpaceID, garageID, 3, realParkTime, frontWheelbase, rearWheelbase);
|
|
|
}
|
|
|
}
|
|
|
//异常写入日志文件
|
|
@@ -695,6 +710,7 @@ namespace parkMonitor.server.CoreThread
|
|
|
{
|
|
|
private bool waitForFetchCompletionSignal(Command queueCmd, ref int parkingSpaceID, ref bool robotError, int status)
|
|
|
{
|
|
|
+ string connectionStr = null;
|
|
|
PLCMessage PLCMsg = null;
|
|
|
MyTimer mt = new MyTimer();
|
|
|
mt.StartTiming();
|
|
@@ -717,11 +733,13 @@ namespace parkMonitor.server.CoreThread
|
|
|
queuingThread.SetMessage(queueCmd);
|
|
|
if (!queueCmd.manual)
|
|
|
{
|
|
|
- oper.UpdateParkingSpaceState(parkingSpaceID, 0);
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- locationOper.UpdateParkingSpaceState(parkingSpaceID, 0);
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 0);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
@@ -746,15 +764,18 @@ namespace parkMonitor.server.CoreThread
|
|
|
|
|
|
public override void executeCmd(Command queueCmd)
|
|
|
{
|
|
|
+ string connectionStr = null;
|
|
|
PLCMessage PLCMsg = null;
|
|
|
Vehicle vehiclelist = null;
|
|
|
if (queueCmd.manual)
|
|
|
{
|
|
|
- vehiclelist = locationOper.GetVehicle(queueCmd.LicenseNum, queueCmd.garageID);
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
+ vehiclelist = oper.GetLocalVehicle(connectionStr,queueCmd.LicenseNum, queueCmd.garageID);
|
|
|
}
|
|
|
else
|
|
|
- {
|
|
|
- vehiclelist = oper.GetVehicle(queueCmd.LicenseNum);
|
|
|
+ {
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
+ vehiclelist = oper.GetVehicle(connectionStr,queueCmd.LicenseNum);
|
|
|
}
|
|
|
int parkingSpaceID = vehiclelist.parkingSpaceID;
|
|
|
int garageID = vehiclelist.garageID;
|
|
@@ -764,11 +785,13 @@ namespace parkMonitor.server.CoreThread
|
|
|
Fetching_Space fslist = null;
|
|
|
if (queueCmd.manual)
|
|
|
{
|
|
|
- fslist = locationOper.GetFetchingSpace(parkingSpaceID);
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
+ fslist = oper.GetFetchingSpace(connectionStr,parkingSpaceID);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- fslist = oper.GetFetchingSpace(parkingSpaceID);
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
+ fslist = oper.GetFetchingSpace(connectionStr,parkingSpaceID);
|
|
|
}
|
|
|
int parkingSpaceX = fslist.parkingSpaceX;
|
|
|
int parkingSpaceY = fslist.parkingSpaceY;
|
|
@@ -823,19 +846,20 @@ namespace parkMonitor.server.CoreThread
|
|
|
Log.WriteLog("号牌:" + queueCmd.LicenseNum + "取车完成");
|
|
|
UILogServer.ins.info("号牌:" + queueCmd.LicenseNum + "取车完成");
|
|
|
//数据库更新
|
|
|
- if (queueCmd.manual == false)
|
|
|
+ if (!queueCmd.manual)
|
|
|
{
|
|
|
+ connectionStr = "SqlConnectionStr";
|
|
|
//云端数据库更新
|
|
|
//更新车库表车位数
|
|
|
- int freeSpaceCount = oper.getGarageFreeSpace(garageID);
|
|
|
+ int freeSpaceCount = oper.getGarageFreeSpace(connectionStr,garageID);
|
|
|
freeSpaceCount = freeSpaceCount + 1;
|
|
|
- oper.UpdateGarageFreeSpace(freeSpaceCount, garageID);
|
|
|
+ oper.UpdateGarageFreeSpace(connectionStr,freeSpaceCount, garageID);
|
|
|
//更新车位表车位状态
|
|
|
- oper.UpdateParkingSpaceState(parkingSpaceID, 0);
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 0);
|
|
|
//更新车辆表车辆停车状态
|
|
|
- oper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
|
|
|
+ oper.UpdateVehicleParkState(connectionStr,queueCmd.LicenseNum, 0);
|
|
|
//更新停车记录表
|
|
|
- oper.UpdateParkingRecords(6, queueCmd.TimeRecord, queueCmd.parkingRecordsID);
|
|
|
+ oper.UpdateParkingRecords(connectionStr,6, queueCmd.TimeRecord, queueCmd.parkingRecordsID);
|
|
|
|
|
|
////本地数据库更新
|
|
|
//locationOper.UpdateGarageFreeSpace(freeSpaceCount, garageID);
|
|
@@ -848,16 +872,17 @@ namespace parkMonitor.server.CoreThread
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+ connectionStr = "SqlConnectionLocation";
|
|
|
//更新车库表车位数
|
|
|
- int freeSpaceCount = locationOper.getGarageFreeSpace(garageID);
|
|
|
+ int freeSpaceCount = oper.getGarageFreeSpace(connectionStr,garageID);
|
|
|
freeSpaceCount = freeSpaceCount + 1;
|
|
|
- locationOper.UpdateGarageFreeSpace(freeSpaceCount, garageID);
|
|
|
+ oper.UpdateGarageFreeSpace(connectionStr,freeSpaceCount, garageID);
|
|
|
//更新车位表车位状态
|
|
|
- locationOper.UpdateParkingSpaceState(parkingSpaceID, 0);
|
|
|
+ oper.UpdateParkingSpaceState(connectionStr,parkingSpaceID, 0);
|
|
|
////更新车辆表车辆停车状态
|
|
|
//locationOper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
|
|
|
//更新停车记录表
|
|
|
- locationOper.UpdateParkingRecords(0, 6, queueCmd.TimeRecord, queueCmd.parkingRecordsID);
|
|
|
+ oper.UpdateParkingRecords(connectionStr,0, 6, queueCmd.TimeRecord, queueCmd.parkingRecordsID);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -869,13 +894,14 @@ namespace parkMonitor.server.CoreThread
|
|
|
{
|
|
|
public override void executeCmd(Command queueCmd)
|
|
|
{
|
|
|
+ string connectionStr = "SqlConnectionLocation";
|
|
|
if (queueCmd.commandType == 'e')
|
|
|
{
|
|
|
int userId = Convert.ToInt32(queueCmd.userID);
|
|
|
//过期用户指令
|
|
|
- oper.InsertToMessageQueue(userId, "停车异常,请联系管理员!", 2);
|
|
|
+ oper.InsertToMessageQueue(connectionStr,userId, "停车异常,请联系管理员!", 2);
|
|
|
//未能停车,将车辆状态复位
|
|
|
- oper.UpdateVehicleParkState(queueCmd.LicenseNum, 0);
|
|
|
+ oper.UpdateVehicleParkState(connectionStr,queueCmd.LicenseNum, 0);
|
|
|
LogFile logFile = LogFile.ERROR_NUMBERPLATE;
|
|
|
Log.WriteLog(logFile, "过期用户指令,车牌号:" + queueCmd.LicenseNum);
|
|
|
UILogServer.ins.error("过期用户指令,车牌号:" + queueCmd.LicenseNum);
|