Esempio n. 1
0
 /// <summary>
 /// 初始化网址
 /// </summary>
 private void Initwww()
 {
     try
     {
         //查找ip和port;
         DeviceCommViewModel.VM.Execute(new List <object>
         {
             DeviceCommViewModel.ExecuteCommand.ec_QueryComInfo,
             cbeCommunication.Text.Trim(),
         });
         if (DeviceCommViewModel.VM.ComInfoEntities == null || DeviceCommViewModel.VM.ComInfoEntities.Count == 0)
         {
             return;
         }
         DTCommunicationInfo dt = (DTCommunicationInfo)DeviceCommViewModel.VM.ComInfoEntities[0];
         if (dt != null && dt.IP != null && dt.PortNumberTCP != null && dt.IP.Value != null && dt.PortNumberTCP.Value != null)
         {
             Uri uri = new Uri("http://" + dt.IP.Value.ToString().Trim() + ":" + dt.PortNumberTCP.Value.ToString().Trim());
             webBrowser.Url = uri;
         }
     }
     catch (Exception ex)
     {
         ErrorLog.Error(ex.ToString());
     }
 }
Esempio n. 2
0
        /// <summary>0
        /// 删除通讯信息
        /// </summary>
        /// <param name="comName"></param>
        /// <returns></returns>
        public bool DeleteCommunicationInfo(string comName)
        {
            DTCommunicationInfo dt = new DTCommunicationInfo();

            dt.Name.Value = comName;
            bool rs = _DataServer.DeleteResult(dt);

            return(rs);
        }
Esempio n. 3
0
        /// <summary>
        /// 查询相机 ip,用户名,密码,端口号
        /// </summary>
        /// <returns></returns>
        private bool LoadCameraParam()
        {
            List <object> lsDevice = ResultDataViewModel.VM.Devices;

            if (lsDevice == null || lsDevice.Count < 1)
            {
                ErrorLog.Error(TIPS_DeviceListIsNull);
                return(false);
            }
            for (int i = 0; i < lsDevice.Count; i++)
            {
                if (lsDevice[i] is DTDeviceInfo)
                {
                    try
                    {
                        DTDeviceInfo dt = lsDevice[i] as DTDeviceInfo;
                        if (dt.Name.Value.ToString().Trim() == CameraName)
                        {
                            string  param = dt.Param.Value.ToString();
                            JObject dp    = JsonNewtonsoft.FromJSON(param) as JObject;
                            JToken  jt;
                            dp.TryGetValue("userName", out jt);
                            UserName = jt.ToString();
                            dp.TryGetValue("Password", out jt);
                            PassWord = jt.ToString();
                            string CommInfo = dt.Commuunication.Value.ToString();
                            if (String.IsNullOrEmpty(CommInfo))
                            {
                                ErrorLog.Error(TIPS_CommInfoIsNull);
                                return(false);
                            }
                            ResultDataViewModel.VM.Execute(new List <object> {
                                ResultDataViewModel.ExecuteCommand.ec_QueryCommunicationInfo,
                                CommInfo
                            });
                            if (ResultDataViewModel.VM.QueryComSingleEntities == null || ResultDataViewModel.VM.QueryComSingleEntities.Count < 1)
                            {
                                ErrorLog.Error(TIPS_CommInfoIsNull);
                                //          lcVedioTips.Text = ;
                                return(false);
                            }
                            DTCommunicationInfo dtCom = ResultDataViewModel.VM.QueryComSingleEntities[0] as DTCommunicationInfo;
                            IpAddress = dtCom.IP.Value.ToString().Trim();
                            Port      = Convert.ToInt32(dtCom.PortNumberTCP.Value.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorLog.Error(ex.ToString());
                        //      lcVedioTips.Text = TIPS_Error;
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// 查询通讯信息
        /// </summary>
        /// <param name="ComName"></param>
        /// <returns>有通讯名称则查通讯,无通讯名称则查整个列表</returns>
        public ArrayList QueryCommunicationInfo(string ComName = null)
        {
            DTCommunicationInfo dt = new DTCommunicationInfo();

            if (ComName != null)
            {
                dt.Name.Value = ComName;
            }
            ArrayList rs = _DataServer.GetResult(dt);

            return(rs);
        }
Esempio n. 5
0
        /// <summary>
        /// 保存通讯信息
        /// </summary>
        /// <param name="comName">通讯名</param>
        /// <param name="portNumber">端口号</param>
        /// <param name="baudRate">波特率</param>
        /// <param name="dataBit">数据位</param>
        /// <param name="stopBit">停止位</param>
        /// <param name="checkBit">校验位</param>
        /// <param name="IP">IP</param>
        /// <param name="portNumberTCP">TCP端口号</param>
        /// <returns></returns>
        public bool SaveCommunicationInfo(string comName, string portNumber = null, int baudRate = -1, int dataBit = -1, float stopBit = -1, int checkBit = -1, string IP = null, string portNumberTCP = null, string CSType = null)
        {
            DTCommunicationInfo dtCondition = new DTCommunicationInfo();

            dtCondition.Name.Value = comName;
            DTCommunicationInfo dt = new DTCommunicationInfo();

            if (portNumber != null)
            {
                dt.PortNumber.Value = portNumber;
            }
            if (baudRate != -1)
            {
                dt.BaudRate.Value = baudRate;
            }
            if (dataBit != -1)
            {
                dt.DataBit.Value = dataBit;
            }
            if (stopBit != -1)
            {
                dt.StopBit.Value = stopBit;
            }
            if (checkBit != -1)
            {
                dt.CheckBit.Value = checkBit;
            }
            if (IP != null)
            {
                dt.IP.Value = IP;
            }
            if (portNumberTCP != null)
            {
                dt.PortNumberTCP.Value = portNumberTCP;
            }
            if (CSType != null)
            {
                dt.CSType.Value = CSType;
            }
            bool rs = _DataServer.UpdateResult(dt, dtCondition);

            return(rs);
        }
Esempio n. 6
0
 /// <summary>
 /// 初始化通讯列表(可用于刷新)
 /// </summary>
 /// <param name="IsRightControlsRefresh">右侧控件是否需要同步刷新</param>
 /// <param name="isFirst">true:右侧列表显示第一个,false:显示最后一个</param>
 private void InitComList(bool IsRightControlsRefresh = false, bool isFirst = true)
 {
     tlCommunication.Nodes.Clear();
     ResultDataViewModel.VM.Execute(new List <object> {
         ResultDataViewModel.ExecuteCommand.ec_QueryCommunicationInfo
     });
     if (ResultDataViewModel.VM.QueryCommunicationEntities == null || ResultDataViewModel.VM.QueryCommunicationEntities.Count == 0)
     {
         return;
     }
     for (int i = 0; i < ResultDataViewModel.VM.QueryCommunicationEntities.Count; i++)
     {
         try
         {
             DTCommunicationInfo dt = (DTCommunicationInfo)ResultDataViewModel.VM.QueryCommunicationEntities[i];
             tlCommunication.AppendNode(new object[] { dt.Name.Value.ToString() }, -1, CheckState.Unchecked, dt.ComType.Value.ToString());
         }
         catch
         {
         }
     }
     //右侧列表是否需要刷新
     if (IsRightControlsRefresh)
     {
         try
         {
             int n = ResultDataViewModel.VM.QueryCommunicationEntities.Count - 1;
             DeviceClickEventArgs args = new DeviceClickEventArgs();
             args.Key   = tlCommunication.Nodes[isFirst ? 0 : n].Tag == null ? "" : tlCommunication.Nodes[isFirst ? 0 : n].Tag.ToString().Trim();
             args.Param = tlCommunication.Nodes[isFirst ? 0 : n].GetDisplayText(tlCommunication.Columns[0]);
             SelectedNodeChanged(args, true);
         }
         catch (Exception ex)
         {
             ErrorLog.Error(ex.StackTrace.ToString());
         }
     }
 }