Ejemplo n.º 1
0
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, Uri from, string action, string callerIdentity, Guid iid, int instanceID, bool traceContextTransaction)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusMethodCallSchema schema = null;
         Guid empty = Guid.Empty;
         if (traceContextTransaction)
         {
             IComThreadingInfo info2 = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(IID_IComThreadingInfo);
             if (info2 != null)
             {
                 IObjectContextInfo info3 = info2 as IObjectContextInfo;
                 if ((info3 != null) && info3.IsInTransaction())
                 {
                     info3.GetTransactionId(out empty);
                 }
             }
             if (empty != Guid.Empty)
             {
                 schema = new ComPlusMethodCallContextTxSchema(from, info.AppID, info.Clsid, iid, action, instanceID, Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId(), callerIdentity, empty);
             }
         }
         else
         {
             schema = new ComPlusMethodCallSchema(from, info.AppID, info.Clsid, iid, action, instanceID, Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId(), callerIdentity);
         }
         if (schema != null)
         {
             TraceUtility.TraceEvent(type, traceCode, System.ServiceModel.SR.GetString(description), (TraceRecord)schema);
         }
     }
 }
            public void OnCall()
            {
                ServiceModelActivity activity = null;

                try
                {
                    Guid guidLogicalThreadID = Guid.Empty;

                    if (DiagnosticUtility.ShouldUseActivity)
                    {
                        IComThreadingInfo comThreadingInfo;
                        comThreadingInfo = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(ComPlusActivityTrace.IID_IComThreadingInfo);

                        if (comThreadingInfo != null)
                        {
                            comThreadingInfo.GetCurrentLogicalThreadId(out guidLogicalThreadID);

                            activity = ServiceModelActivity.CreateBoundedActivity(guidLogicalThreadID);
                        }
                        ServiceModelActivity.Start(activity, SR.GetString(SR.TransferringToComplus, guidLogicalThreadID.ToString()), ActivityType.TransferToComPlus);
                    }
                    ComPlusActivityTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationExecutingCall, SR.TraceCodeComIntegrationExecutingCall);

                    this.callback(this.state);
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    DiagnosticUtility.InvokeFinalHandler(e);
                }
                finally
                {
                    if (activity != null)
                    {
                        activity.Dispose();
                        activity = null;
                    }
                }
            }
 public static void Trace(TraceEventType type, int traceCode, string description)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         Guid empty             = Guid.Empty;
         Guid guid              = Guid.Empty;
         IComThreadingInfo info = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(IID_IComThreadingInfo);
         if (info != null)
         {
             info.GetCurrentLogicalThreadId(out empty);
             IObjectContextInfo info2 = info as IObjectContextInfo;
             if (info2 != null)
             {
                 info2.GetActivityId(out guid);
             }
         }
         ComPlusActivitySchema schema = new ComPlusActivitySchema(guid, empty, Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId());
         TraceUtility.TraceEvent(type, traceCode, System.ServiceModel.SR.GetString(description), (TraceRecord)schema);
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, Uri from, string action, string callerIdentity,
                          Guid iid, int instanceID, bool traceContextTransaction)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         ComPlusMethodCallSchema record = null;
         Guid guidContextTrsansactionID = Guid.Empty;
         if (traceContextTransaction)
         {
             IComThreadingInfo comThreadingInfo;
             comThreadingInfo = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(IID_IComThreadingInfo);
             if (comThreadingInfo != null)
             {
                 IObjectContextInfo contextInfo = comThreadingInfo as IObjectContextInfo;
                 if (contextInfo != null)
                 {
                     if (contextInfo.IsInTransaction())
                     {
                         contextInfo.GetTransactionId(out guidContextTrsansactionID);
                     }
                 }
             }
             if (guidContextTrsansactionID != Guid.Empty)
             {
                 record = new ComPlusMethodCallContextTxSchema(from, info.AppID, info.Clsid, iid, action,
                                                               instanceID, System.Threading.Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId(), callerIdentity, guidContextTrsansactionID);
             }
         }
         else
         {
             record = new ComPlusMethodCallSchema(from, info.AppID, info.Clsid, iid, action,
                                                  instanceID, System.Threading.Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId(), callerIdentity);
         }
         if (record != null)
         {
             TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
         }
     }
 }
 public static void Trace(TraceEventType type, int traceCode, string description)
 {
     if (DiagnosticUtility.ShouldTrace(type))
     {
         Guid guidLogicalThreadID = Guid.Empty;
         Guid guidActivityID      = Guid.Empty;
         IComThreadingInfo comThreadingInfo;
         comThreadingInfo = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(IID_IComThreadingInfo);
         if (comThreadingInfo != null)
         {
             comThreadingInfo.GetCurrentLogicalThreadId(out guidLogicalThreadID);
             IObjectContextInfo contextInfo = comThreadingInfo as IObjectContextInfo;
             if (contextInfo != null)
             {
                 contextInfo.GetActivityId(out guidActivityID);
             }
         }
         ComPlusActivitySchema record =
             new ComPlusActivitySchema(guidActivityID, guidLogicalThreadID,
                                       System.Threading.Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId());
         TraceUtility.TraceEvent(type, traceCode, ServiceModelSR.GetString(description), record);
     }
 }
            public void OnCall()
            {
                ServiceModelActivity activity = null;

                try
                {
                    Guid empty = Guid.Empty;
                    if (DiagnosticUtility.ShouldUseActivity)
                    {
                        IComThreadingInfo info = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(ComPlusActivityTrace.IID_IComThreadingInfo);
                        if (info != null)
                        {
                            info.GetCurrentLogicalThreadId(out empty);
                            activity = ServiceModelActivity.CreateBoundedActivity(empty);
                        }
                        ServiceModelActivity.Start(activity, System.ServiceModel.SR.GetString("TransferringToComplus", new object[] { empty.ToString() }), ActivityType.TransferToComPlus);
                    }
                    ComPlusActivityTrace.Trace(TraceEventType.Verbose, 0x50016, "TraceCodeComIntegrationExecutingCall");
                    this.callback(this.state);
                }
                catch (Exception exception)
                {
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    DiagnosticUtility.InvokeFinalHandler(exception);
                }
                finally
                {
                    if (activity != null)
                    {
                        activity.Dispose();
                        activity = null;
                    }
                }
            }