예제 #1
0
        protected override void InitUIOnShown()
        {
            HintProvider.WaitingDone(Application.ProductName);
            base.InitUIOnShown();

            this.pnlButtom.Visible = false;
            this.btnMin.Visible    = true;
            ControlUtilityTool.SetControlDefaultFont(this.lblCaption, 15, FontStyle.Bold);

            //this.lblCaption.Text = "网络设备参数设置工具";
            string strVersion = string.Format("V{0}", StrUtils.GetFileVersion(Path.Combine(Application.StartupPath, "ParamsSettingTool.exe")));

            title = "网络设备参数设置工具" + "(" + strVersion + ")";
            this.lblCaption.Text = title;

            f_UserControls = new Dictionary <string, GeneralUserControl>();

            //启动Udp监听
            int udpPort = StrUtils.StrToIntDef(AppXmlConfig.Singleton[AppXmlConfig.UDP_SOURCE_PORT].ToString(), AppConst.UDP_SOURCE_PORT);

            f_UdpListener = new UdpListener(udpPort);
            string errMsg = string.Empty;

            if (!f_UdpListener.StartUdp(ref errMsg))
            {
                HintProvider.ShowAutoCloseDialog(this, string.Format("启动Udp监听失败,错误:{0}", errMsg));
            }
            AppXmlConfig.Singleton.Save();


            //暂时无云对讲设备
            this.nbItemCloudIntercom.Visible = false;
        }
 private void gpcDevicesInfo_CustomButtonClick(object sender, DevExpress.XtraBars.Docking2010.BaseButtonEventArgs e)
 {
     if (e.Button.Properties.Caption == "搜索设备")
     {
         if (!this.ExcuteSearchDevices())
         {
             return;
         }
         //if(this.IsBusy)
         //{
         //    return;
         //}
         //f_DevicesDataTable.Clear();
         //if(!this.SearchDevices())
         //{
         //    return;
         //}
         ////发送报文成功开始计时
         //this.BeginTick = Environment.TickCount;
         //this.CoolingTick = 3000;
         //this.IsBusy = true;
         //f_SearchDevicesCount = 2; //剩余自动广播次数
         HintProvider.StartWaiting(null, "正在搜索设备", "", Application.ProductName, showDelay: 0, showCloseButtonDelay: int.MaxValue);
         //this.tmrCommunication.Start();
     }
 }
예제 #3
0
        private bool CheckUIValid()
        {
            string exportPath = this.edtPath.Text.Trim();

            if (!Directory.Exists(exportPath))
            {
                HintProvider.ShowAutoCloseDialog(this, "请选择合法的导出路径!");
                return(false);
            }
            return(true);
        }
예제 #4
0
        /// <summary>
        /// 加载dll依赖
        /// </summary>
        private void LoadDllFiles()
        {
            string strPath = Path.Combine(Application.StartupPath, @"DependentFiles\Delphi");

            if (!Directory.Exists(strPath))
            {
                string strMsg = string.Format("{0} not exists!", strPath);
                RunLog.Log(strMsg, LogType.ltError);
                HintProvider.ShowConfirmDialog(null, strMsg, buttons: ConfirmFormButtons.OK);
                return;
            }
            UtilityTool.LoadDllFile(strPath, TripleDESIntf.TRIDES_DLL);
        }
        /// <summary>
        /// 搜索设备
        /// </summary>
        private bool SearchDevices()
        {
            string writeReport = this.GetWriteReport(0, AppConst.CMD_WORD_SEARCH_DEVIDES, AppEnv.Singleton.SystemPsd);
            string errMsg      = string.Empty;

            IPEndPoint endpoint = new IPEndPoint(IPAddress.Broadcast,
                                                 StrUtils.StrToIntDef(AppXmlConfig.Singleton[AppXmlConfig.UDP_PURPOSE_PORT].ToString(), AppConst.UDP_PURPOSE_PORT)
                                                 );

            if (!this.UdpListener.SendData(endpoint, writeReport, ref errMsg))
            {
                HintProvider.ShowAutoCloseDialog(null, string.Format("搜索设备失败,错误:{0}", errMsg));
                return(false);
            }
            return(true);
        }
        private bool CheckIPRepeat(LinkageCtrlInfo linkageCtrlInfo)
        {
            Dictionary <string, int> ipList = new Dictionary <string, int>();

            for (int i = 1; i <= linkageCtrlInfo.CloudElevatorCount; i++)
            {
                string ip = linkageCtrlInfo.CloudElevatorItems[i].DevIp;
                if (ipList.ContainsKey(ip))
                {
                    int devId = ipList[ip];
                    HintProvider.ShowAutoCloseDialog(null, string.Format("{0}号与{1}号云电梯IP地址重复!", devId, i));
                    return(false);
                }
                ipList.Add(ip, i);
            }
            return(true);
        }
예제 #7
0
        private void OnItemLoaded(object sender, EventArgs e)
        {
            var editor = (RoslynCodeEditor)sender;

            editor.Loaded -= this.OnItemLoaded;
            editor.Focus();

            var viewModel        = (DocumentViewModel)editor.DataContext;
            var workingDirectory = Directory.GetCurrentDirectory();

            var documentId = editor.Initialize(
                this.host,
                new ClassificationHighlightColors(),
                workingDirectory,
                HintProvider.GetInitalScriptText());

            viewModel.Initialize(documentId);
        }
        protected override void InitUIOnShown()
        {
            HintProvider.WaitingDone(Application.ProductName);
            base.InitUIOnShown();

            ControlUtilityTool.SetITLTextEditStyle(this.edtPsd);
            ControlUtilityTool.SetSuperToolTip(this.edtPsd, "密码必须由8位纯数字组成!");

            this.rgpPsd.SelectedIndex        = 1;
            this.edtPsd.Properties.MaxLength = 8;
            this.edtPsd.KeyPress            += CommonUtils.edtPort_KeyPress; //只能输入整形
            ControlUtilityTool.SetFocus(this.edtPsd);
            char        a     = '*';
            List <char> lisrt = new List <char>();

            lisrt.Add(a);
            //指定密码框样式
            this.edtPsd.Properties.PasswordChar = lisrt[0];//采用的样式
        }
예제 #9
0
        /// <summary>
        /// 确定事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_QSetcloudFloorTable_OK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(this.cbbE_StartAuthFlag.Text.Trim()))
            {
                HintProvider.ShowAutoCloseDialog(null, "开始标识不能为空");
                return;
            }
            if (string.IsNullOrWhiteSpace(this.cBbE_EndAuthFlag.Text.Trim()))
            {
                HintProvider.ShowAutoCloseDialog(null, "结束标识不能为空");
                return;
            }
            if (string.IsNullOrWhiteSpace(this.cbbE_Start.Text.Trim()))
            {
                HintProvider.ShowAutoCloseDialog(null, "开始标号不能为空");
                return;
            }
            //if((!RaBtn_DevNo.Checked) && (!RaBtn_CheckFloor.Checked) && (!RaBtn_KeyName.Checked))
            //{
            //    HintProvider.ShowAutoCloseDialog(null, "请选择类别");
            //    return;
            //}
            f_QuickSetInfo_StratAuthFlag = cbbE_StartAuthFlag.Text;
            f_QuickSetInfo_EndAuthFlag   = cBbE_EndAuthFlag.Text;
            f_QuickSetInfo_StartDevNo    = cbbE_Start.Text;

            int StartAuthFlag = int.Parse(f_QuickSetInfo_StratAuthFlag);
            int EndAuthFlag   = int.Parse(f_QuickSetInfo_EndAuthFlag);

            string errMsg = "结束标识不能小于开始标识";

            if (EndAuthFlag < StartAuthFlag)
            {
                HintProvider.ShowAutoCloseDialog(null, string.Format("错误:{0}", errMsg));
            }
            else
            {
                this.Close();
                this.DialogResult = DialogResult.OK;
            }
        }
        private void AnalysisDownParams(string strCmdStr)
        {
            //取返回的数据部分
            string strCmdReport = StrUtils.CopySubStr(strCmdStr, 18, strCmdStr.Length - 22);

            //判断设备Id是否正确
            int devId = CommandProcesserHelper.GetDevIDByCmdInfo(StrUtils.CopySubStr(strCmdStr, 2, 4));

            if (devId != f_CurrentLinkageCtrlInfo.DevId)
            {
                return;
            }
            //获取返回的状态
            int intStatus = StrUtils.StrToIntDef(StrUtils.CopySubStr(strCmdReport, 0, 2), -1, 16);

            switch (intStatus)
            {
            case 0x00:
            {
                this.AddOneDeviceToUI(f_CurrentLinkageCtrlInfo);
                HintProvider.ShowAutoCloseDialog(null, "参数设置成功");
            }
            break;

            case 0x01:
            {
                HintProvider.ShowAutoCloseDialog(null, "参数设置失败");
            }
            break;

            default:
            {
                HintProvider.ShowAutoCloseDialog(null, "参数设置失败,未知错误");
            }
            break;
            }

            this.IsBusy = false;
        }
예제 #11
0
        /// <summary>
        /// 动态加载窗体到pnlReportContainer
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ucName"></param>
        private void ShowUserControl <T>(string ucName) where T : GeneralDeviceUserControl
        {
            foreach (GeneralDeviceUserControl userControl in f_UserControls.Values)
            {
                userControl.Visible = false;
            }
            if (f_UserControls.ContainsKey(ucName))
            {
                GeneralUserControl uc = f_UserControls[ucName];
                uc.Visible = true;
                uc.BringToFront();
                return;
            }
            HintProvider.StartWaiting(null, "正在加载", "", Application.ProductName, showDelay: 0, showCloseButtonDelay: int.MaxValue);
            T t = UtilityTool.ShowUserControl <T>(this.pnlReportContainer);

            //绑定udp监听器到pnlReportContainer
            t.UdpListener = f_UdpListener;
            //绑定接收数据的函数
            t.UdpListener.RecvCallback += t.RecvCallBack;
            f_UserControls.Add(ucName, t);
        }
 private void tmrCommunication_Tick(object sender, EventArgs e)
 {
     if ((Environment.TickCount - this.BeginTick >= this.CoolingTick) ||
         (!this.IsBusy))
     {
         this.tmrCommunication.Stop();
         this.IsBusy = false;
         this.tmrCommunication.Interval = 100;
         HintProvider.WaitingDone(Application.ProductName);
     }
     if (this.tmrCommunication.Interval != 800)
     {
         this.tmrCommunication.Interval = 800;
         return;
     }
     //如果是广播命令,则继续广播,间隔为900
     if (f_SearchDevicesCount > 0)
     {
         //    f_SearchDevicesCount--;
         //   this.SearchDevices();
     }
 }
        protected override void AnalysisRecvDataEx(string strCmdStr)
        {
            //报文格式F2 XX XX ... XX XX F3
            //判断设备类型是否合法
            DeviceType devType = CommandProcesserHelper.GetDevTypeByCmdInfo(StrUtils.CopySubStr(strCmdStr, 6, 2));

            if (devType != DeviceType.LinkageCtrl)
            {
                return;
            }
            //根据命令字,解析对应命令
            string strCmdWord = StrUtils.CopySubStr(strCmdStr, 14, 4);

            if (strCmdWord == AppConst.CMD_WORD_SEARCH_DEVIDES)
            {
                //判断报文长度
                //取云电梯数量
                int cloudElevatorCount = StrUtils.StrToIntDef(StrUtils.CopySubStr(strCmdStr, 64, 2), 0, 16);
                if (strCmdStr.Length < 70 + cloudElevatorCount * 10) //35 + cloudElevatorCount 字节
                {
                    HintProvider.ShowAutoCloseDialog(null, string.Format("报文长度错误,报文:{0}", strCmdStr));
                    return;
                }
                this.AnalysisSearchDevicesRecvData(strCmdStr);
            }
            else if (strCmdWord == AppConst.CMD_WORD_SET_CLOUD_ELEVATOR_PARAMS)
            {
                //判断报文长度
                if (strCmdStr.Length < 24) //12字节
                {
                    HintProvider.ShowAutoCloseDialog(null, string.Format("报文长度错误,报文:{0}", strCmdStr));
                    return;
                }
                this.AnalysisDownParams(strCmdStr);
            }

            //this.UpdateHintInfo(strCmdStr);
        }
 private bool CheckUIValid()
 {
     if (string.IsNullOrWhiteSpace(this.edtDevIp.Text.Trim()))
     {
         HintProvider.ShowAutoCloseDialog(null, "设备IP不能为空");
         return(false);
     }
     if (string.IsNullOrWhiteSpace(this.edtSubnetMark.Text.Trim()))
     {
         HintProvider.ShowAutoCloseDialog(null, "子网掩码不能为空");
         return(false);
     }
     if (string.IsNullOrWhiteSpace(this.edtGateWay.Text.Trim()))
     {
         HintProvider.ShowAutoCloseDialog(null, "网关不能为空");
         return(false);
     }
     if (string.IsNullOrWhiteSpace(this.edtCloudUdpPort.Text.Trim()))
     {
         HintProvider.ShowAutoCloseDialog(null, "云电梯UDP端口不能为空");
         return(false);
     }
     if (string.IsNullOrWhiteSpace(this.edtThirdUdpPort.Text.Trim()))
     {
         HintProvider.ShowAutoCloseDialog(null, "第三方对讲UDP端口不能为空");
         return(false);
     }
     for (int i = 1; i <= this.cmbCloudCtrlCount.SelectedIndex; i++)
     {
         if (string.IsNullOrWhiteSpace(f_UCloudElevatorItems[i].DevIp))
         {
             HintProvider.ShowAutoCloseDialog(null, string.Format("{0}号云电梯IP地址不能为空", i));
             return(false);
         }
     }
     return(true);
 }
        protected override void DownParams()
        {
            LinkageCtrlInfo linkageCtrlInfo = GetLinkageCtrlInfoBeforeDown();

            if (linkageCtrlInfo == null)
            {
                return;
            }
            //检测IP地址重复
            if (!this.CheckIPRepeat(linkageCtrlInfo))
            {
                return;
            }
            string strWriteCmd = this.GetWriteCmdStr(linkageCtrlInfo);

            //判断长度
            if (strWriteCmd.Length < 36 + linkageCtrlInfo.CloudElevatorCount * 10) //18 + linkageCtrlInfo.CloudElevatorCount *5 字节
            {
                HintProvider.ShowAutoCloseDialog(null, "生成的报文长度错误,请检查设置的参数是否正确");
                return;
            }
            string     writeReport = this.GetWriteReport(linkageCtrlInfo.DevId, AppConst.CMD_WORD_SET_LINKAGE_CTRL_PARAMS, strWriteCmd);
            string     errMsg      = string.Empty;
            IPEndPoint endpoint    = new IPEndPoint(IPAddress.Broadcast, StrUtils.StrToIntDef(AppXmlConfig.Singleton[AppXmlConfig.UDP_PURPOSE_PORT].ToString(), AppConst.UDP_PURPOSE_PORT));

            if (!this.UdpListener.SendData(endpoint, writeReport, ref errMsg))
            {
                HintProvider.ShowAutoCloseDialog(null, string.Format("设置参数失败,错误:{0}", errMsg));
            }
            f_CurrentLinkageCtrlInfo = linkageCtrlInfo;

            //发送报文成功开始计时
            this.BeginTick   = Environment.TickCount;
            this.CoolingTick = 600;
            this.IsBusy      = true;
            this.tmrCommunication.Start();
        }
        protected override void InitUIOnLoad()
        {
            base.InitUIOnLoad();

            ControlUtilityTool.SetITLLayOutControlStyle(this.lcLinkageCtrl);
            ControlUtilityTool.SetITLTextEditStyle(this.edtDevIp);
            ControlUtilityTool.SetITLTextEditStyle(this.edtSubnetMark);
            ControlUtilityTool.SetITLTextEditStyle(this.edtGateWay);
            ControlUtilityTool.SetITLTextEditStyle(this.edtCloudUdpPort);
            ControlUtilityTool.SetITLTextEditStyle(this.edtThirdUdpPort);
            ControlUtilityTool.SetITLComboBoxEditStyle(this.cmbCloudCtrlCount);
            ControlUtilityTool.SetControlDefaultColor(this.sclCtrlItems, ControlUtilityTool.PubBackColorNormal);
            ControlUtilityTool.SetTextEditIPRegEx(this.edtDevIp);
            ControlUtilityTool.SetTextEditIPRegEx(this.edtSubnetMark);
            ControlUtilityTool.SetTextEditIPRegEx(this.edtGateWay);

            this.edtDevIp.Properties.MaxLength        = 15;
            this.edtSubnetMark.Properties.MaxLength   = 15;
            this.edtGateWay.Properties.MaxLength      = 15;
            this.edtCloudUdpPort.Properties.MaxLength = 5;
            this.edtThirdUdpPort.Properties.MaxLength = 5;

            this.edtDevIp.KeyPress        += CommonUtils.edtIp_KeyPress;
            this.edtSubnetMark.KeyPress   += CommonUtils.edtIp_KeyPress;
            this.edtGateWay.KeyPress      += CommonUtils.edtIp_KeyPress;
            this.edtCloudUdpPort.KeyPress += CommonUtils.edtPort_KeyPress;
            this.edtThirdUdpPort.KeyPress += CommonUtils.edtPort_KeyPress;

            this.InitDevicesCountCmdEdit();
            this.InitCloudElevatorItemsUI();

            this.DevType = DeviceType.LinkageCtrl;
            HintProvider.WaitingDone(Application.ProductName);

            FindCount = new Dictionary <string, hintInfo>();
        }
        //获取项目编号
        private void Btn_ReadcloudFloorTable_GetData_Click(object sender, EventArgs e)
        {
            try
            {
                if (TextEdit_ProNo.Text.Length < 8)
                {
                    HintProvider.ShowAutoCloseDialog(null, string.Format("请输入8位项目编号"));
                    return;
                }
                //string HttpAddress = "15w07q0502.51mypc.cn:15234/smartCard/syncdata/device/elevator/getCloudElevatorList?";//http地址
                string _uSysCode = TextEdit_ProNo.Text;//传递的参数  00000126;

                //string _sAppKey = "";
                DateTime currentTime = System.DateTime.Now;
                string   createTime  = currentTime.ToString("yyyyMMddHHmmss");
                string   _MD5        = "projectId" + createTime + "1177BE55278MMN5412365UHBN85214BE";
                string   _sSign      = Md5Func(_MD5);

                string postString = "projectId=" + _uSysCode + "&sign=" + _sSign + "&createTime=" + createTime; //传递的参数  00000126
                byte[] postData   = Encoding.UTF8.GetBytes(postString);                                         //编码

                //RunLog.Log("获取项目请求:  ccccccccccccc POSTString  " + postString);

                iniFileControl ReadIniConfig = new iniFileControl(Application.StartupPath + @"\CloudAdd.ini");
                string         socketHttp    = ReadIniConfig.IniReadValue("云服务配置", "地址");
                //string url = "http://test.smartcard.jia-r.com/smartCard/syncdata/device/elevator/getCloudElevatorList";//地址
                string url = socketHttp;

                WebClient webClient = new WebClient();
                webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); //采取POST方式
                byte[] responseData = webClient.UploadData(url, "POST", postData);          //得到返回字符流
                string srcString    = Encoding.UTF8.GetString(responseData);                //解码

                //RunLog.Log("接收项目:  ccccccccccccc srcString  " + srcString);

                //srcString = CommonUtils.ToHex(srcString, "utf-8", true);
                //CloudFloorTableBaseInfo FloorTableSerializer = JsonConvert.DeserializeObject<CloudFloorTableBaseInfo>(srcString);

                //string Test = Md5Func("projectId201903091355181177BE55278MMN5412365UHBN85214BE");



                comboBox_FloorName.Items.Clear(); //清空列表

                for (int i = 0; i <= 112; i++)
                {
                    try
                    {
                        string JsonData = cutJson(srcString, "data", i);

                        if (JsonData == null)
                        {
                            return;
                        }

                        CloudFloorTableBaseInfo FloorTable = JsonConvert.DeserializeObject <CloudFloorTableBaseInfo>(JsonData);
                        string f_deviceName = FloorTable.deviceName;
                        f_deviceUnique = FloorTable.deviceUnique;

                        //comboBox_FloorName
                        // 添加项目
                        comboBox_FloorName.DropDownStyle = ComboBoxStyle.DropDownList;
                        comboBox_FloorName.Items.Add(f_deviceName);
                        //添加list
                        var Listueq = new { ID = i, deviceName = f_deviceName, deviceUnique = f_deviceUnique };

                        list.Add(Listueq);
                    }
                    catch (Exception ex)
                    {
                        RunLog.Log(ex);
                    }
                }
            }
            catch (Exception elog)
            {
                string errMsg = "获取项目编号失败";
                HintProvider.ShowAutoCloseDialog(null, string.Format("通讯失败,错误:{0}", errMsg));

                RunLog.Log(elog);
            }


            //string JsonData = cutJson(srcString, "data", 1);
            //CloudFloorTableBaseInfo FloorTable = JsonConvert.DeserializeObject<CloudFloorTableBaseInfo>(JsonData);
        }
        private void Btn_ReadcloudFloorTable_OK_Click(object sender, EventArgs e)
        {
            try
            {
                string devUnique = string.Empty;
                if (list != null)
                {
                    foreach (var one in list)
                    {
                        PropertyDescriptorCollection pdc    = TypeDescriptor.GetProperties(one);
                        PropertyDescriptor           pdID   = pdc.Find("deviceUnique", true);
                        string             lhcodeunique     = pdID.GetValue(one).ToString();
                        PropertyDescriptor pdDevName        = pdc.Find("deviceName", true);
                        string             lhcodedeviceName = pdDevName.GetValue(one).ToString();

                        if (lhcodedeviceName == comboBox_FloorName.Text.ToString())
                        {
                            devUnique = lhcodeunique;
                        }
                    }
                }
                string   _uSysCode   = devUnique;//传递的参数  0000012610080;
                DateTime currentTime = System.DateTime.Now;
                string   createTime  = currentTime.ToString("yyyyMMddHHmmss");

                string _MD5   = "deviceUnique" + createTime + "1177BE55278MMN5412365UHBN85214BE";
                string _sSign = Md5Func(_MD5);
                RunLog.Log("_MD5" + _MD5);
                string postString = /*"projectId=" + TextEdit_ProNo.Text.ToString() + */ "deviceUnique=" + _uSysCode + "&sign=" + _sSign + "&createTime=" + createTime; //传递的参数  00000126
                byte[] postData   = Encoding.UTF8.GetBytes(postString);                                                                                                 //编码

                //RunLog.Log("请求:  ccccccccccccc deviceUnique  " + _uSysCode);

                //RunLog.Log("请求:  ccccccccccccc POSTString  " + postString);

                iniFileControl ReadIniConfig = new iniFileControl(Application.StartupPath + @"\CloudAdd.ini");
                string         socketHttp    = ReadIniConfig.IniReadValue("云楼层对应表配置", "地址");
                //string url = "http://test.smartcard.jia-r.com/smartCard/syncdata/device/elevator/getElevatorFloorConfig";//地址
                string url = socketHttp.ToString();

                WebClient webClient = new WebClient();
                webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); //采取POST方式
                byte[] responseData = webClient.UploadData(url, "POST", postData);          //得到返回字符流
                string srcString    = Encoding.UTF8.GetString(responseData);                //解码


                RunLog.Log("1 云接收 :ccccccccccccc srcString  " + srcString + "Length = " + srcString.Length);
                if (srcString.Length == 50)
                {
                    HintProvider.ShowAutoCloseDialog(null, string.Format("获取楼层映射表异常,请前往物业后台重置。"));
                    this.Close();
                    return;
                }

                ResponseInfo FloorTable = JsonConvert.DeserializeObject <ResponseInfo>(srcString);

                RunLog.Log("2 云接收 :ccccccccccccc srcString  " + srcString);

                this.Close();


                SendCloudFloorHex = FloorTable; //
                RunLog.Log("Read 实际楼层对比:SendCloudFloorHex ********* :" + FloorTable.data.logicFloor);

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                string errMsg = "获取楼层对应表失败";
                HintProvider.ShowAutoCloseDialog(null, string.Format("通讯失败,错误:{0}", errMsg));

                RunLog.Log(ex);
            }
        }
        private void AddOneDeviceToUI(LinkageCtrlInfo linkageCtrlInfo)
        {
            DataRow[] rows = f_DevicesDataTable.Select(string.Format("{0}={1}", DEV_ID, linkageCtrlInfo.DevId));
            FindCount.AddToUpdate("" + linkageCtrlInfo.DevId);
            FindCount.AddToUpdate("" + linkageCtrlInfo.DevIp);
            if (rows.Length > 0)
            {
                rows[0].BeginEdit();
                try
                {
                    int FindSumCount = AppEnv.Singleton.UdpCount * AppEnv.Singleton.UdpCount + 1;

                    if (FindCount["" + linkageCtrlInfo.DevId].FontCount > FindSumCount && !FindCount["" + linkageCtrlInfo.DevId].IsHint)
                    {
                        FindCount["" + linkageCtrlInfo.DevId].IsHint = true;
                        HintProvider.ShowAutoCloseDialog(null, "设备ID冲突,ID:" + linkageCtrlInfo.DevId);
                    }
                    if (FindCount[linkageCtrlInfo.DevIp].FontCount > FindSumCount && !FindCount["" + linkageCtrlInfo.DevIp].IsHint)
                    {
                        FindCount["" + linkageCtrlInfo.DevIp].IsHint = true;
                        HintProvider.ShowAutoCloseDialog(null, string.Format("设备IP冲突,IP:{0},ID:{1}", linkageCtrlInfo.DevIp, linkageCtrlInfo.DevId));
                    }

                    rows[0][DEV_MAC]                 = linkageCtrlInfo.DevMac;
                    rows[0][DEV_IP]                  = linkageCtrlInfo.DevIp;
                    rows[0][SUBNET_MARK]             = linkageCtrlInfo.SubnetMask;
                    rows[0][GATE_WAY]                = linkageCtrlInfo.GateWay;
                    rows[0][CLOUD_ELEVATOR_UDP_PORT] = linkageCtrlInfo.CloudUdpPort;
                    rows[0][THIRD_INTERCOM_UDP_PORT] = linkageCtrlInfo.ThirdUdpPort;
                    rows[0][CLOUD_ELEVATOR_COUNT]    = linkageCtrlInfo.CloudElevatorCount;
                    for (int i = 1; i <= 8; i++)
                    {
                        rows[0][string.Format(CLOUD_ELEVATOR_ITEM_IP, i)]   = linkageCtrlInfo.CloudElevatorItems[i].DevIp;
                        rows[0][string.Format(CLOUD_ELEVATOR_ITEM_PROP, i)] =
                            CommonUtils.GetNameByCloudElevatorProperties(linkageCtrlInfo.CloudElevatorItems[i].CtrlProporties);
                    }
                }
                finally
                {
                    rows[0].EndEdit();
                }
            }
            else
            {
                f_DevicesDataTable.Rows.Add(linkageCtrlInfo.DevId, linkageCtrlInfo.DevMac, linkageCtrlInfo.DevIp,
                                            linkageCtrlInfo.SubnetMask, linkageCtrlInfo.GateWay, linkageCtrlInfo.CloudUdpPort,
                                            linkageCtrlInfo.ThirdUdpPort, linkageCtrlInfo.CloudElevatorCount,
                                            linkageCtrlInfo.CloudElevatorItems[1].DevIp,
                                            CommonUtils.GetNameByCloudElevatorProperties(linkageCtrlInfo.CloudElevatorItems[1].CtrlProporties),
                                            linkageCtrlInfo.CloudElevatorItems[2].DevIp,
                                            CommonUtils.GetNameByCloudElevatorProperties(linkageCtrlInfo.CloudElevatorItems[2].CtrlProporties),
                                            linkageCtrlInfo.CloudElevatorItems[3].DevIp,
                                            CommonUtils.GetNameByCloudElevatorProperties(linkageCtrlInfo.CloudElevatorItems[3].CtrlProporties),
                                            linkageCtrlInfo.CloudElevatorItems[4].DevIp,
                                            CommonUtils.GetNameByCloudElevatorProperties(linkageCtrlInfo.CloudElevatorItems[4].CtrlProporties),
                                            linkageCtrlInfo.CloudElevatorItems[5].DevIp,
                                            CommonUtils.GetNameByCloudElevatorProperties(linkageCtrlInfo.CloudElevatorItems[5].CtrlProporties),
                                            linkageCtrlInfo.CloudElevatorItems[6].DevIp,
                                            CommonUtils.GetNameByCloudElevatorProperties(linkageCtrlInfo.CloudElevatorItems[6].CtrlProporties),
                                            linkageCtrlInfo.CloudElevatorItems[7].DevIp,
                                            CommonUtils.GetNameByCloudElevatorProperties(linkageCtrlInfo.CloudElevatorItems[7].CtrlProporties),
                                            linkageCtrlInfo.CloudElevatorItems[8].DevIp,
                                            CommonUtils.GetNameByCloudElevatorProperties(linkageCtrlInfo.CloudElevatorItems[8].CtrlProporties)
                                            );
            }
            //排序
            f_DevicesDataTable.DefaultView.Sort = string.Format("{0} {1}", DEV_ID, "ASC");
            ControlUtilityTool.AdjustIndicatorWidth(this.gvDevices);
        }
        private bool CheckPsdValid()
        {
            if (this.rgpPsd.SelectedIndex == 0)
            {
                return(true);
            }
            string psd = this.edtPsd.Text.Trim();

            if (psd.Length != 8)
            {
                HintProvider.ShowAutoCloseDialog(this, "密码必须由8位纯数字组成!");
                return(false);
            }
            //密码不能为8个0,8个0为默认密码
            if (psd.Equals(KeyMacOperate.DEFAULT_SYSTEM_PSD))
            {
                HintProvider.ShowAutoCloseDialog(this, "密码不能为8个0,请重新输入!");
                return(false);
            }

            if (string.IsNullOrWhiteSpace(psd))
            {
                HintProvider.ShowAutoCloseDialog(this, "密码不能为空!");
                return(false);
            }
            char[] charArr = psd.ToArray();
            if (charArr.Length < 6 || charArr.Length > 20)
            {
                HintProvider.ShowAutoCloseDialog(this, "密码必须6-20位之间!");
                return(false);
            }
            int count      = charArr.Length;
            int oneIndex   = 1;
            int twoIndex   = 1;
            int threeIndex = 1;

            for (int i = 1; i < count; i++)
            {
                int beforValue = int.Parse(charArr[i - 1].ToString());
                int curValue   = int.Parse(charArr[i].ToString());
                if (beforValue == curValue)
                {
                    oneIndex++;
                }
                if (beforValue + 1 == curValue)
                {
                    twoIndex++;
                }
                if (beforValue == curValue + 1)
                {
                    threeIndex++;
                }
            }
            if (oneIndex == count)
            {
                HintProvider.ShowAutoCloseDialog(this, "密码不能为相同的数字!");
                return(false);
            }
            if (twoIndex == count)
            {
                HintProvider.ShowAutoCloseDialog(this, "密码不能为顺序的连续数字!");
                return(false);
            }
            if (threeIndex == count)
            {
                HintProvider.ShowAutoCloseDialog(this, "密码不能为逆序的连续数字!");
                return(false);
            }
            return(true);
        }
        private void AnalysisRecvData(string strData)
        {
            //非忙碌状态,不解析数据
            //if(!this.IsBusy)
            //{
            //    return;
            //}
            //去F0
            string strCmdStr = CommandProcesserHelper.DelF0Escape(strData);

            //判断报文长度
            if (strCmdStr.Length < 18)
            {
                RunLog.Log(string.Format("返回的报文长度错误,报文:{0}", strCmdStr));
                HintProvider.ShowAutoCloseDialog(null, string.Format("返回的报文校验错误,错误:{0}", strCmdStr), HintIconType.Err);
                return;
            }
            //判断校验码
            string requiredCheckValue = StrUtils.GetXORCheck(strCmdStr, 2, strCmdStr.Length - 6).ToUpper();
            string factCheckValue     = StrUtils.CopySubStr(strCmdStr, strCmdStr.Length - 4, 2);

            if (string.Compare(requiredCheckValue, factCheckValue, true) != 0)
            {
                RunLog.Log(string.Format("返回的报文校验错误,报文:{0}", strCmdStr));
                HintProvider.ShowAutoCloseDialog(null, string.Format("返回的报文校验错误,错误:{0}", strCmdStr), HintIconType.Err);

                return;
            }
            //判断返回的命令状态
            string strCmdStatus = StrUtils.CopySubStr(strCmdStr, 12, 2);

            //string strCmdStatus = StrUtils.CopySubStr(strCmdStr, 10, 2);
            if (StrUtils.HexStrToInt(strCmdStatus) != CommonUtils.RES_OK)
            {
                if (strCmdStatus == "7F")
                {
                    string strCmdStatus2 = StrUtils.CopySubStr(strCmdStr, 18, 2);
                    if (strCmdStatus2 == "02")
                    {
                        HintProvider.ShowAutoCloseDialog(null, string.Format("需要初始化设备,才能重新设置网络参数"));
                        return;
                    }
                }

                RunLog.Log(string.Format("命令状态错误:{0}", CommonUtils.GetErrMsgByCode(StrUtils.HexStrToInt(strCmdStatus))));

                string Error = string.Format("命令状态错误:{0}", CommonUtils.GetErrMsgByCode(StrUtils.HexStrToInt(strCmdStatus)));
                HintProvider.ShowAutoCloseDialog(null, string.Format(Error), HintIconType.Err);

                return;
            }
            else if (StrUtils.HexStrToInt(strCmdStatus) == CommonUtils.RES_OK)
            {
                string strDevID = CommandProcesserHelper.GetDevIDByCmdInfo(StrUtils.CopySubStr(strCmdStr, 2, 4)).ToString();
                if (IsDownParm || AppConst.IsDownParmCloudLinkage)
                {
                    HintProvider.ShowAutoCloseDialog(null, string.Format("下载成功"));
                    AppConst.IsDownParmCloudLinkage = false;
                    IsDownParm = false;
                }
            }

            DeviceType devType = CommandProcesserHelper.GetDevTypeByCmdInfo(StrUtils.CopySubStr(strCmdStr, 6, 2));

            if (devType == DeviceType.CloudLinkageInfoCtrl)
            {
                //云联动器
                string strCmdStatusLink = StrUtils.CopySubStr(strCmdStr, 15, 4);

                if (strCmdStatusLink == "0121" || strCmdStatusLink == "012E" || strCmdStatusLink == "0100")
                {
                    HintProvider.ShowAutoCloseDialog(null, "下载成功", HintIconType.OK);
                    Thread.Sleep(1000);
                }
            }

            //重置
            IsDownLoadDevLength = string.Empty;

            this.AnalysisRecvDataEx(strCmdStr);
        }