Example #1
0
        /// <summary>
        /// 增加岗亭信息
        /// </summary>
        /// <param name="AreaID"></param>
        /// <returns></returns>
        public static ParkBox GetParkBox(string AreaID)
        {
            ParkBox model = new ParkBox();

            model.AreaID          = AreaID;
            model.BoxID           = GuidGenerator.GetGuidString();
            model.BoxName         = "收费岗亭";
            model.BoxNo           = "0001";
            model.DataStatus      = DataStatus.Normal;
            model.HaveUpdate      = 3;
            model.IsCenterPayment = YesOrNo.No;
            model.LastUpdateTime  = DateTime.Now;
            string      hostName  = Dns.GetHostName();           //获取本机名
            IPHostEntry localhost = Dns.GetHostByName(hostName); //方法已过期,可以获取IPv4的地址

            if (localhost.AddressList.Length > 0)
            {
                model.ComputerIP = localhost.AddressList[0].ToString();
            }
            else
            {
                model.ComputerIP = "127.0.0.1";
            }
            return(model);
        }
Example #2
0
        public bool Update(ParkBox model)
        {
            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                model.DataStatus     = DataStatus.Normal;
                model.LastUpdateTime = DateTime.Now;
                model.HaveUpdate     = SystemDefaultConfig.DataUpdateFlag;

                StringBuilder strSql = new StringBuilder();
                strSql.Append("update ParkBox set BoxNo=@BoxNo,BoxName=@BoxName,ComputerIP=@ComputerIP,AreaID=@AreaID,Remark=@Remark");
                strSql.Append(",IsCenterPayment=@IsCenterPayment,LastUpdateTime=@LastUpdateTime,HaveUpdate=@HaveUpdate,IsOnLine=@IsOnLine,ProxyNo=@ProxyNo where BoxID=@BoxID");
                dbOperator.ClearParameters();
                dbOperator.AddParameter("BoxID", model.BoxID);
                dbOperator.AddParameter("BoxNo", model.BoxNo);
                dbOperator.AddParameter("BoxName", model.BoxName);
                dbOperator.AddParameter("ComputerIP", model.ComputerIP);
                dbOperator.AddParameter("AreaID", model.AreaID);
                dbOperator.AddParameter("Remark", model.Remark);
                dbOperator.AddParameter("IsCenterPayment", (int)model.IsCenterPayment);
                dbOperator.AddParameter("LastUpdateTime", model.LastUpdateTime);
                dbOperator.AddParameter("HaveUpdate", model.HaveUpdate);
                dbOperator.AddParameter("IsOnLine", model.IsOnLine);
                dbOperator.AddParameter("ProxyNo", model.ProxyNo);
                return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0);
            }
        }
Example #3
0
        public bool Add(ParkBox model)
        {
            using (DbOperator dbOperator = ConnectionManager.CreateConnection())
            {
                model.DataStatus     = DataStatus.Normal;
                model.LastUpdateTime = DateTime.Now;
                model.HaveUpdate     = SystemDefaultConfig.DataUpdateFlag;

                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into ParkBox(BoxID,BoxNo,BoxName,ComputerIP,AreaID,Remark,DataStatus,HaveUpdate,LastUpdateTime,IsCenterPayment)");
                strSql.Append(" values(@BoxID,@BoxNo,@BoxName,@ComputerIP,@AreaID,@Remark,@DataStatus,@HaveUpdate,@LastUpdateTime,@IsCenterPayment)");
                dbOperator.ClearParameters();
                dbOperator.AddParameter("BoxID", model.BoxID);
                dbOperator.AddParameter("BoxNo", model.BoxNo);
                dbOperator.AddParameter("BoxName", model.BoxName);
                dbOperator.AddParameter("ComputerIP", model.ComputerIP);
                dbOperator.AddParameter("AreaID", model.AreaID);
                dbOperator.AddParameter("Remark", model.Remark);
                dbOperator.AddParameter("IsCenterPayment", (int)model.IsCenterPayment);
                dbOperator.AddParameter("LastUpdateTime", model.LastUpdateTime);
                dbOperator.AddParameter("HaveUpdate", model.HaveUpdate);
                dbOperator.AddParameter("DataStatus", (int)model.DataStatus);
                return(dbOperator.ExecuteNonQuery(strSql.ToString()) > 0);
            }
        }
Example #4
0
        public JsonResult DownloadQRCode(string gateId, int size)
        {
            try
            {
                List <int> dics = new List <int>();
                dics.Add(258);
                dics.Add(344);
                dics.Add(430);
                dics.Add(860);
                dics.Add(1280);

                List <string> imgs = new List <string>();
                ParkGate      gate = ParkGateServices.QueryByRecordId(gateId);
                if (gate == null)
                {
                    throw new MyException("获取通道信息失败");
                }
                BaseCompany company = CompanyServices.QueryByBoxID(gate.BoxID);
                if (company == null)
                {
                    throw new MyException("获取单位信息失败");
                }

                ParkBox box = ParkBoxServices.QueryByRecordId(gate.BoxID);
                if (box == null)
                {
                    throw new MyException("获取岗亭信息失败");
                }

                ParkArea area = ParkAreaServices.QueryByRecordId(box.AreaID);
                if (area == null)
                {
                    throw new MyException("获取区域信息失败");
                }

                BaseParkinfo parking = ParkingServices.QueryParkingByParkingID(area.PKID);
                if (parking == null)
                {
                    throw new MyException("获取车场信息失败");
                }
                string content = string.Format("{0}/qrl/scio_ix_pid={1}^io={2}", SystemDefaultConfig.SystemDomain, parking.PKID, gate.GateID);
                foreach (var item in dics)
                {
                    string parkingName = string.Format("{0}_{1}_{2}_{3}_{4}", parking.PKName, area.AreaName, box.BoxName, gate.GateName, item);
                    string result      = QRCodeServices.GenerateQRCode(company.CPID, content, item, parkingName);
                    imgs.Add(item.ToString() + "|" + result);
                }

                return(Json(MyResult.Success("", imgs)));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "下载二维码失败");
                return(Json(MyResult.Error("下载二维码失败")));
            }
        }
Example #5
0
 public JsonResult SaveEdit(ParkBox model)
 {
     try
     {
         bool result = false;
         if (string.IsNullOrWhiteSpace(model.BoxID))
         {
             result = ParkBoxServices.Add(model);
             if (!result)
             {
                 throw new MyException("添加失败");
             }
             return(Json(MyResult.Success()));
         }
         else
         {
             result = ParkBoxServices.Update(model);
             if (!result)
             {
                 throw new MyException("修改失败");
             }
             return(Json(MyResult.Success()));
         }
     }
     catch (MyException ex)
     {
         return(Json(MyResult.Error(ex.Message)));
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptions(ex, "保存岗亭信息失败");
         return(Json(MyResult.Error("保存岗亭信息失败")));
     }
 }
Example #6
0
        public static bool Update(ParkBox model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            IParkBox factory = ParkBoxFactory.GetFactory();
            bool     result  = factory.Update(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <ParkBox>(model, OperateType.Update);
            }
            return(result);
        }
Example #7
0
        public static bool Add(ParkBox model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            model.BoxID = GuidGenerator.GetGuid().ToString();
            IParkBox factory = ParkBoxFactory.GetFactory();
            bool     result  = factory.Add(model);

            if (result)
            {
                OperateLogServices.AddOperateLog <ParkBox>(model, OperateType.Add);
            }
            return(result);
        }
Example #8
0
        private string GetParkingId(string pid, string bid, string gid)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(pid))
                {
                    return(pid);
                }
                if (!string.IsNullOrWhiteSpace(bid))
                {
                    ParkBox box = ParkBoxServices.QueryByRecordId(bid);
                    if (box != null)
                    {
                        ParkArea area = ParkAreaServices.QueryByRecordId(box.AreaID);
                        if (area != null)
                        {
                            return(area.PKID);
                        }
                    }
                }

                if (!string.IsNullOrWhiteSpace(gid))
                {
                    ParkGate gate = ParkGateServices.QueryByRecordId(gid);
                    if (gate != null)
                    {
                        ParkBox box = ParkBoxServices.QueryByRecordId(gate.BoxID);
                        if (box != null)
                        {
                            ParkArea area = ParkAreaServices.QueryByRecordId(box.AreaID);
                            if (area != null)
                            {
                                return(area.PKID);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptionToDbAndTxt("QRCodeParkPayment", "GetParkingId方法处理异常", ex, LogFrom.WeiXin);
            }
            return(string.Empty);
        }
Example #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);
        }
Example #10
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);
        }