气象信息服务平台

时间:2015-11-29 08:37:47
【文件属性】:

文件名称:气象信息服务平台

文件大小:452KB

文件格式:RAR

更新时间:2015-11-29 08:37:47

气象 短信

气象短息发布平台,适合地市级气象局使用 private void timer1_Tick(object sender, EventArgs e) { // DateTime now = DateTime.Now; DateTime t = DateTime.Now; DateTime zhengdian = new DateTime(t.Year, t.Month, t.Day, t.Hour, t.Minute, t.Second); DateTime shijian = new DateTime(t.Year, t.Month, t.Day, 15, 50, 0); // DateTime shijian1 = new DateTime(t.Year, t.Month, t.Day); if (shijian == zhengdian) { StreamReader sr = new StreamReader("d:\\forecast\\dq1", System.Text.Encoding.Default); string chr1, chr2, fx1, fx2, fs1, fs2; string wea, wind, wins, tqxx; int tmax, tmin; string[] tq = new string[32] { "晴", "多云", "阴", "阵雨", "雷阵雨", "雷阵雨夹雪", "雨夹雪", "小雨", "中雨", "大雨", "暴雨", "大暴雨", "特大暴雨", "阵雪", "小雪", "中雪", "大雪", "暴雪", "雾", "冻雨", "沙尘暴", "小到中雨", "中到大雨", "大到暴雨", "暴雨到大暴雨", "大暴雨到特大暴雨", "小到中雪", "中到大雪", "大到暴雪", "浮尘", "扬沙", "强沙尘暴" }; string[] st = new string[7] { "拉萨", "日喀则", "那曲", "林芝", "泽当", "狮泉河", "昌都" }; string[] stnum = new string[7] { "55591", "55578", "55299", "56312", "55598", "55228", "56137" }; string[] fx = new string[10] { "", "东北风", "东风", "东南风", "南风", "西南风", "西风", "西北风", "北风", "旋转不定风" }; string[] fs = new string[10] { "", "3~4级", "4~5级", "5~6级", "6~7级", "7~8级", "8~9级", "9~10级", "10~11级", "11~12级" }; string strline = sr.ReadLine(); int i = 0, c, w1, w2; SqlConnection con5 = bc1.getcon(); con5.Open(); int rn = bc1.getrecnum("select count(*)from ybdata"); SqlCommand cmd5 = new SqlCommand(); string sqlins; while (strline != null) { chr1 = strline.Substring(0, 5); if (chr1 == stnum[i]) { chr1 = strline.Substring(6, 5); w1 = Convert.ToInt32(chr1) / 100; w2 = Convert.ToInt32(chr1) % 100; if (w1 == w2) { wea = tq[w1]; } else { wea = tq[w1] + "转" + tq[w2]; } chr1 = strline.Substring(12, 5); c = Convert.ToInt32(chr1) - 10000; if (c == 0) { wind = ""; wins = ""; } else { chr2 = c.ToString(); fx1 = fx[Convert.ToInt32(chr2.Substring(0, 1))]; fx2 = fx[Convert.ToInt32(chr2.Substring(1, 1))]; fs1 = fs[Convert.ToInt32(chr2.Substring(2, 1))]; fs2 = fs[Convert.ToInt32(chr2.Substring(3, 1))]; if (fx1 == fx2) { wind = fx1; } else { wind = fx1 + "转" + fx2; } if (fs1 == fs2) { wins = fs1; } else { wins = fs1 + "转" + fs2; } } chr1 = strline.Substring(18, 5); tmin = (Convert.ToInt32(chr1) - 20000) / 100; tmax = (Convert.ToInt32(chr1) - 20000) % 100; if (tmin >= 50) { tmin = 0 - (tmin - 50); } if (tmax >= 50) { tmax = 0 - (tmax - 50); } if (wind == "") { tqxx = "便民气象站:" + st[i] + "今晚到明天" + wea + ",气温" + tmin + "到" + tmax + "度。"; } else { tqxx = "便民气象站:" + st[i] + "今晚到明天" + wea + "," + wind + wins + ",气温" + tmin + "到" + tmax + "度。"; } rn = rn + 1; sqlins = "insert into ybdata (id,diming,yubao,time) values('" + rn + "','" + st[i] + "','" + tqxx + "','" + DateTime.Now.ToString("yyyy-MM-dd") + "')"; cmd5.CommandText = sqlins; cmd5.Connection = con5; cmd5.ExecuteNonQuery(); } strline = sr.ReadLine(); i = i + 1; if (i > 6) { break; } } // MessageBox.Show("预报文件已生成!"); con5.Close(); sr.Close(); }


网友评论

  • 还好吧,不过没有防雷信息系统吗?