private void ParkfullCheckThread() { ShowMessage("启动车场满位短信通知线程"); Ralid.Park.BusinessModel.Model.TimeZone curTz = null; while (true) { try { if (Mysetting.Current != null && Mysetting.Current.ParkfullCheckTimezones != null && Mysetting.Current.ParkfullCheckTimezones.Count > 0) { List <Ralid.Park.BusinessModel.Model.TimeZone> tzs = Mysetting.Current.ParkfullCheckTimezones.Where(tz => tz.IsIn(DateTime.Now)).ToList(); if (tzs != null && tzs.Count > 0) { List <ParkInfo> parks = (new ParkBll(AppSettings.CurrentSetting.ParkConnect)).GetAllParks().QueryObjects; if (parks != null && parks.Count > 0 && parks.Exists(park => park.Vacant == 0) && !tzs[0].Equals(curTz)) { string msg = string.Empty; List <ParkInfo> temp1 = parks.Where(park => park.Vacant == 0).ToList(); List <ParkInfo> temp2 = parks.Where(park => park.Vacant > 0).ToList(); if (temp2 != null && temp2.Count > 0) { msg = string.Format("{0} 车位已满,各位可以将车停放至 {1}", GetParkNameString(temp1), GetParkNameString(temp2)); } else { msg = string.Format("{0} 车位已满,各位可以将车停放至周边其它停车场", GetParkNameString(temp1)); } CardSearchCondition con = new CardSearchCondition(); con.Status = Ralid.Park.BusinessModel.Enum.CardStatus.Enabled; con.ParkingStatus = Ralid.Park.BusinessModel.Enum.ParkingStatus.Out; List <CardInfo> cards = (new CardBll(AppSettings.CurrentSetting.ParkConnect)).GetCards(con).QueryObjects; if (cards != null && cards.Count > 0) { if (NotifyECar(msg, cards)) { curTz = tzs[0]; } } } } } } catch (Exception ex) { Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex); } Thread.Sleep(5000); } }
private Mysetting GetSettingFromInput() { Mysetting ms = Mysetting.Current; if (Mysetting.Current == null) { ms = new Mysetting(); } if (ms.ParkfullCheckTimezones == null) { ms.ParkfullCheckTimezones = new List <Ralid.Park.BusinessModel.Model.TimeZone>(); } ms.ParkfullCheckTimezones.Clear(); if (chk1.Checked) { TimeEntity te1 = new TimeEntity(dtLimitationBegin1.Value.Hour, dtLimitationBegin1.Value.Minute); TimeEntity te2 = new TimeEntity(dtLimitationEnd1.Value.Hour, dtLimitationEnd1.Value.Minute); Ralid.Park.BusinessModel.Model.TimeZone tz = new Ralid.Park.BusinessModel.Model.TimeZone(te1, te2); ms.ParkfullCheckTimezones.Add(tz); } if (chk2.Checked) { TimeEntity te1 = new TimeEntity(dtLimitationBegin2.Value.Hour, dtLimitationBegin2.Value.Minute); TimeEntity te2 = new TimeEntity(dtLimitationEnd2.Value.Hour, dtLimitationEnd2.Value.Minute); Ralid.Park.BusinessModel.Model.TimeZone tz = new Ralid.Park.BusinessModel.Model.TimeZone(te1, te2); ms.ParkfullCheckTimezones.Add(tz); } if (chk3.Checked) { TimeEntity te1 = new TimeEntity(dtLimitationBegin3.Value.Hour, dtLimitationBegin3.Value.Minute); TimeEntity te2 = new TimeEntity(dtLimitationEnd3.Value.Hour, dtLimitationEnd3.Value.Minute); Ralid.Park.BusinessModel.Model.TimeZone tz = new Ralid.Park.BusinessModel.Model.TimeZone(te1, te2); ms.ParkfullCheckTimezones.Add(tz); } if (chk4.Checked) { TimeEntity te1 = new TimeEntity(dtLimitationBegin4.Value.Hour, dtLimitationBegin4.Value.Minute); TimeEntity te2 = new TimeEntity(dtLimitationEnd4.Value.Hour, dtLimitationEnd4.Value.Minute); Ralid.Park.BusinessModel.Model.TimeZone tz = new Ralid.Park.BusinessModel.Model.TimeZone(te1, te2); ms.ParkfullCheckTimezones.Add(tz); } return(ms); }