Ejemplo n.º 1
0
        public static List <ParkDevice> QueryParkDeviceDetectionByParkingID(string parkingid)
        {
            if (string.IsNullOrWhiteSpace(parkingid))
            {
                throw new ArgumentNullException("parkingid");
            }
            IParkDevice factory = ParkDeviceFactory.GetFactory();

            return(factory.QueryParkDeviceDetectionByParkingID(parkingid));
        }
Ejemplo n.º 2
0
        public static List <ParkDevice> QueryParkDeviceByIPAddress(string ipaddress)
        {
            if (string.IsNullOrWhiteSpace(ipaddress))
            {
                throw new ArgumentNullException("ipaddress");
            }

            IParkDevice factory = ParkDeviceFactory.GetFactory();

            return(factory.QueryParkDeviceByIPAddress(ipaddress));
        }
Ejemplo n.º 3
0
        public static ParkDevice QueryParkDeviceByRecordId(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            IParkDevice factory = ParkDeviceFactory.GetFactory();

            return(factory.QueryParkDeviceByRecordId(recordId));
        }
Ejemplo n.º 4
0
        public static List <ParkDevice> QueryParkDeviceByGateRecordId(string gateRecordId)
        {
            if (string.IsNullOrWhiteSpace(gateRecordId))
            {
                throw new ArgumentNullException("gateRecordId");
            }

            IParkDevice factory = ParkDeviceFactory.GetFactory();

            return(factory.QueryParkDeviceByGateRecordId(gateRecordId));
        }
Ejemplo n.º 5
0
        public static bool Update(ParkDevice model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            IParkDevice          factory          = ParkDeviceFactory.GetFactory();
            IParkDeviceDetection factoryDetection = ParkDeviceDetectionFactory.GetFactory();
            bool result = false;

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();

                    result = factory.Update(model, dbOperator);
                    if (!result)
                    {
                        throw new MyException("修改设备失败");
                    }

                    if (model.DeviceType == DeviceType.NZ_CONTROL)
                    {
                        ParkDeviceParam deviceParam = factory.QueryParkDeviceParamByDID(model.DeviceID);
                        if (deviceParam == null)
                        {
                            AddDefaultParkDeviceParam(model.GateID, model.DeviceID, model.DeviceNo, dbOperator);
                        }
                        else
                        {
                            factory.UpdateParam(model.DeviceID, model.DeviceNo, dbOperator);
                        }
                    }

                    dbOperator.CommitTransaction();
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
            if (result)
            {
                OperateLogServices.AddOperateLog <ParkDevice>(model, OperateType.Update);
            }
            return(result);
        }
Ejemplo n.º 6
0
        public static bool Add(ParkDevice model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            IParkDeviceDetection factoryDetection = ParkDeviceDetectionFactory.GetFactory();

            model.DeviceID = GuidGenerator.GetGuid().ToString();
            IParkDevice factory = ParkDeviceFactory.GetFactory();
            bool        result  = false;

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();

                    result = factory.Add(model, dbOperator);
                    if (!result)
                    {
                        throw new MyException("添加设备失败");
                    }
                    if (model.DeviceType == DeviceType.NZ_CONTROL)
                    {
                        int devId = 0;
                        if (!int.TryParse(model.DeviceNo, out devId))
                        {
                            throw new MyException("设备编号只能输入纯数字");
                        }
                        AddDefaultParkDeviceParam(model.GateID, model.DeviceID, model.DeviceNo, dbOperator);
                    }
                    dbOperator.CommitTransaction();
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
            if (result)
            {
                OperateLogServices.AddOperateLog <ParkDevice>(model, OperateType.Add);
            }
            return(result);
        }
Ejemplo n.º 7
0
        public static bool AddParam(ParkDeviceParam model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            model.RecordID = GuidGenerator.GetGuid().ToString();
            IParkDevice factory = ParkDeviceFactory.GetFactory();

            ParkDeviceParam deviceParam = factory.QueryParkDeviceParamByDevID(model.DevID);

            if (deviceParam != null)
            {
                throw new MyException("设备编号不能重复");
            }

            bool result = false;

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();

                    result = factory.AddParam(model, dbOperator);
                    if (!result)
                    {
                        throw new MyException("添加设备参数失败");
                    }
                    dbOperator.CommitTransaction();
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
            if (result)
            {
                OperateLogServices.AddOperateLog <ParkDeviceParam>(model, OperateType.Add);
            }
            return(result);
        }
Ejemplo n.º 8
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }

            IParkDevice          factory          = ParkDeviceFactory.GetFactory();
            IParkDeviceDetection factoryDetection = ParkDeviceDetectionFactory.GetFactory();
            bool result = false;

            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                try
                {
                    dbOperator.BeginTransaction();

                    result = factory.Delete(recordId, dbOperator);
                    if (!result)
                    {
                        throw new MyException("删除设备失败");
                    }

                    factoryDetection.Delete(recordId, dbOperator);

                    factory.DeleParam(recordId, dbOperator);

                    dbOperator.CommitTransaction();
                }
                catch
                {
                    dbOperator.RollbackTransaction();
                    throw;
                }
            }
            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
            }
            return(result);
        }
Ejemplo n.º 9
0
        private static bool AddDefaultParkDeviceParam(string gateId, string deviceId, string deviceNo, DbOperator dbOperator)
        {
            ParkGate        gate        = ParkGateServices.QueryByRecordId(gateId);
            ParkBox         box         = ParkBoxServices.QueryByRecordId(gate.BoxID);
            ParkArea        area        = ParkAreaServices.QueryByRecordId(box.AreaID);
            ParkDeviceParam param       = CreateDefualtParam(deviceId, int.Parse(deviceNo), area.CarbitNum, (int)gate.IoState);
            IParkDevice     factory     = ParkDeviceFactory.GetFactory();
            ParkDeviceParam deviceParam = factory.QueryParkDeviceParamByDevID(param.DevID);

            if (deviceParam != null)
            {
                throw new MyException("设备编号不能重复");
            }

            bool result = factory.AddParam(param, dbOperator);

            if (!result)
            {
                throw new MyException("添加设备默认参数失败");
            }
            return(result);
        }
Ejemplo n.º 10
0
        public static ParkDeviceParam QueryParkDeviceParamByDID(string DeviceID)
        {
            IParkDevice factory = ParkDeviceFactory.GetFactory();

            return(factory.QueryParkDeviceParamByDID(DeviceID));
        }
Ejemplo n.º 11
0
        public static List <ParkDevice> QueryParkDeviceAll()
        {
            IParkDevice factory = ParkDeviceFactory.GetFactory();

            return(factory.QueryParkDeviceAll());
        }