public PagedMessage GetPagedMessage(DataMessage dataMessage, Sequence sequence) { int pageSize = (int)dataMessage.headers[DataMessage.PageSizeHeader]; int pageIndex = 0; if (dataMessage.headers.ContainsKey(DataMessage.PageIndexHeader)) { pageIndex = (int)dataMessage.headers[DataMessage.PageIndexHeader]; } pageIndex = Math.Max(0, pageIndex);//negative pageIndex??? int pageCount = (int)Math.Ceiling((double)sequence.Size / pageSize); int pageStart = pageIndex * pageSize; int pageEnd = Math.Min(pageStart + pageSize, sequence.Size); PagedMessage pagedMessage = new PagedMessage(); pagedMessage.pageIndex = pageIndex; pagedMessage.pageCount = pageCount; pagedMessage.sequenceSize = sequence.Size; pagedMessage.sequenceId = sequence.Id; object[] pagedResult = new object[pageEnd - pageStart]; lock (_objLock) { for (int i = pageStart; i < pageEnd; i++) { Identity identity = sequence[i]; //pagedResult.Add( _itemIdToItemHash[identity] ); if (_itemIdToItemHash.Contains(identity)) { pagedResult[i - pageStart] = (_itemIdToItemHash[identity] as ItemWrapper).Instance; } } } pagedMessage.body = pagedResult; pagedMessage.destination = dataMessage.destination; pagedMessage.dataMessage = dataMessage; return(pagedMessage); }
public PagedMessage GetPagedMessage(DataMessage dataMessage, Sequence sequence) { int num = (int)dataMessage.headers["pageSize"]; int num2 = 0; if (dataMessage.headers.ContainsKey("pageIndex")) { num2 = (int)dataMessage.headers["pageIndex"]; } num2 = Math.Max(0, num2); int num3 = (int)Math.Ceiling((double)(((double)sequence.Size) / ((double)num))); int num4 = num2 * num; int num5 = Math.Min(num4 + num, sequence.Size); PagedMessage message = new PagedMessage { pageIndex = num2, pageCount = num3, sequenceSize = sequence.Size, sequenceId = sequence.Id }; object[] objArray = new object[num5 - num4]; lock (_objLock) { for (int i = num4; i < num5; i++) { Identity key = sequence[i]; if (this._itemIdToItemHash.Contains(key)) { objArray[i - num4] = (this._itemIdToItemHash[key] as ItemWrapper).Instance; } } } message.body = objArray; message.destination = dataMessage.destination; message.dataMessage = dataMessage; return(message); }
/// <summary> /// Initializes a new instance of the <see cref="Message"/> class. /// </summary> /// <param name="row"> /// The row. /// </param> public Message([NotNull] PagedMessage row) { this.ID = row.MessageID; this.UserID = row.UserID; this.UserName = row.UserName; this.MessageText = row.Message; this.TopicID = row.TopicID; this.Posted = row.Posted; this.Topic = row.Topic; this.Flags = row.Flags; this.Edited = row.Edited; this.EditReason = row.EditReason; try { this.Position = row.Position; } catch (Exception) { this.Position = 0; } try { this.IsModeratorChanged = row.IsModeratorChanged; } catch (Exception) { this.IsModeratorChanged = false; } try { this.DeleteReason = row.DeleteReason; } catch (Exception) { this.DeleteReason = string.Empty; } try { this.IP = row.IP; } catch (Exception) { this.IP = string.Empty; } try { this.ExternalMessageId = row.ExternalMessageId; } catch (Exception) { this.ExternalMessageId = string.Empty; } try { this.ReferenceMessageId = row.ReferenceMessageId; } catch (Exception) { this.ReferenceMessageId = string.Empty; } try { this.AnswerMessageId = row.AnswerMessageId; } catch (Exception) { this.AnswerMessageId = null; } try { this.Signature = row.Signature; } catch (Exception) { this.Signature = string.Empty; } }
/// <summary> /// Initializes a new instance of the <see cref="PostDataHelperWrapper"/> class. /// </summary> /// <param name="dataRow"> /// The data row. /// </param> public PostDataHelperWrapper(PagedMessage dataRow) : this() { this.DataRow = dataRow; }