Exemple #1
0
        private List <ZoneForecastInfo> GetForecastInfo(DateTime dt, string area, DateTime dtStart)
        {
            List <ZoneForecastInfo> listInfo = null;
            DataTable dtTable  = null;
            DataTable dtTable2 = null;

            try
            {
                string strSQL  = "SELECT distinct RECID,DDATETIME,YBSX,RAIN,T2M,RHSFC,WSPD10M,WDIR10M,FORECASTTIME";
                string strSQL1 = "SELECT max(T2M) as MAXTEMPERATURE,MIN(T2M) AS MINTEMPERATURE";
                strSQL  += string.Format(" FROM T_HK_NEW_GRID_FORECAST T WHERE DDATETIME = TO_DATE('{0}','YYYY-MM-DD HH24:MI:SS') AND VENUEID = {1} AND  FORECASTTIME>TO_DATE('{2}','YYYY-MM-DD HH24:MI:SS') AND ROWNUM<=24  ORDER BY YBSX,FORECASTTIME", dt, GetZoneNum(area).Split(';')[0], dtStart);
                strSQL1 += string.Format(" FROM T_HK_NEW_GRID_FORECAST T WHERE DDATETIME = TO_DATE('{0}','YYYY-MM-DD HH24:MI:SS') AND VENUEID = {1} AND  FORECASTTIME>TO_DATE('{2}','YYYY-MM-DD HH24:MI:SS') AND ROWNUM<=24  ORDER BY YBSX,FORECASTTIME", dt, GetZoneNum(area).Split(';')[0], dtStart);
                try
                {
                    OracleHelper th = new OracleHelper("HAIKOUConnect");
                    dtTable  = th.ExecuteDataTable(strSQL);
                    dtTable2 = th.ExecuteDataTable(strSQL1);
                    if (dtTable != null && dtTable.Rows.Count > 0 && dtTable2 != null && dtTable2.Rows.Count > 0)
                    {
                        listInfo = new List <ZoneForecastInfo>();
                        string name = GetZoneNum(area).Split(';')[1].Trim();
                        for (int i = 0; i < dtTable.Rows.Count; i++)
                        {
                            ZoneForecastInfo info = new ZoneForecastInfo();
                            info.AreaName       = name;
                            info.Recid          = dtTable.Rows[i]["RECID"].ToString();
                            info.Ddatetime      = dtTable.Rows[i]["DDATETIME"].ToString();
                            info.Ybsx           = dtTable.Rows[i]["YBSX"].ToString();
                            info.Rain           = Convert.ToDouble(dtTable.Rows[i]["RAIN"]).ToString("####0.#");
                            info.T2m            = Convert.ToDouble(dtTable.Rows[i]["T2M"]).ToString("####0.#");
                            info.Rhsfc          = Convert.ToDouble(dtTable.Rows[i]["RHSFC"]).ToString("####0.#");
                            info.Wspd10m        = Convert.ToDouble(dtTable.Rows[i]["WSPD10M"]).ToString("####0.#");
                            info.Wdir10m        = Convert.ToDouble(dtTable.Rows[i]["WDIR10M"]).ToString("####0.#");
                            info.Forecasttime   = dtTable.Rows[i]["FORECASTTIME"].ToString();
                            info.Rain2          = info.Rain;
                            info.T2m2           = info.T2m;
                            info.Maxtemperature = Convert.ToDouble(dtTable2.Rows[0]["MAXTEMPERATURE"]).ToString("####0.#");
                            info.Mintemperature = Convert.ToDouble(dtTable2.Rows[0]["MINTEMPERATURE"]).ToString("####0.#");
                            listInfo.Add(info);
                        }
                    }
                }
                catch (Exception ex)
                {
                    CreateLogTxt.ErrWriter(ex);
                }
            }
            catch (Exception ex)
            {
                CreateLogTxt.WriteLog(ex.ToString());
            }
            return(listInfo);
        }