예제 #1
0
        private void DealAddQueryChanResponse(ReturnMessage retMessage)
        {
            try
            {
                OperationReturn optReturn;
                if (retMessage.ListData == null || retMessage.ListData.Count < 1)
                {
                    CurrentApp.WriteLog("DealAddQueryChan", string.Format("ListData is null or count invalid"));
                    return;
                }
                string strCount = retMessage.ListData[0];
                int    intCount;
                if (!int.TryParse(strCount, out intCount))
                {
                    CurrentApp.WriteLog("DealAddQueryChan", string.Format("ListData count param invalid"));
                    return;
                }
                if (retMessage.ListData.Count > 1)
                {
                    var strInfo = retMessage.ListData[1];
                    optReturn = XMLHelper.DeserializeObject <MonitorObject>(strInfo);
                    if (!optReturn.Result)
                    {
                        CurrentApp.WriteLog("DealAddQueryChan",
                                            string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    MonitorObject obj = optReturn.Data as MonitorObject;
                    if (obj == null)
                    {
                        CurrentApp.WriteLog("DealAddQueryChan", string.Format("MonitorObject is null"));
                        return;
                    }
                    if (mMonitorObject.ObjID == obj.ObjID && mMonitorObject.Role == obj.Role)
                    {
                        mMonitorObject.MonID = obj.MonID;
                        mMonitorObject.UpdateInfo(obj);
                        if (mMonitorItem != null)
                        {
                            Dispatcher.Invoke(new Action(mMonitorItem.UpdateState));
                        }

                        //查询通道状态
                        QueryChanState();

                        //开始监听
                        StartNMonObject();
                    }
                }
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }