Esempio n. 1
0
        protected void BtnImport_Click(object sender, EventArgs e)
        {
            DATAHOUR_BLL hbll      = new DATAHOUR_BLL();
            LiveData_BLL lbll      = new LiveData_BLL();
            DateTime     startTime = DateTime.ParseExact("2017" + MonthDDL.SelectedItem.Value + "01" + "08", "yyyyMMddHH", CultureInfo.InvariantCulture);
            DateTime     endTime   = startTime.AddMonths(1);

            TimeSpan ts = endTime - startTime;

            for (int i = 0; i < ts.Days; i++)
            {
                DateTime stime = startTime.AddDays(i);
                DateTime etime = stime.AddDays(1);

                List <string> citynames = CityUtility.AllNameList();
                foreach (string cityname in citynames)
                {
                    string selectname = cityname;
                    if (cityname == "黄岛")
                    {
                        selectname = "胶南";
                    }

                    List <DATAHOUR> dlist = hbll.GetList(a => a.STANAME == selectname && a.MINTEMP != 9999 && a.MAXTEMP != 9999 && a.FDATE >= stime && a.FDATE < etime).ToList();
                    if (dlist.Count > 0)
                    {
                        DateTime seletime = DateTime.Parse(stime.ToShortDateString());

                        LiveData liveData = lbll.Get(a => a.CountryName == cityname && a.FDate == seletime && a.Category == "08时");
                        if (liveData != null)
                        {
                            liveData.MaxTemp = dlist.Max(a => a.MAXTEMP);
                            liveData.MinTemp = dlist.Min(a => a.MINTEMP);
                            lbll.Update(liveData);
                        }
                        else
                        {
                            LiveData newModel = new LiveData();
                            newModel.LDID        = Guid.NewGuid();
                            newModel.FDate       = stime;
                            newModel.Category    = "08时";
                            newModel.CountryCode = CityUtility.GetCode(cityname);
                            newModel.CountryName = cityname;
                            newModel.CreateTime  = DateTime.Now;
                            newModel.MaxTemp     = dlist.Max(a => a.MAXTEMP);
                            newModel.MinTemp     = dlist.Min(a => a.MINTEMP);
                            lbll.Add(newModel);
                        }
                        Response.Write(cityname + "<br/>");
                    }
                }

                Response.Write(stime.ToString("yyyy-MM-dd HH:mm") + "~" + etime.ToString("yyyy-MM-dd HH:mm") + "<br/>");
            }
        }
Esempio n. 2
0
        public void DataImport()
        {
            LiveData_BLL    bll         = new LiveData_BLL();
            List <FileInfo> allFileList = FileHelper.GetShareFileInfos(@"\\172.18.226.109\市县一体化平台文档\检验\r24-8-p", "*.000", "administrator", "yubk0501!");

            foreach (FileInfo fileInfo in allFileList)
            {
                DateTime fileDateTime = DateTime.ParseExact("20" + fileInfo.Name.Substring(0, 6), "yyyyMMdd", CultureInfo.InvariantCulture);


                if (fileDateTime.Day == 7)
                {
                    var aaa = fileDateTime;
                }
                DateTime      dataDateTime = fileDateTime.AddDays(-1);
                string[]      contents     = FileHelper.GetShareTextLines(@"\\172.18.226.109\市县一体化平台文档\检验\r24-8-p\" + fileInfo.Name, "Administrator", "yubk0501!");
                List <string> citycodes    = CityUtility.AllCodeList();
                foreach (string citycode in citycodes)
                {
                    string  line = contents.Where(a => a.Contains(citycode)).FirstOrDefault();
                    decimal rain = 0;
                    if (!string.IsNullOrEmpty(line))
                    {
                        rain = decimal.Parse(line.Substring(27, 5).Trim());
                    }
                    LiveData liveData = bll.Get(a => a.CountryCode == citycode && a.FDate == dataDateTime && a.Category == "08时");
                    if (liveData != null)
                    {
                        liveData.Rain = rain;
                        bll.Update(liveData);
                    }
                    else
                    {
                        LiveData newModel = new LiveData();
                        newModel.LDID        = Guid.NewGuid();
                        newModel.Category    = "08时";
                        newModel.CountryCode = citycode;
                        newModel.CountryName = CityUtility.GetName(citycode);
                        newModel.CreateTime  = DateTime.Now;
                        newModel.Rain        = rain;
                        newModel.FDate       = dataDateTime;
                        bll.Add(newModel);
                    }
                }
            }

            Response.Write(allFileList.Count.ToString());
        }
Esempio n. 3
0
        public void Calculate08()
        {
            File_Z_BLL    zbll    = new File_Z_BLL();
            LiveData_BLL  lbll    = new LiveData_BLL();
            DateTime      lastDay = DateTime.Now.AddDays(-5);
            List <File_Z> zlist   = zbll.GetList(a => a.Date >= lastDay).ToList();

            DateTime newDay = (DateTime)zlist.Max(a => a.Date);

            List <File_Z> prelist = zlist.Where(a => a.Date != newDay).OrderBy(a => a.Date).ToList();


            foreach (File_Z fileZ in prelist)
            {
                DateTime nextDay = ((DateTime)fileZ.Date).AddDays(1);

                File_Z nextFileZ = zlist.Where(a => a.Date == nextDay && a.CountryCode == fileZ.CountryCode).FirstOrDefault();


                LiveData liveData = lbll.Get(a => a.FDate == fileZ.Date && a.CountryCode == fileZ.CountryCode && a.Category == "08时");
                if (liveData != null)
                {
                    if (liveData.Rain == null)
                    {
                        liveData.Rain = fileZ.Eight_Twenty + nextFileZ.Twenty_Eight;
                        lbll.Update(liveData);
                    }
                }
                else
                {
                    liveData = new LiveData()
                    {
                        LDID        = Guid.NewGuid(),
                        Category    = "08时",
                        CountryCode = fileZ.CountryCode,
                        CountryName = fileZ.CountryName,
                        CreateTime  = DateTime.Now,
                        FDate       = fileZ.Date,
                        Rain        = fileZ.Eight_Twenty + nextFileZ.Twenty_Eight
                    };
                    lbll.Add(liveData);
                }
                Console.WriteLine("成功计算08时:" + fileZ.CountryName + fileZ.Date.ToString());
            }
        }
Esempio n. 4
0
        public void Calculate20()
        {
            File_Z_BLL   zbll    = new File_Z_BLL();
            LiveData_BLL lbll    = new LiveData_BLL();
            DateTime     lastDay = DateTime.Now.AddDays(-5);

            List <File_Z> zlist = zbll.GetList(a => a.Date >= lastDay).OrderBy(a => a.Date).ToList();

            foreach (File_Z fileZ in zlist)
            {
                LiveData liveData = lbll.Get(a => a.FDate == fileZ.Date && a.CountryCode == fileZ.CountryCode && a.Category == "20时");
                if (liveData != null)
                {
                    if (liveData.Rain == null)
                    {
                        liveData.Rain = fileZ.Twenty_Eight + fileZ.Eight_Twenty;
                        lbll.Update(liveData);
                    }
                }
                else
                {
                    liveData = new LiveData()
                    {
                        LDID        = Guid.NewGuid(),
                        Category    = "20时",
                        CountryCode = fileZ.CountryCode,
                        CountryName = fileZ.CountryName,
                        CreateTime  = DateTime.Now,
                        FDate       = fileZ.Date,
                        Rain        = fileZ.Twenty_Eight + fileZ.Eight_Twenty
                    };
                    lbll.Add(liveData);
                }

                Console.WriteLine("成功计算20时:" + fileZ.CountryName + fileZ.Date.ToString());
            }
        }
Esempio n. 5
0
        public void Temp20()
        {
            DATAHOUR_BLL hbll = new DATAHOUR_BLL();
            LiveData_BLL lbll = new LiveData_BLL();



            DateTime.Now.AddDays(-1).ToString("yyyyMMdd");


            DateTime startTime = DateTime.ParseExact(DateTime.Now.AddDays(-5).ToString("yyyyMMdd") + "20", "yyyyMMddHH", CultureInfo.InvariantCulture);
            DateTime endTime   = startTime.AddDays(4);

            TimeSpan ts = endTime - startTime;

            for (int i = 0; i < ts.Days; i++)
            {
                DateTime stime = startTime.AddDays(i);
                DateTime etime = stime.AddDays(1);

                List <string> citynames = CityUtility.AllNameList();
                foreach (string cityname in citynames)
                {
                    string selectname = cityname;
                    if (cityname == "黄岛")
                    {
                        selectname = "胶南";
                    }

                    List <DATAHOUR> dlist = hbll.GetList(a => a.STANAME == selectname && a.MINTEMP != 9999 && a.MAXTEMP != 9999 && a.FDATE >= stime && a.FDATE < etime).ToList();
                    if (dlist.Count > 0)
                    {
                        DateTime seletime = DateTime.Parse(etime.ToShortDateString());

                        LiveData liveData = lbll.Get(a => a.CountryName == cityname && a.FDate == seletime && a.Category == "20时");
                        if (liveData != null)
                        {
                            liveData.MaxTemp = dlist.Max(a => a.MAXTEMP);
                            liveData.MinTemp = dlist.Min(a => a.MINTEMP);
                            lbll.Update(liveData);
                        }
                        else
                        {
                            LiveData newModel = new LiveData();
                            newModel.LDID        = Guid.NewGuid();
                            newModel.FDate       = etime;
                            newModel.Category    = "20时";
                            newModel.CountryCode = CityUtility.GetCode(cityname);
                            newModel.CountryName = cityname;
                            newModel.CreateTime  = DateTime.Now;
                            newModel.MaxTemp     = dlist.Max(a => a.MAXTEMP);
                            newModel.MinTemp     = dlist.Min(a => a.MINTEMP);
                            lbll.Add(newModel);
                        }

                        Console.WriteLine(cityname);
                    }
                }

                Console.WriteLine(stime.ToString("yyyy-MM-dd HH:mm") + "~" + etime.ToString("yyyy-MM-dd HH:mm"));
            }
        }