Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            CardPaymentRecordBll     cbll  = new CardPaymentRecordBll(AppSettings.CurrentSetting.CurrentMasterConnect);
            LDB_CardPaymentRecordBll lcbll = new LDB_CardPaymentRecordBll(LDB_AppSettings.Current.LDBConnect);

            InitProgress();
            NotifyProgress(0);
            foreach (DataGridViewRow row in GridView.Rows)
            {
                LDB_CardPaymentInfo info    = row.Tag as LDB_CardPaymentInfo;
                CardPaymentInfo     payment = LDB_InfoFactory.CreateCardPaymentInfo(info);
                CommandResult       result  = cbll.InsertRecordWithCheck(payment);
                if (result.Result == ResultCode.Successful)
                {
                    info.UpdateFlag = true;
                    lcbll.Update(info);
                    ShowCardPaymentOnRow(info, row.Index);
                    row.DefaultCellStyle.ForeColor = Color.Green;
                }
                else
                {
                    row.DefaultCellStyle.ForeColor = Color.Red;
                }
                GridView.Refresh();
                NotifyProgress(null);
            }
            NotifyProgress(this.progressBar1.Maximum);
            this.progressBar1.Visible = false;
        }
        public void AddARecord()
        {
            CardPaymentInfo record = new CardPaymentInfo();

            record.CardID         = "233955501";
            record.CardType       = CardType.TempCard;
            record.CarType        = CarTypeSetting.DefaultCarType;
            record.ChargeDateTime = new DateTime(2011, 3, 27, 12, 15, 20);
            record.EnterDateTime  = new DateTime(2011, 3, 27, 9, 1, 15);
            record.Accounts       = 30;
            record.Paid           = 30;
            record.PaymentMode    = PaymentMode.Cash;
            record.TariffType     = TariffType.Normal;
            record.OperatorID     = "test";
            record.StationID      = "一号中央收费";

            CardPaymentRecordBll bll    = new CardPaymentRecordBll(StaticConnectString.ConnStr);
            CommandResult        result = bll.Insert(record);

            Assert.IsTrue(result.Result == ResultCode.Successful);

            CardPaymentInfo r = bll.GetByID(new Ralid.Park.BusinessModel.Report.RecordID(record.CardID, record.ChargeDateTime));

            Assert.IsTrue(r != null && r.CardID == record.CardID);

            bll.Delete(record);
            r = bll.GetByID(new Ralid.Park.BusinessModel.Report.RecordID(record.CardID, record.ChargeDateTime));
            Assert.IsTrue(r == null);
        }
Exemplo n.º 3
0
        private void UpdateDevicePaymentRecord_Thread()
        {
            while (true)
            {
                try
                {
                    if (DataBaseConnectionsManager.Current.MasterConnected)
                    {
                        List <EntranceBase> entrances = new List <EntranceBase>();
                        entrances.AddRange(_Entrances);
                        foreach (ParkBase park in _SubParks)
                        {
                            entrances.AddRange(park.Entrances);
                        }
                        foreach (NetEntrance entrance in entrances)
                        {
                            int capacity    = 0;
                            int latestIndex = 0;
                            int beginIndex  = entrance.EntranceInfo.PaymentEventIndex + 1;
                            if (entrance.GetPaymentStorageInfo(out capacity, out latestIndex))
                            {
                                int count = latestIndex - beginIndex + 1;
                                count = count < 0 ? count + 0xFFFFFF : count;
                                if (count > 0)
                                {
                                    List <DevicePaymentRecord> deviceRecords = entrance.GetPaymentRecords(beginIndex, count);
                                    List <CardPaymentInfo>     records       = GetCardPaymentRecordsFromDeviceRecords(deviceRecords, entrance.EntranceName);
                                    if (records != null)
                                    {
                                        CardPaymentRecordBll crb = new CardPaymentRecordBll(AppSettings.CurrentSetting.ParkConnect);
                                        bool success             = true;
                                        foreach (CardPaymentInfo record in records)
                                        {
                                            success = crb.InsertRecordWithCheck(record).Result == ResultCode.Successful ? success : false;
                                            if (success)
                                            {
                                                entrance.EntranceInfo.PaymentEventIndex++;
                                            }
                                        }
                                        if (entrance.EntranceInfo.PaymentEventIndex > 0xFFFFFF)//流水号最大3个字节0xFFFFFF
                                        {
                                            entrance.EntranceInfo.PaymentEventIndex -= 0xFFFFFF;
                                        }

                                        EntranceBll ebll = new EntranceBll(AppSettings.CurrentSetting.ParkConnect);
                                        ebll.Update(entrance.EntranceInfo);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                }
                //每30分钟,获取一次
                Thread.Sleep(30 * 60 * 1000);
            }
        }
        protected override void OnItemSearching(EventArgs e)
        {
            this.customDataGridView1.Rows.Clear();
            CardPaymentRecordSearchCondition con = new CardPaymentRecordSearchCondition();

            con.RecordDateTimeRange       = new DateTimeRange();
            con.RecordDateTimeRange.Begin = this.ucDateTimeInterval1.StartDateTime;
            con.RecordDateTimeRange.End   = this.ucDateTimeInterval1.EndDateTime;
            con.CardType       = this.comCardType.SelectedCardType;
            con.CardID         = this.txtCardID.Text.Trim();
            con.OperatorCardID = this.txtOperatorCardID.Text.Trim();
            con.PaymentCode    = this.comPaymentCode.SelectedPaymentCode;

            if (chkPaymentMode.Checked)
            {
                con.PaymentMode = comPaymentMode.SelectedPaymentMode;
            }

            if (this.comOperator.SelectecOperator != null)
            {
                con.Operator = this.comOperator.SelectecOperator;
            }
            if (carTypeComboBox1.SelectedIndex > 0)
            {
                con.CarType = carTypeComboBox1.SelectedCarType;
            }
            con.StationID = this.workStationCombobox1.Text;

            CardPaymentRecordBll bll = new CardPaymentRecordBll(AppSettings.CurrentSetting.ParkConnect);
            QueryResultList <CardPaymentInfo> result = bll.GetItems(con);

            if (result.Result == ResultCode.Successful)
            {
                CarFlowStatisticsType group;
                if (this.rdPerHour.Checked)
                {
                    group = CarFlowStatisticsType.perHour;
                }
                else if (this.rdPerDay.Checked)
                {
                    group = CarFlowStatisticsType.perDay;
                }
                else
                {
                    group = CarFlowStatisticsType.perMonth;
                }
                GroupBy(result.QueryObjects, group);
            }
            else
            {
                MessageBox.Show(result.Message);
            }
        }
Exemplo n.º 5
0
        private void ItemSearching_Handler(object sender, EventArgs e)
        {
            CardPaymentRecordSearchCondition con = new CardPaymentRecordSearchCondition();

            con.RecordDateTimeRange       = new DateTimeRange();
            con.RecordDateTimeRange.Begin = this.ucDateTimeInterval1.StartDateTime;
            con.RecordDateTimeRange.End   = this.ucDateTimeInterval1.EndDateTime;
            con.CardType        = this.comCardType.SelectedCardType;
            con.CardID          = this.txtCardID.Text.Trim();
            con.CardCertificate = txtCertificate.Text.Trim();
            if (carTypeComboBox1.SelectedIndex > 0)
            {
                con.CarType = carTypeComboBox1.SelectedCarType;
            }
            if (rdSettled.Checked)
            {
                con.IsUnSettled = false;
            }
            if (rdUnsettled.Checked)
            {
                con.IsUnSettled = true;
            }
            if (chkCenterCharge.Checked)
            {
                con.IsCenterCharge = true;
            }
            if (chkPaymentMode.Checked)
            {
                con.PaymentMode = comPaymentMode.SelectedPaymentMode;
            }
            con.CarPlate = this.txtCarPlate.Text.Trim();

            if (this.comOperator.SelectecOperator != null)
            {
                con.Operator = this.comOperator.SelectecOperator;
            }
            con.StationID      = this.workStationCombobox1.Text.Trim();
            con.PaymentCode    = this.comPaymentCode.SelectedPaymentCode;
            con.OperatorCardID = this.txtOperatorCardID.Text.Trim();;

            CardPaymentRecordBll bll = new CardPaymentRecordBll(AppSettings.CurrentSetting.ParkConnect);
            QueryResultList <CardPaymentInfo> result = bll.GetItems(con);

            if (result.Result == ResultCode.Successful)
            {
                ShowReportsOnGrid(result.QueryObjects);
            }
            else
            {
                MessageBox.Show(result.Message);
            }
        }
Exemplo n.º 6
0
        private void SavePaymentsToPark(List <string> records)
        {
            FrmProcessing frmP   = new FrmProcessing();
            Action        action = delegate()
            {
                try
                {
                    int success = 0;
                    int fail    = 0;
                    CardPaymentRecordBll bll = new CardPaymentRecordBll(AppSettings.CurrentSetting.ParkConnect);
                    foreach (string record in records)
                    {
                        Ralid.Park.POS.Model.CardPaymentInfo p = Ralid.Park.POS.Model.CardPaymentInfoSerializer.Deserialize(record);
                        if (p != null)
                        {
                            CardPaymentInfo item = CreateFrom(p);
                            CommandResult   ret  = bll.InsertRecordWithCheck(item);
                            if (ret.Result == ResultCode.Successful)
                            {
                                success++;
                            }
                            else
                            {
                                fail++;
                            }
                        }
                        else
                        {
                            fail++;
                        }
                        frmP.ShowProgress(string.Format(Resource1.FrmMain_ImportCharges + " " + Resource1.FrmMain_Success + ":{0}  " + Resource1.FrmMain_Fail + ":{1}  " + Resource1.FrmMain_ImportTotal + ": {2}", success, fail, records.Count), (decimal)(success + fail) / records.Count);
                    }
                    ShowMessage(string.Format(Resource1.FrmMain_ImportCharges + " " + Resource1.FrmMain_Success + ":{0}  " + Resource1.FrmMain_Fail + ":{1}  " + Resource1.FrmMain_ImportTotal + ": {2}", success, fail, records.Count), Color.Black);
                }
                catch (ThreadAbortException)
                {
                }
                catch (Exception ex)
                {
                    frmP.ShowProgress(ex.Message, 1);
                    ShowMessage(ex.Message, Color.Red);
                }
            };
            Thread t = new Thread(new ThreadStart(action));

            t.Start();
            if (frmP.ShowDialog() != DialogResult.OK)
            {
                t.Abort();
            }
        }
Exemplo n.º 7
0
        private void ItemSearching_Handler(object sender, EventArgs e)
        {
            CardPaymentRecordSearchCondition con = new CardPaymentRecordSearchCondition();

            if (this.chkChargeDateTime.Checked)
            {
                con.RecordDateTimeRange       = new DateTimeRange();
                con.RecordDateTimeRange.Begin = this.UCChargeDateTime.StartDateTime;
                con.RecordDateTimeRange.End   = this.UCChargeDateTime.EndDateTime;
            }
            if (this.chkEnterDateTime.Checked)
            {
                con.EnterDateTimeRange       = new DateTimeRange();
                con.EnterDateTimeRange.Begin = this.UCEnterDateTime.StartDateTime;
                con.EnterDateTimeRange.End   = this.UCEnterDateTime.EndDateTime;
            }
            con.CardType        = this.comCardType.SelectedCardType;
            con.CardID          = this.txtCardID.Text.Trim();
            con.CardCertificate = txtCertificate.Text.Trim();
            if (carTypeComboBox1.SelectedIndex > 0)
            {
                con.CarType = carTypeComboBox1.SelectedCarType;
            }
            if (rdSettled.Checked)
            {
                con.IsUnSettled = false;
            }
            if (rdUnsettled.Checked)
            {
                con.IsUnSettled = true;
            }
            if (chkCenterCharge.Checked)
            {
                con.IsCenterCharge = true;
            }
            if (chkPaymentMode.Checked)
            {
                con.PaymentMode = comPaymentMode.SelectedPaymentMode;
            }
            con.CarPlate = this.txtCarPlate.Text.Trim();

            if (this.comOperator.SelectecOperator != null)
            {
                con.Operator = this.comOperator.SelectecOperator;
            }
            con.StationID      = this.workStationCombobox1.Text.Trim();
            con.PaymentCode    = this.comPaymentCode.SelectedPaymentCode;
            con.OperatorCardID = this.txtOperatorCardID.Text.Trim();
            con.StationIDs     = this.txtWorkStations.Tag as List <string>;
            con.OperatorDeptID = this.comOperatorDept.SelectedDeptID;
            con.StationDeptID  = this.comStationDept.SelectedDeptID;

            //if (!string.IsNullOrEmpty(this.comOperatorDept.SelectedDeptIDString))
            //{//操作员部门
            //    OperatorBll opeBll = new OperatorBll(AppSettings.CurrentSetting.ParkConnect);
            //    OperatorSearchCondition opeCon = new OperatorSearchCondition();
            //    opeCon.DeptID = Guid.Parse(this.comOperatorDept.SelectedDeptIDString);
            //    List<OperatorInfo> operators = opeBll.GetOperators(opeCon).QueryObjects;
            //    List<string> lts_operators = new List<string>();
            //    if (operators.Count > 0)
            //    {
            //        foreach (OperatorInfo item in operators)
            //        {
            //            //lts_operators.Add(item.OperatorID);
            //            lts_operators.Add(item.OperatorName);
            //        }
            //    }
            //    else
            //    {
            //        lts_operators.Add("此部门没有操作员");
            //    }
            //    con.OperatorIDs = lts_operators;
            //}
            //if (!string.IsNullOrEmpty(this.comStationDept.SelectedDeptIDString))
            //{//工作站部门
            //    WorkstationBll workBll = new WorkstationBll(AppSettings.CurrentSetting.ParkConnect);
            //    WorkstationSearchCondition workCon = new WorkstationSearchCondition();
            //    workCon.DeptID = Guid.Parse(this.comStationDept.SelectedDeptIDString);
            //    List<WorkStationInfo> stations = workBll.GetWorkstations(workCon).QueryObjects;
            //    List<string> lts_stations = new List<string>();
            //    if (stations.Count > 0)
            //    {
            //        foreach (WorkStationInfo item in stations)
            //        {
            //            lts_stations.Add(item.StationName);
            //        }
            //    }
            //    else
            //    {
            //        lts_stations.Add("此部门没有工作站");
            //    }
            //    con.StationIDs = lts_stations;
            //}

            CardPaymentRecordBll bll = new CardPaymentRecordBll(AppSettings.CurrentSetting.ParkConnect);
            QueryResultList <CardPaymentInfo> result = bll.GetItems(con);

            if (result.Result == ResultCode.Successful)
            {
                ShowReportsOnGrid(result.QueryObjects);
            }
            else
            {
                MessageBox.Show(result.Message);
            }
        }
Exemplo n.º 8
0
        private void UpdateDevicePaymentRecord_Thread()
        {
            try
            {
                //开始前先等待10分钟,用于等待硬件设备连接状态检测完成
                Thread.Sleep(10 * 60 * 1000);
                Ralid.GeneralLibrary.LOG.FileLog.Log("UpdateDevicePaymentRecord", "开始UpdateDevicePaymentRecord服务");
                while (true)
                {
                    try
                    {
                        if (DataBaseConnectionsManager.Current.MasterConnected)
                        {
                            List <EntranceBase> entrances = new List <EntranceBase>();
                            entrances.AddRange(_Entrances);
                            foreach (ParkBase park in _SubParks)
                            {
                                entrances.AddRange(park.Entrances);
                            }

                            Ralid.GeneralLibrary.LOG.FileLog.Log("UpdateDevicePaymentRecord", string.Format("控制器数量: {0} ", entrances.Count));

                            foreach (NetEntrance entrance in entrances)
                            {
                                int capacity     = 0;
                                int latestIndex  = 0;
                                int currentIndex = entrance.EntranceInfo.PaymentEventIndex;
                                int beginIndex   = entrance.EntranceInfo.PaymentEventIndex + 1;

                                string logDesc = string.Format("【{0}】 当前索引:{1} ", entrance.EntranceName, currentIndex);

                                if (entrance.GetPaymentStorageInfo(out capacity, out latestIndex))
                                {
                                    logDesc += string.Format(" 容量:{0} 最后索引:{1} ", capacity, latestIndex);

                                    int count = latestIndex - beginIndex + 1;
                                    count = count < 0 ? count + 0xFFFFFF : count;
                                    if (count > 0)
                                    {
                                        List <DevicePaymentRecord> deviceRecords = entrance.GetPaymentRecords(beginIndex, count);
                                        List <CardPaymentInfo>     records       = GetCardPaymentRecordsFromDeviceRecords(deviceRecords, entrance.EntranceName);
                                        if (records != null)
                                        {
                                            logDesc += string.Format(" 获取到记录:{0}  ", records.Count);

                                            CardPaymentRecordBll crb = new CardPaymentRecordBll(AppSettings.CurrentSetting.ParkConnect);
                                            bool success             = true;
                                            foreach (CardPaymentInfo record in records)
                                            {
                                                success = crb.InsertRecordWithCheck(record).Result == ResultCode.Successful ? success : false;
                                                if (success)
                                                {
                                                    currentIndex += 1;
                                                }
                                            }
                                            if (currentIndex > 0xFFFFFF)//流水号最大3个字节0xFFFFFF
                                            {
                                                currentIndex -= 0xFFFFFF;
                                            }
                                            if (currentIndex != entrance.EntranceInfo.PaymentEventIndex)
                                            {
                                                entrance.EntranceInfo.PaymentEventIndex = currentIndex;
                                                EntranceBll ebll = new EntranceBll(AppSettings.CurrentSetting.ParkConnect);
                                                ebll.Update(entrance.EntranceInfo);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    logDesc += string.Format(" 获取容量信息失败 ");
                                }

                                Ralid.GeneralLibrary.LOG.FileLog.Log("UpdateDevicePaymentRecord", logDesc);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                    }
                    //每30分钟,获取一次
                    Thread.Sleep(30 * 60 * 1000);
                }
            }
            catch (Exception ex)
            {
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
                Ralid.GeneralLibrary.LOG.FileLog.Log("UpdateDevicePaymentRecord", "UpdateDevicePaymentRecord服务异常终止");
            }
        }