Esempio n. 1
0
        private void FrmRemotGate_Load(object sender, EventArgs e)
        {
            this.paramwin = BindManager.getSystemParam();
            NameObjectList pstrans = BindManager.getTransParam();
            ParamManager.MergeParam(this.paramwin, pstrans);

            unitName = pstrans["name"].ToString();//单元
            this.Text = RemotGroup.Text = unitName;
            //获取当前单元名称
            Dictionary<string, string> dict = new Dictionary<string, string>();
            dict.Add("远程控制记录", "@db=remote_control");

            dict.Add("入、出场记录历史查询", "@db=park_stall");
            //dict.Add("非法开闸记录", "@db=InvalidOpenGate");
            //数据源
            string datasource = dict[this.unitName];
            this.dbGrid.Tag = datasource;

            unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
            //绑定数据
            BindManager bg = new BindManager(this);
            ds = bg.BuildDataset(this.unitItem, this.paramwin);
            bg.BindFld(this, ds);
            //特殊业务处理
            int count = this.dbGrid.Rows.Count - 1;
            if (count < 0)
            {
                count = 0;
            }
            //this.lblCount.Text = "总计 " + Convert.ToString(count) + " 条";
        }
Esempio n. 2
0
        /// <summary>
        /// 根据相应条件查询记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtQuery_Click(object sender, EventArgs e)
        {
            if (this.dateStart.Text == string.Empty)
            {
                XtraMessageBox.Show("请输入开始时间", "系统提示!");
                return;
            }
            if (this.dateEnd.Text == string.Empty)
            {
                XtraMessageBox.Show("请输入结束时间", "系统提示!");
                return;
            }

            NameObjectList pstrans = new NameObjectList();
            ParamManager.MergeParam(pstrans, this.paramwin);
            pstrans["StartDate"] = this.dateStart.EditValue.ToString();
            pstrans["EndDate"] = this.dateEnd.EditValue.ToString();
            pstrans["CommMac"] = this.lookCommMac.Text != null ? this.lookCommMac.Text.ToString() : null;
            //查询数据
            QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);
            BindManager bg = new BindManager(this);
            ds = bg.BuildDataset(this.unitItem, pstrans);
            Report.viwReports View = new Granity.granityMgr.Report.viwReports();
            View.ReportName = "消费机收入汇总";
            View.ds = ds;
            View.StartTime = this.dateStart.Text.Trim();
            View.EndTime = this.dateEnd.Text.Trim();
            View.Activate();
            View.Dock = DockStyle.Fill;
            this.groReport.Controls.Clear();
            this.groReport.Controls.Add(View);
        }
Esempio n. 3
0
        private void FrmTable_Load(object sender, EventArgs e)
        {
            //读取业务单元和传递参数
            this.paramwin = BindManager.getSystemParam();
            NameObjectList pstrans = BindManager.getTransParam();
            ParamManager.MergeParam(this.paramwin, pstrans);

            unitName = pstrans["name"].ToString();//单元
            this.Text = this.CountRecordGroup.Text = unitName;
            //获取当前单元名称
            Dictionary<string, string> dict = new Dictionary<string, string>();
            dict.Add("入场车流量统计表", "@db=入场车流量统计");
            dict.Add("出场车流量统计表", "@db=出场车流量统计");
            dict.Add("停车场收费统计表", "@db=停车场收费统计");
            dict.Add("收费员收费统计表", "@db=收费员收费统计");
            dict.Add("远程控制记录统计表", "@db=stateremote");
            //数据源
            string datasource = dict[this.unitName];
            this.RecordGrid.Tag = datasource;
            NameObjectList ps = new NameObjectList();
            ParamManager.MergeParam(ps, this.paramwin);
            ps["dt"] = this.dtpDate.Value;
            ps["type"] = this.cbRecordTp.SelectedIndex + 1;
            ps["操作员"] = null;
            unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
            //绑定数据
            BindManager bg = new BindManager(this);
            ds = bg.BuildDataset(this.unitItem, ps);
            bg.BindFld(this, ds);
            //特殊业务处理
            this.lbcount.Text = "总记录: " + Convert.ToString(ds.Tables[0].Rows.Count) + " 条";
        }
Esempio n. 4
0
 /// <summary>
 /// 根据数据记录DataRow创建参数
 /// </summary>
 /// <param name="dr">数据记录</param>
 /// <returns>返回新建立的参数</returns>
 public static NameObjectList createParam(DataRow dr)
 {
     NameObjectList ps = new NameObjectList();
     if (null == dr) return ps;
     DataColumnCollection dbcols = dr.Table.Columns;
     foreach (DataColumn dbcol in dbcols)
         ps[dbcol.ColumnName] = dr[dbcol];
     return ps;
 }
Esempio n. 5
0
        /// <summary>
        /// 添加监控管理的设备
        /// </summary>
        /// <param name="devid">请求的客户端</param>
        /// <param name="ispatrol">是否持续巡检</param>
        private void addDevice(string devid, bool ispatrol)
        {
            //设备已经监控,则不再增加设备信息
            DeviceBase[] devices = this.devlist.ToArray();
            for (int i = 0; i < devices.Length; i++)
            {
                if (devid == devices[i].DevID)
                {
                    return;
                }
            }

            //增加设备监控
            Estar.Common.Tools.NameObjectList ps = new Estar.Common.Tools.NameObjectList();
            ps["设备ID"] = devid;
            DataTable tab = this.query.getTable("设备通讯参数", ps);

            if (null == tab || tab.Rows.Count < 1)
            {
                return;
            }
            DataRow dr     = tab.Rows[0];
            string  dvtype = Convert.ToString(dr["通讯协议"]);

            if (string.IsNullOrEmpty(dvtype) || DBNull.Value == dr["站址"])
            {
                return;
            }
            int          station  = Convert.ToInt32(dr["站址"]);
            CommiTarget  target   = this.getTarget(dr);
            CommiManager commimgr = CommiManager.GlobalManager;
            DeviceBase   device   = null;

            switch (dvtype)
            {
            case "门禁":
                device = new DeviceDoor();
                target.setProtocol(Protocol.PTLDoor);
                break;

            case "消费":
                device = new DeviceEatery();
                target.setProtocol(Protocol.PTLEatery);
                break;

            default:
                return;
            }
            device.IsPatrol = ispatrol;
            device.SetDevice(commimgr, target, devid, station);
            this.devlist.Add(device);
            device.RecordHandle += new EventHandler <DvRecordEventArgs>(device_RecordHandle);
            device.SignalHandle += new EventHandler <DvSignalEventArgs>(device_SignalHandle);
            device.AlarmHandle  += new EventHandler <DvAlarmEventArgs>(device_AlarmHandle);
            device.StartGather();
        }
Esempio n. 6
0
 /// <summary>
 /// ��ȡ��������
 /// </summary>
 public void getNewDataByCardNo(string cardno)
 {
     NameObjectList pstrans = new NameObjectList();
     ParamManager.MergeParam(pstrans, this.paramwin);
     pstrans["����"] = cardno;
     //��ѯ����
     QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);
     DataTable tab = dsUnit.Tables["�����"];
     tab.Clear();
     query.FillDataSet(tab.TableName, pstrans, this.dsUnit);
 }
Esempio n. 7
0
 public DataTable getUser()
 {
     //�õ�����Դ
     QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);
     this.dsUnit.Tables["������Ա"].Clear();
     //ִ�в�ѯ����
     NameObjectList ps = new NameObjectList();
     ps["ֵ����"] = cbbAccount.Text;
     query.FillDataSet("������Ա", ps, this.dsUnit);
     return dsUnit.Tables["������Ա"];
 }
Esempio n. 8
0
 private void FrmTest_Load(object sender, EventArgs e)
 {
     //初始化参数和单元
     this.paramwin = BindManager.getSystemParam();
     NameObjectList pstrans = BindManager.getTransParam();
     ParamManager.MergeParam(this.paramwin, pstrans);
     this.unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
     //绑定数据
     BindManager bg = new BindManager(this);
     this.ds = bg.BuildDataset(this.unitItem, this.paramwin);
     bg.BindFld(this, this.ds);
 }
Esempio n. 9
0
 private void FrmCardParam_Load(object sender, EventArgs e)
 {
     //��ȡҵ��Ԫ�ʹ��ݲ���
     this.paramwin = BindManager.getSystemParam();
     NameObjectList pstrans = BindManager.getTransParam();
     ParamManager.MergeParam(this.paramwin, pstrans);
     unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
     //������
     BindManager bg = new BindManager(this);
     this.dsUnit = bg.BuildDataset(this.unitItem, this.paramwin);
     bg.BindFld(this, this.dsUnit);
 }
Esempio n. 10
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);
        }
Esempio n. 11
0
        /// <summary>
        /// 根据参数Xml文档列表生成指定段名的宏变量参数:
        /// </summary>
        /// <param name="xmldoc">文档参数</param>
        /// <param name="bandName">段名称</param>
        /// <returns>返回参数</returns>
        static public NameObjectList BuildParamMacro(XmlDocument xmldoc, string bandName)
        {
            if (string.IsNullOrEmpty(bandName))
            {
                return(BuildParams(xmldoc));
            }
            string         strPath   = "/*/PL[(@t='{0}' and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/P[@pt='M']";
            string         strPass   = "******";
            NameObjectList paramList = new NameObjectList();

            for (int i = _typerange.Length - 1; i > -1; i--)
            {
                for (int j = _typeuser.Length - 1; j > -1; j--)
                {
                    string      strFind = string.Format(strPath, _typerange[i], _typeuser[j], bandName);
                    XmlNodeList xnlist  = xmldoc.SelectNodes(strFind);
                    foreach (XmlNode xnP in xnlist)
                    {
                        if (null == xnP.Attributes["n"])
                        {
                            continue;
                        }
                        string key     = xnP.Attributes["n"].Value;
                        bool   isParam = true;
                        for (int m = i; m > -1; m--)
                        {
                            for (int n = j - 1; n > -1; n--)
                            {
                                string  strFindPass = string.Format(strPass, _typerange[m], _typeuser[n], key, bandName);
                                XmlNode xnPtemp     = xnP.SelectSingleNode(strFindPass);
                                if (null != xnPtemp)
                                {
                                    isParam = false;
                                    break;
                                }
                            }
                            if (!isParam)
                            {
                                break;
                            }
                        }
                        //增加到参数列表
                        if (isParam)
                        {
                            BuildParamList.setParamByParamNode(paramList, xnP);
                        }
                    }//foreach (XmlNode xnP in xnlist)
                }
            }
            return(paramList);
        }
Esempio n. 12
0
 private void Frm_DoorCardInfo_Load(object sender, EventArgs e)
 {
     //初始化参数和单元
     this.paramwin = BindManager.getSystemParam();
     NameObjectList pstrans = BindManager.getTransParam();
     ParamManager.MergeParam(this.paramwin, pstrans);
     this.unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
     //绑定数据0
     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);
 }
Esempio n. 13
0
		/// <summary>
		/// 根据单据类别和部门生成编号
		/// </summary>
		/// <param name="billType">单据类型</param>
		/// <param name="deptCode">部门</param>
		/// <returns></returns>
		static public string	GetBillSn(string	billType,string		deptCode)
		{
			if(""==billType || ""==deptCode)
				return "";
			NameObjectList	paramList=new NameObjectList();
            QueryDataRes query = QueryDataRes.CreateQuerySys();
			paramList.Add("单据类型",billType);
			paramList.Add("部门",deptCode);
            //没有就创建一个
            DataTable tab = query.getTable("单据流水号", paramList);
            if (tab.Rows.Count < 1 || null==tab.Rows[0]["流水号"])
                return "";
            return tab.Rows[0]["流水号"].ToString();
		}
Esempio n. 14
0
        private void FrmSysUsers_Load(object sender, EventArgs e)
        {
            //初始化参数和单元
            this.paramwin = BindManager.getSystemParam();
            NameObjectList pstrans = BindManager.getTransParam();
            ParamManager.MergeParam(this.paramwin, pstrans);
            this.unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);

            //绑定数据
            BindManager bg = new BindManager(this);
            this.dsUnit = bg.BuildDataset(this.unitItem, this.paramwin);
            DataTable tab = dsUnit.Tables["新单位树全集"];
            XunFan(tab);
        }
Esempio n. 15
0
 /// <summary>
 /// ����tag��Ǵ�������
 /// </summary>
 /// <param name="tag">����������tag���</param>
 /// <returns>�����½����IJ���</returns>
 public static NameObjectList createParam(string tag)
 {
     MatchCollection matchs = regex.Matches(tag);
     NameObjectList ps = new NameObjectList();
     foreach (Match m in matchs)
     {
         string key = m.Groups[1].Value;
         string k = key;
         if (key.StartsWith("{") && key.EndsWith("}"))
             k = key.Substring(1, key.Length - 2);
         ps[k] = basefun.valtag(tag, key);
     }
     return ps;
 }
Esempio n. 16
0
 /// <summary>
 /// 根据条件查询相应的记录
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtQuery_Click(object sender, EventArgs e)
 {
     NameObjectList ps = new NameObjectList();
     ps["StartDate"] = this.dateStart.EditValue;
     ps["EndDate"] = this.dateEnd.EditValue;
     ps["Type"] = this.lookType.EditValue;
     ps["Dept"] = this.lookDept.EditValue;
     ps["EmployNO"] = (object)this.txtEmployNo.Text;
     ParamManager.MergeParam(ps, this.paramwin,false);
     //查询数据
     QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);
     DataTable tab = this.grdConsumeList.DataSource as DataTable;
     tab.Clear();
     query.FillDataSet(tab.TableName, ps, this.ds);
 }
Esempio n. 17
0
        private void FrmCarStallSet_Load(object sender, EventArgs e)
        {
            this.paramwin = BindManager.getSystemParam();
            NameObjectList pstrans = BindManager.getTransParam();
            ParamManager.MergeParam(this.paramwin, pstrans);
            unitName = pstrans["name"].ToString();//单元
            this.Text = unitName;
            //获取当前单元名称
            Dictionary<string, string> dict = new Dictionary<string, string>();
            dict.Add("车位组设置", "@db=车位组设置");
            dict.Add("时段设置", "@db=时段设置");
            if (unitName == "车位组设置")
            {
                panel3.Visible = false;
                this.panel4.Dock = System.Windows.Forms.DockStyle.Top;
                this.panel5.Dock = System.Windows.Forms.DockStyle.Top;
            }
            else if (unitName == "时段设置")
            {
                panel4.Visible = false;
                this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
                this.panel5.Dock = System.Windows.Forms.DockStyle.Top;
            }

            //数据源
            string datasource = dict[this.unitName];
            this.dbGrid.Tag = datasource;
            unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
            //绑定数据
            BindManager bg = new BindManager(this);
            ds = bg.BuildDataset(this.unitItem, this.paramwin);
            bg.BindFld(this, ds);
            //列名显示
            if (datasource == "@db=车位组设置")
            {
                string cols = "车组编号 100,名称 301, 数量 150, 备注 205";
                bg.SetGridCols(this.dbGrid, cols);
            }
            if (datasource == "@db=时段设置")
            {
                string cols = "时段编号 80,时段名称 85, 开始时间1 85,截止时间1 85,开始时间2 85,截止时间2 85,";
                cols += "开始日期 83,截止日期 83,星期六 50,星期日 50";
                bg.SetGridCols(this.dbGrid, cols);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 添加监控管理的设备
        /// </summary>
        /// <param name="devid">请求的客户端</param>
        /// <param name="ispatrol">是否持续巡检</param>
        private DeviceBase addDevice(string devid, bool ispatrol)
        {
            //增加设备监控
            Estar.Common.Tools.NameObjectList ps = new Estar.Common.Tools.NameObjectList();
            ps["设备ID"] = devid;
            DataTable tab = this.query.getTable("设备通讯参数", ps);

            if (null == tab || tab.Rows.Count < 1)
            {
                return(null);
            }
            DataRow dr     = tab.Rows[0];
            string  dvtype = Convert.ToString(dr["通讯协议"]);

            if (string.IsNullOrEmpty(dvtype) || DBNull.Value == dr["站址"])
            {
                return(null);
            }
            int          station  = Convert.ToInt32(dr["站址"]);
            CommiTarget  target   = this.getTarget(dr);
            CommiManager commimgr = CommiManager.GlobalManager;
            DeviceBase   device   = null;

            switch (dvtype)
            {
            case "门禁":
                device = new DeviceDoor();
                target.setProtocol(Protocol.PTLDoor);
                break;

            case "消费":
                device = new DeviceEatery();
                target.setProtocol(Protocol.PTLEatery);
                break;

            default:
                return(null);
            }
            device.IsPatrol = ispatrol;
            device.dtBeat   = DateTime.Now;
            device.SetDevice(commimgr, target, devid, station);
            this.devlist.Add(device);
            device.StartGather();
            return(device);
        }
Esempio n. 19
0
 private void FrmCheckWorkList_Load(object sender, EventArgs e)
 {
     //初始化参数和单元
     this.paramwin = BindManager.getSystemParam();
     NameObjectList pstrans = BindManager.getTransParam();
     ParamManager.MergeParam(this.paramwin, pstrans);
     this.unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
     //绑定数据
     BindManager bg = new BindManager(this);
     NameObjectList ps = new NameObjectList();
     ParamManager.MergeParam(ps, this.paramwin);
     this.dateStart.EditValue = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm");
     this.dateEnd.EditValue = System.DateTime.Now.AddDays(1).ToString("yyyy-MM-dd HH:mm");
     ps["StartDate"] = this.dateStart.EditValue.ToString();
     ps["EndDate"] = this.dateEnd.EditValue.ToString();
     ds = bg.BuildDataset(this.unitItem, ps);
     InitLookUp();
 }
Esempio n. 20
0
 private void FormUpDownWork_Load(object sender, EventArgs e)
 {
     //初始化参数和单元
     this.paramwin = BindManager.getSystemParam();
     NameObjectList pstrans = BindManager.getTransParam();
     ParamManager.MergeParam(this.paramwin, pstrans);
     this.unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
     //绑定数据
     BindManager bg = new BindManager(this);
     this.dsUnit = bg.BuildDataset(this.unitItem, this.paramwin);
     bg.BindFld(this, this.dsUnit);
     DataTable tab = this.dsUnit.Tables["接班人员"];
     if (null == tab || tab.Rows.Count < 1)
         return;
     DataTable tabUser = this.dsUnit.Tables["用户信息"];
     foreach (DataRow dr in tabUser.Rows)
         this.ccbNextUser.Items.Add(Convert.ToString(dr["帐号"]));
     tbUserName.Text = BindManager.getUser().UserAccounts;
 }
Esempio n. 21
0
        /// <summary>
        /// ������ͳ��
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtQuery_Click(object sender, EventArgs e)
        {
            if (this.dateStart.Text == string.Empty)
            {
                XtraMessageBox.Show("�����뿪ʼʱ��", "ϵͳ��ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.cboDoorName.Text == string.Empty)
            {
                XtraMessageBox.Show("��ѡ�����Ա", "ϵͳ��ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (this.lookDate.EditValue == null)
            {
                XtraMessageBox.Show("��ѡ����", "ϵͳ��ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            NameObjectList pstrans = new NameObjectList();
            ParamManager.MergeParam(pstrans, this.paramwin);
            pstrans["dt"] = this.dateStart.EditValue.ToString();
            pstrans["type"] = this.lookDate.EditValue.ToString();
            pstrans["UserName"] = Convert.ToString(this.cboDoorName.Text);
            //��ѯ����
            QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);
            BindManager bg = new BindManager(this);
            ds = bg.BuildDataset(this.unitItem, pstrans);
            //if (ds.Tables["�շ�Ա�շ�ͳ��"].Rows.Count < 1 || ds.Tables["�շ�Ա�շ�ͳ��"] == null)
            //{
            //    XtraMessageBox.Show("û�����ݣ�", "ϵͳ��ʾ��", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    this.groReport.Controls.Clear();
            //    return;
            //}
            Granity.granityMgr.Report.viwReports View = new Granity.granityMgr.Report.viwReports();
            View.ReportName = "�շ�Ա�շ�ͳ��";
            View.ds = ds;
            View.StartTime = this.dateStart.Text.Trim();
            View.EndTime = "";
            View.Activate();
            View.Dock = DockStyle.Fill;
            this.groReport.Controls.Clear();
            this.groReport.Controls.Add(View);
        }
Esempio n. 22
0
 /// <summary>
 /// 根据数据表创建参数列表
 /// </summary>
 /// <param name="tab">数据表</param>
 /// <returns>返回参数列表</returns>
 public static NameObjectList[] createParam(DataTable tab, DataRowState state)
 {
     if (null == tab || tab.Rows.Count < 1)
         return new NameObjectList[0];
     List<NameObjectList> psList = new List<NameObjectList>();
     DataView dvsub = new DataView(tab, "", "", DataViewRowState.ModifiedCurrent | DataViewRowState.Added | DataViewRowState.Deleted);
     DataColumnCollection cols = tab.Columns;
     int len = cols.Count;
     for (int i = 0; i < dvsub.Count; i++)
     {
         if (state != dvsub[i].Row.RowState)
             continue;
         DataRowView drv = dvsub[i];
         NameObjectList ps = new NameObjectList();
         for (int c = 0; c < len; c++)
             ps[cols[c].ColumnName] = drv[c];
         psList.Add(ps);
     }
     return psList.ToArray();
 }
Esempio n. 23
0
        /// <summary>
        /// 根据开始时间,结束时间查询开门记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtQuery_Click(object sender, EventArgs e)
        {
            if( this.dateStart.Text ==string.Empty )
            {
                XtraMessageBox.Show("请输入开始时间","系统提示!");
                return;
            }
            if (this.dateEnd.Text == string.Empty)
            {
                XtraMessageBox.Show("请输入结束时间", "系统提示!");
                return;
            }

            string  dataStart= this.dateStart.Text.Trim();
            string dataEnd = this.dateEnd.Text.Trim();
            string where = " 时间 >=  '" + dataStart + "' and 时间 <= '" + dataEnd + "' ";
            if (this.lookDoor.EditValue != null && this.lookDoor.EditValue.ToString() != "全部")
            {
                where += " and 门编号='" + this.lookDoor.EditValue.ToString() + "'";
            }
            this.paramwin = BindManager.getSystemParam();
            NameObjectList ps = new NameObjectList();
            ps["StartDate"] = this.dateStart.EditValue.ToString();
            ps["EndDate"] = this.dateEnd.EditValue.ToString();
            ParamManager.MergeParam(ps, this.paramwin, false);
            this.unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
            this.ds = this.bindMgr.BuildDataset(this.unitItem,ps);
            DataTable dt = this.ds.Tables["刷卡记录"].Clone();
            DataTable dtReport = FunShare.GetTable(dt, this.ds.Tables["刷卡记录"].Select(where));
            Report.viwReports View = new viwReports();
            View.ReportName = "刷卡报表";
            View.dt = dt;
            View.StartTime = this.dateStart.Text.Trim();
            View.EndTime = this.dateEnd.Text.Trim();
            View.Activate();
            View.Dock = DockStyle.Fill;
            this.groReport.Controls.Clear();
            this.groReport.Controls.Add(View);
        }
Esempio n. 24
0
 private void FrmDepart_Load(object sender, EventArgs e)
 {
     //读取业务单元和传递参数
     this.paramwin = BindManager.getSystemParam();
     NameObjectList pstrans = BindManager.getTransParam();
     ParamManager.MergeParam(this.paramwin, pstrans);
     unitName = pstrans["name"].ToString();//单元
     //获取当前单元名称
     Dictionary<string, string> dict = new Dictionary<string, string>();
     dict.Add("组织机构管理", "@db=组织机构");
     //数据源
     string datasource = dict[this.unitName];
     NameObjectList ps = new NameObjectList();
     ParamManager.MergeParam(ps, this.paramwin);
     ps["UnitCode"] = "10";
     unitItem = new UnitItem(DataAccRes.AppSettings("WorkConfig"), unitName);
     //绑定数据
     BindManager bg = new BindManager(this);
     dsUnit = bg.BuildDataset(this.unitItem, ps);
     bg.BindFld(this, dsUnit);
     //对树的操作
     bg.BindTrv(this.trvDept, this.dsUnit.Tables["组织机构"], "名称", "ID", "PID", "@名称={名称},@代码={代码},@序号={序号},@ParentCode={ParentCode},@独立管理={独立管理},@分类={分类},@性质={性质},@部门主管={部门主管},@部门职责={部门职责},@班次代码={班次代码},@班次名称={班次名称},@周一={周},@周二={周二},@周三={周三},@周四={周四},@周五={周五},@周六={周六},@周日={周日},@level={level}");
     this.trvDept.ExpandAll();
 }
 /// <summary>
 /// 年月日报表统计
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtQuery_Click(object sender, EventArgs e)
 {
     if (this.dateStart.Text == string.Empty)
     {
         XtraMessageBox.Show("请输入开始时间", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     if (this.lookDate.EditValue == null)
     {
         XtraMessageBox.Show("请选择表报", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         return;
     }
     NameObjectList pstrans = new NameObjectList();
     ParamManager.MergeParam(pstrans, this.paramwin);
     pstrans["dt"] = this.dateStart.EditValue.ToString();
     pstrans["type"] = this.lookDate.EditValue.ToString();
     //查询数据
     QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);
     BindManager bg = new BindManager(this);
     ds = bg.BuildDataset(this.unitItem, pstrans);
     //if (ds.Tables["入场车流量统计"] == null || ds.Tables["入场车流量统计"].Rows.Count < 1)
     //{
     //    XtraMessageBox.Show("没有数据!", "系统提示!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     //    this.groReport.Controls.Clear();
     //    return;
     //}
     Granity.granityMgr.Report.viwReports View = new Granity.granityMgr.Report.viwReports();
     View.ReportName = "入场车流量统计表";
     View.ds = ds;
     View.StartTime = this.dateStart.Text.Trim();
     View.EndTime = "";
     View.Activate();
     View.Dock = DockStyle.Fill;
     this.groReport.Controls.Clear();
     this.groReport.Controls.Add(View);
 }
Esempio n. 26
0
        /// <summary>
        /// 根据条件,查询出相应的记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtQuery_Click(object sender, EventArgs e)
        {
            if ( this.dateStart.Text ==string.Empty )
               {
               XtraMessageBox.Show("请输入开始时间","系统提示!");
               return;
               }
               if (this.dateEnd.Text == string.Empty)
               {
               XtraMessageBox.Show("请输入结束时间", "系统提示!");
               return;
               }

               NameObjectList pstrans = new NameObjectList();
               ParamManager.MergeParam(pstrans, this.paramwin);
               pstrans["StartDate"] = this.dateStart.EditValue.ToString();
               pstrans["EndDate"] = this.dateEnd.EditValue.ToString();
               //查询数据
               QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);
               DataTable tab = this.grdConsumeList.DataSource as DataTable;
               if (null == tab) return;
               tab.Clear();
               query.FillDataSet(tab.TableName, pstrans, this.ds);
        }
Esempio n. 27
0
        /// <summary>
        /// 根据参数Xml文档列表生成指定段对应参数:数组List只限定于PL[@t='B']/L[@='D']/List
        /// </summary>
        /// <param name="xmldoc">文档参数</param>
        /// <param name="bandName">段名称</param>
        /// <returns>返回参数数组</returns>
        static public NameObjectList[] BuildParamsList(XmlDocument xmldoc, string   bandName)
        {
            if (string.IsNullOrEmpty(bandName))
                return BuildParamsList(xmldoc);
            string strPath  = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/P[not(@pt) or @pt!='M']";
            string strPath2 = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/List/P";
            string strPass  = "******";
            string strPass2 = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{3}')]/L[@t='{1}']/List/P[@n='{2}']";
            NameObjectList paramList = new NameObjectList();
            for (int i = _typerange.Length - 1; i > -1; i--)
                for (int j = _typeuser.Length - 1; j > -1; j--)
                {
                    string strFind = string.Format(strPath, _typerange[i], _typeuser[j], bandName);
                    if (null != xmldoc.SelectSingleNode(string.Format(strPath2, _typerange[i], _typeuser[j], bandName)))
                        continue;
                    XmlNodeList xnlist = xmldoc.SelectNodes(strFind);
                    foreach (XmlNode xnP in xnlist)
                    {
                        if (null == xnP.Attributes["n"]) continue;
                        string key = xnP.Attributes["n"].Value;
                        bool isParam = true;
                        for (int m = i; m > -1; m--)
                        {
                            for (int n = j - 1; n > -1; n--)
                            {
                                string strFindPass = string.Format(strPass, _typerange[m], _typeuser[n], key, bandName);
                                XmlNode xnPtemp = xnP.SelectSingleNode(strFindPass);
                                if (null != xnPtemp)
                                {
                                    isParam = false;
                                    break;
                                }
                                string strFindPass2 = string.Format(strPass2, _typerange[m], _typeuser[n], key, bandName);
                                xnPtemp = xnP.SelectSingleNode(strFindPass2);
                                if (null != xnPtemp)
                                {
                                    isParam = false;
                                    break;
                                }
                            }
                            if (!isParam) break;
                        }
                        //增加到参数列表
                        if (isParam)
                            BuildParamList.setParamByParamNode(paramList, xnP);
                    }//foreach (XmlNode xnP in xnlist)
                }

            strPath2 = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/List";
            string strFind2 = string.Format(strPath2, "B", "D",bandName);
            XmlNodeList xnlistList = xmldoc.SelectNodes(strFind2);
            NameObjectList[] param = new NameObjectList[xnlistList.Count];
            for (int i = 0; i < xnlistList.Count; i++)
            {
                param[i] = new NameObjectList();
                for (int k = 0; k < paramList.Count; k++)
                    param[i][paramList.Keys[k]] = paramList[k];
                XmlNodeList xnlist = xnlistList[i].SelectNodes("P");
                foreach (XmlNode xnP in xnlist)
                    BuildParamList.setParamByParamNode(param[i], xnP);
            }
            return param;
        }
Esempio n. 28
0
 /// <summary>
 /// 设置节点值参数
 /// </summary>
 /// <param name="param">参数表</param>
 /// <param name="xmlNodeValue">值节点</param>
 /// <param name="xmlNodeCol">列结构节点</param>
 private void setParam(NameObjectList param, XmlNode xmlNodeValue, XmlNode xmlNodeCol)
 {
     if (null == param || null == xmlNodeCol || null == xmlNodeCol.Attributes["name"])
         return;
     string colname = xmlNodeCol.Attributes["name"].Value;
     string strvalue = "";
     if (null == xmlNodeValue)
     {
         param[colname] = DBNull.Value;
         return;
     }
     if (null != xmlNodeValue.FirstChild && XmlNodeType.Text == xmlNodeValue.FirstChild.NodeType)
         strvalue = xmlNodeValue.FirstChild.Value;
     string strDBType = "";
     if (null != xmlNodeCol.Attributes["msdata:DataType"] && xmlNodeCol.Attributes["msdata:DataType"].Value.StartsWith("System.Guid"))
         strDBType = "guid";
     if ("ID" == colname.ToUpper())
         strDBType = "guid";
     if ("" == strDBType)
         strDBType = xmlNodeCol.Attributes["type"].Value.ToLower();
     if ("" == strvalue && "guid" != strDBType)
     {
         param[colname] = DBNull.Value;
         return;
     }
     try
     {
         switch (strDBType)
         {
             case "xs:string":
                 if (null != xmlNodeCol.Attributes["msdata:DataType"] && xmlNodeCol.Attributes["msdata:DataType"].Value.StartsWith("System.Guid"))
                 {
                     if ("" == strvalue)
                         param[colname] = DBNull.Value;
                     else
                         param[colname] = new Guid(strvalue);
                 }
                 else
                     param[colname] = strvalue;
                 break;
             case "xs:int":
                 param[colname] = Convert.ToInt16(strvalue);
                 break;
             case "xs:double":
             case "xs:decimal":
             case "xs:float":
                 param[colname] = Convert.ToDecimal(strvalue);
                 break;
             case "xs:datetime":
             case "xs:date":
                 param[colname] = DateTime.Parse(strvalue);
                 break;
             case "xs:boolean":
                 if ("0" == strvalue || "false" == strvalue.ToLower())
                 {
                     xmlNodeValue.FirstChild.Value = "false";
                     strvalue = "false";
                 }
                 else
                 {
                     xmlNodeValue.FirstChild.Value = "true";
                     strvalue = "true";
                 }
                 param[colname] = Convert.ToBoolean(strvalue);
                 break;
             case "guid":
                 if ("" == strvalue)
                 {
                     strvalue = Guid.NewGuid().ToString();
                     xmlNodeValue.InnerText = strvalue;
                 }
                 if (null != xmlNodeCol.Attributes["msdata:DataType"] && xmlNodeCol.Attributes["msdata:DataType"].Value.StartsWith("System.Guid"))
                     param[colname] = new Guid(strvalue);
                 else
                     param[colname] = strvalue;
                 break;
             default:
                 param[colname] = strvalue;
                 break;
         }
     }
     catch
     {
         param[colname] = DBNull.Value;
     }//try
 }
Esempio n. 29
0
 /// <summary>
 /// 生成删除参数数组
 /// </summary>
 /// <returns></returns>
 private NameObjectList[] CreateDelParamLists()
 {
     BasePage page = this.Page as BasePage;
     XmlNodeList xmlNodeRows = this.CtrlXmlDelete.Document.SelectNodes("//*[@state='delete']");
     if (xmlNodeRows.Count < 1) return new NameObjectList[0];
     XmlNodeList xmlColList = this.CtrlXmlSchema.Document.SelectNodes("//xs:sequence//xs:element", this._xmlNsMglSchema);
     NameObjectList[] paramList = new NameObjectList[xmlNodeRows.Count];
     NameObjectList param = BuildParamList.BuildParams(page.PgParamXmlDoc);
     for (int i = 0; i < xmlNodeRows.Count; i++)
     {
         if (null == paramList[i]) paramList[i] = new NameObjectList();
         for (int j = 0; j < param.Count; j++)
             paramList[i][param.Keys[j]] = param[param.Keys[j]];
         for (int j = 0; j < xmlColList.Count; j++)
         {
             XmlNode xmlNodeValue = xmlNodeRows[i].SelectSingleNode(xmlColList[j].Attributes["name"].Value);
             this.setParam(paramList[i], xmlNodeValue, xmlColList[j]);
         }
     }
     return paramList;
 }
Esempio n. 30
0
 /// <summary>
 /// ����ͣ������Ʊ��
 /// </summary>
 private void searchPark()
 {
     QueryDataRes query = new QueryDataRes("cardone");
     NameObjectList ps = new NameObjectList();
     DataTable tab = query.getTable("devlist", ps);
     if (null == tab || tab.Rows.Count < 1)
         return;
     for (int i = 0; i < tab.Rows.Count; i++)
     {
         DataRow dr = tab.Rows[i];
         string commitype = Convert.ToString(dr["���ʷ�ʽ"]);
         if ("1" == commitype) commitype = "Ser";
         if ("2" == commitype) commitype = "TCP";
         if ("Ser" != commitype && "TCP" != commitype)
             commitype = "UDP";
         string port = Convert.ToString(dr["�˿�"]);
         if ("Ser" == commitype)
             port = "COM" + port;
         //����ֶ�˳�����, �豸����, �豸����, IP��ַ, �˿�, ͨѶ���, ͨѶվַ, ��������, Ĭ������, �����ַ
         string[] ipAddrs = new string[10];
         ipAddrs[0] = i.ToString();
         ipAddrs[1] = "ͣ������Ʊ��";
         ipAddrs[2] = Convert.ToString(dr["����"]);
         ipAddrs[3] = Convert.ToString(dr["��ַ"]);
         ipAddrs[4] = port;
         ipAddrs[5] = commitype;
         ipAddrs[6] = Convert.ToString(dr["�豸��ַ"]);
         ipAddrs[7] = "";
         ipAddrs[8] = "";
         ipAddrs[9] = "";
         DataGridViewRow drPark = this.getRow(ipAddrs[3], port, ipAddrs[6]);
         if (null != drPark)
             drPark.SetValues(ipAddrs);
         else
             this.gdGrid.Rows.Add(ipAddrs);
     }
 }
Esempio n. 31
0
        /// <summary>
        /// 根据<Param name="" value="" type=""></Param>节点设置参数
        /// </summary>
        /// <param name="paramList">参数列表</param>
        /// <param name="xmlParam">xml的参数值</param>
        static private void             setParamByParamNode(NameObjectList paramList, XmlNode xmlParam)
        {
            string strName = ""; string strValue = ""; string strtype = "";

            if (null == xmlParam.Attributes["name"] && null == xmlParam.Attributes["n"])
            {
                return;
            }
            if (null != xmlParam.Attributes["name"])
            {
                strName = xmlParam.Attributes["name"].Value;
            }
            else
            {
                strName = xmlParam.Attributes["n"].Value;
            }
            if (null != xmlParam.Attributes["value"])
            {
                strValue = xmlParam.Attributes["value"].Value;
            }
            else if (null != xmlParam.Attributes["v"])
            {
                strValue = xmlParam.Attributes["v"].Value;
            }
            if (null != xmlParam.Attributes["type"])
            {
                strtype = xmlParam.Attributes["type"].Value;
            }
            else if (null != xmlParam.Attributes["t"])
            {
                strtype = xmlParam.Attributes["t"].Value;
            }

            try
            {
                if (string.IsNullOrEmpty(strValue) && null == paramList[strName])
                {
                    paramList[strName] = DBNull.Value;
                    return;
                }
                //if (paramList[strName].ToString() != "" && strValue=="") return;
                if (string.IsNullOrEmpty(strtype))
                {
                    try
                    {
                        Guid guid = new Guid(strValue);
                        paramList[strName] = guid;
                    }
                    catch
                    {
                        paramList[strName] = strValue;
                    }
                }
                else
                {
                    switch (strtype.ToLower())
                    {
                    case "int":
                    case "i":
                        paramList[strName] = int.Parse(strValue);
                        break;

                    case "decimal":
                    case "f":
                        paramList[strName] = decimal.Parse(strValue);
                        break;

                    case "bool":
                    case "b":
                        paramList[strName] = bool.Parse(strValue);
                        break;

                    case "datetime":
                    case "date":
                    case "d":
                        paramList[strName] = DateTime.Parse(strValue);
                        break;

                    case "string":
                    case "s":
                        paramList[strName] = strValue;
                        break;

                    case "guid":
                        paramList[strName] = new Guid(strValue);
                        break;

                    case "macro":
                        break;

                    default:                                    //可能是Guid
                        paramList[strName] = strValue;
                        break;
                    }
                }
            }
            catch
            {
                if (null == paramList[strName])
                {
                    paramList[strName] = DBNull.Value;
                }
            }
        }
Esempio n. 32
0
        /// <summary>
        /// 设置设备指令,使用dvID做指令ID
        /// </summary>
        /// <param name="tpl">协议类型</param>
        /// <param name="cmd">指令</param>
        /// <param name="tagdata">数据参数,使用tag标记格式</param>
        public bool setCommand(string tpl, string cmd, string tagdata)
        {
            //if (string.IsNullOrEmpty(tpl) || string.IsNullOrEmpty(cmd) || CmdState.Response == this.CheckState())
            //    return false;

            PtlParam ptlParam = new PtlParam();

            if (PTLParam.ContainsKey(tpl + ":" + cmd))
            {
                ptlParam = PTLParam[tpl + ":" + cmd];
            }
            else
            {
                Estar.Common.Tools.NameObjectList ps = new Estar.Common.Tools.NameObjectList();
                ps["tpl"] = tpl;
                ps["cmd"] = cmd;
                if (null == this.query)
                {
                    return(false);
                }
                DataTable tab = this.query.getTable(dbItem, ps);
                if (null == tab || tab.Rows.Count < 1)
                {
                    return(false);
                }
                //从数据库中取出的参数转换成tag格式参数
                DataColumnCollection dbcols = tab.Columns;
                if (!dbcols.Contains("type") || !dbcols.Contains("pms"))
                {
                    return(false);
                }
                foreach (DataRow dr in tab.Rows)
                {
                    if (DBNull.Value == dr["type"])
                    {
                        continue;
                    }
                    string pmtype = Convert.ToString(dr["type"]);
                    switch (pmtype)
                    {
                    case "协议":
                        ptlParam.pmdevice = Convert.ToString(dr["pms"]);
                        break;

                    case "Input":
                        ptlParam.pminput += Convert.ToString(dr["pms"]) + ";";
                        break;

                    case "Output":
                        ptlParam.pmout += Convert.ToString(dr["pms"]) + ";";
                        break;
                    }
                }
                if (ptlParam.pmdevice.EndsWith(";"))
                {
                    ptlParam.pmdevice = ptlParam.pmdevice.Substring(0, ptlParam.pmdevice.Length - 1);
                }
                if (string.IsNullOrEmpty(ptlParam.pmdevice))
                {
                    return(false);
                }
                if (ptlParam.pminput.EndsWith(";"))
                {
                    ptlParam.pminput = ptlParam.pminput.Substring(0, ptlParam.pminput.Length - 1);
                }
                if (ptlParam.pmout.EndsWith(";"))
                {
                    ptlParam.pmout = ptlParam.pmout.Substring(0, ptlParam.pmout.Length - 1);
                }
                ptlParam.pmdevice = ptlParam.pmdevice.Replace(";;", ";");
                ptlParam.pminput  = ptlParam.pminput.Replace(";;", ";");
                ptlParam.pmout    = ptlParam.pmout.Replace(";;", ";");
                if (!PTLParam.ContainsKey(tpl + ":" + cmd))
                {
                    try { PTLParam.Add(tpl + ":" + cmd, ptlParam); }
                    catch { }
                }
            }
            this.inputParam     = ptlParam.pminput;
            this.outterParam    = ptlParam.pmout;
            this.responseFormat = "";
            //根据协议组成通讯指令
            string pmdevice = basefun.setvaltag(ptlParam.pmdevice, "devid", basefun.valtag(tagdata, "设备地址"));

            dvParam.Command = "";
            string cmdstr = "";

            if (string.IsNullOrEmpty(tagdata))
            {
                dvParam = this.setDevObj(pmdevice);
            }
            else
            {
                cmdstr = comparse.CommandString(pmdevice, ptlParam.pminput, tagdata, ref dvParam);
            }
            IsAscii   = dvParam.IsAsc;
            Exchanges = dvParam.Exchanges;
            if (string.IsNullOrEmpty(dvParam.Buss))
            {
                dvParam.Buss = tpl;
            }
            if (string.IsNullOrEmpty(dvParam.Command))
            {
                dvParam.Command = cmd;
            }
            //没有数据参数,则只获取格式参数,便于解析结果
            if (string.IsNullOrEmpty(tagdata))
            {
                return(true);
            }
            //转义成字节,使用""""代替原来帧头帧尾的处理
            if (dvParam.IsAsc)
            {
                if (cmdstr.StartsWith("02") && cmdstr.EndsWith("03"))
                {
                    cmdstr = "" + cmdstr.Substring(2, cmdstr.Length - 4) + "";
                }

                return(this.setCommand(cmdstr));
            }
            return(this.setCommand(cmdstr, true));
        }
Esempio n. 33
0
        /// <summary>
        /// 设置设备指令,使用dvID做指令ID
        /// </summary>
        /// <param name="tpl">协议类型</param>
        /// <param name="cmd">指令</param>
        /// <param name="tagdata">数据参数,使用tag标记格式</param>
        public bool setCommand(string tpl, string cmd, string tagdata)
        {
            if (CmdState.Response == this.CheckState())
            {
                return(false);
            }
            Estar.Common.Tools.NameObjectList ps = new Estar.Common.Tools.NameObjectList();
            ps["tpl"] = tpl;
            ps["cmd"] = cmd;
            DataTable tab = query.getTable(dbItem, ps);

            if (null == tab || tab.Rows.Count < 1)
            {
                return(false);
            }
            //设备参数
            string pmdevice = "";
            //输入格式参数
            string pminput = "";
            //输出格式参数
            string pmout = "";

            //从数据库中取出的参数转换成tag格式参数
            DataColumnCollection dbcols = tab.Columns;

            if (!dbcols.Contains("type") || !dbcols.Contains("pms"))
            {
                return(false);
            }
            foreach (DataRow dr in tab.Rows)
            {
                if (DBNull.Value == dr["type"])
                {
                    continue;
                }
                string pmtype = Convert.ToString(dr["type"]);
                switch (pmtype)
                {
                case "协议":
                    pmdevice = Convert.ToString(dr["pms"]);
                    break;

                case "Input":
                    pminput += Convert.ToString(dr["pms"]) + ";";
                    break;

                case "Output":
                    pmout += Convert.ToString(dr["pms"]) + ";";
                    break;
                }
            }

            if (pmdevice.EndsWith(";"))
            {
                pmdevice = pmdevice.Substring(0, pmdevice.Length - 1);
            }
            if (pminput.EndsWith(";"))
            {
                pminput = pminput.Substring(0, pminput.Length - 1);
            }
            if (pmout.EndsWith(";"))
            {
                pmout = pmout.Substring(0, pmout.Length - 1);
            }
            pmdevice         = pmdevice.Replace(";;", ";");
            this.inputParam  = pminput = pminput.Replace(";;", ";");
            this.outterParam = pmout = pmout.Replace(";;", ";");

            // begin 临时补充,在将来完善协议解析后去掉
            pmdevice = basefun.setvaltag(pmdevice, "devid", basefun.valtag(tagdata, "设备地址"));
            // end
            string cmdstr = comparse.CommandString(pmdevice, pminput, tagdata, ref dvParam);

            IsAscii   = dvParam.IsAsc;
            Exchanges = dvParam.Exchanges;
            //转义成字节,使用""""代替原来帧头帧尾的处理
            if (dvParam.IsAsc)
            {
                if (cmdstr.StartsWith("02") && cmdstr.EndsWith("03"))
                {
                    cmdstr = "" + cmdstr.Substring(2, cmdstr.Length - 4) + "";
                }
                return(this.setCommand(cmdstr));
            }
            return(this.setCommand(cmdstr, true));
        }
Esempio n. 34
0
        /// <summary>
        /// 对同一个target循环执行数据记录关联的指令,执行成功后执行sql更新
        /// </summary>
        /// <param name="drs">指令数据数组</param>
        /// <param name="colmap">字段与指令的映射</param>
        /// <param name="tpl">指令协议类别:停车场/消费/门禁/考勤/卡务中心</param>
        /// <param name="cmd">指令命令名称</param>
        /// <param name="target">通讯目标位置</param>
        /// <param name="deviceID">设备下位机地址</param>
        /// <param name="query">数据更新执行实例</param>
        /// <param name="dbItem">执行更新的数据项</param>
        /// <returns>成功执行返回空,失败返回错误原因</returns>
        public static string ExecuteDataRows(DataRow[] drs, string[,] colmap, string tpl, string cmd, CommiTarget target, string deviceID, QueryDataRes query, string dbItem)
        {
            if (null == drs || drs.Length < 1 || null == colmap || colmap.GetLength(1) < 2 || string.IsNullOrEmpty(tpl) || string.IsNullOrEmpty(cmd))
            {
                return("");
            }
            if (null == target || string.IsNullOrEmpty(deviceID))
            {
                return("");
            }
            //声明一个集合来储存数据
            List <DataRow> drList = new List <DataRow>();
            string         msg    = "";

            //执行指令
            CmdProtocol cmdP = new CmdProtocol(deviceID, false);

            //循环得到传过来的数据
            foreach (DataRow dr in drs)
            {
                if (null == dr)
                {
                    continue;
                }
                string tagdata = "@设备地址=" + deviceID;
                for (int c = 0; c < colmap.GetLength(0); c++)
                {
                    object val = dr[colmap[c, 1]];
                    if (true.Equals(val))
                    {
                        val = "1";
                    }
                    if (false.Equals(val))
                    {
                        val = "0";
                    }
                    tagdata = basefun.setvaltag(tagdata, colmap[c, 0], Convert.ToString(val));
                }
                //设置指令
                cmdP.setCommand(tpl, cmd, tagdata);
                cmdP.ResetState();
                //发送指令
                CommiManager.GlobalManager.SendCommand(target, cmdP);
                if (!cmdP.EventWh.WaitOne(2000, false))
                {
                    msg = basefun.setvaltag(tagdata, "{状态}", "通讯超时失败!");
                    break;
                }
                if (string.IsNullOrEmpty(cmdP.ResponseFormat))
                {
                    msg = basefun.setvaltag(tagdata, "{状态}", tagdata + "指令错误!");
                    break;
                }
                drList.Add(dr);
            }
            //更新数据库
            //判断数据源和存储过程是否为空
            if (null == query || string.IsNullOrEmpty(dbItem))
            {
                return(msg);
            }
            //得到数据的数量
            Estar.Common.Tools.NameObjectList[] ps = new Estar.Common.Tools.NameObjectList[drList.Count];
            for (int i = 0; i < drList.Count; i++)
            {
                ps[i] = ParamManager.createParam(drList[i]);
            }
            //得到数据与配置的数据已经保持一致,但发现没有执行存储过程。。。
            //执行数据库操作(方法封装在query内)
            bool success = query.ExecuteNonQuery(dbItem, ps, ps, ps);

            if (!success)
            {
                msg = basefun.setvaltag(msg, "{状态}", basefun.valtag(msg, "{状态}") + "更新数据库失败!");
            }
            return(msg);
        }
Esempio n. 35
0
 /// <summary>
 /// 根据参数Xml文档列表生成指定段名的宏变量参数:
 /// </summary>
 /// <param name="xmldoc">文档参数</param>
 /// <param name="bandName">段名称</param>
 /// <returns>返回参数</returns>
 static public NameObjectList BuildParamMacro(XmlDocument xmldoc, string bandName)
 {
     if (string.IsNullOrEmpty(bandName))
         return BuildParams(xmldoc);
     string strPath = "/*/PL[(@t='{0}' and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/P[@pt='M']";
     string strPass = "******";
     NameObjectList paramList = new NameObjectList();
     for (int i = _typerange.Length - 1; i > -1; i--)
         for (int j = _typeuser.Length - 1; j > -1; j--)
         {
             string strFind = string.Format(strPath, _typerange[i], _typeuser[j], bandName);
             XmlNodeList xnlist = xmldoc.SelectNodes(strFind);
             foreach (XmlNode xnP in xnlist)
             {
                 if (null == xnP.Attributes["n"]) continue;
                 string key = xnP.Attributes["n"].Value;
                 bool isParam = true;
                 for (int m = i; m > -1; m--)
                 {
                     for (int n = j - 1; n > -1; n--)
                     {
                         string strFindPass = string.Format(strPass, _typerange[m], _typeuser[n], key, bandName);
                         XmlNode xnPtemp = xnP.SelectSingleNode(strFindPass);
                         if (null != xnPtemp)
                         {
                             isParam = false;
                             break;
                         }
                     }
                     if (!isParam) break;
                 }
                 //增加到参数列表
                 if (isParam)
                     BuildParamList.setParamByParamNode(paramList, xnP);
             }//foreach (XmlNode xnP in xnlist)
         }
     return paramList;
 }
Esempio n. 36
0
        /// <summary>
        /// ��ʼ��������
        /// </summary>
        public void initCmdCard()
        {
            IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
            string myip = IpEntry.AddressList[0].ToString();

            NameObjectList pstrans = new NameObjectList();
            ParamManager.MergeParam(pstrans, this.paramwin);
            pstrans["IP��ַ"] = myip;
            //��ѯ����
            QueryDataRes query = new QueryDataRes(this.unitItem.DataSrcFile);
            DataTable tab = dsUnit.Tables["�豸����"];
            tab.Clear();
            query.FillDataSet(tab.TableName, pstrans, this.dsUnit);
            if (null == tab || tab.Rows.Count < 1) return;
            if (tab.Rows.Count < 1)
            {
                MessageBox.Show("�����÷�����");
                return;
            }
            DataRow dr = this.dsUnit.Tables["�豸����"].Rows[0];
            string port = Convert.ToString(dr["����"]);
            int baudrate = Convert.ToInt32(dr["������"]);
            Parity parity = Parity.None;
            int databits = Convert.ToInt32(dr["����λ"]);
            StopBits stopbits = StopBits.One;
            switch (Convert.ToString(dr["ֹͣλ"]))
            {
                case "1.5λ": stopbits = StopBits.OnePointFive; break;
                case "2λ": stopbits = StopBits.Two; break;
                default: stopbits = StopBits.One; break;
            }
            CommiTarget target = new CommiTarget(port, baudrate, parity, databits, stopbits);
            int addrst = Convert.ToInt32(dr["վַ"]);
            bool success = this.cmdCard.SetTarget(target, addrst, this.radic.Checked);
            if (success)
                this.cmdCard.Buzz(true);
        }
Esempio n. 37
0
		/// <summary>
		/// 根据<Param name="" value="" type=""></Param>节点设置参数
		/// </summary>
		/// <param name="paramList">参数列表</param>
		/// <param name="xmlParam">xml的参数值</param>
		static private void		setParamByParamNode(NameObjectList	paramList,XmlNode	xmlParam)
		{
            string strName = ""; string strValue = ""; string strtype = "";
            if (null == xmlParam.Attributes["name"] && null == xmlParam.Attributes["n"])
                return;
            if (null != xmlParam.Attributes["name"])
                strName = xmlParam.Attributes["name"].Value;
            else
                strName = xmlParam.Attributes["n"].Value;
            if (null != xmlParam.Attributes["value"])
                strValue = xmlParam.Attributes["value"].Value;
            else if (null != xmlParam.Attributes["v"])
                strValue = xmlParam.Attributes["v"].Value;
            if (null != xmlParam.Attributes["type"])
                strtype = xmlParam.Attributes["type"].Value;
            else if (null != xmlParam.Attributes["t"])
                strtype = xmlParam.Attributes["t"].Value;

			try
			{
                if (string.IsNullOrEmpty(strValue) && null == paramList[strName])
                {
                    paramList[strName] = DBNull.Value;
                    return;
                }
                //if (paramList[strName].ToString() != "" && strValue=="") return; 
				if(string.IsNullOrEmpty(strtype))
				{
					try
					{
						Guid	guid=new Guid(strValue);
						paramList[strName]=guid;
					}
					catch
					{
						paramList[strName]=strValue;
					}
				}else
					switch(strtype.ToLower())
					{
						case "int":
                        case "i":
							paramList[strName]=int.Parse(strValue);
							break;
						case "decimal":
                        case "f":
							paramList[strName]=decimal.Parse(strValue);
							break;
						case "bool":
                        case "b":
							paramList[strName]=bool.Parse(strValue);
							break;
						case "datetime":
                        case "date":
                        case "d":
							paramList[strName]=DateTime.Parse(strValue);
							break;
						case "string":
                        case "s":
								paramList[strName]=strValue;
							break;
						case "guid":
							paramList[strName]=new Guid(strValue);
							break;
                        case "macro":
                            break;
						default:	//可能是Guid
							paramList[strName]=strValue;
							break;
					}
			}
			catch
			{
				if(null==paramList[strName])
					paramList[strName]=DBNull.Value;
			}
        }
Esempio n. 38
0
        /// <summary>
        /// 根据参数Xml文档列表生成指定段对应参数:数组List只限定于PL[@t='B']/L[@='D']/List
        /// </summary>
        /// <param name="xmldoc">文档参数</param>
        /// <param name="bandName">段名称</param>
        /// <returns>返回参数数组</returns>
        static public NameObjectList[] BuildParamsList(XmlDocument xmldoc, string bandName)
        {
            if (string.IsNullOrEmpty(bandName))
            {
                return(BuildParamsList(xmldoc));
            }
            string         strPath   = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/P[not(@pt) or @pt!='M']";
            string         strPath2  = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/List/P";
            string         strPass   = "******";
            string         strPass2  = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{3}')]/L[@t='{1}']/List/P[@n='{2}']";
            NameObjectList paramList = new NameObjectList();

            for (int i = _typerange.Length - 1; i > -1; i--)
            {
                for (int j = _typeuser.Length - 1; j > -1; j--)
                {
                    string strFind = string.Format(strPath, _typerange[i], _typeuser[j], bandName);
                    if (null != xmldoc.SelectSingleNode(string.Format(strPath2, _typerange[i], _typeuser[j], bandName)))
                    {
                        continue;
                    }
                    XmlNodeList xnlist = xmldoc.SelectNodes(strFind);
                    foreach (XmlNode xnP in xnlist)
                    {
                        if (null == xnP.Attributes["n"])
                        {
                            continue;
                        }
                        string key     = xnP.Attributes["n"].Value;
                        bool   isParam = true;
                        for (int m = i; m > -1; m--)
                        {
                            for (int n = j - 1; n > -1; n--)
                            {
                                string  strFindPass = string.Format(strPass, _typerange[m], _typeuser[n], key, bandName);
                                XmlNode xnPtemp     = xnP.SelectSingleNode(strFindPass);
                                if (null != xnPtemp)
                                {
                                    isParam = false;
                                    break;
                                }
                                string strFindPass2 = string.Format(strPass2, _typerange[m], _typeuser[n], key, bandName);
                                xnPtemp = xnP.SelectSingleNode(strFindPass2);
                                if (null != xnPtemp)
                                {
                                    isParam = false;
                                    break;
                                }
                            }
                            if (!isParam)
                            {
                                break;
                            }
                        }
                        //增加到参数列表
                        if (isParam)
                        {
                            BuildParamList.setParamByParamNode(paramList, xnP);
                        }
                    }//foreach (XmlNode xnP in xnlist)
                }
            }

            strPath2 = "/*/PL[(@t='{0}'and @t!='B')or(@t='B' and @n='{2}')]/L[@t='{1}']/List";
            string      strFind2   = string.Format(strPath2, "B", "D", bandName);
            XmlNodeList xnlistList = xmldoc.SelectNodes(strFind2);

            NameObjectList[] param = new NameObjectList[xnlistList.Count];
            for (int i = 0; i < xnlistList.Count; i++)
            {
                param[i] = new NameObjectList();
                for (int k = 0; k < paramList.Count; k++)
                {
                    param[i][paramList.Keys[k]] = paramList[k];
                }
                XmlNodeList xnlist = xnlistList[i].SelectNodes("P");
                foreach (XmlNode xnP in xnlist)
                {
                    BuildParamList.setParamByParamNode(param[i], xnP);
                }
            }
            return(param);
        }