private static void SetMessageValuesIfNotSetInClient(IRequestBase message, IRuntime runtime)
 {
     if (message.MessageId.IsNullOrWhiteSpace())
         message.MessageId = Guid.NewGuid().ToString();
     if (message.Environment.IsNullOrWhiteSpace())
         message.Environment = runtime.Environment;
     if (message.ServiceName.IsNullOrWhiteSpace())
         message.ServiceName = runtime.ServiceName;
     if (message.ConfigSet.IsNullOrWhiteSpace())
         message.ConfigSet = ConfigurationManagerHelper.GetValueOnKey("configSet");
     if (message.TimeStamp == null)
         message.TimeStamp = DateTime.UtcNow;
     if (runtime.RequestContext.IsInstance())
         message.ReferingMessageId = runtime.RequestContext.MessageId;
 }
示例#2
0
        internal void LogCall(string name, IRequestBase request)
        {
            // unfortunately we cannot return the CallInfo object
            // the [Conditional] of this Log method requires void return type.
            // therefore we store it in the request;
            // the LogResponse method can then retrieve it from the request that is passed in.

            if (_LogServiceCalls == -1) return;

            if (request != null) request.DebugInfo = new CallInfo(name);

            switch (_LogServiceCalls)
            {
                case 0:
                    return;
                case 1:
                    _Log.Info("+" + name);
                    return;
            }

            if (request != null)
            {
                string session = request.SessionID.ShortString();
                switch (_LogServiceCalls)
                {
                    case 2:
                        _Log.InfoFormat("{0}|+{1}", session, name);
                        break;
                    case 3:
                        _Log.InfoFormat("{0}|+{1}: {2}", session, name, request);
                        break;
                    case 4:
                        string detail = RequestDetail(request);
                        _Log.InfoFormat("{0}|+{1}: {2}", session, name, detail);
                        break;
                }
            }
            else
            {
                _Log.InfoFormat("----|+{0}", name);
            }
        }
示例#3
0
        internal void LogResult(IRequestBase request, object response)
        {
            if (_LogServiceCalls == -1 || request == null) return;
            var info = request.DebugInfo as CallInfo;
            if (_LogServiceResults == 0 || info == null) return;

            string duration = info.Stopwatch != null
                                                    ? string.Format(" ({0} ms)", info.Stopwatch.ElapsedMilliseconds)
                                                    : string.Empty;

            string session = request.SessionID.ShortString();
            string name = info.MethodName;
            switch (_LogServiceResults)
            {
                case 1:
                    _Log.Info("-" + name + duration);
                    break;
                case 2:
                    _Log.InfoFormat("{0}|-{1}{2}", session, name, duration);
                    break;
                case 3:
                    _Log.InfoFormat("{0}|-{1}{2}: {3}", session, name, duration, response);
                    break;
                case 4:
                    string detail = ResponseDetail(response);
                    _Log.InfoFormat("{0}|-{1}{2}: {3}", session, name, duration, detail);
                    break;
            }
        }
示例#4
0
 private string RequestDetail(IRequestBase request)
 {
     var sb = new StringBuilder();
     sb.Append(request);
     if (request is ParameterMessageBase)
     {
         sb.Append('+');
         var r = (ParameterMessageBase)request;
         if (r.HasParameters)
         {
             foreach (var k in r.Keys)
             {
                 sb.AppendFormat("{0}={1},", k, r[k]);
             }
         }
     }
     if (sb[sb.Length - 1] == ',')
     {
         sb.Length--;
     }
     return sb.ToString();
 }