Пример #1
0
        private bool ImportDataToFujica(CardServiceModel model, string idx)
        {
            Dictionary <string, object> dicParam = new Dictionary <string, object>();
            string beginDt = model.StartDate.Date.ToString("yyyy-MM-dd HH:mm:ss");                         //开始时间从0分秒
            string endDt   = model.EndDate.Date.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss"); //结束时间截止到23:59:59

            model.EndDate        = Convert.ToDateTime(model.EndDate.Date.ToString("yyyy-MM-dd HH:mm:ss"));
            model.PrimaryEndDate = Convert.ToDateTime(model.PrimaryEndDate.Date.ToString("yyyy-MM-dd HH:mm:ss"));
            RequestFujicaStandard requestFujica = new RequestFujicaStandard();
            //请求方法
            string servername = "Park/UnderLineMonthCard";

            dicParam["OperatType"] = 0; //操作类型 -新增
            //请求参数
            dicParam["CarType"]          = idx;
            dicParam["PhoneNumber"]      = model.Mobile;
            dicParam["OwnerName"]        = model.CarOwnerName;
            dicParam["StartDate"]        = Convert.ToDateTime(beginDt);
            dicParam["PrimaryEndDate"]   = model.PrimaryEndDate;      //计算前结束日期
            dicParam["EndDate"]          = Convert.ToDateTime(endDt); //计算后结束日期
            dicParam["RenewalType"]      = 1;                         //目前默认都是按天延期
            dicParam["RenewalValue"]     = (model.EndDate - model.PrimaryEndDate).Days;
            dicParam["ParkingCode"]      = model.ParkCode;
            dicParam["CarNo"]            = model.CarNo;
            dicParam["RechargeAmount"]   = model.PayAmount;
            dicParam["PaymentType"]      = 98; //支付类型:4G支付
            dicParam["OrderType"]        = 99; //订单类型:现金支付
            dicParam["TransactionTime"]  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            dicParam["Remarks"]          = model.Remark;
            dicParam["OrderStauts"]      = 4; //线下确认
            dicParam["RechargeOperator"] = model.RechargeOperator;
            return(requestFujica.RequestInterfaceV2(servername, dicParam));
        }
Пример #2
0
        private bool ImportDataToMQ(CardServiceModel model)
        {
            try
            {
                bool           result    = false;
                MonthCardModel sendmodel = new MonthCardModel()
                {
                    CarOwnerName = model.CarOwnerName,
                    CarNo        = model.CarNo,
                    Delete       = model.Enable ? false : true,
                    CarTypeGuid  = model.CarTypeGuid,
                    Locked       = model.Locked,
                    StartDate    = model.StartDate.Date.AddHours(0).AddMinutes(0).AddSeconds(0).ToString("yyyy-MM-dd HH:mm:ss"),
                    EndDate      = model.EndDate.Date.AddDays(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss") //结束时间截止到23:59:59
                };

                CommandEntity <MonthCardModel> entity = new CommandEntity <MonthCardModel>()
                {
                    command = BussineCommand.MonthCar,
                    idMsg   = Convert.ToBase64String(Guid.NewGuid().ToByteArray()),
                    message = sendmodel
                };

                result = m_rabbitMQ.SendMessageForRabbitMQ("发送月卡命令", m_serializer.Serialize(entity), entity.idMsg, model.ParkCode);
                return(result);
            }
            catch (Exception ex)
            {
                m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", model.ParkCode, model.CarNo, "CameraUpdateTool.MainForm.ImportDataToMQ", "下发月卡时发生异常", ex.ToString());
                return(false);
            }
        }
Пример #3
0
        /// <summary>
        /// 保存月卡信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        private bool SaveCardService(CardServiceModel model)
        {
            try
            {
                string            connectionString = ConfigurationManager.ConnectionStrings["parklotManager"].ConnectionString;
                DbProviderFactory factory          = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
                DbConnection      dbc = factory.CreateConnection();
                dbc.ConnectionString = connectionString;
                dbc.Open();

                DbCommand command = factory.CreateCommand();
                command.Connection = dbc;
                if (command.Connection.State != ConnectionState.Open)
                {
                    command.Connection.Open();
                }
                command.CommandTimeout = 120;
                command.CommandText    = @"insert into t_monthcard(projectGuid,identifying,parkCode,carNo,carOwnerName,mobile,carTypeGuid,remark,enable,locked,startDate,endDate,pauseDate,continueDate,drivewayListContent,rechargeOperator)
                                values(@projectGuid,@identifying,@parkCode,@carNo,@carOwnerName,@mobile,@carTypeGuid,@remark,@enable,@locked,@startDate,@endDate,@pauseDate,@continueDate,@drivewayListContent,@rechargeOperator)";
                command.CommandType    = CommandType.Text;


                DbParameter projectGuid = factory.CreateParameter();
                projectGuid.ParameterName = "@projectGuid";
                projectGuid.Value         = model.ProjectGuid;

                DbParameter identifying = factory.CreateParameter();
                identifying.ParameterName = "@identifying";
                identifying.Value         = model.ParkCode + Convert.ToBase64String(Encoding.UTF8.GetBytes(model.CarNo));

                DbParameter parkCode = factory.CreateParameter();
                parkCode.ParameterName = "@parkCode";
                parkCode.Value         = model.ParkCode;

                DbParameter carNo = factory.CreateParameter();
                carNo.ParameterName = "@carNo";
                carNo.Value         = model.CarNo;

                DbParameter carOwnerName = factory.CreateParameter();
                carOwnerName.ParameterName = "@carOwnerName";
                carOwnerName.Value         = model.CarOwnerName;

                DbParameter mobile = factory.CreateParameter();
                mobile.ParameterName = "@mobile";
                mobile.Value         = model.Mobile;

                DbParameter carTypeGuid = factory.CreateParameter();
                carTypeGuid.ParameterName = "@carTypeGuid";
                carTypeGuid.Value         = model.CarTypeGuid;

                DbParameter remark = factory.CreateParameter();
                remark.ParameterName = "@remark";
                remark.Value         = model.Remark;

                DbParameter enable = factory.CreateParameter();
                enable.ParameterName = "@enable";
                enable.Value         = model.Enable;

                DbParameter locked = factory.CreateParameter();
                locked.ParameterName = "@locked";
                locked.Value         = model.Locked;

                DbParameter startDate = factory.CreateParameter();
                startDate.ParameterName = "@startDate";
                startDate.Value         = model.StartDate.ToString("yyyy-MM-dd HH:mm:ss");

                DbParameter endDate = factory.CreateParameter();
                endDate.ParameterName = "@endDate";
                endDate.Value         = model.EndDate.ToString("yyyy-MM-dd HH:mm:ss");

                DbParameter pauseDate = factory.CreateParameter();
                pauseDate.ParameterName = "@pauseDate";
                pauseDate.Value         = model.PauseDate.ToString("yyyy-MM-dd HH:mm:ss");

                DbParameter continueDate = factory.CreateParameter();
                continueDate.ParameterName = "@continueDate";
                continueDate.Value         = model.ContinueDate.ToString("yyyy-MM-dd HH:mm:ss");

                DbParameter drivewayListContent = factory.CreateParameter();
                drivewayListContent.ParameterName = "@drivewayListContent";
                drivewayListContent.Value         = m_serializer.Serialize(model.DrivewayGuidList ?? new List <string>());


                DbParameter rechargeOperator = factory.CreateParameter();
                rechargeOperator.ParameterName = "@rechargeOperator";
                rechargeOperator.Value         = model.RechargeOperator;

                DbParameter[] parameter = new DbParameter[] { projectGuid, identifying, parkCode, carNo, carOwnerName, mobile, carTypeGuid, remark, enable, locked, startDate, endDate, pauseDate, continueDate, drivewayListContent, rechargeOperator };

                command.Parameters.AddRange(parameter);

                return(command.ExecuteNonQuery() > 0 ? true : false);
            }
            catch (Exception ex)
            {
                m_ilogger.LogFatal(LoggerLogicEnum.Tools, "", "", "", "CameraUpdateTool.MainForm.SaveCardService", string.Format("保存卡信息时发生异常,入参:{0}", m_serializer.Serialize(model)), ex.ToString());
            }
            return(false);
        }
Пример #4
0
 private bool ImportDataToDB(CardServiceModel model)
 {
     return(SaveCardService(model));
 }
Пример #5
0
        /// <summary>
        /// 月卡信息导入到4G项目
        /// </summary>
        /// <param name="dataRow"></param>
        /// <param name="rowIndex"></param>
        /// <param name="e"></param>
        private void ImportData(DataGridViewRow dataRow, int rowIndex, AutoResetEvent e)
        {
            string carOwnerName = Convert.ToString(dataRow.Cells[1].Value);
            string carNo        = Convert.ToString(dataRow.Cells[0].Value);

            if (string.IsNullOrEmpty(carOwnerName) || string.IsNullOrEmpty(carNo))
            {
                this.Invoke(ShowMsgDistance, ShowMsgType.ShowFail, rowIndex, "空数据");
                e.Set();
                return;
            }

            CardServiceModel cardServiceModel = new CardServiceModel()
            {
                ProjectGuid      = ProjectGuid,
                ParkCode         = ParkingCode,
                CarOwnerName     = carOwnerName,
                CarNo            = carNo,
                CarTypeGuid      = CarTypeGuid,
                DrivewayGuidList = new List <string>(),//DrivewayList,
                Mobile           = dataRow.Cells[2].Value.ToString(),
                PayAmount        = Convert.ToDecimal(dataRow.Cells[6].Value),
                PayStyle         = "现金",
                Remark           = "批量导入",
                Balance          = Convert.ToDecimal(dataRow.Cells[6].Value), //新开卡时余额就等于支付金额(仅当储值卡时后端逻辑才会读取此值)
                StartDate        = Convert.ToDateTime(dataRow.Cells[5].Value),
                PrimaryEndDate   = Convert.ToDateTime(dataRow.Cells[5].Value),
                EndDate          = Convert.ToDateTime(dataRow.Cells[4].Value),
                RechargeOperator = "系统管理员",
                PauseDate        = default(DateTime),
                Locked           = false,
                Enable           = true
            };


            //先验证月卡数据是否已存在
            bool carExist = ExistCardService(cardServiceModel.ParkCode, cardServiceModel.CarNo);

            if (carExist)
            {
                this.Invoke(ShowMsgDistance, ShowMsgType.ShowFail, rowIndex, "已存在");
                e.Set();
                return;
            }

            bool flag = ImportDataToFujica(cardServiceModel, CarTypeIdx);

            if (!flag)
            {
                this.Invoke(ShowMsgDistance, ShowMsgType.ShowFail, rowIndex, "保存fujica失败");
                e.Set();
                return;
            }
            flag = ImportDataToDB(cardServiceModel);
            if (!flag)
            {
                this.Invoke(ShowMsgDistance, ShowMsgType.ShowFail, rowIndex, "保存数据库失败");
                e.Set();
                return;
            }

            flag = ImportDataToMQ(cardServiceModel);
            if (!flag)
            {
                this.Invoke(ShowMsgDistance, ShowMsgType.ShowFail, rowIndex, "发送MQ失败");
                e.Set();
                return;
            }

            if (flag)
            {
                this.Invoke(ShowMsgDistance, ShowMsgType.ShowSuccess, rowIndex, "");
            }



            //Thread.Sleep(Convert.ToInt32(new Random().Next(5) + "000"));

            ////ShowMsgDistance.Invoke(ShowMsgType.ShowTip, rowIndex);

            //if (rowIndex.ToString().IndexOf("20") > -1)
            //{

            //    this.Invoke(ShowMsgDistance, ShowMsgType.ShowFail, rowIndex);
            //}
            //else
            //{

            //    this.Invoke(ShowMsgDistance, ShowMsgType.ShowSuccess, rowIndex);
            //}

            //ShowMsgDistance.Invoke(ShowMsgType.ShowMsgOne, rowIndex + 1);
            e.Set();
        }