コード例 #1
0
ファイル: ScoreDay.aspx.cs プロジェクト: cycle13/QiXiang_YBPF
        //计算全部在下面
        protected void Button_Calculate_Click(object sender, EventArgs e)
        {
            LiveData_BLL liveBll   = new LiveData_BLL();
            DateTime     startTime = DateTime.Parse(DropDownList_Year.SelectedItem.Value + "-" + DropDownList_Month.SelectedItem.Value + "-01");
            DateTime     endTime   = startTime.AddMonths(1);

            if (liveBll.DataCheck(startTime, DropDownList_YBTime.SelectedItem.Value))
            {
                JavaScriptHelper.Loading("大人请稍后,奴才正在拼命计算...");


                Score_Day_BLL bll = new Score_Day_BLL();
                if (DropDownList_YBTime.SelectedItem.Value == "08时")
                {
                    bll.Caculate08_ByYbUser(startTime, endTime);
                }
                else
                {
                    bll.Caculate20_ByYbUser(startTime, endTime);
                }
                JavaScriptHelper.UnLoading();

                Response.Write("<script language=javascript defer>alert('计算完成!');</script>");
            }
            else
            {
                Response.Write("<script language=javascript defer>alert('抱歉,该月实况数据不完整,请校验!');</script>");
            }
        }
コード例 #2
0
        protected void Btn_LiveData_Query_Click(object sender, EventArgs e)
        {
            DateTime        startTime = DateTime.Parse(DDL_LiveData_Query_Year.SelectedItem.Value + "-" + DDL_LiveData_Query_Month.SelectedItem.Value + "-01");
            DateTime        endTime   = startTime.AddMonths(1);
            LiveData_BLL    bll       = new LiveData_BLL();
            List <LiveData> list      = bll.GetList(a => a.Category == DDL_LiveData_Query_Time.SelectedItem.Value && a.FDate >= startTime && a.FDate < endTime).OrderBy(a => a.FDate).ThenBy(a => a.CountryName).ToList();

            GridView_LiveData.DataSource = list;
            GridView_LiveData.DataBind();
        }
コード例 #3
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/>");
            }
        }
コード例 #4
0
        protected void Btn_Import_TempAndRain20_Click(object sender, EventArgs e)
        {
            JavaScriptHelper.Loading("大人请稍后,奴才正在拼命计算...");

            DateTime     date    = DateTime.Parse(DropDownList_Year.SelectedItem.Value + "-" + DropDownList_Month.SelectedItem.Value + "-01");
            LiveData_BLL bll     = new LiveData_BLL();
            string       message = bll.DataImportAFile(date);

            Label_DataMiss.Text = message;
            JavaScriptHelper.UnLoading();
        }
コード例 #5
0
        protected void Btn_Import_MonthEarlier_Click(object sender, EventArgs e)
        {
            JavaScriptHelper.Loading("大人请稍后,奴才正在拼命计算...");

            DateTime      date    = DateTime.Parse(DropDownList_Year.SelectedItem.Value + "-" + DropDownList_Month.SelectedItem.Value + "-01");
            LiveData_BLL  bll     = new LiveData_BLL();
            StringBuilder message = new StringBuilder();

            message.Append("1、" + bll.DataImportTemp08(date, 3));
            message.Append("2、" + bll.DataImportTemp20(date, 3));
            Label_DataMiss.Text = message.ToString();
            JavaScriptHelper.UnLoading();
        }
コード例 #6
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());
        }
コード例 #7
0
ファイル: ZFile.cs プロジェクト: cycle13/QiXiang_YBPF
        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());
            }
        }
コード例 #8
0
ファイル: ZFile.cs プロジェクト: cycle13/QiXiang_YBPF
        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());
            }
        }
コード例 #9
0
        public void DataImport()
        {
            LiveData_BLL    bll         = new LiveData_BLL();
            List <FileInfo> allFileList = FileHelper.GetShareFileInfos(@"\\172.18.226.109\市县一体化平台文档\检验\A", "A*", "administrator", "yubk0501!");

            foreach (FileInfo fileInfo in allFileList)
            {
                List <LiveData> sklist = new List <LiveData>();

                //string contents = File.ReadAllText(@"\\172.18.226.10\nt40\zdzh\" + item.Value);
                string countrycode = fileInfo.Name.Substring(1, 5);
                //string apath = @"P:\zdzh\" + item.Value;
                string contents   = FileHelper.GetShareTextContent(@"\\172.18.226.109\市县一体化平台文档\检验\A\" + fileInfo.Name, "Administrator", "yubk0501!", Encoding.Default);
                string tbcontents =
                    contents.Substring(contents.IndexOf("TB") + 4,
                                       (contents.IndexOf("IB") - contents.IndexOf("TB") - 7)).Replace("\r\n", "");
                string[] tb = tbcontents.Split('.');


                for (int i = 0; i < tb.Length; i++)
                {
                    LiveData shikuang = new LiveData();
                    shikuang.LDID        = Guid.NewGuid();
                    shikuang.FDate       = DateTime.ParseExact(fileInfo.Name.Substring(7, 6) + (i + 1).ToString("00"), "yyyyMMdd", CultureInfo.InvariantCulture);
                    shikuang.CountryCode = countrycode;
                    shikuang.CreateTime  = DateTime.Now;
                    shikuang.CountryName = CityUtility.GetName(countrycode);
                    shikuang.Category    = "20时";

                    shikuang.MaxTemp = decimal.Parse(tb[i].Substring(119, 4)) / 10;
                    shikuang.MinTemp = decimal.Parse(tb[i].Substring(129, 4)) / 10;
                    sklist.Add(shikuang);
                }
                string raincontents =
                    contents.Substring(contents.IndexOf("R6") + 4, tb.Length * 16 - 2).Replace("\r\n", ".");
                string raincontents2 =
                    contents.Substring(contents.IndexOf("R6") + 4, tb.Length * 18 - 3).Replace("\r\n", ".");
                string[] rains = raincontents.Split('.');


                for (int i = 0; i < rains.Length; i++)
                {
                    string rainstr = rains[i].Substring(10, 4);
                    if (rainstr != ",,,,")
                    {
                        sklist.ElementAt(i).Rain = decimal.Parse(rainstr) / 10;
                    }
                    else
                    {
                        sklist.ElementAt(i).Rain = (decimal)0.01;
                    }
                }

                foreach (var item in sklist)
                {
                    int count = bll.GetCount(a => a.CountryCode == item.CountryCode && a.FDate == item.FDate && a.Category == "20时");
                    if (count <= 0)
                    {
                        bll.Add(item);
                    }
                }

                Response.Write(countrycode + " " + fileInfo.Name.Substring(7, 6) + sklist.Count().ToString());
            }

            Response.Write(allFileList.Count().ToString());
        }
コード例 #10
0
        protected void Btn_DataCheck_Click(object sender, EventArgs e)
        {
            DateTime        startTime = DateTime.Parse(DropDownList_Year.SelectedItem.Value + "-" + DropDownList_Month.SelectedItem.Value + "-01");
            DateTime        endTime   = startTime.AddMonths(1);
            LiveData_BLL    bll       = new LiveData_BLL();
            List <LiveData> list      =
                bll.GetList(
                    a =>
                    a.FDate >= startTime & a.FDate < endTime && a.Category == DropDownList_YBTime.SelectedItem.Value)
                .OrderBy(a => a.FDate).ThenBy(a => a.CountryCode)
                .ToList();
            //GridView1.DataSource = list;
            //GridView1.DataBind();

            TimeSpan timeSpan = endTime - startTime;

            List <LiveData_Check> ldcList = new List <LiveData_Check>();
            List <string>         citys   = CityUtility.AllNameList();

            for (int i = 0; i < timeSpan.Days; i++)
            {
                DateTime currentDate = startTime.AddDays(i);

                List <LiveData> daylist = list.Where(a => a.FDate == currentDate).ToList();

                LiveData_Check ldc = new LiveData_Check();
                ldc.Date = currentDate;
                StringBuilder dataMissStr = new StringBuilder();
                foreach (string city in citys)
                {
                    LiveData dayCity = daylist.Where(a => a.CountryName == city).FirstOrDefault();

                    if (dayCity != null)
                    {
                        if (dayCity.MaxTemp == null || dayCity.MinTemp == null || dayCity.Rain == null)
                        {
                            dataMissStr.Append("<li style='color:#ff6a00;'>" + city + " 缺少 ");
                            string missElement = string.Empty;
                            if (dayCity.MaxTemp == null)
                            {
                                missElement += "最高温度 ";
                            }
                            if (dayCity.MinTemp == null)
                            {
                                missElement += "最低温度 ";
                            }
                            if (dayCity.Rain == null)
                            {
                                missElement += "降水 ";
                            }

                            dataMissStr.Append(missElement);
                            dataMissStr.Append("数据<br/></li>");
                        }
                    }
                    else
                    {
                        dataMissStr.Append("<li  style='color:#ff0000;'>" + city + " 缺少 最高温度 最低温度 降水 数据<br/></li>");
                    }
                }
                ldc.DataMiss = dataMissStr.ToString();
                if (!String.IsNullOrWhiteSpace(ldc.DataMiss))
                {
                    ldcList.Add(ldc);
                }
            }
            Repeater_DataCheck.DataSource = ldcList;
            Repeater_DataCheck.DataBind();
            if (ldcList.Count() > 0)
            {
                Label_DataMiss.Text    = startTime.ToString("yyyy年MM月") + DropDownList_YBTime.SelectedItem.Value + "实况数据有缺失,请及时补充!";
                Panel_DataMiss.Visible = true;
            }
            else
            {
                Label_DataMiss.Text    = startTime.ToString("yyyy年MM月") + DropDownList_YBTime.SelectedItem.Value + "实况数据齐全!";
                Panel_DataMiss.Visible = false;
            }
        }
コード例 #11
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"));
            }
        }