public OperationLogViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) { //if (newsFeedService == null) //{ // throw new ArgumentNullException("newsFeedService"); //} if (regionManager == null) { throw new ArgumentNullException("regionManager"); } if (eventAggregator == null) { throw new ArgumentNullException("eventAggregator"); } eventAggregator.GetEvent<ResidentialIndexInfoEvent>().Subscribe(OnIndexInfoChange, ThreadOption.UIThread); //this.newsFeedService = newsFeedService; this.regionManager = regionManager; this.showArticleListCommand = new DelegateCommand(this.ShowArticleList); this.showNewsReaderViewCommand = new DelegateCommand(this.ShowNewsReaderView); //eventAggregator.GetEvent<TickerSymbolSelectedEvent>().Subscribe(OnTickerSymbolSelected, ThreadOption.UIThread); this.Articles = new List<NewsArticle>(); NewsArticle item = new NewsArticle(); item.PublishedDate = DateTime.Now; item.Title = @"新消息:曹家巷选房系统当前投入使用中"; Articles.Add(item); }
protected override void OnTimerRefreshNewsInfo() { base.OnTimerRefreshNewsInfo(); IList<NewsArticle> tmpList = new List<NewsArticle>(); foreach (NewsArticle item in articles) { tmpList.Add(item); } bool bIsAdd = false; foreach (Apartment item in SellNews) { if (apartmentHistorys.Contains(item.ApartmentId)) continue; try { NewsArticle newInfo = new NewsArticle(); newInfo.PublishedDate = item.Consumer.OperateTime; string szResidentialName = item.ResidentialId.ToString(); ; lock(this) { if (Index2NameDic != null && Index2NameDic.ContainsKey(item.ResidentialId)) { szResidentialName = Index2NameDic[item.ResidentialId]; } } //item.Title = string.Format("泉水人家:5栋3单元0{0}房,套2,被锁定", i); string szTitle = string.Format("小区[{0}]: {1}栋{2}单元{3}房,{4},已经被售出。", szResidentialName, item.Builing, item.Uint, item.Number, item.RoomType); newInfo.Title = szTitle; string szBody = string.Format("销售面积:{0}\n购买者:{1}\n身份证:{2}\n操作员:{3}\n时间:{4}\n住址:{5}", item.Area, item.Consumer.Name, item.Consumer.IdCard, item.Consumer.OperateUser, item.Consumer.OperateTime.ToString(), item.Consumer.OriginAddress); newInfo.Body = szBody; tmpList.Add(newInfo); apartmentHistorys.Add(item.ApartmentId); bIsAdd = true; } catch (Exception e) { continue; } } ////test code, earse it later. //NewsArticle testitem = new NewsArticle(); //testitem.PublishedDate = DateTime.Now; //testitem.Title = @"一条新消息"; //string szBody2 = string.Format("{0}\n购买者:{1}\n身份证:{2}\n操作员:{3}\n时间:{4}", // testitem.Title, "张三", "54235708043300004545353", "马自达", DateTime.Now); //testitem.Body = szBody2; //tmpList.Add(testitem); //triger property change Articles = tmpList; bIsAdd = true; if (bIsAdd) { this.RaisePropertyChanged(() => this.Articles); } }