示例#1
0
        /// <summary>
        /// 有效卡
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ValidCardBtn_Click(object sender, EventArgs e)
        {
            int[]  indexlist = this.getCheckedList();
            string msg       = "";

            if (indexlist.Length < 1)
            {
                msg = "请选择一个设备";
            }
            else if (indexlist.Length > 1)
            {
                msg = "不能同时下载多个设备的有效卡";
            }
            if (!string.IsNullOrEmpty(msg))
            {
                MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DataTable tab = this.dbGrid.DataSource as DataTable;
            DataRow   dr  = tab.Rows[indexlist[0]];

            BindManager.setTransParam(ParamManager.createParam(dr));
            FrmValCard ValCard = new FrmValCard();

            ValCard.DeviceID   = Convert.ToString(dr["站址"]);
            ValCard.DeviceName = Convert.ToString(dr["名称"]);
            ValCard.Target     = this.getTarget(dr);
            ValCard.Query      = new QueryDataRes("设备控制维护");
            ValCard.ShowDialog(this);
        }
示例#2
0
        /// <summary>
        /// 退还押金
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btBack_Click(object sender, EventArgs e)
        {
            string province = this.cbbProvince.Text;

            if (!string.IsNullOrEmpty(province))
            {
                province = regUperCase.Replace(province, "");
            }
            string carnum = this.tbCarnum.Text;

            if (!string.IsNullOrEmpty(carnum))
            {
                carnum = province + carnum;
            }
            this.tag = basefun.setvaltag(this.tag, "{车牌号码}", carnum);
            //押金处理
            NameObjectList ps = ParamManager.createParam(this.tag);

            //ps["操作类别"] = "退费";
            ps["操作类别"] = "不退费再入场";
            this.tag   = basefun.setvaltag(this.tag, "{收费操作}", "不退费再入场");
            ParamManager.MergeParam(ps, BindManager.getSystemParam(), false);
            this.Query.ExecuteNonQuery("押金处理", ps, ps, ps);
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
示例#3
0
        /// <summary>
        /// 加载有效时段
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SetValTimeBtn_Click(object sender, EventArgs e)
        {
            int[]  indexlist = this.getCheckedList();
            string msg       = "";

            if (indexlist.Length < 1)
            {
                msg = "请选择一个设备";
            }
            else if (indexlist.Length > 1)
            {
                msg = "不能同时巡检多个设备";
            }
            if (!string.IsNullOrEmpty(msg))
            {
                MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DataTable tab = this.dbGrid.DataSource as DataTable;
            DataRow   dr  = tab.Rows[indexlist[0]];

            BindManager.setTransParam(ParamManager.createParam(dr));

            FrmDownTime frmdowntime = new FrmDownTime();

            frmdowntime.DeviceID   = Convert.ToString(dr["站址"]);
            frmdowntime.DeviceName = Convert.ToString(dr["名称"]);
            frmdowntime.Target     = this.getTarget(dr);
            frmdowntime.ShowDialog(this);
        }
示例#4
0
        private void FrmParkDeposit_Load(object sender, EventArgs e)
        {
            this.setContainerTagValue(this.grpInfo, this.tag, "pm");
            //直接通讯获取停车费用
            if (this.addrst < 0 || null == this.target)
            {
                return;
            }
            string cardnum  = basefun.valtag(this.tag, "卡号");
            string cardtype = basefun.valtag(this.tag, "卡类");
            string cartype  = basefun.valtag(this.tag, "车型");
            string dtparkin = basefun.valtag(this.tag, "入场时间");

            if (string.IsNullOrEmpty(cardtype) || string.IsNullOrEmpty(cartype) || string.IsNullOrEmpty(dtparkin))
            {
                return;
            }
            string         data = "";
            NameObjectList ps   = ParamManager.createParam(this.tag);

            foreach (string key in ps.AllKeys)
            {
                data = basefun.setvaltag(data, "{" + key + "}", Convert.ToString(ps[key]));
            }

            data = basefun.setvaltag(data, "设备地址", Convert.ToString(this.addrst));
            data = basefun.setvaltag(data, "{设备地址}", Convert.ToString(this.addrst));
            string dtparkout = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            data     = basefun.setvaltag(data, "{出场时间}", dtparkout);
            data     = basefun.setvaltag(data, "{出入场时间}", dtparkout);
            data     = basefun.setvaltag(data, "{开闸方式}", "00");
            this.tag = data;
            CmdProtocol cmdP = new CmdProtocol(false);

            cmdP.setCommand("停车场", "计算收费金额", data);
            CommiManager.GlobalManager.SendCommand(this.target, cmdP);
            if (!cmdP.EventWh.WaitOne(2000, false))
            {
                return;
            }
            string money = basefun.valtag(cmdP.ResponseFormat, "{收费金额}");

            if (string.IsNullOrEmpty(money))
            {
                return;
            }
            this.tbPkmoney.Text = money;
            this.tag            = basefun.setvaltag(this.tag, "{收费金额}", money);
            string cardmoney = basefun.valtag(this.tag, "{卡片余额}");

            try
            {
                money             = Convert.ToString(Convert.ToDecimal(money) - Convert.ToDecimal(cardmoney));
                this.tbPkfee.Text = money;
                this.tag          = basefun.setvaltag(this.tag, "{收费}", money);
            }
            catch { }
        }
示例#5
0
        private void trvDept_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (null == e.Node)
            {
                return;
            }
            //查询明细数据
            DataTable      tabDetail = this.dsUnit.Tables["组织机构"];
            string         tag       = Convert.ToString(e.Node.Tag);
            NameObjectList ps        = new NameObjectList();

            ParamManager.MergeParam(ps, this.paramwin);
            ParamManager.MergeParam(ps, ParamManager.createParam(tag));
            ps["UnitCode"] = basefun.valtag(e.Node.Tag.ToString(), "代码");
            if (null != tabDetail)
            {
                tabDetail.Clear();
            }
            QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);

            query.FillDataSet("组织机构", ps, this.dsUnit);
            checkBox1.Checked = Convert.ToBoolean(this.dsUnit.Tables[0].Rows[0]["独立管理"].ToString());
            checkBox2.Checked = Convert.ToBoolean(this.dsUnit.Tables[0].Rows[0]["周一"].ToString());
            checkBox3.Checked = Convert.ToBoolean(this.dsUnit.Tables[0].Rows[0]["周二"].ToString());
            checkBox4.Checked = Convert.ToBoolean(this.dsUnit.Tables[0].Rows[0]["周三"].ToString());
            checkBox5.Checked = Convert.ToBoolean(this.dsUnit.Tables[0].Rows[0]["周四"].ToString());
            checkBox6.Checked = Convert.ToBoolean(this.dsUnit.Tables[0].Rows[0]["周五"].ToString());
            checkBox7.Checked = Convert.ToBoolean(this.dsUnit.Tables[0].Rows[0]["周六"].ToString());
            checkBox8.Checked = Convert.ToBoolean(this.dsUnit.Tables[0].Rows[0]["周日"].ToString());
            //if (null == tabChanged)
            //    return;

            //tabDetail = this.dsUnit.Tables["组织机构"];

            //TreeNode trnsel, trn;
            //trn = trnsel = e.Node;
            //string strdept = "";
            //while (null != trnsel)
            //{
            //    if (null != trn.FirstNode)
            //    {
            //        trn = trn.FirstNode;
            //        continue;
            //    }
            //    string t = Convert.ToString(trn.Tag);
            //    strdept += " or 部门='" + basefun.valtag(t, "部门") + "'";
            //    if (trnsel == trn)
            //        break;
            //    if (null != trn.NextNode)
            //        trn = trn.NextNode;
            //    else
            //        trn = trn.Parent;
            //    if (trnsel == trn)
            //        break;
            //}
            //if (strdept.Length > 0)
            //    strdept = strdept.Substring(3);
            //BindManager.UpdateTable(tabDetail, tabChanged, strdept);
        }
示例#6
0
        private void printFee_PrintPage(object sender, PrintPageEventArgs e)
        {
            if (null == sender || null == e || null == e.Graphics || null == e.PageSettings)
            {
                return;
            }
            NameObjectList ps = ParamManager.createParam(this.tag);

            if (null == ps["车牌号码"])
            {
                ps["车牌号码"] = "";
            }
            string[] info =
            {
                "南方停车场",
                "hr",
                "卡号:{卡号}",
                "姓名:{姓名}",
                "编号:{打印编号}",
                "车号:{车牌号码}",
                "进场时间:{入场时间}",
                "出场时间:{出场时间}",
                "停车时长:{停车时长}",
                "金    额:{收费金额}",
                "hr"
            };
            Font  font   = new Font(new FontFamily("黑体"), 12);
            Brush brush  = System.Drawing.Brushes.Blue;
            int   height = 0;

            e.PageSettings.PaperSize = new PaperSize("B5", 250, 200);
            e.PageSettings.Margins   = new Margins(0, 0, 0, 0);
            for (int i = 0; i < info.Length; i++)
            {
                if ("hr" == info[i])
                {
                    height += 25;
                    e.Graphics.DrawLine(Pens.Blue, 0, height, 250, height);
                    height += -20;
                    continue;
                }
                string val = info[i];
                foreach (string key in ps.AllKeys)
                {
                    val = val.Replace("{" + key + "}", Convert.ToString(ps[key]));
                }
                height += 25;
                if (0 == i)
                {
                    e.Graphics.DrawString(val, font, brush, 80, height);
                }
                else
                {
                    e.Graphics.DrawString(val, font, brush, 0, height);
                }
            }
        }
示例#7
0
        /// <summary>
        /// 确定交班
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbOK_Click(object sender, EventArgs e)
        {
            bool   isNotExist = false;
            string user       = Convert.ToString(this.ccbNextUser.Text);
            string pws        = this.tbPassword.Text;

            if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(pws))
            {
                MessageBox.Show("请选择接班人和输入接班人密码!", "接班提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            this.paramwin["交班人"] = BindManager.getUser().UserAccounts;
            this.paramwin["密码"]  = pws;

            User user1 = new User(user, ref isNotExist);

            if (!isNotExist)
            {
                isNotExist = !user1.login(tbUserName.Text, pws);
            }
            if (isNotExist)
            {
                MessageBox.Show("密码不正确!", "系统提示");
                return;
            }
            QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);

            this.paramwin["操作员"] = BindManager.getUser().UserName;
            this.paramwin["值班人"] = ccbNextUser.Text;
            IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
            string      myip    = IpEntry.AddressList[0].ToString();

            this.paramwin["电脑IP"] = myip;
            bool isSuccess = query.ExecuteNonQuery("交接班", this.paramwin, this.paramwin, this.paramwin);

            if (!isSuccess)
            {
                MessageBox.Show("执行交接班时失败请与管理员联系!", "接班提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            BindManager.setUser(user);
            string operName      = this.ccbNextUser.Text.Trim();
            string workStartTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string ip            = this.paramwin.AllValues.GetValue(2).ToString();
            string tag           = string.Empty;

            tag = basefun.setvaltag(tag, "值班人", operName);
            tag = basefun.setvaltag(tag, "接班时间", workStartTime);
            tag = basefun.setvaltag(tag, "电脑IP", ip);
            NameObjectList ps = ParamManager.createParam(tag);

            ParamManager.MergeParam(ps, this.paramwin, false);
            query.ExecuteNonQuery("当班状态", ps, ps, ps);
            MessageBox.Show("已经成功执行交接班!\r\n" + this.ccbNextUser.Text + " 开始工作!", "接班提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
示例#8
0
        /// <summary>
        /// 保存补助记录,修改卡片余额
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtMoney.Text) || moneyList.Items.Count < 1)
            {
                XtraMessageBox.Show("补助金额为空或者卡号为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            #region 循环写入数据
            for (int i = 0; i < moneyList.Items.Count; i++)
            {
                string[] sArray = moneyList.Items[i].ToString().Split('(');
                foreach (string j in sArray)
                {
                    if (j.ToString().Contains(")"))
                    {
                        string[] ssArray = j.ToString().Split(')');
                        foreach (string h in ssArray)
                        {
                            if (!string.IsNullOrEmpty(h.ToString()))
                            {
                                string         CardNo = h.ToString();
                                NameObjectList ps     = new NameObjectList();
                                ParamManager.MergeParam(ps, this.paramwin);
                                ps["卡号"] = CardNo;

                                #region 查询当前记录
                                QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);
                                DataTable    tab   = dsUnit.Tables["补助信息"];
                                if (null == tab)
                                {
                                    return;
                                }
                                tab.Clear();
                                query.FillDataSet(tab.TableName, ps, this.dsUnit);
                                #endregion

                                //保存充值记录并且更新卡片余额
                                DataRow dr = tab.Rows[0];
                                dr["卡号"]   = CardNo;
                                dr["补助充值"] = txtMoney.Text;
                                dr["操作员"]  = BindManager.getUser().UserName;
                                NameObjectList ps1 = ParamManager.createParam(dr);
                                ParamManager.MergeParam(ps1, this.paramwin, false);
                                this.Query.ExecuteNonQuery("补助信息", ps1, ps1, ps1);
                            }
                        }
                    }
                }
            }
            #endregion

            moneyList.Items.Clear();
            MessageBox.Show("补助成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
        }
示例#9
0
        /// <summary>
        /// 用户登录,判断交接班
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btOK_Click(object sender, EventArgs e)
        {
            //软件过期禁止使用

            if (string.IsNullOrEmpty(this.cbbAccount.Text) || string.IsNullOrEmpty(this.tbPassword.Text))
            {
                MessageBox.Show("用户名或密码不能为空!", "登录提示");
                return;
            }
            //判断是停车场否交班
            if (IHandOver() == false)
            {
                MessageBox.Show("该电脑未交班,请首先交接班!", "提示", MessageBoxButtons.OK);
                return;
            }
            else
            {
                PopupBaseEdit pe;
                bool          isNotExist = false;
                User          user       = new User(this.cbbAccount.Text, ref isNotExist);
                if (!isNotExist)
                {
                    isNotExist = !user.login(tbPassword.Text);
                }
                if (isNotExist)
                {
                    MessageBox.Show("用户名或密码不正确!", "登录提示");
                    return;
                }
                //设置当前系统用户并打开主窗口
                BindManager.setUser(user.UserAccounts);
                DataTable tab = this.dsUnit.Tables["当班状态"];
                if (tab != null && tab.Select("值班人='" + this.cbbAccount.Text.Trim() + "'").Length == 0)
                {
                    string operName      = this.cbbAccount.Text.Trim();
                    string workStartTime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    string ip            = this.paramwin.AllValues.GetValue(2).ToString();
                    string tag           = string.Empty;
                    tag = basefun.setvaltag(tag, "值班人", operName);
                    tag = basefun.setvaltag(tag, "接班时间", workStartTime);
                    tag = basefun.setvaltag(tag, "电脑IP", ip);
                    NameObjectList ps = ParamManager.createParam(tag);
                    ParamManager.MergeParam(ps, this.paramwin, false);
                    this.Query.ExecuteNonQuery("当班状态", ps, ps, ps);
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
示例#10
0
        /// <summary>
        /// 发卡数据写入数据库
        /// </summary>
        public void WriteDate(string typeName, string cardno)
        {
            DataRow      dr        = this.dsUnit.Tables["发行"].Rows[0];
            QueryDataRes query     = new QueryDataRes(this.unitItem.DataSrcFile);
            bool         isSuccess = BindManager.Save(query, this.dsUnit, this.paramwin);

            if (radic.Checked)
            {
                dr["卡号"] = textEdit1.Text;
            }
            if (radid.Checked)
            {
                dr["卡号"] = cardno;
            }
            dr["消费"]    = EateryCard;
            dr["门禁"]    = DoorCard;
            dr["停车场"]   = ParkCard;
            dr["卡片序列号"] = cardno;
            dr["用户编号"]  = txtNum.Text;
            dr["车型"]    = carTypeNo.ToString();
            dr["车辆颜色"]  = comboBox4.Text;
            // 发卡未成功 可能是修改数据失败
            bool           isflag = false;
            NameObjectList ps     = ParamManager.createParam(dr);

            ParamManager.MergeParam(ps, this.paramwin, false);
            if (typeName == "发行")
            {
                if (chkZD.Checked)
                {
                    dr["车型"] = carTypeNo;
                    if (gridView.FocusedRowHandle + 1 < dsUnit.Tables["用户选择"].Rows.Count)
                    {
                        isflag = this.Query.ExecuteNonQuery("用户选择", ps, ps, ps);
                    }
                }
                isflag = this.Query.ExecuteNonQuery("发行", ps, ps, ps);
            }
            if (isflag)
            {
                XtraMessageBox.Show("发行成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                XtraMessageBox.Show("发行失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#11
0
 /// <summary>
 /// 写入指令响应
 /// </summary>
 /// <param name="cmd">指令对象</param>
 private void cmdP_ResponseWritedHandle(CmdProtocol cmd)
 {
     if (null == cmd || string.IsNullOrEmpty(cmd.ResponseFormat))
     {
         MessageBox.Show("通讯失败!检查指令", "通讯提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (null != this.ds && null != this.Query && this.ds.Tables.Contains("park") && this.ds.Tables["park"].Rows.Count > 0)
     {
         DataTable tab = this.ds.Tables["park"];
         DataRow   dr  = this.ds.Tables["park"].Rows[0];
         if (DataRowState.Modified == dr.RowState)
         {
             NameObjectList ps = ParamManager.createParam(dr);
             this.Query.ExecuteUpdate(tab.TableName, ps);
         }
     }
     MessageBox.Show("成功下载设备控制参数!", "通讯提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
示例#12
0
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnReset_Click(object sender, EventArgs e)
        {
            if (this.dbUserView.RowCount < 1)
            {
                return;
            }
            DataRow        dr    = this.dbUserView.GetDataRow(this.dbUserView.FocusedRowHandle);
            NameObjectList ps    = ParamManager.createParam(dr);
            QueryDataRes   query = new QueryDataRes(this.unitItem.DataSrcFile);

            if (!query.ExecuteNonQuery("用户密码初始化", ps, ps, ps))
            {
                MessageBox.Show("重置密码失败!", "重置密码", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("成功重置密码为:abc123\r\n请及时修改密码确保安全", "重置密码", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#13
0
        /// <summary>
        /// 押金处理,小票打印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btCharge_Click(object sender, EventArgs e)
        {
            string province = this.cbbProvince.Text;

            if (!string.IsNullOrEmpty(province))
            {
                province = regUperCase.Replace(province, "");
            }
            string carnum = this.tbCarnum.Text;

            if (!string.IsNullOrEmpty(carnum))
            {
                carnum = province + carnum;
            }
            this.tag = basefun.setvaltag(this.tag, "{车牌号码}", carnum);
            //编号
            string code = BindManager.getCodeSn("P");

            this.tag = basefun.setvaltag(this.tag, "{打印编号}", code);
            //打印小票
            string printer = DataAccRes.AppSettings("押金打印机");

            try
            {
                if (!string.IsNullOrEmpty(printer))
                {
                    this.printDeposit.PrinterSettings.PrinterName = printer;
                }
                this.printDeposit.Print();
            }
            catch { }
            //押金处理
            NameObjectList ps = ParamManager.createParam(this.tag);

            ps["操作类别"] = "收取";
            ParamManager.MergeParam(ps, BindManager.getSystemParam(), false);
            this.Query.ExecuteNonQuery("押金处理", ps, ps, ps);
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
示例#14
0
        private void FrmDoorManager_Load(object sender, EventArgs e)
        {
            //初始化参数和单元
            this.paramwin = BindManager.getSystemParam();
            NameObjectList pstrans = BindManager.getTransParam();

            ParamManager.MergeParam(this.paramwin, pstrans);
            this.Text     = this.unitName = Convert.ToString(this.paramwin["功能单元"]);
            this.unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
            //绑定数据
            string         tagps = "@门禁管理=门禁,@消费机管理=消费,@参数下载=停车场";
            NameObjectList ps    = ParamManager.createParam(tagps);

            this.paramwin["通讯协议"] = ps[unitName];
            this.bindMgr          = new BindManager(this);
            this.paramwin["code"] = DBNull.Value;
            this.ds    = this.bindMgr.BuildDataset(this.unitItem, this.paramwin);
            this.Query = new QueryDataRes(this.unitItem.DataSrcFile);
            this.bindMgr.BindFld(this, ds);
            this.frmPrb = new frmProcessBar();
            this.frmPrb.Hide();
        }
示例#15
0
        /// <summary>
        /// 写入记录
        /// </summary>
        /// <param name="msg">tag格式信息:{卡号}、状态编号,读卡器号,{刷卡时间}</param>
        private string writeRecord(string msg)
        {
            string cardnum = basefun.valtag(msg, "{卡号}");
            string suc     = basefun.valtag(msg, "Success");

            if ("true" != suc || "16777215" == cardnum || "0" == cardnum || string.IsNullOrEmpty(cardnum))
            {
                return(msg);
            }
            NameObjectList ps = new NameObjectList();

            ps["卡号"] = cardnum;
            DataTable tabuser = null;

            try
            {
                Monitor.Enter(objquery);
                tabuser = this.qyemp.getTable("卡用户信息", ps);
            }
            finally
            {
                Monitor.PulseAll(objquery);
                Monitor.Exit(objquery);
            }
            if (null != tabuser && tabuser.Rows.Count > 0)
            {
                DataRow  dr     = tabuser.Rows[0];
                string[] strcol = { "部门ID", "部门代码", "部门", "姓名", "用户编号", "照片", "卡号", "卡号NUM", "卡片序列号", "卡片SN" };
                foreach (string c in strcol)
                {
                    msg = basefun.setvaltag(msg, "{" + c + "}", Convert.ToString(dr[c]));
                }
                if (DBNull.Value != dr["进入时间"])
                {
                    msg = basefun.setvaltag(msg, "{进入时间}", Convert.ToDateTime(dr["进入时间"]).ToString("yyyy-MM-dd HH:mm:ss"));
                }
            }
            string info = "";

            string[] cols = { "{卡号}", "{卡号NUM}", "{卡片序列号}", "{卡片SN}", "{部门}", "{部门ID}", "{部门代码}", "{姓名}", "{照片}", "{用户编号}", "状态编号", "读卡器", "{刷卡时间}", "{进入时间}" };
            for (int c = 0; c < cols.Length; c++)
            {
                info = basefun.setvaltag(info, cols[c], basefun.valtag(msg, cols[c]));
            }
            string idx    = basefun.valtag(info, "读卡器");
            string chname = channels[0];

            if ("进出口" == devtype || "出入口" == devtype)
            {
                chname = "2" == idx || "3" == idx ? channels[1] : chname;
            }
            info = basefun.setvaltag(info, "通道", chname);
            info = basefun.setvaltag(info, "区域", region);
            info = basefun.setvaltag(info, "区域ID", regionID);
            info = basefun.setvaltag(info, "控制器类型", devtype);
            string strstate = this.getStateDoorCard(cardnum, basefun.valtag(info, "状态编号"), idx);

            msg       = basefun.setvaltag(msg, "状态", strstate);
            info      = basefun.setvaltag(info, "状态", strstate);
            ps        = ParamManager.createParam(info);
            ps["控制器"] = this.devid;
            ps["时间"]  = ps["刷卡时间"] = DateTime.MinValue;
            DateTime dt = DateTime.MinValue;

            try
            {
                string dtstr = basefun.valtag(msg, "{刷卡时间}");
                if (!string.IsNullOrEmpty(dtstr) && "0001-1-1 0:00:00" != dtstr)
                {
                    ps["时间"] = ps["刷卡时间"] = dt = Convert.ToDateTime(dtstr);
                }
            }
            catch { dt = DateTime.MinValue; }
            if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
            {
                if (null == dtobj)
                {
                    return(msg);
                }
                try { dt = Convert.ToDateTime(dtobj); }
                catch { return(msg); }
                if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
                {
                    return(msg);
                }
                ps["时间"] = ps["刷卡时间"] = dtobj;
            }
            else
            {
                dtobj = ps["时间"];
            }
            bool success = true;

            try
            {
                Monitor.Enter(objquery);
                success = qydata.ExecuteNonQuery("采集道闸数据", ps, ps, ps);
            }
            finally
            {
                Monitor.PulseAll(objquery);
                Monitor.Exit(objquery);
            }
            if (!success)
            {
                NameValueCollection attr = new NameValueCollection();
                attr["功能"] = "采集道闸数据保存失败";
                ServiceTool.LogMessage(info, null, EventLogEntryType.Warning);
            }
            this.AddRecord(info);
            DvRecordEventArgs arg = new DvRecordEventArgs(this.devid, this.station, dt, info);

            this.RaiseRecord(arg);
            return(msg);
        }
示例#16
0
        /// <summary>-
        /// 保存设备
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbSave_Click(object sender, EventArgs e)
        {
            this.validateFeeTab();
            DataTable tabpark  = this.ds.Tables["停车场管理"];
            DataTable tabfee   = this.ds.Tables["收费标准"];
            DataTable tabdspan = this.ds.Tables["收费标准时段"];
            DataTable tabdtime = this.ds.Tables["收费标准时刻"];

            DataTable[] tablist   = { tabpark, tabfee, tabdspan, tabdtime };
            bool        isSuccess = this.Query.BeginTransaction();
            string      msg       = "";

            if (!isSuccess)
            {
                msg = "保存失败,无法打开事务!";
            }
            else
            {
                foreach (DataTable tab in tablist)
                {
                    NameObjectList[] psins = ParamManager.createParam(tab, DataRowState.Added);
                    NameObjectList[] psupt = ParamManager.createParam(tab, DataRowState.Modified);
                    NameObjectList[] psdel = ParamManager.createParam(tab, DataRowState.Deleted);
                    isSuccess = this.Query.ExecuteNonQuery(tab.TableName, psins, psupt, psdel);
                    if (!isSuccess)
                    {
                        msg = "保存失败,请检查数据是否合法!";
                        break;
                    }
                }
            }
            if (!isSuccess)
            {
                this.Query.RollbackAndClose();
            }
            else
            {
                this.Query.Commit();
                this.Query.Close();
                foreach (DataTable tab in tablist)
                {
                    tab.AcceptChanges();
                }
                //发出通讯更新设备
                int    port  = 2010;
                string sport = DataAccRes.AppSettings("Granity文件服务");
                if (!string.IsNullOrEmpty(sport))
                {
                    try { port = Convert.ToInt32(sport); }
                    catch { return; }
                }
                string conn  = DataAccRes.DefaultDataConnInfo.Value;
                Regex  regIP = new Regex(@"server=([\w.\(\)]*)(;|\\)");
                string ipsrv = "127.0.0.1";
                if (regIP.IsMatch(conn))
                {
                    Match mt = regIP.Match(conn);
                    if (mt.Groups.Count > 1)
                    {
                        ipsrv = mt.Groups[1].Value.ToLower();
                    }
                    if ("(local)" == ipsrv || "127.0.0.1" == ipsrv)
                    {
                        ipsrv = Dns.GetHostName();
                    }
                    ipsrv = Dns.GetHostAddresses(ipsrv)[0].ToString();
                }
                CmdFileTrans cmd = new CmdFileTrans(false);
                cmd.ExtRefreshDevice();
                CommiTarget target = new CommiTarget(ipsrv, port, CommiType.TCP);
                CommiManager.GlobalManager.SendCommand(target, cmd);
            }
            if (!isSuccess)
            {
                MessageBox.Show(msg, "保存提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("保存成功!", "保存提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#17
0
        private void tmRefresh_Tick(object sender, EventArgs e)
        {
            if (isRunning)
            {
                return;
            }
            isRunning = true;
            //巡检过的设备地址加入devs中,避免重复巡检
            string devs = ",", tpl = "消费";
            // isrealtime/是否实时状态,在最后刷卡时间5分钟不变化时可对累积数据大批量采集
            bool     isrealtime = false;
            TimeSpan tspre      = new TimeSpan(0, 5, 0);
            //有信息则记录日志
            DataView dvinfo = gridViewInfo.DataSource as DataView;
            //站址/记录数列表,非实时采集状态时优先批量采集记录数大的
            Dictionary <string, int>      devrecord  = new Dictionary <string, int>();
            Dictionary <string, string[]> devinfo    = new Dictionary <string, string[]>();
            List <CommiTarget>            targetlist = new List <CommiTarget>();
            CmdProtocol cmdP = new CmdProtocol(false);

            cmdP.TimeOut       = new TimeSpan(400 * 10000);
            cmdP.TimeSendInv   = new TimeSpan(1, 0, 0);
            cmdP.TimeFailLimit = new TimeSpan(900 * 10000);
            cmdP.TimeLimit     = new TimeSpan(900 * 10000);
            NameObjectList psdata = new NameObjectList();

            for (int i = 0; i < lvEatery.Items.Count; i++)
            {
                string tag = Convert.ToString(lvEatery.Items[i].Tag);
                if (string.IsNullOrEmpty(tag))
                {
                    continue;
                }
                string[] devps = tag.Split(",".ToCharArray());
                if (devs.Contains("," + devps[7] + ","))
                {
                    continue;
                }
                CommiTarget target = this.getTarget(devps);
                if (null == target)
                {
                    continue;
                }
                targetlist.Add(target);
                tag   = "@设备地址=" + devps[7];
                devs += devps[7] + ",";
                cmdP.setCommand(tpl, "检测状态", tag);
                cmdP.ResetState();
                CommiManager.GlobalManager.SendCommand(target, cmdP);
                ListViewItem list1 = this.lvEatery.Items[i];
                if (!cmdP.EventWh.WaitOne(300, false))
                {
                    continue;
                }
                string msg = cmdP.ResponseFormat;

                EateryStatus(list1, basefun.valtag(msg, "{状态}"));
                if ("true" != basefun.valtag(msg, "Success"))
                {
                    continue;
                }
                string val = basefun.valtag(msg, "工作中");
                if (!this.dtprelist.ContainsKey(devps[7]))
                {
                    this.dtprelist.Add(devps[7], DateTime.Now.AddMinutes(-4));
                }
                if ("1" == val)
                {
                    this.dtprelist[devps[7]] = DateTime.Now;
                }
                //记录数列表
                int sum = Convert.ToInt32(basefun.valtag(msg, "{采集标志}"));
                devrecord.Add(devps[7], sum);
                devinfo.Add(devps[7], devps);
                //检查状态改变则记录
                this.validateSate(lvEatery.Items[i], devps[8], msg);
            }
            foreach (string key in devrecord.Keys)
            {
                if (devrecord[key] < 1 || !this.dtprelist.ContainsKey(key) || !devinfo.ContainsKey(key))
                {
                    continue;
                }
                if (DateTime.Now - this.dtprelist[key] < tspre)
                {
                    continue;
                }
                //在间隔tspre(5分钟)没有工作状态,则可以采集10条记录
                string[] info = devinfo[key];
                for (int i = 0; i < 11; i++)
                {
                    string      tag    = "@设备地址=" + info[7];
                    CommiTarget target = this.getTarget(info);
                    if (null == target)
                    {
                        continue;
                    }
                    if (i < 1)
                    {
                        cmdP.setCommand(tpl, "取当前消费记录", tag);
                    }
                    else
                    {
                        cmdP.setCommand(tpl, "取下一条消费记录", tag);
                    }
                    cmdP.ResetState();
                    CommiManager.GlobalManager.SendCommand(target, cmdP);
                    if (!cmdP.EventWh.WaitOne(300, false))
                    {
                        continue;
                    }
                    string msg = cmdP.ResponseFormat;
                    if ("true" != basefun.valtag(msg, "Success"))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(basefun.valtag(msg, "{卡号}")))
                    {
                        break;
                    }
                    NameObjectList ps = ParamManager.createParam(msg);
                    ps["消费机"] = info[8];
                    bool success = this.Query.ExecuteNonQuery("采集数据", ps, ps, ps);
                    AddEateryStatus(msg);
                    if (!success)
                    {
                        break;
                    }
                }
                break;
            }
            foreach (CommiTarget tar in targetlist)
            {
                CommiManager.GlobalManager.RemoveCommand(tar, cmdP);
            }
            isRunning = false;
        }
示例#18
0
        /// <summary>
        /// 在当前没有执行指令响应时利用响应事件保存数据
        /// </summary>
        /// <param name="sender">事件指令实例</param>
        /// <param name="e"></param>
        private void execResponse(object sender, ResponseEventArgs e)
        {
            if (null == sender || null == e || !e.Success)
            {
                return;
            }
            CmdProtocol cmdP = sender as CmdProtocol;

            if (null == cmdP || 0 == this.stateChecking || this.isexecuting)
            {
                return;
            }
            string msg     = cmdP.ResponseFormat;
            string suc     = basefun.valtag(msg, "Success");
            string cardnum = basefun.valtag(msg, "{卡号}");
            string st      = basefun.valtag(msg, "{状态}");

            if ("true" != suc || string.IsNullOrEmpty(cardnum) || "16777215" == cardnum || "0" == cardnum)
            {
                return;
            }
            string info = "";

            Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " 执行:" + msg);
            myLog.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " 执行:" + msg);
            string[] cols = { "{卡号}", "{卡类}", "{消费时间}", "{消费金额}", "{卡余额}", "{累计补助金额}", "{消费机号}", "{操作员号}" };
            if ("补助机" == this.devName)
            {
                cols = new string[] { "{卡号}", "{卡类}", "{充值时间}", "{本次补助金额}", "{补助后总额}" }
            }
            ;
            for (int c = 0; c < cols.Length; c++)
            {
                info = basefun.setvaltag(info, cols[c], basefun.valtag(msg, cols[c]));
            }
            NameObjectList ps = ParamManager.createParam(info);

            ps["消费机"] = this.devid;
            DateTime dt  = DateTime.MinValue;
            string   fld = "补助机" == this.devName ? "充值时间" : "消费时间";

            try
            {
                dt = Convert.ToDateTime(ps[fld]);
            }
            catch { }
            if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
            {
                NameValueCollection datainfo = new NameValueCollection();
                datainfo["操作"] = "提取消费记录";
                datainfo["报文"] = CommandBase.Parse(cmdP.ResponseData, true);
                ServiceTool.LogMessage(msg, datainfo, EventLogEntryType.FailureAudit);
                if (null == dtobj)
                {
                    return;
                }
                try { dt = Convert.ToDateTime(dtobj); }
                catch { return; }
                ps[fld] = dtobj;
            }
            else
            {
                dtobj = ps[fld];
            }
            bool success = false;

            if ("补助机" == this.devName)
            {
                success = this.query.ExecuteNonQuery("消费接收补助", ps, ps, ps);
            }
            else
            {
                success = this.query.ExecuteNonQuery("采集数据", ps, ps, ps);
            }

            if (!success)
            {
                ServiceTool.LogMessage(info, null, EventLogEntryType.Warning);
            }
        }
示例#19
0
        private void btnCardUpdate_Click(object sender, EventArgs e)
        {
            if (this.txtnewcard.Text == "此卡已发行")
            {
                XtraMessageBox.Show("此卡已发行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DataRow        dr        = this.dsUnit.Tables["换卡"].Rows[0];
            QueryDataRes   query     = new QueryDataRes(this.unitItem.DataSrcFile);
            bool           isSuccess = BindManager.Save(query, this.dsUnit, this.paramwin);
            bool           isflag    = false;
            NameObjectList ps        = ParamManager.createParam(dr);
            IPHostEntry    IpEntry   = Dns.GetHostEntry(Dns.GetHostName());
            string         myip      = IpEntry.AddressList[0].ToString();

            if (this.radYou.Checked)
            {
                ps["是否有卡"] = 1;
            }
            else if (this.radWu.Checked)
            {
                ps["是否有卡"] = 0;
            }
            ps["补助累加"]         = IsaddBZMoney;
            ps["卡号"]           = txtCardNo.Text;
            ps["新卡片序列号"]       = this.txtnewcard.Text;
            ps["新卡号"]          = this.txtnewcard.Text;
            ps["补助充值"]         = this.txtBZ.Text;
            ps["现金充值"]         = this.txtMoney.Text;
            ps["UserAccounts"] = BindManager.getUser().UserName;
            if (Dtime1 == DateTime.Now.ToString("yyyy-MM-dd"))
            {
                Dtime1 = Dtime.Text;
            }
            if (Etime1 == DateTime.Now.ToString("yyyy-MM-dd"))
            {
                Etime1 = this.Etime.Text;
            }
            if (PTime1 == DateTime.Now.ToString("yyyy-MM-dd"))
            {
                PTime1 = this.Ptime.Text;
            }
            if (string.IsNullOrEmpty(Dtime1))
            {
                Dtime1 = DateTime.Now.ToString("yyyy-MM-dd");
            }
            if (string.IsNullOrEmpty(Etime1))
            {
                Etime1 = DateTime.Now.ToString("yyyy-MM-dd");
            }
            if (string.IsNullOrEmpty(PTime1))
            {
                PTime1 = DateTime.Now.ToString("yyyy-MM-dd");
            }
            ps["门禁延期"]      = Dtime1;
            ps["消费延期"]      = Etime1;
            ps["停车场延期"]     = PTime1;
            ps["设备"]        = DevIdS;
            ps["LocalIP"]   = myip;
            ps["Localhost"] = System.Net.Dns.GetHostName();
            ps["备注"]        = "";
            ParamManager.MergeParam(ps, this.paramwin, false);
            isflag = this.Query.ExecuteNonQuery("换卡", ps, ps, ps);
            if (isflag)
            {
                XtraMessageBox.Show("换卡成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                XtraMessageBox.Show("换卡失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            this.dsUnit.Tables["用户选择"].Clear();
            this.Query.FillDataSet("用户选择", new NameObjectList(), this.dsUnit);
            this.dsUnit.Tables["换卡"].Clear();
            this.Query.FillDataSet("换卡", new NameObjectList(), this.dsUnit);
            getNewDataByCardNo(this.txtnewcard.Text);
        }
示例#20
0
        /// <summary>
        /// 写入记录,分补助或消费分别保存
        /// </summary>
        /// <param name="msg">tag格式信息:{卡号}、状态编号,读卡器号,{刷卡时间}</param>
        private string writeRecord(string msg)
        {
            string cardnum = basefun.valtag(msg, "{卡号}");
            string suc     = basefun.valtag(msg, "Success");

            if ("true" != suc || "16777215" == cardnum || "0" == cardnum || string.IsNullOrEmpty(cardnum))
            {
                return(msg);
            }
            string info = "";

            string[] cols = { "{卡号}", "{卡类}", "{消费时间}", "{消费金额}", "{卡余额}", "{累计补助金额}", "{消费机号}", "{操作员号}" };
            if ("补助机" == this.devName)
            {
                cols = new string[] { "{卡号}", "{卡类}", "{充值时间}", "{本次补助金额}", "{补助后总额}" }
            }
            ;
            for (int c = 0; c < cols.Length; c++)
            {
                info = basefun.setvaltag(info, cols[c], basefun.valtag(msg, cols[c]));
            }
            NameObjectList ps = ParamManager.createParam(info);

            ps["消费机"] = this.devid;

            //msg = "@{帧头}=C0,@{设备地址}=17,@{控制场}=01,@{长度场}=25,@Success=true,@{状态}=操作成功!,@{命令长度}=23,@{消费机号}=17,@{操作员号}=255,@{卡号}=16777215,@{卡类}=255,@{消费时间}=0001/1/1 0:00:00,@{卡余额}=1677721.5,@{累计补助金额}=6553.5,@{消费金额}=6553.5,@{记录指针}=11297,@{校验字}=32,@{帧尾}=C0";
            ///*************************查看时间格式是否正确 2012-06-20
            string dtTime = Convert.ToString(basefun.valtag(msg, "{消费时间}"));

            try
            {
                DateTime s = Convert.ToDateTime(dtTime);
                if (dtTime.ToString() == "0001/1/1 0:00:00" || Convert.ToDateTime(dtTime) < Convert.ToDateTime("2000-01-01 00:00:00"))
                {
                    ps["设备ID"] = this.devid;
                    ps["卡号"]   = cardnum;
                    ps["日期"]   = dtTime;
                    ps["金额"]   = basefun.valtag(msg, "{卡余额}");
                    this.query.ExecuteNonQuery("错误记录", ps, ps, ps);
                }
            }
            catch
            {
                ps["设备ID"] = this.devid;
                ps["卡号"]   = cardnum;
                ps["日期"]   = dtTime;
                ps["金额"]   = basefun.valtag(msg, "{卡余额}");
                this.query.ExecuteNonQuery("错误记录", ps, ps, ps);
            }
            ///*************************查看时间格式是否正确 2012-06-20



            DateTime dt  = DateTime.MinValue;
            string   fld = "补助机" == this.devName ? "充值时间" : "消费时间";

            try
            {
                dt = Convert.ToDateTime(ps[fld]);
            }
            catch { }
            if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
            {
                if (null == dtobj)
                {
                    return(msg);
                }
                try { dt = Convert.ToDateTime(dtobj); }
                catch { return(msg); }
                ps[fld] = dtobj;
            }
            else
            {
                dtobj = ps[fld];
            }
            bool success = false;

            if ("补助机" == this.devName)
            {
                success = this.query.ExecuteNonQuery("消费接收补助", ps, ps, ps);
            }
            else
            {
                success = this.query.ExecuteNonQuery("采集数据", ps, ps, ps);
            }
            Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " 保存:" + this.devName + " " + this.station.ToString());
            myLog.WriteLine(DateTime.Now.ToString("HH:mm:ss.fff") + " 保存:" + this.devName + " " + this.station.ToString());
            if (!success)
            {
                ServiceTool.LogMessage(info, null, EventLogEntryType.Warning);
            }
            if (recordpos.ContainsKey(this.devid))
            {
                recordpos[this.devid]++;
                ps.Clear();
                ps["消费机"]  = this.devid;
                ps["记录位置"] = recordpos[this.devid];
                query.ExecuteNonQuery("记录指针", ps, ps, ps);
            }
            this.AddRecord(info);
            DvRecordEventArgs arg = new DvRecordEventArgs(this.devid, this.station, dt, info);

            this.RaiseRecord(arg);
            return(msg);
        }

        object dtobj = null;
示例#21
0
        /// <summary>
        /// 直接采集一条数据,并自动存入数据库,返回获取数据的记录
        /// 没有记录时恢复巡检
        /// </summary>
        /// <param name="isfirst">是否首次提取,首次会补充采集当前记录以防漏采</param>
        public override string GatherData(bool isfirst)
        {
            if (null == this.commimgr || null == this.target || string.IsNullOrEmpty(this.devid) || this.station < 1)
            {
                return("");
            }
            CmdProtocol cmdP = this.cmdGather;

            if (null == cmdP)
            {
                cmdP = new CmdProtocol(false);
            }
            string[] cols = { "{卡号}", "状态编号", "读卡器", "{刷卡时间}" };
            string   tag  = "@设备地址=" + Convert.ToString(this.station);

            if ("考勤机" == this.devtype)
            {
                tag = basefun.setvaltag(tag, "{记录索引}", Convert.ToString(this.posRecord));
            }
            this.reChecking(0);
            cmdP.setCommand("门禁", "读取记录", tag);
            string msg     = getResponse(this.commimgr, this.target, cmdP, this.waitTime);
            string cardnum = basefun.valtag(msg, "{卡号}");
            string suc     = basefun.valtag(msg, "Success");

            if ("true" == suc)
            {
                this.posRecord++;
            }
            if ("true" != suc || string.IsNullOrEmpty(cardnum) || "16777215" == cardnum || "0" == cardnum)
            {
                if (this.posRecord > 10000 && ("false" == suc || "16777215" == cardnum || "0" == cardnum))
                {
                    //清空记录
                    cmdP.setCommand("门禁", "清空记录", tag);
                    cmdP.ResetState();
                    this.commimgr.SendCommand(this.target, cmdP);
                    if (cmdP.EventWh.WaitOne(this.waitTime, false))
                    {
                        suc = basefun.valtag(cmdP.ResponseFormat, "Success");
                        if ("true" == suc)
                        {
                            this.posRecord = 0;
                            NameObjectList pspos = new NameObjectList();
                            pspos["控制器"] = this.devid;
                            this.query.ExecuteNonQuery("重置记录位置", pspos, pspos, pspos);
                        }
                    }
                }
                this.reChecking(1);
                return(msg);
            }
            string info = "";

            for (int c = 0; c < cols.Length; c++)
            {
                info = basefun.setvaltag(info, cols[c], basefun.valtag(msg, cols[c]));
            }
            info = basefun.setvaltag(info, "状态", this.getStateDoorCard(basefun.valtag(info, "状态编号")));
            NameObjectList ps = ParamManager.createParam(info);

            ps["控制器"] = this.devid;
            ps["时间"]  = ps["刷卡时间"];
            DateTime dt = DateTime.MinValue;

            try
            {
                dt = Convert.ToDateTime(basefun.valtag(msg, "{刷卡时间}"));
            }
            catch { dt = DateTime.MinValue; }
            if (dt < DateTime.Today.AddYears(-5) || dt > DateTime.Today.AddYears(5))
            {
                ps["时间"] = ps["刷卡时间"] = null;
            }
            bool success = this.query.ExecuteNonQuery("采集门禁数据", ps, ps, ps);

            if (!success || dt < DateTime.Today.AddYears(-5) || dt > DateTime.Today.AddYears(5))
            {
                ServiceTool.LogMessage(info, null, EventLogEntryType.Warning);
            }
            this.AddRecord(info);
            DvRecordEventArgs arg = new DvRecordEventArgs(this.devid, this.station, dt, info);

            this.RaiseRecord(arg);
            return(msg);
        }
 /// <summary>
 /// 保存增加门,增加门禁设备,增加门组信息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtSave_Click(object sender, EventArgs e)
 {
     try
     {
         this.validateFeeTab();
         DataTable   tabfee    = this.ds.Tables["门"];
         DataTable   tabdspan  = this.ds.Tables["门禁"];
         DataTable   tabdtime  = this.ds.Tables["门禁分组"];
         DataTable   tabExtend = this.ds.Tables["扩展板参数"];
         DataTable   tabEff    = this.ds.Tables["门禁有效时段"];
         DataTable   tabTask   = this.ds.Tables["定时任务"];
         DataTable[] tablist   = { tabfee, tabdspan, tabdtime, tabEff, tabExtend, tabTask };
         bool        isSuccess = this.Query.BeginTransaction();
         string      msg       = "";
         if (!isSuccess)
         {
             msg = "保存失败,无法打开事务!";
         }
         else
         {
             foreach (DataTable tab in tablist)
             {
                 NameObjectList[] psins = ParamManager.createParam(tab, DataRowState.Added);
                 NameObjectList[] psupt = ParamManager.createParam(tab, DataRowState.Modified);
                 NameObjectList[] psdel = ParamManager.createParam(tab, DataRowState.Deleted);
                 isSuccess = this.Query.ExecuteNonQuery(tab.TableName, psins, psupt, psdel);
                 if (!isSuccess)
                 {
                     msg = "保存失败,请检查数据是否合法!";
                     break;
                 }
             }
         }
         if (!isSuccess)
         {
             this.Query.RollbackAndClose();
         }
         else
         {
             this.Query.Commit();
             this.Query.Close();
             foreach (DataTable tab in tablist)
             {
                 tab.AcceptChanges();
             }
             //发出通讯更新设备
             int    port  = 2010;
             string sport = DataAccRes.AppSettings("Granity文件服务");
             if (!string.IsNullOrEmpty(sport))
             {
                 try { port = Convert.ToInt32(sport); }
                 catch { return; }
             }
             string conn = DataAccRes.DefaultDataConnInfo.Value;
             System.Text.RegularExpressions.Regex regIP = new System.Text.RegularExpressions.Regex(@"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}");
             string ipsrv = "127.0.0.1";
             if (regIP.IsMatch(conn))
             {
                 ipsrv = regIP.Match(conn).Value;
             }
             //CmdFileTrans cmd = new CmdFileTrans(false);
             //cmd.ExtRefreshDevice();
             //CommiTarget target = new CommiTarget(ipsrv, port, CommiType.TCP);
             //CommiManager.GlobalManager.SendCommand(target, cmd);
         }
         if (!isSuccess)
         {
             XtraMessageBox.Show(msg, "保存提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             XtraMessageBox.Show("保存成功!", "保存提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch
     {
         XtraMessageBox.Show("保存失败", "保存提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     finally
     {
         this.Query.Close();
     }
 }
示例#23
0
        /// <summary>
        /// 巡检响应,连续失败5分钟(tsbusy)则认为停机,间隔tsbusy巡检
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdGather_ResponseHandle(object sender, ResponseEventArgs e)
        {
            if (null == sender || null == e)
            {
                return;
            }
            CmdProtocol cmdP = sender as CmdProtocol;

            if (null == cmdP || 0 == this.stateChecking)
            {
                return;
            }
            if (!e.Success)
            {
                //连续长时间失败时,增大巡检周期
                if (cmdP.TimeSendInv < this.tsbusy && DateTime.Now - cmdP.ResponseDatetime > this.tsbusy)
                {
                    if (cmdP.TimeSendInv < this.tsbusy)
                    {
                        cmdP.TimeSendInv = this.tsbusy.Add(this.tsinv);
                    }
                }
                return;
            }
            string msg = cmdP.ResponseFormat;

            if ("true" != basefun.valtag(msg, "Success"))
            {
                return;
            }
            //离线后恢复在线时,恢复巡检周期
            if (cmdP.TimeSendInv > this.tsbusy)
            {
                cmdP.TimeSendInv = this.tsinv;
            }
            //工作中或没有新记录,则
            string valwk = basefun.valtag(msg, "工作中");
            int    sum   = Convert.ToInt32(basefun.valtag(msg, "{采集标志}"));

            if ("1" == valwk || sum < 1)
            {
                this.dtwork = DateTime.Now;
            }
            this.validateSate(msg);
            //有新记录且不繁忙时可采集新记录50条
            if (sum < 1 || DateTime.Now - this.dtwork < tsbusy)
            {
                return;
            }
            string[] cols = { "{卡号}", "{卡类}", "{消费时间}", "{消费金额}", "{卡余额}", "{累计补助金额}", "{消费机号}", "{操作员号}" };
            string   tag  = "@设备地址=" + Convert.ToString(this.station);

            this.reChecking(0);
            TimeSpan tswait = this.waitTime;

            for (int i = 0; i < 51; i++)
            {
                if (i < 1)
                {
                    cmdP.setCommand("消费", "取当前消费记录", tag);
                }
                else if (i < 2)
                {
                    cmdP.setCommand("消费", "取下一条消费记录", tag);
                }
                msg = getResponse(this.commimgr, this.target, cmdP, tswait);
                if ("true" != basefun.valtag(msg, "Success"))
                {
                    break;
                }
                string cardnum = basefun.valtag(msg, "{卡号}");
                if (string.IsNullOrEmpty(cardnum) || "16777215" == cardnum || "0" == cardnum)
                {
                    continue;
                }
                string info = "";
                for (int c = 0; c < cols.Length; c++)
                {
                    info = basefun.setvaltag(info, cols[c], basefun.valtag(msg, cols[c]));
                }
                NameObjectList ps = ParamManager.createParam(info);
                ps["消费机"] = this.devid;
                bool success = this.query.ExecuteNonQuery("采集数据", ps, ps, ps);
                if (!success)
                {
                    ServiceTool.LogMessage(info, null, EventLogEntryType.Warning);
                }
                DateTime dt = Convert.ToDateTime(ps["消费时间"]);
                this.AddRecord(info);
                DvRecordEventArgs arg = new DvRecordEventArgs(this.devid, this.station, dt, info);
                this.RaiseRecord(arg);
                if (!success)
                {
                    break;
                }
            }
            this.reChecking(1);
        }
示例#24
0
        /// <summary>
        /// 写入记录
        /// </summary>
        /// <param name="tagmsg">tag格式信息:{卡号}、状态编号,读卡器号,{刷卡时间}</param>
        /// <param name="isevent">是否触发事件</param>
        private string writeRecord(string tagmsg, bool isevent)
        {
            string cardnum = basefun.valtag(tagmsg, "{卡号}");
            string suc     = basefun.valtag(tagmsg, "Success");

            // if ("true" != suc || "16777215" == cardnum || "0" == cardnum || string.IsNullOrEmpty(cardnum))
            if ("16777215" == cardnum || "0" == cardnum || string.IsNullOrEmpty(cardnum))
            {
                return(tagmsg);
            }
            NameObjectList ps = new NameObjectList();

            ps["卡号"] = cardnum;
            DataTable tabuser = null;

            try
            {
                Monitor.Enter(objquery);
                tabuser = this.qyemp.getTable("卡用户信息", ps);
            }
            finally
            {
                Monitor.PulseAll(objquery);
                Monitor.Exit(objquery);
            }
            if (null != tabuser && tabuser.Rows.Count > 0)
            {
                DataRow dr = tabuser.Rows[0];
                tagmsg = basefun.setvaltag(tagmsg, "{部门ID}", Convert.ToString(dr["部门ID"]));
                tagmsg = basefun.setvaltag(tagmsg, "{部门代码}", Convert.ToString(dr["部门代码"]));
                tagmsg = basefun.setvaltag(tagmsg, "{部门}", Convert.ToString(dr["部门"]));
                tagmsg = basefun.setvaltag(tagmsg, "{姓名}", Convert.ToString(dr["姓名"]));
            }
            string info = "";

            string[] cols = { "{卡号}", "{部门}", "{部门ID}", "{部门代码}", "{姓名}", "状态编号", "读卡器", "{刷卡时间}" };
            for (int c = 0; c < cols.Length; c++)
            {
                info = basefun.setvaltag(info, cols[c], basefun.valtag(tagmsg, cols[c]));
            }
            string strstate = this.getStateDoorCard(cardnum, basefun.valtag(info, "状态编号"), basefun.valtag(info, "读卡器"));

            tagmsg    = basefun.setvaltag(tagmsg, "状态", strstate);
            info      = basefun.setvaltag(info, "状态", strstate);
            ps        = ParamManager.createParam(info);
            ps["控制器"] = this.devid;
            ps["时间"]  = ps["刷卡时间"] = DateTime.MinValue;
            DateTime dt = DateTime.MinValue;

            try
            {
                string dtstr = basefun.valtag(tagmsg, "{刷卡时间}");
                if (!string.IsNullOrEmpty(dtstr) && "0001-1-1 0:00:00" != dtstr)
                {
                    ps["时间"] = ps["刷卡时间"] = dt = Convert.ToDateTime(dtstr);
                }
            }
            catch { dt = DateTime.MinValue; }
            if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
            {
                if (null == dtobj)
                {
                    return(tagmsg);
                }
                try { dt = Convert.ToDateTime(dtobj); }
                catch { ServiceTool.LogMessage(info, null, EventLogEntryType.Warning); return(tagmsg); }
                if (dt < DateTime.Today.AddYears(-3) || dt > DateTime.Today.AddYears(3))
                {
                    ServiceTool.LogMessage(info, null, EventLogEntryType.Warning);
                    return(tagmsg);
                }
                ps["时间"] = ps["刷卡时间"] = dtobj;
            }
            else
            {
                dtobj = ps["时间"];
            }
            bool success = false;

            try
            {
                Monitor.Enter(objquery);
                success = qydata.ExecuteNonQuery("采集门禁数据", ps, ps, ps);
            }
            finally
            {
                Monitor.PulseAll(objquery);
                Monitor.Exit(objquery);
            }
            if (!success)
            {
                ServiceTool.LogMessage(info, null, EventLogEntryType.Warning);
            }
            if (isevent)
            {
                this.AddRecord(info);
                DvRecordEventArgs arg = new DvRecordEventArgs(this.devid, this.station, dt, info);
                this.RaiseRecord(arg);
            }
            return(tagmsg);
        }
示例#25
0
        /// <summary>
        /// 直接采集一条数据,并自动存入数据库,返回获取数据的记录
        /// 没有记录时恢复巡检
        /// </summary>
        /// <param name="isfirst">是否首次提取,首次会补充采集当前记录以防漏采</param>
        public override string GatherData(bool isfirst)
        {
            if (null == this.commimgr || null == this.target || string.IsNullOrEmpty(this.devid) || this.station < 1)
            {
                return("");
            }
            CmdProtocol cmdP = this.cmdGather;

            if (null == cmdP)
            {
                cmdP = new CmdProtocol(false);
            }
            string[] cols = { "{卡号}", "{卡类}", "{消费时间}", "{消费金额}", "{卡余额}", "{累计补助金额}", "{消费机号}", "{操作员号}" };
            string   tag  = "@设备地址=" + Convert.ToString(this.station);

            this.reChecking(0);
            if (recordpos.ContainsKey(this.devid))
            {
                tag = basefun.setvaltag(tag, "{记录值指针}", Convert.ToString(recordpos[this.devid]));
                cmdP.setCommand("消费", "取指定记录", tag);
            }
            else
            {
                if (isfirst)
                {
                    this.getSubsidy();
                    cmdP.setCommand("消费", "取当前消费记录", tag);
                }
                else
                {
                    cmdP.setCommand("消费", "取下一条消费记录", tag);
                }
            }
            string msg     = getResponse(this.commimgr, this.target, cmdP, this.waitTime);
            string cardnum = basefun.valtag(msg, "{卡号}");
            string suc     = basefun.valtag(msg, "Success");

            if ("true" != suc || string.IsNullOrEmpty(cardnum) || "16777215" == cardnum || "0" == cardnum)
            {
                this.reChecking(1);
                if ("false" == suc || "16777215" == cardnum || "0" == cardnum)
                {
                    recordpos.Remove(this.devid);
                }
                return(msg);
            }
            string info = "";

            for (int c = 0; c < cols.Length; c++)
            {
                info = basefun.setvaltag(info, cols[c], basefun.valtag(msg, cols[c]));
            }
            NameObjectList ps = ParamManager.createParam(info);

            ps["消费机"] = this.devid;
            bool success = this.query.ExecuteNonQuery("采集数据", ps, ps, ps);

            if (!success)
            {
                ServiceTool.LogMessage(info, null, EventLogEntryType.Warning);
            }
            if (recordpos.ContainsKey(this.devid))
            {
                recordpos[this.devid]++;
                ps.Clear();
                ps["消费机"]  = this.devid;
                ps["记录位置"] = recordpos[this.devid];
                query.ExecuteNonQuery("记录指针", ps, ps, ps);
            }
            DateTime dt = DateTime.MinValue;

            try
            {
                dt = Convert.ToDateTime(ps["消费时间"]);
            }
            catch { }
            this.AddRecord(info);
            DvRecordEventArgs arg = new DvRecordEventArgs(this.devid, this.station, dt, info);

            this.RaiseRecord(arg);
            return(msg);
        }
示例#26
0
        /// <summary>
        /// 巡检响应,连续失败5分钟(tsbusy)则认为停机,间隔tsbusy巡检
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdGather_ResponseHandle(object sender, ResponseEventArgs e)
        {
            if (null == sender || null == e)
            {
                return;
            }
            CmdProtocol cmdP = sender as CmdProtocol;

            if (null == cmdP || 0 == this.stateChecking)
            {
                return;
            }
            if (!e.Success)
            {
                //连续长时间失败时,增大巡检周期
                if (cmdP.TimeSendInv < this.tsbusy && DateTime.Now - cmdP.ResponseDatetime > this.tsbusy)
                {
                    if (cmdP.TimeSendInv < this.tsbusy)
                    {
                        cmdP.TimeSendInv = this.tsbusy.Add(this.tsinv);
                    }
                }
                return;
            }
            string msg = cmdP.ResponseFormat;

            if (string.IsNullOrEmpty(msg) || "true" != basefun.valtag(msg, "Success"))
            {
                return;
            }
            //离线后恢复在线时,恢复巡检周期
            if (cmdP.TimeSendInv > this.tsbusy)
            {
                cmdP.TimeSendInv = this.tsinv;
            }
            this.validateSate(msg);

            //2分钟内记录数大于20条,则设备处于繁忙状态,空闲时可采集
            string sumstr = basefun.valtag(msg, "{刷卡记录数}");
            string dtstr  = basefun.valtag(msg, "{刷卡时间}");

            if (string.IsNullOrEmpty(sumstr) || string.IsNullOrEmpty(dtstr))
            {
                return;
            }
            int      sum    = Convert.ToInt32(sumstr);
            DateTime dtcard = DateTime.MinValue;

            try { dtcard = Convert.ToDateTime(dtstr); }
            catch { }
            if ("考勤机" == this.devtype && this.posRecord > sum)
            {
                this.posRecord = 0;
                NameObjectList posps = new NameObjectList();
                posps["控制器"] = this.devid;
                this.query.ExecuteNonQuery("重置记录位置", posps, posps, posps);
            }
            //判定是否繁忙状态
            if (sum < 1 || (sum > 60 && DateTime.Now - dtcard < this.tsbusy))
            {
                return;
            }

            //有新记录且不繁忙时可采集新记录50条
            string[] cols = { "{卡号}", "状态编号", "读卡器", "{刷卡时间}" };
            string   tag  = "@设备地址=" + Convert.ToString(this.station);
            int      st   = this.stateChecking;

            this.reChecking(0);
            bool isreset = false;

            if (sum > 10 && DateTime.Now - dtcard > (this.tsbusy + this.tsbusy + this.tsbusy))
            {
                isreset = sum <= 50;
                sum     = sum > 50 ? 51 : sum + 1;
            }
            else
            {
                isreset = sum <= 10;
                sum     = sum > 10 ? 11 : sum + 1;
            }
            TimeSpan tswait = this.waitTime;

            for (int i = 0; i < sum; i++)
            {
                if ("考勤机" == this.devtype)
                {
                    tag = basefun.setvaltag(tag, "{记录索引}", Convert.ToString(this.posRecord));
                }
                cmdP.setCommand("门禁", "读取记录", tag);
                msg = getResponse(this.commimgr, e.Target, cmdP, tswait);
                if ("true" != basefun.valtag(msg, "Success"))
                {
                    break;
                }
                string cardnum = basefun.valtag(msg, "{卡号}");
                if (string.IsNullOrEmpty(cardnum) || "16777215" == cardnum || "0" == cardnum)
                {
                    this.posRecord++;
                    continue;
                }
                string info = "";
                for (int c = 0; c < cols.Length; c++)
                {
                    info = basefun.setvaltag(info, cols[c], basefun.valtag(msg, cols[c]));
                }
                info = basefun.setvaltag(info, "状态", this.getStateDoorCard(basefun.valtag(info, "状态编号")));
                NameObjectList ps = ParamManager.createParam(info);
                ps["控制器"] = this.devid;
                ps["时间"]  = ps["刷卡时间"];
                bool success = this.query.ExecuteNonQuery("采集门禁数据", ps, ps, ps);
                if (!success)
                {
                    ServiceTool.LogMessage(info, null, EventLogEntryType.Warning);
                }
                DateTime dt = Convert.ToDateTime(ps["刷卡时间"]);
                this.AddRecord(info);
                DvRecordEventArgs arg = new DvRecordEventArgs(this.devid, this.station, dt, info);
                this.RaiseRecord(arg);
                if (!success)
                {
                    break;
                }
                this.posRecord++;
                //最后一条提取记录
                if (i == sum - 1 && isreset && this.posRecord > 10000)
                {
                    cmdP.setCommand("门禁", "清空记录", tag);
                    cmdP.ResetState();
                    this.commimgr.SendCommand(this.target, cmdP);
                    if (cmdP.EventWh.WaitOne(this.waitTime, false))
                    {
                        string suc = basefun.valtag(cmdP.ResponseFormat, "Success");
                        if ("true" == suc)
                        {
                            this.query.ExecuteNonQuery("重置记录位置", ps, ps, ps);
                        }
                    }
                }
            }
            this.reChecking(st);
        }