Beispiel #1
0
        public static bool Delete(string recordId)
        {
            if (string.IsNullOrWhiteSpace(recordId))
            {
                throw new ArgumentNullException("recordId");
            }
            List <ParkGate> gates = ParkGateServices.QueryByParkBoxRecordId(recordId);

            if (gates.Count != 0)
            {
                throw new MyException("请先删除该岗亭下面的所有通道");
            }

            IParkBox factory = ParkBoxFactory.GetFactory();
            bool     result  = factory.Delete(recordId);

            if (result)
            {
                OperateLogServices.AddOperateLog(OperateType.Delete, string.Format("recordId:{0}", recordId));
            }
            return(result);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        /// <summary>
        /// 系统初始化默认单位CS
        /// </summary>
        public static bool InitSystemDefaultCompanyCS(string VName, string CPName, string userno, string pwd, string systemmodelpath)
        {
            try
            {
                ICompany factory = CompanyFactory.GetFactory();
                using (DbOperator dbOperator = ConnectionManager.CreateConnection())
                {
                    try
                    {
                        dbOperator.BeginTransaction();
                        BaseCompany compamy = GetCompanyModel();
                        compamy.CPName       = CPName;
                        compamy.UserAccount  = userno;
                        compamy.UserPassword = pwd;
                        bool result = factory.Add(compamy, dbOperator);
                        if (!result)
                        {
                            throw new MyException("添加默认单位失败");
                        }
                        BaseVillage village = GetVillage(compamy.CPID);
                        village.VName = VName;
                        result        = VillageServices.AddVillageDefaultUser(village, dbOperator);
                        if (!result)
                        {
                            throw new MyException("添加默认小区失败");
                        }
                        result = SysUserServices.AddCompanyDefaultUserCS(compamy, village, dbOperator, systemmodelpath);
                        if (!result)
                        {
                            throw new MyException("添加默认用户失败");
                        }

                        BaseParkinfo parkinfo = GetParkinfo(village.VID);
                        result = ParkingServices.AddParkinfoDefault(parkinfo, dbOperator);
                        if (!result)
                        {
                            throw new MyException("添加默认车场失败");
                        }
                        dbOperator.CommitTransaction();

                        ParkArea area = GetParkArea(parkinfo.PKID);
                        result = ParkAreaServices.AddDefualt(area);
                        if (result)
                        {
                            ParkBox box = GetParkBox(area.AreaID);
                            result = ParkBoxServices.AddDefault(box);
                            if (result)
                            {
                                result = ParkGateServices.AddDefault(GetParkGate(box.BoxID, 1));
                                result = ParkGateServices.AddDefault(GetParkGate(box.BoxID, 2));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        dbOperator.RollbackTransaction();
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "添加系统默认单用户失败");
                return(false);
            }
            return(true);
        }