/// <summary> /// 查询设备状态日志 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnStatusFind_Click(object sender, EventArgs e) { if (!CStaticClass.CheckPushService()) {// 检查服务 return; } QueryServiceClient proxy = new QueryServiceClient(); try { int nIndex = this.CboStatusCondition.SelectedIndex; string strContent = "所有"; if (this.TxtStatusContent.Visible && this.TxtStatusContent.Enabled) { if (string.IsNullOrEmpty(this.TxtStatusContent.Text)) { strContent = string.Empty; } else { strContent = this.TxtStatusContent.Text.Trim(); } } else if (this.CboStatusContent.Visible) { if (string.IsNullOrEmpty(this.CboStatusContent.Text)) { strContent = string.Empty; } else { strContent = this.CboStatusContent.Text.Trim(); } } if (0 > nIndex || string.IsNullOrEmpty(strContent)) { MessageBox.Show("查询条件和查询内容不能为空!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DateTime dtStart = this.DtpStatusStart.Value; // 起始日期 DateTime dtEnd = this.DtpStatusEnd.Value; // 截止日期 if (0 == nIndex) { // 根据库区查询 strContent = CStaticClass.ConvertWareHouse(strContent).ToString(); } // 获取所有设备状态日志列表(根据查询条件查询) List <CDeviceStatusLogDto> lstLogDto = proxy.GetDeviceStatusLogListByContent(nIndex, dtStart, dtEnd, strContent); //// 根据查询条件查询 //switch (nIndex) //{ // case 0:// 根据库区查询 // { // lstLogDto = lstLogDto.FindAll(s => CompareDateTime(s.time, dtStart, dtEnd) && CStaticClass.ConvertWareHouse(s.warehouse) == strContent); // break; // } // case 1:// 根据设备号 // { // lstLogDto = lstLogDto.FindAll(s => CompareDateTime(s.time, dtStart, dtEnd) && s.devicecode.ToString() == strContent); // break; // } // default: // lstLogDto = lstLogDto.FindAll(s => CompareDateTime(s.time, dtStart, dtEnd)); // break; //} m_lstDeviceStatusLog = lstLogDto; this.DgvStatus.DataSource = new BindingList <CDeviceStatusLogDto>(lstLogDto); if (null == lstLogDto || 0 == lstLogDto.Count) { MessageBox.Show("抱歉,没有找到符合条件的记录!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch (TimeoutException) { MessageBox.Show("The service operation timed out. ", "超时", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FaultException exception) { MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "SOAP错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (CommunicationException exception) { MessageBox.Show("There was a communication problem. " + CStaticClass.GetExceptionInfo(exception), "通信错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception exception) { MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "应用程序异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } proxy.Close(); }