Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ZSTSettings zst = new ZSTSettings();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (!string.IsNullOrEmpty(row.Cells["colEntrance"].Value.ToString()))
                {
                    Ralid.OpenCard.OpenCardService.ZSTItem item = new Ralid.OpenCard.OpenCardService.ZSTItem()
                    {
                        ReaderIP   = (string)row.Cells["colReaderIP"].Value,
                        EntranceID = (int)row.Cells["colEntrance"].Tag,
                        Memo       = (string)row.Cells["colMemo"].Value
                    };
                    zst.Items.Add(item);
                }
                else
                {
                    Ralid.OpenCard.OpenCardService.ZSTItem item = new Ralid.OpenCard.OpenCardService.ZSTItem()
                    {
                        ReaderIP   = (string)row.Cells["colReaderIP"].Value,
                        EntranceID = 0,
                        Memo       = (string)row.Cells["colMemo"].Value
                    };
                    zst.Items.Add(item);
                }
            }
            CommandResult ret = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).SaveSetting <ZSTSettings>(zst);

            if (CustomCardTypeSetting.Current.GetCardType(ZSTSettings.CardType) == null) //增加自定义卡片类型
            {
                CustomCardTypeSetting.Current.AddCardType(ZSTSettings.CardType, (byte)Ralid.Park.BusinessModel.Enum.CardType.MonthRentCard);
                new SysParaSettingsBll(AppSettings.CurrentSetting.MasterParkConnect).SaveSetting <CustomCardTypeSetting>(CustomCardTypeSetting.Current);
            }
            if (ret.Result == ResultCode.Successful)
            {
                AppSettings.CurrentSetting.SaveConfig("EnableZST", chkEnable.Checked.ToString());
                OpenCardMessageHandler handler = GlobalSettings.Current.Get <OpenCardMessageHandler>();
                if (chkEnable.Checked)
                {
                    handler.InitService(zst);
                }
                else
                {
                    handler.CloseService <ZSTSettings>();
                }
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show(ret.Message);
            }
        }
Exemple #2
0
        private void FrmZSTSetting_Load(object sender, EventArgs e)
        {
            if (_Reader == null)
            {
                _Reader = new ZSTReader();
                _Reader.Init();
                Ralid.OpenCard.OpenCardService.GlobalSettings.Current.Set <ZSTReader>(_Reader);
            }
            dataGridView1.Rows.Clear();
            ZSTSettings _ZSTSetting = (new SysParaSettingsBll(AppSettings.CurrentSetting.ParkConnect)).GetSetting <ZSTSettings>();

            if (_ZSTSetting != null && _ZSTSetting.Items != null && _ZSTSetting.Items.Count > 0)
            {
                foreach (Ralid.OpenCard.OpenCardService.ZSTItem item in _ZSTSetting.Items)
                {
                    EntranceInfo entrance = ParkBuffer.Current.GetEntrance(item.EntranceID);
                    int          row      = dataGridView1.Rows.Add();
                    ShowItemOnRow(dataGridView1.Rows[row], item.ReaderIP, entrance != null ? entrance.EntranceName : string.Empty, entrance != null ? entrance.EntranceID : 0, item.Memo);
                }
            }
            chkEnable.Checked = GlobalSettings.Current.Get <OpenCardMessageHandler>().ContainService <ZSTSettings>();
        }
Exemple #3
0
        private void InitOpenCardServices(object obj)
        {
            OpenCardMessageHandler handler = new OpenCardMessageHandler();

            GlobalSettings.Current.Set <OpenCardMessageHandler>(handler);
            GlobalSettings.Current.Set <Dictionary <int, CardEventReport> >(new Dictionary <int, CardEventReport>());
            handler.Debug       = this.chkDebug.Checked;
            handler.OnReadCard += new EventHandler <OpenCardEventArgs>(handler_OnReadCard);
            handler.OnPaying   += new EventHandler <OpenCardEventArgs>(handler_OnPaying);
            handler.OnPaidOk   += new EventHandler <OpenCardEventArgs>(handler_OnPaidOk);
            handler.OnPaidFail += new EventHandler <OpenCardEventArgs>(handler_OnPaidFail);
            handler.OnError    += new EventHandler <OpenCardEventArgs>(handler_OnError);

            SysParaSettingsBll ssb  = new SysParaSettingsBll(AppSettings.CurrentSetting.AvailableParkConnect);
            string             temp = AppSettings.CurrentSetting.GetConfigContent("EnableZST");
            bool enabled            = false;

            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                ZSTSettings zst = ssb.GetSetting <ZSTSettings>();
                if (zst != null)
                {
                    handler.InitService(zst);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableYiTingShanFu");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                YiTingShanFuSetting yt = ssb.GetSetting <YiTingShanFuSetting>();
                if (yt != null)
                {
                    AppSettings.CurrentSetting.GetYiTingConfig(yt);
                    handler.InitService(yt);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableYCT");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                YCTSetting yct = ssb.GetSetting <YCTSetting>();
                if (yct != null)
                {
                    handler.InitService(yct);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableETC");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                ETCSetting etc = ETCSetting.GetSetting();
                if (etc != null)
                {
                    handler.InitService(etc);
                }
            }

            temp = AppSettings.CurrentSetting.GetConfigContent("EnableLR280");
            if (!string.IsNullOrEmpty(temp) && bool.TryParse(temp, out enabled) && enabled)
            {
                Ralid.OpenCard.OpenCardService.LR280.LR280Setting lr280 = ssb.GetSetting <OpenCardService.LR280.LR280Setting>();
                if (lr280 != null)
                {
                    handler.InitService(lr280);
                }
            }
            this.Invoke((Action)(() => { ShowServiceState(); }));
        }