using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RDH.PharmacyPlatform.Sync.Core
{
    /// <summary>
    /// 表示消息内容的类
    /// </summary>
    [Serializable]
    public class MessageData
    {
        private DateTime _createTime;
        private String _sourceId;
        private MessageFilterType _filter;
        private String _targetId;
        private String _messageContent;
        private String _messageContentType;
        public MessageData() 
        {
            _createTime = DateTime.Now;
        }
        public MessageData(String sourceId, String content, MessageFilterType filter, String target) 
        {
            _createTime = DateTime.Now;
            _sourceId = sourceId;
            _filter = filter;
            _targetId = target;
            MessageContent = content;
        }
        /// <summary>
        /// 获取或设置创建时间
        /// </summary>
        public DateTime CreateTime 
        {
            get => _createTime; 
            set => _createTime = value; 
        }
        /// <summary>
        /// 获取或设置消息来源名称
        /// </summary>
        public String SourceId 
        {
            get => _sourceId;
            set => _sourceId = value; 
        }
        /// <summary>
        /// 获取或设置消息内容
        /// </summary>
        public String MessageContent 
        {
            get { return _messageContent; }
            set 
            { 
                _messageContent = value;
            }
        }
        public String MessageContentType 
        {
            get { return _messageContentType; }
            set { _messageContentType = value; }
        }
        /// <summary>
        /// 获取或设置消息过滤条件
        /// </summary>
        public MessageFilterType FilterType 
        {
            get => _filter;
            set => _filter = value;
        }
        /// <summary>
        /// 获取或设置消息发送到的目标的名称
        /// </summary>
        public String TargetId 
        {
            get => _targetId;
            set => _targetId = value;
        }
        public override string ToString()
        {
            return $"{_createTime.ToString("yyyy-MM-dd HH:mm:ss")}, Source:{_sourceId}, Target:{_targetId}, Filter:{_filter.ToString()}";
        }
    }
}
