protected override void Encode(IChannelHandlerContext context, ProtoMessage message, List <object> output) { var protoMessageCodec = _protoMessageCodecHandler.EncoderCodecs[message.Opcode]; var messageCodec = protoMessageCodec.MessageCodec; var fieldCodecs = protoMessageCodec.FieldCodec; Serilog.Log.Logger.Debug("Encoder Sent: {0} - {1} to {2}", message.Message, message.Message.Descriptor.ClrType.Name, message.Player.Username); var frameType = messageCodec.SizeType.GetFrameType(); var bldr = new MessageFrameBuilder(context.Allocator, message.Opcode, frameType); foreach (var field in fieldCodecs) { var isString = field.FieldCodec.Type == Models.FieldType.String; MessageType?messageType = isString ? null : field.FieldCodec.Type.GetMessageType(); var dataTransform = field.FieldCodec.Transform.GetDataTransformation(); var dataOrder = field.FieldCodec.Order.GetDataOrder(); object value = field.FieldDescriptor.Accessor.GetValue(message.Message); if (!isString) { long unboxedInt = field.ToUnboxedNumber(value); bldr.Put(messageType.Value, dataOrder, dataTransform, unboxedInt); } else { bldr.PutString((string)value); } } output.Add(bldr.ToMessageFrame()); }
public AddMessageTemplate CreateAddMessageTemplateData( Guid?brandId = null, string cultureCode = null, MessageType?messageType = null, MessageDeliveryMethod?messageDeliveryMethod = null, string content = null, string subject = null) { var brand = brandId.HasValue ? _messagingRepository.Brands.Include(x => x.Languages).Single(x => x.Id == brandId.Value) : _messagingRepository.Brands.Include(x => x.Languages).First(); messageDeliveryMethod = messageDeliveryMethod ?? TestDataGenerator.GetRandomMessageDeliveryMethod(); var addMessageTemplateData = new AddMessageTemplate { BrandId = brand.Id, LanguageCode = cultureCode ?? brand.Languages.First().Code, MessageType = messageType ?? TestDataGenerator.GetRandomMessageType(), MessageDeliveryMethod = messageDeliveryMethod.Value, TemplateName = TestDataGenerator.GetRandomString(), Subject = messageDeliveryMethod == MessageDeliveryMethod.Email ? subject ?? TestDataGenerator.GetRandomString() : null }; addMessageTemplateData.MessageContent = content ?? string.Format("Test Message - {0} {1}", addMessageTemplateData.MessageType, addMessageTemplateData.MessageDeliveryMethod); return(addMessageTemplateData); }
/// <summary> /// Checks This Object For Required Values and Conformance /// </summary> /// <param name="messageContent">Pointer to messageContent which represents the resource type of Resource Message sent</param> private void Validate(MessageType?messageContent) { if (string.IsNullOrEmpty(this.resourceID) && string.IsNullOrEmpty(this.name) && this.typeStructure == null) { throw new ArgumentNullException("Need a ResourceID, Name or TypeStructure"); } if (messageContent == MessageType.RequestResource && this.responsibleParty != null) { throw new ArgumentNullException("ResponsibleParty is not applicable for Message Content of RequestResource"); } if (messageContent == MessageType.RequestResource && this.ownershipInformation != null) { throw new ArgumentNullException("OwndershipInformation is not applicable for Message Content of RequestResource"); } if (this.resourceStatus != null && (messageContent == MessageType.RequestResource || messageContent == MessageType.RequisitionResource || messageContent == MessageType.RequestQuote || messageContent == MessageType.RequestResourceDeploymentStatus)) { throw new ArgumentNullException("ResourceStatus is not applicable for Message Content of: " + messageContent); } if (this.resourceStatus == null && messageContent == MessageType.ResponseToRequestReturn) { throw new ArgumentNullException("ResourceStatus is required for Message Content of: " + messageContent); } }
/// <summary> /// Checks This Object For Required Values and Conformance /// </summary> /// <param name="messageContentType">Pointer to messageContentType which represents the resource type of Resource Message sent</param> private void Validate(MessageType?messageContentType) { if ((this.inventoryRefreshDateTime != DateTime.MinValue) && (messageContentType == MessageType.RequestResource || messageContentType == MessageType.RequisitionResource || messageContentType == MessageType.ReleaseResource || messageContentType == MessageType.RequestReturn || messageContentType == MessageType.ResponseToRequestReturn || messageContentType == MessageType.RequestQuote || messageContentType == MessageType.RequestResourceDeploymentStatus || messageContentType == MessageType.RequestExtendedDeploymentDuration || messageContentType == MessageType.ResponseToRequestExtendedDeploymentDuration)) { throw new ArgumentNullException("InventoryRefreshDateTime is not applicable if MessageContentType is: " + messageContentType); } if (this.deploymentStatus != null && (messageContentType == MessageType.RequestResource || messageContentType == MessageType.RequisitionResource || messageContentType == MessageType.RequestQuote || messageContentType == MessageType.RequestResourceDeploymentStatus)) { throw new ArgumentNullException("DeploymentStatus is not applicable if MessageContentType is: " + messageContentType); } if (this.deploymentStatus == null && messageContentType == MessageType.ResponseToRequestReturn) { throw new ArgumentNullException("DeploymentStatus is required if MessageContentType is: " + messageContentType); } if (!string.IsNullOrEmpty(this.availability) && (messageContentType == MessageType.RequestResource || messageContentType == MessageType.RequisitionResource || messageContentType == MessageType.CommitResource || messageContentType == MessageType.RequestQuote || messageContentType == MessageType.RequestResourceDeploymentStatus)) { throw new ArgumentNullException("Availability is not applicable if MessageContentType is: " + messageContentType); } if (string.IsNullOrEmpty(this.availability) && messageContentType == MessageType.ResponseToRequestReturn) { throw new ArgumentNullException("Availability is required if MessageContentType is: " + messageContentType); } }
/// <summary> /// Reads an XML Object From An Existing DOM /// </summary> /// <param name="rootNode">Node Containing the root Object element</param> /// <param name="messageContent">MessageType of this RM Message</param> internal void ReadXML(XmlNode rootNode, MessageType?messageContent) { ScheduleInformationType scheduleInformationTmp; foreach (XmlNode node in rootNode.ChildNodes) { if (string.IsNullOrEmpty(node.InnerText)) { continue; } switch (node.LocalName) { case "ResourceInfoElementID": this.resourceInfoElementID = node.InnerText; break; case "ResponseInformation": this.responseInformation = new ResponseInformationType(); this.responseInformation.ReadXML(node); break; case "Resource": this.resource = new ResourceType(); this.resource.ReadXML(node, messageContent); break; case "AssignmentInformation": this.assignmentInformation = new AssignmentInformationType(); if (this.ResponseInformation != null) { this.assignmentInformation.ReadXML(node, messageContent, this.responseInformation.ResponseType); } else { this.assignmentInformation.ReadXML(node, messageContent); } break; case "ScheduleInformation": if (this.scheduleInformation == null) { this.scheduleInformation = new List <ScheduleInformationType>(); } scheduleInformationTmp = new ScheduleInformationType(); scheduleInformationTmp.ReadXML(node, messageContent); this.scheduleInformation.Add(scheduleInformationTmp); break; case "#comment": break; default: throw new ArgumentException("Unexpected node name: " + node.Name + " in ResourceInformationType"); } } this.Validate(messageContent); }
/// <summary> /// Reads an XML Object From An Existing DOM /// </summary> /// <param name="rootNode">Node Containing the root Object element</param> /// <param name="messageContent">MessageType of this RM Message</param> internal void ReadXML(XmlNode rootNode, MessageType?messageContent) { foreach (XmlNode node in rootNode.ChildNodes) { if (string.IsNullOrEmpty(node.InnerText)) { continue; } switch (node.LocalName) { case "ModeOfTransportation": this.modeOfTransportation = node.InnerText; break; case "NavigationInstructions": this.navigationInstructions = node.InnerText; break; case "ReportingInstructions": this.reportingInstructions = node.InnerText; break; case "#comment": break; default: throw new ArgumentException("Unexpected node name: " + node.Name + " in AssignmentInstructionsType"); } } this.Validate(messageContent); }
public virtual async Task <List <UserMessage> > GetUserMessagesAsync( Guid sendUserId, Guid receiveUserId, string filter = "", string sorting = nameof(UserMessage.MessageId), bool reverse = true, MessageType?type = null, int skipCount = 0, int maxResultCount = 10, CancellationToken cancellationToken = default) { sorting ??= nameof(UserMessage.MessageId); sorting = reverse ? sorting + " desc" : sorting; var userMessages = await DbContext.Set <UserMessage>() .Where(x => (x.CreatorId.Equals(sendUserId) && x.ReceiveUserId.Equals(receiveUserId)) || x.CreatorId.Equals(receiveUserId) && x.ReceiveUserId.Equals(sendUserId)) .WhereIf(type != null, x => x.Type.Equals(type)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter)) .OrderBy(sorting) .PageBy(skipCount, maxResultCount) .AsNoTracking() .ToListAsync(GetCancellationToken(cancellationToken)); return(userMessages); }
void OnMessageTypeEdited(object sender, Gtk.EditedArgs e) { Trace.Call(sender, e); Gtk.TreeIter iter; if (!f_ListStore.GetIterFromString(out iter, e.Path)) { return; } FilterModel filter = (FilterModel)f_ListStore.GetValue(iter, 0); int key = (int)f_ListStore.GetValue(iter, 1); // HACK: lame GTK+ 2.12 is not exposing the combo box neither // the iterator of the selected row inside the combo box thus // we have lookup the value in the list store using the text :/ // TODO: starting with GTK+ 2.14 the Changed event can be used // see http://git.gnome.org/browse/gtk+/tree/gtk/gtkcellrenderercombo.c#n178 MessageType?newMsgType = null; foreach (object[] row in f_MessageTypeListStore) { if ((string)row[0] == e.NewText) { newMsgType = (MessageType?)row[1]; break; } } filter.MessageType = newMsgType; f_ListStore.EmitRowChanged(new Gtk.TreePath(e.Path), iter); OnChanged(EventArgs.Empty); }
/// <summary> /// 获取私信会话分页数据(后台用) /// </summary> /// <param name="type">私信类型</param> /// <param name="userId">用户Id(用来搜索用户Id相关的私信会话)</param> /// <param name="pageIndex">页码</param> /// <returns>私信会话分页数据</returns> public PagingDataSet <MessageSession> GetSessions(MessageType?type, long?userId, int pageIndex) { return(GetPagingEntities(pageSize, pageIndex, CachingExpirationType.ObjectCollection, () => { //获取缓存Key StringBuilder cacheKey = new StringBuilder(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.GlobalVersion)); cacheKey.AppendFormat("Sessions-Type:{0}-UserId:{0}", (int)type, userId); return cacheKey.ToString(); }, () => { //组装sql语句 var sql = PetaPoco.Sql.Builder; if (type.HasValue) { sql.Where("MessageType = @0", (int)type); } if (userId.HasValue && userId.Value > 0) { sql.Where("UserId = @0", userId); } sql.OrderBy("UnreadMessageCount desc"); sql.OrderBy("LastMessageId desc"); return sql; } )); }
public ShowMessage2Result AskPost( string title, string message, string area, string ctrl, string act, object routeValues, MessageType?type = null) { if (!(routeValues is Dictionary <string, string> rvd)) { var vtype = routeValues.GetType(); if (!vtype.FullName.StartsWith("<>f__AnonymousType")) { throw new System.ArgumentException(nameof(routeValues)); } rvd = vtype.GetProperties().ToDictionary( keySelector: p => p.Name, elementSelector: p => p.GetValue(routeValues).ToString()); } return(new ShowMessage2Result { ViewData = ViewData, TempData = TempData, Title = title, Content = message, Type = type, AreaName = area, ControllerName = ctrl, ActionName = act, RouteValues = rvd, }); }
public void Section(TSection section, string message, MessageType?type = null) { _activeSection = section; _activeSubSection = ""; SubSection sub; // create if (!_subSections.ContainsKey(_activeSection)) { sub = new SubSection { Section = _activeSection, Name = _activeSubSection, Type = type ?? MessageType.Info, Message = message }; _subSections[_activeSection] = new Dictionary <string, SubSection>(); _subSections[_activeSection].Add(_activeSubSection, sub); } // replace else { sub = _subSections[_activeSection][_activeSubSection]; sub.Message = message; sub.Type = type ?? sub.Type; } _send(sub); }
public void SetMessage(string subSection = null, string message = null, MessageType?type = null, int?progressSteps = null) { _activeSubSection = subSection ?? _activeSubSection; SubSection sub; // create if (!_subSections[_activeSection].ContainsKey(_activeSubSection)) { sub = new SubSection { Section = _activeSection, Name = _activeSubSection, Type = type ?? MessageType.Info, Message = message, MaxProgress = progressSteps ?? 0 }; _subSections[_activeSection].Add(_activeSubSection, sub); } // replace else { sub = _subSections[_activeSection][_activeSubSection]; if (message != null) { sub.Message = message; } if (type != null) { sub.Type = type.Value; } if (progressSteps != null) { sub.MaxProgress = progressSteps.Value; sub.CurrentProgress = 0; } } _send(sub); }
// 查询 public static IQueryable <Message> Search(MessageType?type, string title, DateTime?startDt, DateTime?endDt, int?senderID, int?receiverID) { IQueryable <Message> q = Set.Include(t => t.Sender).Include(t => t.Receiver); if (type != null) { q = q.Where(t => t.Type == type); } if (!String.IsNullOrEmpty(title)) { q = q.Where(t => t.Title.Contains(title)); } if (startDt != null) { q = q.GreaterEqual(t => t.CreateDt, startDt.Value); } if (endDt != null) { q = q.LessEqual(t => t.CreateDt, endDt.Value); } if (senderID != null) { q = q.Where(t => t.SenderID == senderID); } if (receiverID != null) { q = q.Where(t => t.ReceiverID == receiverID); } return(q); }
private static string GetKey(MessageType?type) { if (type == null) { throw new ArgumentNullException(nameof(type)); } switch (type.Value) { case MessageType.Status1: return(ConfigKey.Status1.GetString()); case MessageType.Status2: return(ConfigKey.Status2.GetString()); case MessageType.Status3: return(ConfigKey.Status3.GetString()); case MessageType.BottomRight3: return(ConfigKey.BR3.GetString()); case MessageType.BottomRight2: return(ConfigKey.BR2.GetString()); case MessageType.BottomRight1: return(ConfigKey.BR1.GetString()); default: throw new ArgumentException(nameof(type)); } }
/// <summary> /// Checks This Object For Required Values and Conformance /// </summary> /// <param name="messageContent">Pointer to messageContent which represents the resource type of Resource Message sent</param> private void Validate(MessageType?messageContent) { if (string.IsNullOrEmpty(this.owner) && string.IsNullOrEmpty(this.owningJurisdiction)) { throw new ArgumentNullException("Need an Owner or OwningJurisdiction"); } if (messageContent == MessageType.RequestResource && string.IsNullOrEmpty(this.owner)) { throw new ArgumentNullException("Owner is not applicable if MessageContent is RequestResource"); } if (messageContent == MessageType.RequestResource && string.IsNullOrEmpty(this.owningJurisdiction)) { throw new ArgumentNullException("OwningJurisdiction is not applicable if MessageContent is RequestResource"); } if (messageContent == MessageType.RequestResource && string.IsNullOrEmpty(this.homeDispatch)) { throw new ArgumentNullException("HomeDispatch is not applicable if MessageContent is RequestResource"); } if (messageContent == MessageType.RequestResource && string.IsNullOrEmpty(this.homeUnit)) { throw new ArgumentNullException("HomeUnit is not applicable if MessageContent is RequestResource"); } }
/// <summary> /// Writes This Object to an Existing XML Document /// </summary> /// <param name="xwriter">Pointer to the XMLWriter Writing the Document</param> /// <param name="messageContent">Pointer to messageContent which represents the resource type of Resource Message sent</param> internal void WriteToXML(XmlWriter xwriter, MessageType?messageContent) { this.Validate(messageContent); xwriter.WriteStartElement(EDXLConstants.RM10MsgPrefix, "OwnershipInformation", EDXLConstants.RM10MsgNamespace); if (!string.IsNullOrEmpty(this.owner)) { xwriter.WriteElementString(EDXLConstants.RM10Prefix, "Owner", EDXLConstants.RM10Namespace, this.owner); } if (!string.IsNullOrEmpty(this.owningJurisdiction)) { xwriter.WriteElementString(EDXLConstants.RM10Prefix, "OwningJurisdiction", EDXLConstants.RM10Namespace, this.owningJurisdiction); } if (!string.IsNullOrEmpty(this.homeDispatch)) { xwriter.WriteElementString(EDXLConstants.RM10Prefix, "HomeDispatch", EDXLConstants.RM10Namespace, this.homeDispatch); } if (!string.IsNullOrEmpty(this.homeUnit)) { xwriter.WriteElementString(EDXLConstants.RM10Prefix, "HomeUnit", EDXLConstants.RM10Namespace, this.homeUnit); } xwriter.WriteEndElement(); }
public HandshakeHeader(Int32 fragmentOffset, Int32 fragmentLength, Int32 totalLength, MessageType?messageType, Int16 messageSequence) { this.fragmentOffset = fragmentOffset; this.fragmentLength = fragmentLength; this.totalLength = totalLength; this.messageType = messageType; this.messageSequence = messageSequence; }
public string CreateMessage(MessageType?message) { return(message == MessageType.ChangePasswordSuccess ? "Su password ha sido cambiada." : message == MessageType.Error ? "An error has occurred." : message == MessageType.ChangeEmailSuccess ? "Su correo electrónico ha sido cambiado." : message == MessageType.ChangeImageSuccess ? "Su imagem ha sido cambiado." : ""); }
/// <summary> /// Initializes a new instance of the ResourceMessageType class and sets The RM Message Type /// </summary> /// <param name="type">MessageType of the RM Message</param> public ResourceMessageType(MessageType type) { this.contactInformation = new List <ContactInformationType>(); this.messageContentType = type; this.funding = new List <FundingType>(); this.resourceInformation = new List <ResourceInformationType>(); this.incidentInformation = new List <IncidentInformationType>(); }
public IEnumerable <MessageEntry> GetMessages(MessageType?messageType = null) { if (messageType == null) { return(_messages); } return(_messages.Where(x => x.MessageType == messageType.Value)); }
public void CreateMessage(MessageType?message) { ViewBag.StatusMessage = message == MessageType.ChangePasswordSuccess ? "Su password ha sido cambiada." : message == MessageType.Error ? "Se ocorrió un error." : message == MessageType.BestBid ? "Su puja tiene que ser mas grande." : message == MessageType.LoginError ? "Inicio de sesión incorrecto." : message == MessageType.WithoutBalance ? "Sin saldo para la operación." : ""; }
public Message(COREobject core) { Errors = new List <string>(); Warnings = new List <string>(); Info = new List <string>(); Success = new List <string>(); _core = core; _type = null; }
public ShowMessageResult Message(string title, string message, MessageType?type = null) { return(new ShowMessageResult { ViewData = ViewData, TempData = TempData, Title = title, Content = message, Type = type, }); }
public MessageFilter(string search, Guid?authorId, DateTime? @from, DateTime?to, MessageType?messageType, MessageStatus?messageStatus, string messageStyle, string customType) { Search = search; AuthorId = authorId; From = @from; To = to; MessageType = messageType; MessageStatus = messageStatus; MessageStyle = messageStyle; CustomType = customType; }
public virtual async Task <long> GetGroupMessageCountAsync( Guid?tenantId, long groupId, string filter = "", MessageType?type = null, CancellationToken cancellationToken = default) { using (_currentTenant.Change(tenantId)) { return(await _messageRepository.GetCountAsync(groupId, filter, type, cancellationToken)); } }
public virtual async Task <long> GetCountAsync( long groupId, string filter = "", MessageType?type = null, CancellationToken cancellationToken = default) { return(await DbContext.Set <GroupMessage>() .Where(x => x.GroupId.Equals(groupId)) .WhereIf(type != null, x => x.Type.Equals(type)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter)) .LongCountAsync(GetCancellationToken(cancellationToken))); }
/// <summary> /// Checks This Object For Required Values and Conformance /// </summary> /// <param name="messageContent">Pointer to messageContent which represents the resource type of Resource Message sent</param> private void Validate(MessageType?messageContent) { if (string.IsNullOrEmpty(this.resourceInfoElementID)) { throw new ArgumentNullException("ResourceInfoElementID is required and can't be null"); } if (this.responseInformation != null && (messageContent == MessageType.RequestResource || messageContent == MessageType.RequisitionResource || messageContent == MessageType.RequestInformation || messageContent == MessageType.OfferUnsolicitedResource || messageContent == MessageType.RequestReturn || messageContent == MessageType.RequestResourceDeploymentStatus || messageContent == MessageType.RequestExtendedDeploymentDuration)) { throw new ArgumentNullException("ResponseInformation is not applicable for the MessageContentType: " + messageContent); } if (this.responseInformation == null && (messageContent == MessageType.ResponseToRequestResource || messageContent == MessageType.CommitResource || messageContent == MessageType.ResponseToRequestReturn || messageContent == MessageType.ResponseToRequestQuote || messageContent == MessageType.ResponseToRequestExtendedDeploymentDuration)) { throw new ArgumentNullException("ResponseInformation is required for the MessageContentType: " + messageContent); } if (this.resource == null && (messageContent == MessageType.RequestResource || messageContent == MessageType.RequisitionResource || messageContent == MessageType.OfferUnsolicitedResource || messageContent == MessageType.ReleaseResource || messageContent == MessageType.RequestReturn || messageContent == MessageType.RequestQuote || messageContent == MessageType.RequestResourceDeploymentStatus || messageContent == MessageType.RequestExtendedDeploymentDuration)) { throw new ArgumentNullException("Resource is required for the MessageContentType: " + messageContent); } if (this.resource == null && (messageContent == MessageType.CommitResource || messageContent == MessageType.ResponseToRequestQuote || messageContent == MessageType.ResponseToRequestExtendedDeploymentDuration) && (this.responseInformation.ResponseType == ResponseTypeType.Accept || this.responseInformation.ResponseType == ResponseTypeType.Provisional)) { throw new ArgumentNullException("Resource is required for the MessageContentType: " + messageContent + "ResponseType: " + this.responseInformation.ResponseType.ToString()); } if (this.assignmentInformation == null && messageContent == MessageType.RequisitionResource) { throw new ArgumentNullException("AssignmentInformation is required for the MessageContentType: " + messageContent); } if (this.assignmentInformation == null && (messageContent == MessageType.CommitResource) && (this.responseInformation.ResponseType == ResponseTypeType.Accept || this.responseInformation.ResponseType == ResponseTypeType.Provisional)) { throw new ArgumentNullException("AssignmentInformation is required for the MessageContentType: " + messageContent + "ResponseType: " + this.responseInformation.ResponseType.ToString()); } if (this.assignmentInformation != null && (messageContent == MessageType.CommitResource) && (this.responseInformation.ResponseType == ResponseTypeType.Decline)) { throw new ArgumentNullException("AssignmentInformation is not applicable for the MessageContentType: " + messageContent + "ResponseType: " + this.responseInformation.ResponseType.ToString()); } if (this.scheduleInformation.Count == 0 && (messageContent == MessageType.CommitResource) && (this.responseInformation.ResponseType == ResponseTypeType.Accept || this.responseInformation.ResponseType == ResponseTypeType.Provisional)) { throw new ArgumentNullException("ScheduleInformation is required for the MessageContentType: " + messageContent + "ResponseType: " + this.responseInformation.ResponseType.ToString()); } if (this.scheduleInformation.Count > 0 && (messageContent == MessageType.CommitResource) && (this.responseInformation.ResponseType == ResponseTypeType.Decline)) { throw new ArgumentNullException("ScheduleInformation is not applicable for the MessageContentType: " + messageContent + "ResponseType: " + this.responseInformation.ResponseType.ToString()); } }
public virtual async Task <long> GetCountAsync( Guid sendUserId, Guid receiveUserId, string filter = "", MessageType?type = null, CancellationToken cancellationToken = default) { return(await DbContext.Set <UserMessage>() .Where(x => (x.CreatorId.Equals(sendUserId) && x.ReceiveUserId.Equals(receiveUserId)) || x.CreatorId.Equals(receiveUserId) && x.ReceiveUserId.Equals(sendUserId)) .WhereIf(type != null, x => x.Type.Equals(type)) .WhereIf(!filter.IsNullOrWhiteSpace(), x => x.Content.Contains(filter) || x.SendUserName.Contains(filter)) .LongCountAsync(GetCancellationToken(cancellationToken))); }
private Query buildQuery( Atom channel, Dictionary <string, string> archiveDimensionsFilter, DateTime startDate, DateTime endDate, MessageType?type = null, string host = null, string topic = null, Guid?relatedTo = null) { var args = new List <TemplateArg>(); var wb = new StringBuilder(); wb.AppendFormat(@"{0}: {{ '$gte': '$$start_date', '$lt': '$$end_date' }}", Message.BSON_FLD_TIMESTAMP); args.Add(new TemplateArg("start_date", startDate)); args.Add(new TemplateArg("end_date", endDate)); if (archiveDimensionsFilter != null) { foreach (var item in archiveDimensionsFilter) { wb.AppendFormat(", __{0}:'$${0}'", item.Key); args.Add(new TemplateArg(item.Key, item.Value)); } } if (type.HasValue) { wb.AppendFormat(", {0}:'$$type'", Message.BSON_FLD_TYPE); args.Add(new TemplateArg("type", type.Value)); } if (relatedTo.HasValue) { wb.AppendFormat(", {0}:'$$related'", Message.BSON_FLD_RELATED_TO); args.Add(new TemplateArg("related", relatedTo.Value)); } if (host.IsNotNullOrWhiteSpace()) { wb.AppendFormat(", {0}:'$$host'", Message.BSON_FLD_HOST); args.Add(new TemplateArg("host", host)); } if (topic.IsNotNullOrWhiteSpace()) { wb.AppendFormat(", {0}:'$$host'", Message.BSON_FLD_TOPIC); args.Add(new TemplateArg("topic", topic)); } var where = "$query: { " + wb.ToString() + "},"; return(new Query(@"{{ {0} $orderby: {{ {1}:1 }} }}".Args(where, Message.BSON_FLD_TIMESTAMP), true, args.ToArray())); }
public async Task Test(TlsRptRecord tlsRptRecord, bool isErrorExpected, MessageType?expectedError = null, string markDown = null) { List <Message> messages = await _rule.Evaluate(tlsRptRecord); Assert.That(messages.Any(), Is.EqualTo(isErrorExpected)); Assert.That(messages.FirstOrDefault()?.MessageType, Is.EqualTo(expectedError)); if (markDown != null) { Assert.That(messages.FirstOrDefault()?.MarkDown, Is.EqualTo(markDown)); } }
public static string GetMessage(MessageType type) { if (prevMessageType == null || prevMessageType.Value != type) { Randomize(); prevMessageType = type; } switch (type) { case MessageType.Wave: return waveMessages[messageIndex]; case MessageType.Click: return clickMessages[messageIndex]; case MessageType.Loss: return lossMessages[messageIndex]; } return string.Empty; }
private void button2_Click(object sender, RoutedEventArgs e) { filterNodeId = null; filterSensorId = null; filterMesType = null; if (comboBox1.SelectedItem != null && comboBox1.SelectedItem.ToString() != "") filterNodeId = Int32.Parse(comboBox1.SelectedItem.ToString()); if (comboBox2.SelectedItem != null && comboBox2.SelectedItem.ToString() != "") filterSensorId = Int32.Parse(comboBox2.SelectedItem.ToString()); if (comboBox3.SelectedItem != null && comboBox3.SelectedItem.ToString() != "") { MessageType outType; MessageType.TryParse(comboBox3.SelectedItem.ToString(), true, out outType); filterMesType = outType; } ShowFilteredMessages(); }
private void button1_Click(object sender, RoutedEventArgs e) { filterNodeId = null; filterSensorId = null; filterMesType = null; App.serialController.messagesLog.ClearLog(); UpdateCombos(); ShowFilteredMessages(); }
public void ConfigChanged(IConfigSectionNode atNode) { var webSettingsSection = App.ConfigRoot[CONFIG_WEBSETTINGS_SECTION]; var nSocial = webSettingsSection[CONFIG_SOCIAL_SECTION]; configSocial(nSocial); var nTax = webSettingsSection[CONFIG_TAX_SECTION]; configTaxCalculators(nTax); var webDavSection = webSettingsSection[CONFIG_WEBDAV_SECTION]; m_WebDavLogType = webDavSection.AttrByName(CONFIG_LOGTYPE_ATTR).ValueAsNullableEnum<MessageType>(); m_WebDavDefaultTimeoutMs = webDavSection.AttrByName(CONFIG_DEFAULT_TIMEOUT_MS_ATTR).ValueAsInt(); if (m_WebDavDefaultTimeoutMs < 0) m_WebDavDefaultTimeoutMs = 0; var servicePointManagerSection = webSettingsSection[CONFIG_SERVICEPOINTMANAGER_SECTION]; ((IConfigurable)(ServicePointManagerConfigurator.s_Instance)).Configure(servicePointManagerSection); }