Ejemplo n.º 1
0
        public List <CEntityTSRain> QueryForAll(string stationid, DateTime start, DateTime end)
        {
            List <CEntityTSRain> results = null;
            string         sql           = "select * from " + CT_TableName + " where stationid= " + stationid + " and between '" + start + "' and  '" + end + "' order by datatime desc;";
            SqlDataAdapter adapter       = new SqlDataAdapter(sql, CDBManager.GetInstacne().GetConnection());
            DataTable      dataTableTemp = new DataTable();

            adapter.Fill(dataTableTemp);
            for (int rowid = 0; rowid < dataTableTemp.Rows.Count; ++rowid)
            {
                CEntityTSRain rain = new CEntityTSRain();
                rain.StationID   = dataTableTemp.Rows[rowid][CN_StationId].ToString();
                rain.TimeCollect = DateTime.Parse(dataTableTemp.Rows[rowid][CN_DataTime].ToString());
                if (dataTableTemp.Rows[rowid][CN_TotalRain].ToString() != "")
                {
                    rain.TotalRain = decimal.Parse(dataTableTemp.Rows[rowid][CN_TotalRain].ToString());
                }
                else
                {
                    rain.TotalRain = -9999;
                }
                try
                {
                    rain.TimeCollect = DateTime.Parse(dataTableTemp.Rows[rowid][CN_DataTime].ToString());
#pragma warning disable CS0168 // 声明了变量“e”,但从未使用过
                }catch (Exception e)
#pragma warning restore CS0168 // 声明了变量“e”,但从未使用过
                {
                }
                try
                {
                    rain.TimeRecieved = DateTime.Parse(dataTableTemp.Rows[rowid][CN_RecvDataTime].ToString());
                }
#pragma warning disable CS0168 // 声明了变量“e”,但从未使用过
                catch (Exception e)
#pragma warning restore CS0168 // 声明了变量“e”,但从未使用过
                {
                }


                try
                {
                    //rain.MessageType = dataTableTemp.Rows[rowid][CN_MsgType]));
                }
#pragma warning disable CS0168 // 声明了变量“e”,但从未使用过
                catch (Exception e)
#pragma warning restore CS0168 // 声明了变量“e”,但从未使用过
                {
                }

                results.Add(rain);
            }
            return(results);
        }
Ejemplo n.º 2
0
        public void AddNewRow(CEntityTSRain rain)
        {
            m_mutexDataTable.WaitOne(); //等待互斥量
            DataRow row = m_tableDataAdded.NewRow();

            row[CN_StationId]    = rain.StationID;
            row[CN_DataTime]     = rain.TimeCollect.ToString(CDBParams.GetInstance().DBDateTimeFormat);
            row[CN_TotalRain]    = rain.TotalRain;
            row[CN_TransType]    = CEnumHelper.ChannelTypeToDBStr(rain.ChannelType);
            row[CN_MsgType]      = CEnumHelper.MessageTypeToDBStr(rain.MessageType);
            row[CN_RecvDataTime] = rain.TimeRecieved.ToString(CDBParams.GetInstance().DBDateTimeFormat);
            m_tableDataAdded.Rows.Add(row);
            m_mutexDataTable.ReleaseMutex();
            AddDataToDB();
        }
Ejemplo n.º 3
0
        private List <CEntityTSRain> CopyDataToList(int key, int startRow)
        {
            List <CEntityTSRain> result = new List <CEntityTSRain>();
            // 取最小值 ,保证不越界
            int       endRow = Math.Min(m_mapDataTable[key].Rows.Count, startRow + CDBParams.GetInstance().UIPageRowCount);
            DataTable table  = m_mapDataTable[key];

            for (; startRow < endRow; ++startRow)
            {
                CEntityTSRain rain = new CEntityTSRain();
                //  rain.RainID = long.Parse(table.Rows[startRow][CN_RainID].ToString());
                rain.StationID   = table.Rows[startRow][CN_StationId].ToString();
                rain.TimeCollect = DateTime.Parse(table.Rows[startRow][CN_DataTime].ToString());
                if (!table.Rows[startRow][CN_TotalRain].ToString().Equals(""))
                {
                    rain.TotalRain = Decimal.Parse(table.Rows[startRow][CN_TotalRain].ToString());
                }
                rain.TimeRecieved = DateTime.Parse(table.Rows[startRow][CN_RecvDataTime].ToString());
                rain.ChannelType  = CEnumHelper.DBStrToChannelType(table.Rows[startRow][CN_TransType].ToString());
                rain.MessageType  = CEnumHelper.DBStrToMessageType(table.Rows[startRow][CN_MsgType].ToString());
                result.Add(rain);
            }
            return(result);
        }