private void EndFeedbackSession(bool normalExit) { if (this.sqmSessionHandle == null && (this.sqmSessionHandle == null || !this.sqmSessionHandle.IsInvalid && !this.sqmSessionHandle.IsClosed)) { return; } if (!UnsafeNativeMethods.Set(this.sqmSessionHandle, 4U, normalExit ? 0U : 1U)) { Marshal.GetLastWin32Error(); } string feedbackPath = FeedbackService.FeedbackPath; try { this.sqmSessionHandle.FilePattern = this.EndSessionFileNamePattern; } catch (ArgumentException ex) { } try { if (!UnsafeNativeMethods.EndSession(this.sqmSessionHandle, this.EndSessionFileNamePattern, HSQMSESSION.MaxFilesToQueue, 10U)) { Marshal.GetLastWin32Error(); } } catch (Exception ex) { } this.sqmSessionHandle = (HSQMSESSION)null; }
private bool CreateFeedbackSession(ExpressionApplication application) { if (string.IsNullOrEmpty(this.LoggingFileName)) { this.LoggingFileName = "MySqmSession"; } this.sqmSessionHandle = UnsafeNativeMethods.GetSession(this.LoggingFileName, 65536U, 1U); if (this.sqmSessionHandle == null) { Marshal.GetLastWin32Error(); return(false); } if (this.sqmSessionHandle.IsInvalid) { return(false); } if (!UnsafeNativeMethods.SetAppId(this.sqmSessionHandle, (uint)application.CustomerFeedbackApplicationIdentifier)) { Marshal.GetLastWin32Error(); return(false); } Version version = ExpressionApplication.Version; if (!UnsafeNativeMethods.SetAppVersion(this.sqmSessionHandle, (uint)((version.Major << 16) + version.Minor), (uint)((version.Build << 16) + version.Revision))) { Marshal.GetLastWin32Error(); return(false); } if (!UnsafeNativeMethods.ReadSharedMachineId(ref this.sharedMachineId) && !UnsafeNativeMethods.CreateNewId(ref this.sharedMachineId)) { UnsafeNativeMethods.WriteSharedMachineId(ref this.sharedMachineId); } UnsafeNativeMethods.SetMachineId(this.sqmSessionHandle, ref this.sharedMachineId); if (!UnsafeNativeMethods.ReadSharedUserId(ref this.sharedUserId) && !UnsafeNativeMethods.CreateNewId(ref this.sharedUserId)) { UnsafeNativeMethods.WriteSharedUserId(ref this.sharedUserId); } UnsafeNativeMethods.SetUserId(this.sqmSessionHandle, ref this.sharedUserId); return(true); }
public static extern bool Increment(HSQMSESSION hSession, uint dwId, uint dwInc);
public static extern bool SetIfMin(HSQMSESSION hSession, uint dwId, uint dwVal);
public static extern bool SetAppId(HSQMSESSION hSession, uint dwAppId);
public static extern bool GetEnabled(HSQMSESSION hSession);
public static extern bool ClearFlags(HSQMSESSION hSession, uint dwFlags);
public static extern bool AddToStreamDWord(HSQMSESSION hSession, uint dwId, uint cTuple, uint dwVal);
public static extern bool SetString(HSQMSESSION hSession, uint dwId, string pwszVal);
public static extern bool GetUserId(HSQMSESSION hSession, ref Guid pGuid);
public static extern bool GetMachineId(HSQMSESSION hSession, ref Guid pGuid);
public static extern bool TimerAddToAverage(HSQMSESSION hSession, uint dwId);
public static extern bool TimerAccumulate(HSQMSESSION hSession, uint dwId);
public static extern bool TimerRecord(HSQMSESSION hSession, uint dwId);
public static extern bool TimerStart(HSQMSESSION hSession, uint dwId);
public static extern bool AddToAverage(HSQMSESSION hSession, uint dwId, uint dwVal);
public static extern bool AddToStream(HSQMSESSION hSession, uint dwId, int nArgs, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9);
public static extern System.Runtime.InteropServices.ComTypes.FILETIME GetSessionStartTime(HSQMSESSION hSession);
public static extern bool AddToStreamString(HSQMSESSION hSession, uint dwId, uint cTuple, string pwszVal);
public static extern bool StartSession(HSQMSESSION hSession);
public static extern bool GetFlags(HSQMSESSION hSession, out uint pdwFlags);
public static extern bool EndSession(HSQMSESSION hSession, string pwszPattern, uint dwMaxFilesToQueue, uint dwFlags);
public static extern bool SetEnabled(HSQMSESSION hSession, [MarshalAs(UnmanagedType.Bool)] bool fEnabled);
public static extern bool SqmFlushSession(HSQMSESSION hSession, string pwszFileName);
public static extern bool SetBits(HSQMSESSION hSession, uint dwId, uint dwOrBits);
public static extern bool SetAppVersion(HSQMSESSION hSession, uint dwVersionHigh, uint dwVersionLow);