Ejemplo n.º 1
0
 /// <summary>
 /// 更新最新记录,根据stationId的唯一性
 /// </summary>
 /// <param name="entity"></param>
 public bool UpdateRTD(CEntityRealTime entity)
 {
     // 先找到ID所在的行
     m_mutexDataTable.WaitOne();
     for (int i = 0; i < m_dataTable.Rows.Count; ++i)
     {
         if (m_dataTable.Rows[i][CS_StationId].ToString().Trim() == entity.StrStationID.Trim())
         {
             // 找到匹配,直接更新并退出
             // this.Invoke(new Action(() => { m_bindingSource.ResumeBinding(); }), null);
             //this.DataSource = m_bindingSource;
             m_mutexDataTable.ReleaseMutex();
             return(base.UpdateRowData(i,
                                       GetUIShowStringList(entity).ToArray(),
                                       GetDataStatus(entity)));
         }
     }//end of for
     //this.DataSource = m_bindingSource;
     for (int i = 0; i < m_listEntityRTD.Count; ++i)
     {
         if (m_listEntityRTD[i].StrStationID.Trim() == entity.StrStationID.Trim())
         {
             //找到匹配更新
             m_listEntityRTD[i] = entity;
             break;
         }
     }
     m_mutexDataTable.ReleaseMutex();
     return(false);
 }
Ejemplo n.º 2
0
        // 更新实时数据的线程模拟
        public void SimulatorRTD()
        {
            int count = 0;

            while (true)
            {
                Thread.Sleep(10 * 1000);
                for (int i = 1; i < 401; ++i)
                {
                    CEntityRealTime entity = new CEntityRealTime();
                    entity.StrStationName   = String.Format("站点{0}", i);
                    entity.StrStationID     = (1000 + i).ToString();
                    entity.DDayRainFall     = 1000 + i * 2 + count * 2;
                    entity.StrPort          = "COM4";
                    entity.TimeDeviceGained = DateTime.Now;
                    entity.TimeReceived     = DateTime.Now.AddMinutes(count % 7 + 4);
                    entity.EIChannelType    = EChannelType.BeiDou;
                    entity.EIMessageType    = EMessageType.ETimed;
                    entity.EIStationType    = EStationType.ERainFall;
                    m_formRTD.UpdateRTD(entity);
                    // 睡眠10s钟
                    Thread.Sleep(10 * 1000);
                }
                ++count;
            }
        }
Ejemplo n.º 3
0
        // 计算当前数值的状态信息
        private CExDataGridView.EDataState GetDataStatus(CEntityRealTime entity)
        {
            // 看是否设定最大值,以及最小值,还有变化值之类的东东啦
            //             CExDataGridView.EDataState state = CExDataGridView.EDataState.ENormal;
            //             TimeSpan span = entity.TimeReceived - entity.TimeDeviceGained;
            //             int offset = Math.Abs(span.Minutes);
            //             if (offset > 5 && offset < 10)
            //             {
            //                 state = CExDataGridView.EDataState.EWarning;
            //             }
            //             else if (offset > 10)
            //             {
            //                 state = CExDataGridView.EDataState.EError;
            //             }
            //             return state;
            CExDataGridView.EDataState state = GetDataStatus(entity.TimeDeviceGained);
            if (state == EDataState.ENormal)
            {
                // 只有没超时的时候,才会显示实时数据的状态
                switch (entity.ERTDState)
                {
                case ERTDDataState.EError: state = CExDataGridView.EDataState.EPink; break;

                case ERTDDataState.ENormal: state = CExDataGridView.EDataState.ENormal; break;

                case ERTDDataState.EWarning: state = CExDataGridView.EDataState.EWarning; break;
                }
            }
            return(state);
        }
Ejemplo n.º 4
0
        // 添加一条实时记录
        public void AddRTD(CEntityRealTime entity)
        {
            TimeSpan span = entity.TimeReceived - entity.TimeDeviceGained;

            base.AddRow(GetUIShowStringList(entity).ToArray(), GetDataStatus(entity));
            m_listEntityRTD.Add(entity);
        }
Ejemplo n.º 5
0

        
Ejemplo n.º 6
0
 public void AddNewRow_1(CEntityRealTime realtime)
 {
     if (realtime == null)
     {
         return;
     }
     batchInsertRealtimeList.Add(realtime);
     batchInsertRealtimeList.Add(realtime);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 更新实时数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateRTD(CEntityRealTime entity)
        {
            // 根据ID进行分中心分发
            bool result = (m_dgvAllPage.DataGrid as CDataGridViewRTD).UpdateRTD(entity);
            // 获取每个站点分中心的ID
            CEntityStation station = CDBDataMgr.Instance.GetStationById(entity.StrStationID);

            if (m_mapSubCenterPage.ContainsKey(station.SubCenterID.Value))
            {
                result = result && (m_mapSubCenterPage[station.SubCenterID.Value].DataGrid as CDataGridViewRTD).UpdateRTD(entity);
            }
            return(result);
        }
Ejemplo n.º 8
0
        // 将当前所有数据插入数据库
        //protected override bool UpdateToDB()
        //{
        //    // 然后获取内存表的访问权
        //    m_mutexDataTable.WaitOne();

        //    if (m_tableDataUpdated.Rows.Count <= 0)
        //    {
        //        m_mutexDataTable.ReleaseMutex();
        //        return true;
        //    }
        //    //清空内存表的所有内容,把内容复制到临时表tmp中
        //    DataTable tmp = m_tableDataUpdated.Copy();
        //    m_tableDataUpdated.Rows.Clear();

        //    // 释放内存表的互斥量
        //    m_mutexDataTable.ReleaseMutex();

        //    // 先获取对数据库的唯一访问权
        //    m_mutexWriteToDB.WaitOne();

        //    try
        //    {
        //        //将临时表中的内容写入数据库
        //        //SqlConnection conn = CDBManager.GetInstacne().GetConnection();
        //        //conn.Open();
        //        string connstr = CDBManager.Instance.GetConnectionString();
        //        using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connstr))
        //        {
        //            // 实时表有插入触发器
        //            bulkCopy.BatchSize = 1;
        //            bulkCopy.BulkCopyTimeout = 1800;
        //            bulkCopy.DestinationTableName = CT_TableName;
        //            bulkCopy.ColumnMappings.Add(CN_CName, CN_CName);
        //            bulkCopy.ColumnMappings.Add(CN_StationId, CN_StationId);
        //            bulkCopy.ColumnMappings.Add(CN_StationType, CN_StationType);
        //            bulkCopy.ColumnMappings.Add(CN_YesterdayRain, CN_YesterdayRain);
        //            bulkCopy.ColumnMappings.Add(CN_TodayRain, CN_TodayRain);
        //            bulkCopy.ColumnMappings.Add(CN_PeriodRain, CN_PeriodRain);
        //            bulkCopy.ColumnMappings.Add(CN_WaterStage, CN_WaterStage);
        //            bulkCopy.ColumnMappings.Add(CN_WaterFlow, CN_WaterFlow);
        //            bulkCopy.ColumnMappings.Add(CN_Voltage, CN_Voltage);
        //            bulkCopy.ColumnMappings.Add(CN_DataState, CN_DataState);
        //            bulkCopy.ColumnMappings.Add(CN_TransType, CN_TransType);
        //            bulkCopy.ColumnMappings.Add(CN_MsgType, CN_MsgType);
        //            bulkCopy.ColumnMappings.Add(CN_DataTime, CN_DataTime);
        //            try
        //            {
        //                bulkCopy.WriteToServer(tmp);
        //            }
        //            catch (Exception e)
        //            {
        //                Debug.WriteLine(e.ToString());
        //            }
        //        }
        //        //conn.Close();   //关闭连接
        //        Debug.WriteLine("###{0} :add {1} lines to currentdata db", DateTime.Now, tmp.Rows.Count);
        //        CDBLog.Instance.AddInfo(string.Format("添加{0}行到实时表", tmp.Rows.Count));
        //        return true;
        //    }
        //    catch (System.Exception ex)
        //    {
        //        Debug.WriteLine(ex.ToString());
        //        return false;
        //    }
        //    finally
        //    {
        //        //S_MutexWriteToDB.ReleaseMutex();
        //        m_mutexWriteToDB.ReleaseMutex();
        //    }

        //}

        //private static Boolean IsNew(CEntityRealTime realTime)
        //{
        //    String station = realTime.StrStationID;
        //    DateTime dateTime = realTime.TimeDeviceGained;
        //    String sql = "select * from " + CT_TableName + " where StationID='" + station + " And DataTime >= " + dateTime + "';";
        //    SqlDataAdapter adapter = new SqlDataAdapter(sql, CDBManager.GetInstacne().GetConnection());
        //    DataTable dataTableTemp = new DataTable();
        //    adapter.Fill(dataTableTemp);
        //    if (dataTableTemp.Rows.Count > 0) return true;
        //    return false;
        //}

        private static Boolean IsInDB(CEntityRealTime realTime)
        {
            String         station       = realTime.StrStationID;
            String         sql           = "select * from " + CT_TableName + " where StationID='" + station + "';";
            SqlDataAdapter adapter       = new SqlDataAdapter(sql, CDBManager.GetInstacne().GetConnection());
            DataTable      dataTableTemp = new DataTable();

            adapter.Fill(dataTableTemp);
            if (dataTableTemp.Rows.Count > 0)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 添加实时数据
        /// </summary>
        /// <param name="entity"></param>
        public void AddRTD(CEntityRealTime entity)
        {
            // 根据ID进行分中心分发
            (m_dgvAllPage.DataGrid as CDataGridViewRTD).AddRTD(entity);

            // 获取每个站点分中心的ID
            CEntityStation station = CDBDataMgr.Instance.GetStationById(entity.StrStationID);

            if (m_mapSubCenterPage.ContainsKey(station.SubCenterID.Value))
            {
                (m_mapSubCenterPage[station.SubCenterID.Value].DataGrid as CDataGridViewRTD).AddRTD(entity);
            }
            //RefreshStationState();
            //(m_dgvAllPage.DataGrid as CDataGridViewRTD).RecalculateHeaderSize(); //计算表头宽度
        }
Ejemplo n.º 10
0
        private void RefreshStationState_1(CEntityRealTime entity)
        {
            List <CEntityStation> stationList_1 = CDBDataMgr.Instance.GetAllStation();
            int?subcenterid = 0;

            for (int i = 0; i < stationList_1.Count; i++)
            {
                if (entity.StrStationID == stationList_1[i].StationID)
                {
                    subcenterid = stationList_1[i].SubCenterID;
                }
            }
            Nullable <DateTime> time = CDBDataMgr.Instance.GetStationLastDateTime(entity.StrStationID);

            CListViewStationState.EStationState state = CListViewStationState.EStationState.EError;
            if (time.HasValue)
            {
                // 计算状态
                state = GetStationStateByTime(time.Value);
                (m_lvStationStateAllPage.ListView as CListViewStationState).UpdateStationState(entity.StrStationID, state);
                if (m_mapSubCenterPage.ContainsKey(subcenterid.Value))
                {
                    (m_mapSubCenterPage[subcenterid.Value].ListView as CListViewStationState).UpdateStationState(entity.StrStationID, state);
                }
            }
            else
            {
                // 没有数据红色
                (m_lvStationStateAllPage.ListView as CListViewStationState).UpdateStationState(entity.StrStationID, state);

                if (m_mapSubCenterPage.ContainsKey(subcenterid.Value))
                {
                    (m_mapSubCenterPage[subcenterid.Value].ListView as CListViewStationState).UpdateStationState(entity.StrStationID, state);
                }
            }
        }
Ejemplo n.º 11
0
        public bool UpdateRow(CEntityRealTime realtime)
        {
            bool result = false;

            if (realtime == null)
            {
                return(true);
            }
            List <CEntityRealTime> realTimeList = new List <CEntityRealTime>();

            realTimeList.Add(realtime);
            Dictionary <string, object> param = new Dictionary <string, object>();
            string suffix = "/currentdata/updateCurrentdataCS";
            string url    = "http://" + urlPrefix + suffix;

            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(realTimeList, Newtonsoft.Json.Formatting.None, timeConverter);

            param["currentdata"] = jsonStr;
            try
            {
                string resultJson = HttpHelper.Post(url, param);
                if (resultJson == "1")
                {
                    result = true;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("更新实时数据表失败");
                return(false);
            }
            return(result);
        }
Ejemplo n.º 12
0
        // 添加新列
        public void AddNewRow(CEntityRealTime realtime)
        {
            // 记录超过1000条,或者时间超过1分钟,就将当前的数据写入数据库
            m_mutexDataTable.WaitOne(); //等待互斥量
            DataRow row = m_tableDataAdded.NewRow();

            row[CN_CName]         = realtime.StrStationName;
            row[CN_StationId]     = realtime.StrStationID;
            row[CN_StationType]   = realtime.EIStationType;
            row[CN_YesterdayRain] = realtime.LastDayRainFall;
            row[CN_TodayRain]     = realtime.DDayRainFall;
            row[CN_PeriodRain]    = realtime.DPeriodRain;
            row[CN_WaterStage]    = realtime.DWaterYield;
            row[CN_WaterFlow]     = realtime.DWaterFlowActual;
            row[CN_Voltage]       = realtime.Dvoltage;
            row[CN_DataState]     = realtime.ERTDState;
            row[CN_MsgType]       = CEnumHelper.MessageTypeToDBStr(realtime.EIMessageType);
            row[CN_TransType]     = CEnumHelper.ChannelTypeToDBStr(realtime.EIChannelType);
            row[CN_DataTime]      = realtime.TimeDeviceGained.ToString(CDBParams.GetInstance().DBDateTimeFormat);

            m_tableDataAdded.Rows.Add(row);
            m_mutexDataTable.ReleaseMutex();

            // 判断是否需要创建新分区
            //CSQLPartitionMgr.Instance.MaintainVoltage(voltage.TimeCollect);
            if (m_tableDataAdded.Rows.Count >= CDBParams.GetInstance().AddBufferMax)
            {
                // 如果超过最大值,写入数据库
                NewTask(() => { AddDataToDB(); });
            }
            else
            {
                // 没有超过缓存最大值,开启定时器进行检测,多次调用Start()会导致重新计数
                m_addTimer.Start();
            }
        }
Ejemplo n.º 13
0
        // 添加新列
        public void AddNewRow(CEntityRealTime realtime)
        {
            if (realtime == null)
            {
                return;
            }
            List <CEntityRealTime> realTimeList = new List <CEntityRealTime>();

            realTimeList.Add(realtime);
            Dictionary <string, object> param = new Dictionary <string, object>();
            string suffix = "/currentdata/insertCurrentdataCS";
            string url    = "http://" + urlPrefix + suffix;

            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(realTimeList, Newtonsoft.Json.Formatting.None, timeConverter);

            param["currentdata"] = jsonStr;
            try
            {
                string resultJson = HttpHelper.Post(url, param);
                CDBLog.Instance.AddInfo(string.Format("添加{0}行到雨量表", realTimeList.Count));
            }
            catch (Exception e)
            {
                Debug.WriteLine("添加雨量信息失败");
            }
            //// 记录超过1000条,或者时间超过1分钟,就将当前的数据写入数据库
            //m_mutexDataTable.WaitOne(); //等待互斥量
            //DataRow row = m_tableDataAdded.NewRow();
            //row[CN_CName] = realtime.StrStationName;
            //row[CN_StationId] = realtime.StrStationID;
            //row[CN_StationType] = realtime.EIStationType;
            //row[CN_YesterdayRain] = realtime.LastDayRainFall;
            //row[CN_TodayRain] = realtime.DDayRainFall;
            //row[CN_PeriodRain] = realtime.DPeriodRain;
            //row[CN_WaterStage] = realtime.DWaterYield;
            //row[CN_WaterFlow] = realtime.DWaterFlowActual;
            //row[CN_Voltage] = realtime.Dvoltage;
            //row[CN_DataState] = realtime.ERTDState;
            //row[CN_MsgType] = CEnumHelper.MessageTypeToDBStr(realtime.EIMessageType);
            //row[CN_TransType] = CEnumHelper.ChannelTypeToDBStr(realtime.EIChannelType);
            //row[CN_DataTime] = realtime.TimeDeviceGained.ToString(CDBParams.GetInstance().DBDateTimeFormat);

            //m_tableDataAdded.Rows.Add(row);
            //m_mutexDataTable.ReleaseMutex();

            //// 判断是否需要创建新分区
            ////CSQLPartitionMgr.Instance.MaintainVoltage(voltage.TimeCollect);
            //if (m_tableDataAdded.Rows.Count >= CDBParams.GetInstance().AddBufferMax)
            //{
            //    // 如果超过最大值,写入数据库
            //    NewTask(() => { AddDataToDB(); });
            //}
            //else
            //{
            //    // 没有超过缓存最大值,开启定时器进行检测,多次调用Start()会导致重新计数
            //    m_addTimer.Start();
            //}
        }
Ejemplo n.º 14
0
        private List <string> GetUIShowStringList(CEntityRealTime entity)
        {
            List <string> result = new List <string>();
            TimeSpan      span   = entity.TimeReceived - entity.TimeDeviceGained;

            //表格头部信息
            //this.Header = new string[]
            //{
            //    CS_StationName, CS_StationId, CS_StationType, CS_TimeCollected, CS_DelayTime,
            //    CS_TodayRain, CS_LastdayRain,CS_PeriodRain, CS_WaterLevel,CS_V1,CS_V2,CS_V3,CS_V4, CS_WaterFlowActual,CS_WaterFlowFindInTable,
            //    CS_Volatage,CS_Port, CS_MsgType, CS_ChannelType
            //};

            result.Add(entity.StrStationName);                                                   //站名
            result.Add(entity.StrStationID.ToString());                                          //站号
            result.Add(CEnumHelper.StationTypeToUIStr(entity.EIStationType));                    //站类
            result.Add(entity.TimeDeviceGained.ToString());                                      //数据时间
            result.Add(string.Format("{0}m{1}s", span.Hours * 60 + span.Minutes, span.Seconds)); //延迟时间
            //if (entity.DDayRainFall.HasValue)
            //{
            //    result.Add(entity.DDayRainFall.Value.ToString("0.00"));/*今日雨量,计算*/
            //}
            //else
            //{
            //    result.Add(CS_NullUIStr);
            //}
            result.Add(CS_NullUIStr);//今日雨量
            //if (entity.LastDayRainFall.HasValue)
            //{
            //    result.Add(entity.LastDayRainFall.Value.ToString("0.00"));/*昨日雨量,计算*/
            //}
            //else
            //{
            //    result.Add(CS_NullUIStr);
            //}
            result.Add(CS_NullUIStr);//昨日雨量
            //if (entity.DPeriodRain.HasValue)
            //{
            //    if (entity.DPeriodRain.Value >= 0)
            //    {
            //        result.Add(entity.DPeriodRain.Value.ToString("0.00"));/*时段雨量,计算*/
            //    }
            //    else
            //    {
            //        result.Add("0.00");
            //    }
            //}
            //else
            //{
            //    result.Add(CS_NullUIStr);
            //}
            result.Add(CS_NullUIStr);//时段雨量

            //水位
            if (entity.DWaterYield.HasValue)
            {
                if (entity.DDayRainFall != (decimal) - 20000)
                {
                    result.Add(entity.DWaterYield.Value.ToString("0.00"));/*水位*/
                }
                else
                {
                    result.Add(CS_NullUIStr);
                }
            }
            else
            {
                result.Add(CS_NullUIStr);
            }



            //流速1
            if (entity.DV1.HasValue)
            {
                result.Add(entity.DV1.Value.ToString("0.000"));
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //流速2
            if (entity.DV2.HasValue)
            {
                result.Add(entity.DV2.Value.ToString("0.000"));
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //流速3
            if (entity.DV3.HasValue)
            {
                result.Add(entity.DV3.Value.ToString("0.000"));
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //流速4
            if (entity.DV4.HasValue)
            {
                result.Add(entity.DV4.Value.ToString("0.000"));
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //实测流量
            if (entity.DWaterFlowActual.HasValue)
            {
                result.Add(entity.DWaterFlowActual.Value.ToString("0.00"));/*实测流量*/
            }
            else
            {
                result.Add(CS_NullUIStr);
            }


            if (entity.DWaterFlowFindInTable.HasValue)
            {
                result.Add(entity.DWaterFlowFindInTable.Value.ToString("0.00"));/*相应流量*/
            }
            else
            {
                result.Add(CS_NullUIStr);/*相应流量*/
            }
            //result.Add(CS_NullUIStr); //相应流量

            result.Add(entity.Dvoltage.ToString());/*电压*/
            result.Add(entity.StrPort);
            result.Add(CEnumHelper.MessageTypeToUIStr(entity.EIMessageType));
            result.Add(CEnumHelper.ChannelTypeToUIStr(entity.EIChannelType));
            return(result);
        }
Ejemplo n.º 15
0
        private List <string> GetUIShowStringList(CEntityRealTime entity)
        {
            List <string> result = new List <string>();
            TimeSpan      span   = entity.TimeReceived - entity.TimeDeviceGained;

            //表格头部信息
            //this.Header = new string[]
            //{
            //    CS_StationName, CS_StationId, CS_StationType, CS_TimeCollected, CS_DelayTime,
            //    CS_TodayRain, CS_LastdayRain,CS_PeriodRain, CS_WaterLevel,CS_V1,CS_V2,CS_V3,CS_V4, CS_WaterFlowActual,CS_WaterFlowFindInTable,
            //    CS_Volatage,CS_Port, CS_MsgType, CS_ChannelType
            //};

            //0站名
            result.Add(entity.StrStationName);          //站名
            //1站号
            result.Add(entity.StrStationID.ToString()); //站号
            //result.Add(CEnumHelper.StationTypeToUIStr(entity.EIStationType));//站类
            //2数据时间
            result.Add(entity.TimeDeviceGained.ToString());//数据时间
            //3瞬时风向
            if (entity.SHFX.HasValue)
            {
                result.Add(entity.SHFX.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }
            //4延迟时间
            result.Add(string.Format("{0}m{1}s", span.Hours * 60 + span.Minutes, span.Seconds));//延迟时间

            //5瞬时风速
            if (entity.SHFS.HasValue)
            {
                result.Add(entity.SHFS.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }
            //6 10分钟平均风向
            if (entity.avg10fx.HasValue)
            {
                result.Add(entity.avg10fx.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //7 10分钟平均风速
            if (entity.avg10fs.HasValue)
            {
                result.Add(entity.avg10fs.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //8 1分钟能见度
            if (entity.Visi1min.HasValue)
            {
                result.Add(entity.Visi1min.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //9 10分钟能见度
            if (entity.Visi10min.HasValue)
            {
                result.Add(entity.Visi10min.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //10 深度
            if (entity.Depth.HasValue)
            {
                result.Add(entity.Depth.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //11 温度
            if (entity.Tmp.HasValue)
            {
                result.Add(entity.Tmp.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //12 浊度
            if (entity.Ntu.HasValue)
            {
                result.Add(entity.Ntu.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //13 电导率
            if (entity.Cndcty.HasValue)
            {
                result.Add(entity.Cndcty.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //14 盐度
            if (entity.Salinity.HasValue)
            {
                result.Add(entity.Salinity.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }

            //15 电压
            if (entity.Dvoltage.HasValue)
            {
                result.Add(entity.Dvoltage.ToString());
            }
            else
            {
                result.Add(CS_NullUIStr);
            }
            #region 老代码
            ////水位
            //if (entity.DWaterYield.HasValue)
            //{
            //    if (entity.DDayRainFall != (decimal)-20000)
            //    {
            //        result.Add(entity.DWaterYield.Value.ToString("0.00"));/*水位*/
            //    }
            //    else
            //    {
            //        result.Add(CS_NullUIStr);
            //    }
            //}
            //else
            //{
            //    result.Add(CS_NullUIStr);
            //}



            ////流速1
            //if (entity.DV1.HasValue)
            //{
            //    result.Add(entity.DV1.Value.ToString("0.000"));
            //}else
            //{
            //    result.Add(CS_NullUIStr);
            //}

            ////流速2
            //if (entity.DV2.HasValue)
            //{
            //    result.Add(entity.DV2.Value.ToString("0.000"));
            //}
            //else
            //{
            //    result.Add(CS_NullUIStr);
            //}

            ////流速3
            //if (entity.DV3.HasValue)
            //{
            //    result.Add(entity.DV3.Value.ToString("0.000"));
            //}
            //else
            //{
            //    result.Add(CS_NullUIStr);
            //}

            ////流速4
            //if (entity.DV4.HasValue)
            //{
            //    result.Add(entity.DV4.Value.ToString("0.000"));
            //}
            //else
            //{
            //    result.Add(CS_NullUIStr);
            //}

            ////实测流量
            //if (entity.DWaterFlowActual.HasValue)
            //{
            //    result.Add(entity.DWaterFlowActual.Value.ToString("0.00"));/*实测流量*/
            //}
            //else
            //{
            //    result.Add(CS_NullUIStr);
            //}


            //if (entity.DWaterFlowFindInTable.HasValue)
            //{
            //    result.Add(entity.DWaterFlowFindInTable.Value.ToString("0.00"));/*相应流量*/
            //}
            //else
            //{
            //    result.Add(CS_NullUIStr);/*相应流量*/
            //}
            ////result.Add(CS_NullUIStr); //相应流量

            //result.Add(entity.Dvoltage.ToString());/*电压*/
            //result.Add(entity.StrPort);
            //result.Add(CEnumHelper.MessageTypeToUIStr(entity.EIMessageType));
            //result.Add(CEnumHelper.ChannelTypeToUIStr(entity.EIChannelType));
            #endregion
            return(result);
        }
Ejemplo n.º 16
0
        private List <string> GetUIShowStringList(CEntityRealTime entity)
        {
            List <string> result = new List <string>();
            TimeSpan      span   = entity.TimeReceived - entity.TimeDeviceGained;

            result.Add(entity.StrStationName);
            result.Add(entity.StrStationID.ToString());
            result.Add(CEnumHelper.StationTypeToUIStr(entity.EIStationType));
            result.Add(entity.TimeDeviceGained.ToString());
            result.Add(string.Format("{0}m{1}s", span.Hours * 60 + span.Minutes, span.Seconds));
            if (entity.DDayRainFall.HasValue)
            {
                result.Add(entity.DDayRainFall.Value.ToString("0.00"));/*今日雨量,计算*/
            }
            else
            {
                result.Add(CS_NullUIStr);
            }
            if (entity.LastDayRainFall.HasValue)
            {
                result.Add(entity.LastDayRainFall.Value.ToString("0.00"));/*昨日雨量,计算*/
            }
            else
            {
                result.Add(CS_NullUIStr);
            }
            if (entity.DPeriodRain.HasValue)
            {
                if (entity.DPeriodRain.Value >= 0)
                {
                    result.Add(entity.DPeriodRain.Value.ToString("0.00"));/*时段雨量,计算*/
                }
                else
                {
                    result.Add("0.00");
                }
            }
            else
            {
                result.Add(CS_NullUIStr);
            }
            if (entity.DWaterYield.HasValue)
            {
                if (entity.DDayRainFall != (decimal) - 20000)
                {
                    result.Add(entity.DWaterYield.Value.ToString("0.00"));/*水位*/
                }
                else
                {
                    result.Add(CS_NullUIStr);
                }
            }
            else
            {
                result.Add(CS_NullUIStr);
            }
            if (entity.DWaterFlowActual.HasValue)
            {
                result.Add(entity.DWaterFlowActual.Value.ToString("0.00"));/*实测流量*/
            }
            else
            {
                result.Add(CS_NullUIStr);
            }
            if (entity.DWaterFlowFindInTable.HasValue)
            {
                result.Add(entity.DWaterFlowFindInTable.Value.ToString("0.00"));/*相应流量*/
            }
            else
            {
                result.Add(CS_NullUIStr);/*相应流量*/
            }


            result.Add(entity.Dvoltage.ToString());/*电压*/
            result.Add(entity.StrPort);
            result.Add(CEnumHelper.MessageTypeToUIStr(entity.EIMessageType));
            result.Add(CEnumHelper.ChannelTypeToUIStr(entity.EIChannelType));
            return(result);
        }