Example #1
0
        public int JieXiBaoWen(BaoWens baowen)
        {
            try
            {
                string[] contents = baowen.Content.Replace("\r\n", ";").Split(';');

                List <string>            citycodes    = CityUtility.AllCodeList();
                List <WeatherDictionary> weathercodes = new WeatherDictionary_BLL().GetList().ToList();


                BwYbs_BLL bll = new BwYbs_BLL();

                foreach (string citycode in citycodes)
                {
                    BwYbs model = new BwYbs();
                    model.BWID        = baowen.BWID;
                    model.BWYBID      = Guid.NewGuid();
                    model.CountryCode = citycode;
                    model.CountryName = CityUtility.GetName(citycode);
                    model.CreateTime  = DateTime.Now;
                    model.BWFileName  = baowen.FileName;
                    model.YBDateTime  = baowen.YBDateTime;
                    model.YBType      = baowen.BWType;
                    model.YBUserID    = baowen.YBUserID;
                    model.YBUserName  = baowen.YBUserName;



                    string stringStart = contents.Where(a => a.Contains(citycode)).FirstOrDefault();
                    int    indexStart  = Array.IndexOf(contents, stringStart);

                    model.TianQiCode12 = decimal.Parse(contents[indexStart + 1].Substring(113, 5).Trim());
                    model.TianQiCode24 = decimal.Parse(contents[indexStart + 2].Substring(113, 5).Trim());
                    model.TianQiCode36 = decimal.Parse(contents[indexStart + 3].Substring(113, 5).Trim());
                    model.TianQiCode48 = decimal.Parse(contents[indexStart + 4].Substring(113, 5).Trim());
                    model.TianQiCode60 = decimal.Parse(contents[indexStart + 5].Substring(113, 5).Trim());
                    model.TianQiCode72 = decimal.Parse(contents[indexStart + 6].Substring(113, 5).Trim());

                    model.WindDirCode12 = decimal.Parse(contents[indexStart + 1].Substring(119, 5).Trim());
                    model.WindDirCode24 = decimal.Parse(contents[indexStart + 2].Substring(119, 5).Trim());
                    model.WindDirCode36 = decimal.Parse(contents[indexStart + 3].Substring(119, 5).Trim());
                    model.WindDirCode48 = decimal.Parse(contents[indexStart + 4].Substring(119, 5).Trim());
                    model.WindDirCode60 = decimal.Parse(contents[indexStart + 5].Substring(119, 5).Trim());
                    model.WindDirCode72 = decimal.Parse(contents[indexStart + 6].Substring(119, 5).Trim());

                    model.WindSpeCode12 = decimal.Parse(contents[indexStart + 1].Substring(125, contents[indexStart + 1].Length - 125).Trim());
                    model.WindSpeCode24 = decimal.Parse(contents[indexStart + 2].Substring(125, contents[indexStart + 1].Length - 125).Trim());
                    model.WindSpeCode36 = decimal.Parse(contents[indexStart + 3].Substring(125, contents[indexStart + 1].Length - 125).Trim());
                    model.WindSpeCode48 = decimal.Parse(contents[indexStart + 4].Substring(125, contents[indexStart + 1].Length - 125).Trim());
                    model.WindSpeCode60 = decimal.Parse(contents[indexStart + 5].Substring(125, contents[indexStart + 1].Length - 125).Trim());
                    model.WindSpeCode72 = decimal.Parse(contents[indexStart + 6].Substring(125, contents[indexStart + 1].Length - 125).Trim());

                    model.MaxTemp24 = decimal.Parse(contents[indexStart + 2].Substring(65, 5).Trim());
                    model.MaxTemp48 = decimal.Parse(contents[indexStart + 4].Substring(65, 5).Trim());
                    model.MaxTemp72 = decimal.Parse(contents[indexStart + 6].Substring(65, 5).Trim());

                    model.MinTemp24 = decimal.Parse(contents[indexStart + 2].Substring(71, 5).Trim());
                    model.MinTemp48 = decimal.Parse(contents[indexStart + 4].Substring(71, 5).Trim());
                    model.MinTemp72 = decimal.Parse(contents[indexStart + 6].Substring(71, 5).Trim());



                    model.TianQiName12 = weathercodes.Where(a => a.Code == model.TianQiCode12 && a.Type == "天气").FirstOrDefault().Name;
                    model.TianQiName24 = weathercodes.Where(a => a.Code == model.TianQiCode24 && a.Type == "天气").FirstOrDefault().Name;
                    model.TianQiName36 = weathercodes.Where(a => a.Code == model.TianQiCode36 && a.Type == "天气").FirstOrDefault().Name;
                    model.TianQiName48 = weathercodes.Where(a => a.Code == model.TianQiCode48 && a.Type == "天气").FirstOrDefault().Name;
                    model.TianQiName60 = weathercodes.Where(a => a.Code == model.TianQiCode60 && a.Type == "天气").FirstOrDefault().Name;
                    model.TianQiName72 = weathercodes.Where(a => a.Code == model.TianQiCode72 && a.Type == "天气").FirstOrDefault().Name;


                    model.WindDirName12 = weathercodes.Where(a => a.Code == model.WindDirCode12 && a.Type == "风向").FirstOrDefault().Name;
                    model.WindDirName24 = weathercodes.Where(a => a.Code == model.WindDirCode24 && a.Type == "风向").FirstOrDefault().Name;
                    model.WindDirName36 = weathercodes.Where(a => a.Code == model.WindDirCode36 && a.Type == "风向").FirstOrDefault().Name;
                    model.WindDirName48 = weathercodes.Where(a => a.Code == model.WindDirCode48 && a.Type == "风向").FirstOrDefault().Name;
                    model.WindDirName60 = weathercodes.Where(a => a.Code == model.WindDirCode60 && a.Type == "风向").FirstOrDefault().Name;
                    model.WindDirName72 = weathercodes.Where(a => a.Code == model.WindDirCode72 && a.Type == "风向").FirstOrDefault().Name;



                    model.WindSpeName12 = weathercodes.Where(a => a.Code == model.WindSpeCode12 && a.Type == "风速").FirstOrDefault().Name;
                    model.WindSpeName24 = weathercodes.Where(a => a.Code == model.WindSpeCode24 && a.Type == "风速").FirstOrDefault().Name;
                    model.WindSpeName36 = weathercodes.Where(a => a.Code == model.WindSpeCode36 && a.Type == "风速").FirstOrDefault().Name;
                    model.WindSpeName48 = weathercodes.Where(a => a.Code == model.WindSpeCode48 && a.Type == "风速").FirstOrDefault().Name;
                    model.WindSpeName60 = weathercodes.Where(a => a.Code == model.WindSpeCode60 && a.Type == "风速").FirstOrDefault().Name;
                    model.WindSpeName72 = weathercodes.Where(a => a.Code == model.WindSpeCode72 && a.Type == "风速").FirstOrDefault().Name;


                    bll.Add(model, false);
                    //var aa = model;
                }
                return(bll.SaveChange());
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Example #2
0
        protected void Repeater_YbUser_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            BwYbs_BLL      bll  = new BwYbs_BLL();
            Scheduling_BLL sbll = new Scheduling_BLL();

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater Repeater_YbUser_Morning = (Repeater)e.Item.FindControl("Repeater_YbUser_Morning");
                //找到分类Repeater关联的数据项
                YBUsers_Date_ViewModel drv = (YBUsers_Date_ViewModel)e.Item.DataItem;
                //提取分类ID
                DateTime date      = (DateTime)drv.Date;
                DateTime next_date = (DateTime)drv.Next_Date;
                //根据分类ID查询该分类下的产品,并绑定产品Repeater

                DateTime dateNight        = date.AddMinutes(990);
                DateTime next_dateMorning = next_date.AddMinutes(405);

                List <BwYbs> mlist = bll.GetList(a => a.YBType == "早间报文" && a.YBDateTime == next_dateMorning).OrderBy(a => a.YBUserName).OrderBy(a => a.YbUsers.Order).ToList();

                //List<YBUsers_ViewModel> userListM = mlist.GroupBy(a => new { a.YBUserName }).Select(a => new YBUsers_ViewModel { YBUserName = a.Key.YBUserName }).ToList();
                List <Scheduling> schListMorning = sbll.GetList(a => a.Date == date && a.Work == "领班").ToList();

                List <BaoWen_Check_ViewModel> bcvListMorning = new List <BaoWen_Check_ViewModel>();


                BaoWen_Check_ViewModel bcv_group_morning = new BaoWen_Check_ViewModel();
                bcv_group_morning.YbUserName = "******";
                bcv_group_morning.Work       = "集体";;
                bcv_group_morning.Date       = date;
                BwYbs bwyb_group_morning = mlist.Where(a => a.YBUserName == "集体").FirstOrDefault();
                if (bwyb_group_morning != null)
                {
                    bcv_group_morning.IsMiss  = false;
                    bcv_group_morning.Message = "";
                }
                else
                {
                    bcv_group_morning.IsMiss  = true;
                    bcv_group_morning.Message = "(缺报)";
                }
                bcvListMorning.Add(bcv_group_morning);


                foreach (Scheduling scheduling in schListMorning)
                {
                    BaoWen_Check_ViewModel bcv = new BaoWen_Check_ViewModel();
                    bcv.Work       = scheduling.Work;
                    bcv.Date       = (DateTime)scheduling.Date;
                    bcv.YbUserName = scheduling.YBUserName;
                    BwYbs bwyb = mlist.Where(a => a.YBUserName == scheduling.YBUserName).FirstOrDefault();
                    if (bwyb != null)
                    {
                        bcv.IsMiss  = false;
                        bcv.Message = "";
                    }
                    else
                    {
                        bcv.IsMiss  = true;
                        bcv.Message = "(缺报)";
                    }
                    bcvListMorning.Add(bcv);
                }



                Repeater_YbUser_Morning.DataSource = bcvListMorning;
                Repeater_YbUser_Morning.DataBind();

                Repeater Repeater_YbUser_Night = (Repeater)e.Item.FindControl("Repeater_YbUser_Night");
                //根据分类ID查询该分类下的产品,并绑定产品Repeater
                List <BwYbs> nlist = bll.GetList(a => a.YBType == "晚间报文" && a.YBDateTime == dateNight).OrderBy(a => a.YBUserName).OrderBy(a => a.YbUsers.Order).ToList();
                //List<YBUsers_ViewModel> userListN = nlist.GroupBy(a => new { a.YBUserName }).Select(a => new YBUsers_ViewModel { YBUserName = a.Key.YBUserName }).ToList();



                List <Scheduling> schListNight = sbll.GetList(a => a.Date == date && a.Work != "连线").OrderBy(a => a.Order).ToList();

                List <BaoWen_Check_ViewModel> bcvListNight = new List <BaoWen_Check_ViewModel>();

                BaoWen_Check_ViewModel bcv_group_night = new BaoWen_Check_ViewModel();
                bcv_group_night.YbUserName = "******";
                bcv_group_night.Work       = "集体";
                bcv_group_night.Date       = date;
                BwYbs bwyb_group_night = nlist.Where(a => a.YBUserName == "集体").FirstOrDefault();
                if (bwyb_group_night != null)
                {
                    bcv_group_night.IsMiss  = false;
                    bcv_group_night.Message = "";
                }
                else
                {
                    bcv_group_night.IsMiss  = true;
                    bcv_group_night.Message = "(缺报)";
                }
                bcvListNight.Add(bcv_group_night);


                foreach (Scheduling scheduling in schListNight)
                {
                    BaoWen_Check_ViewModel bcv = new BaoWen_Check_ViewModel();
                    bcv.Work       = scheduling.Work;
                    bcv.Date       = (DateTime)scheduling.Date;
                    bcv.YbUserName = scheduling.YBUserName;
                    BwYbs bwyb = nlist.Where(a => a.YBUserName == scheduling.YBUserName).FirstOrDefault();
                    if (bwyb != null)
                    {
                        bcv.IsMiss = false;

                        bcv.Message = "";
                    }
                    else
                    {
                        bcv.IsMiss  = true;
                        bcv.Message = "(缺报)";
                    }
                    bcvListNight.Add(bcv);
                }



                Repeater_YbUser_Night.DataSource = bcvListNight;
                Repeater_YbUser_Night.DataBind();
            }
        }