void OnShowZones() { var zonesSelectionViewModel = new ZonesSelectionViewModel(Device, Zones); if (DialogService.ShowModalWindow(zonesSelectionViewModel)) { Zones = zonesSelectionViewModel.Zones; Zones = Zones.Take(50).ToList(); OnPropertyChanged("PresenrationZones"); } }
private void Execute() { List<byte> rxBuff = new List<byte>(); while(true) { byte[] read = new byte[1]; try { // Read int rxed = _socket.Receive(read, read.Length, SocketFlags.None); // Add data to buffer rxBuff.AddRange(read.Take(rxed)); // process data if it contains a terminating character if (rxBuff.Contains(0x02)) { // retreive the string string rxStr = Encoding.UTF8.GetString(rxBuff.Take(rxBuff.IndexOf(0x02)).ToArray()); // remove the data that was just converted into a string (plus the 0x02 terminator) rxBuff.RemoveRange(0, rxBuff.IndexOf(0x02) + 1); // Deserialize to the message structure Message msg = JsonConvert.DeserializeObject<Message>(rxStr); // Notify all listeners if (msg != null) { OnMessageRxed(msg); } } } catch { OnDisconnected(); } } }
/// <summary> /// 获取Tag集合 /// </summary> public List<TagInfo> GetTagList(int tid, int count) { List<TagInfo> tags = new List<TagInfo>(); IQueryable<blog_varticle> articles=GetArticles(tid, 0,0); string tagstr = ""; foreach (blog_varticle article in articles) { tagstr += article.tags.Trim() + ","; } string[] arrTag = tagstr.Split(','); arrTag = Utils.DistinctStringArray(arrTag); foreach (string a in arrTag) { if (a.Trim() != "") { tags.Add(new TagInfo { Tag = a.Trim(), Count = Utils.RegexCount(a, tagstr) }); } } tags.Sort(delegate(TagInfo x, TagInfo y) { return y.Count - x.Count; }); if (count > 0) tags = tags.Take(count).ToList(); return tags; }
/// <summary> /// Function to get more search records. /// </summary> /// <param name="presenter">The presenter</param> /// <param name="numberOfRecords">The number of records.</param> /// <param name="searchText">The search text.</param> /// <returns> /// The partial view /// </returns> public ActionResult ShowMoreRecords(GlobalSearchPresenter presenter, int numberOfRecords, string searchText) { if (presenter != null) { IList<SearchResultItem> searchResult = new List<SearchResultItem>(); if (SessionData.Instance.GlobalSearchItems != null) { IList<SearchResultItem> searchRecordList = new List<SearchResultItem>(); searchRecordList = SessionData.Instance.GlobalSearchItems; presenter.AssignAllSearchRecordList(searchRecordList); int totalCount = presenter.RecordCount + numberOfRecords; presenter.RecordCount = totalCount < searchRecordList.Count ? totalCount : searchRecordList.Count; searchResult = searchRecordList.Take(presenter.RecordCount).ToList<SearchResultItem>(); presenter.AssignSearchResultList(searchResult); } } return this.PartialView(SearchRecordsPartialView, presenter); }