private static ScriptTelemetryRecord MakeTelemetryRecord(ref ScriptRuntime runtime) { // determine build number string revitbuild = "20000101_0000(x64)"; #if (REVIT2013 || REVIT2014 || REVIT2015 || REVIT2016 || REVIT2017 || REVIT2018 || REVIT2019 || REVIT2020) revitbuild = runtime.App.VersionBuild; #else // Revit 2021 has a bug on .VersionBuild // it reports identical value as .VersionNumber // let's give a invalid, but correctly formatted value to the telemetry server string revitExePath = Process.GetCurrentProcess().MainModule.FileName; if (revitExePath != null && revitExePath != string.Empty) { HostProductInfo pinfo = RevitProductData.GetBinaryProductInfo(revitExePath); if (pinfo.build != null && pinfo.build != string.Empty) { revitbuild = string.Format("{0}({1})", pinfo.build, pinfo.target); } } #endif // setup a new telemetry record return(new ScriptTelemetryRecord { host_user = UserEnv.GetLoggedInUserName(), username = runtime.App.Username, revit = runtime.App.VersionNumber, revitbuild = revitbuild, sessionid = runtime.SessionUUID, pyrevit = runtime.PyRevitVersion, clone = runtime.CloneName, debug = runtime.ScriptRuntimeConfigs.DebugMode, config = runtime.ScriptRuntimeConfigs.ConfigMode, from_gui = runtime.ScriptRuntimeConfigs.ExecutedFromUI, exec_id = runtime.ExecId, exec_timestamp = runtime.ExecTimestamp, commandname = runtime.ScriptData.CommandName, commandbundle = runtime.ScriptData.CommandBundle, commandextension = runtime.ScriptData.CommandExtension, commanduniquename = runtime.ScriptData.CommandUniqueId, scriptpath = runtime.ScriptSourceFile, docname = runtime.DocumentName, docpath = runtime.DocumentPath, resultcode = runtime.ExecutionResult, commandresults = runtime.GetResultsDictionary(), trace = new ScriptTelemetryRecordTraceInfo { engine = new ScriptTelemetryRecordEngineInfo { type = runtime.EngineType.ToString().ToLower(), version = runtime.EngineVersion, syspath = runtime.ScriptRuntimeConfigs.SearchPaths, configs = new JavaScriptSerializer().Deserialize <Dictionary <string, string> >(runtime.ScriptRuntimeConfigs.EngineConfigs), }, message = runtime.TraceMessage } }); }
public static string GetRevitBuild(object source) { // determine build number string revitbuild = string.Empty; #if (REVIT2013 || REVIT2014 || REVIT2015 || REVIT2016 || REVIT2017 || REVIT2018 || REVIT2019 || REVIT2020) switch (source) { case UIControlledApplication uictrlapp: revitbuild = uictrlapp.ControlledApplication.VersionBuild; break; case UIApplication uiapp: revitbuild = uiapp.Application.VersionBuild; break; case ControlledApplication ctrlapp: revitbuild = ctrlapp.VersionBuild; break; case Application app: revitbuild = app.VersionBuild; break; } #else // Revit 2021 has a bug on .VersionBuild // it reports identical value as .VersionNumber // let's give a invalid, but correctly formatted value to the telemetry server if (_exeBuild is null) { string revitExePath = Process.GetCurrentProcess().MainModule.FileName; if (revitExePath != null && revitExePath != string.Empty) { HostProductInfo pinfo = RevitProductData.GetBinaryProductInfo(revitExePath); if (pinfo.build != null && pinfo.build != string.Empty) { revitbuild = string.Format("{0}({1})", pinfo.build, pinfo.target); _exeBuild = revitbuild; } } } else { revitbuild = _exeBuild; } #endif return(revitbuild); }