public ServiceHeartbeatMonitor(IEndpoint publisherEndpoint, IEndpoint subscriberEndpoint, MessageFormatType expectedMessageFormat) : this(publisherEndpoint, subscriberEndpoint, new SubscriptionsMsmqChannel(subscriberEndpoint, expectedMessageFormat), new ServiceHeartbeatMsmqChannel(subscriberEndpoint, expectedMessageFormat)) { }
public MessageDefinition(IEnumerable <string> attributes, MessageFormatType formatType, string name, IEnumerable <MessageElement> elements) { this.Attributes = attributes?.ToList() ?? throw new ArgumentNullException(nameof(attributes)); this.FormatType = formatType; this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.Elements = elements?.ToList() ?? throw new ArgumentNullException(nameof(elements)); }
public ListMessageCommand(Adaptor adaptor, MessageStateType messageStateType, MessageFormatType messageFormatType) : base(adaptor) { _MessageStateType = messageStateType; _MessageFormatType = messageFormatType; _MessageCollection = new MessageCollection(); }
public static ShortMessage Resolve(string header, string footer, MessageFormatType formatType) { try { if (!header.ToUpper().StartsWith("+CMGL:")) { throw new ArgumentException(); } header = header.Substring(6); string[] items = header.Split(new[] { ',' }); if (items.Length == 0) { throw new ArgumentException(); } if (formatType == MessageFormatType.Text) { return(new ShortMessage(int.Parse(items[0].Trim()), items[2].Replace("\"", ""), footer)); } return(new ShortMessage(int.Parse(items[0].Trim()), int.Parse(items[3].Trim()), footer)); } catch (Exception p) { logger.Error("Exception; {0} and Args; {1}, {2}, {3}", p, header, footer, formatType); return(null); } }
/// <summary> /// 序列化请求 /// </summary> /// <param name="requestType"></param> /// <param name="o"></param> /// <param name="format"></param> /// <returns></returns> public string SerializeRequest(string requestType, object o, MessageFormatType format) { string s = string.Empty; if (requestTypeList.ContainsKey(requestType)) { Type t = requestAssemblyList[requestType].GetType(requestTypeList[requestType]); if (format == MessageFormatType.JSON) { JsonSerializerSettings settings = new JsonSerializerSettings(); settings.Formatting = Formatting.Indented; s = JsonConvert.SerializeObject(o, t, settings); } else { XmlSerializer serilizer = new XmlSerializer(t); using (MemoryStream ms = new MemoryStream()) { serilizer.Serialize(ms, o); s = Encoding.UTF8.GetString(ms.ToArray()); } } } return(s); }
public SerializableMessageInfoData(ulong pID, DateTime pDate, MessageStateType pMessageStateType, string pContent, MessageFormatType pMessageFormatType, MessageDirectionType pMessageDirectionType) { _ID = pID; _Date = pDate; _MessageStateType = pMessageStateType; _Content = pContent; _MessageFormatType = pMessageFormatType; _MessageDirectionType = pMessageDirectionType; }
public MessageFormatAttribute(MessageFormatType formatType) { if (Enum.IsDefined(typeof(MessageFormatType), formatType)) { Value = formatType; } else { Value = MessageFormatType.Binary; } }
/// <summary> /// 生成示例请求 /// </summary> /// <param name="requestType"></param> /// <param name="format"></param> /// <returns></returns> public string GenerateRequest(string requestType, MessageFormatType format) { string result = string.Empty; object request = null; Assembly ass = requestAssemblyList[requestType]; if (ass != null) { request = ass.CreateInstance(requestTypeList[requestType]); request.InitSelf(new FlightObjectPropertySetter()); } if (request != null) { result = SerializeRequest(requestType, request, format); } return(result); }
/// <summary> /// Creates a new instance of the message format attribute /// </summary> public MessageFormatAttribute(MessageFormatType format) { this.MessageFormat = format; }
public ReadMessageCommand(Adaptor adaptor, int index, MessageFormatType messageFormatType) : base(adaptor) { _Index = index; _MessageFormatType = messageFormatType; }
/// <summary> /// 反序列化请求 /// </summary> /// <param name="requestType"></param> /// <param name="message"></param> /// <param name="format"></param> /// <returns></returns> public object DeserializeRequest(out string error, string requestType, string message, MessageFormatType format) { error = null; object o = null; try { if (requestTypeList.ContainsKey(requestType)) { Type t = requestAssemblyList[requestType].GetType(requestTypeList[requestType]); if (format == MessageFormatType.JSON) { o = JsonConvert.DeserializeObject(message, t); } else { XmlSerializer serilizer = new XmlSerializer(t); using (MemoryStream ms = new MemoryStream()) { byte[] messageBytes = Encoding.UTF8.GetBytes(message); ms.Write(messageBytes, 0, messageBytes.Length); ms.Position = 0; o = serilizer.Deserialize(ms); } } } } catch (Exception ex) { error = string.Format("报文格式错误\n\r{0}", ex.ToString()); } return(o); }