Beispiel #1
0
        public static LogMessage InitLogMessage(string guid, IRequest request, string objectName,
                                                string data, string status, string response, string message = "", string interfaceName = "", Exception e = null)
        {
            LogMessage newMessage = new LogMessage
            {
                MesID         = guid,
                IP            = GetWebClientIp(),//request.RemoteIp,
                Mac           = request.UserHostAddress,
                InterFaceNo   = "",
                RequestSystem = "测试",
                InterFaceName = interfaceName,
                ObjectName    = objectName,
                RequestUrl    = request.AbsoluteUri,
                Data          = data,
                Status        = status,
                Response      = response
            };

            //获取上一步的方法名称
            var method1 = new StackTrace().GetFrame(1).GetMethod();
            //获取方法的自定义属性
            var item = method1.GetCustomAttribute(typeof(MethodAttribute)) as MethodAttribute;

            newMessage.InterFaceName = (item != null && string.IsNullOrEmpty(interfaceName)) ? item.Name : interfaceName;

            return(newMessage);
        }
Beispiel #2
0
        protected void Throttle()
        {
            MethodBase          Method          = new StackTrace().GetFrame(1).GetMethod();
            AmazonCallAttribute AmazonAttribute = Method.GetCustomAttribute <AmazonCallAttribute>();

            if (AmazonAttribute == default(AmazonCallAttribute))
            {
                throw new NotImplementedException($"Error the method [{Method.Name}] is not properly implemented and cannot be called!");
            }
            else
            {
                this.Throttle(AmazonAttribute.RequestType);
            }
        }
Beispiel #3
0
        public MaplePakcet(byte[] buffer)
        {
            //获取运行函数
            MethodBase @base = new StackTrace().GetFrame(1).GetMethod();

            System.Attribute attribute = @base.GetCustomAttribute(typeof(PacketHead), true);
            if (attribute != null)
            {
                m_stream = new MemoryStream();
                m_stream.WriteByte(byte.Parse(((PacketHead)attribute).Head.ToString()));
                m_stream.Write(buffer, 0, buffer.Length);
            }
            else
            {
                m_stream = new MemoryStream(buffer);
            }
        }