Skip to content

Commit

Permalink
Update CallerFormula_Run.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
travispotterBH authored and Fraser Greenroyd committed Sep 12, 2022
1 parent c666325 commit 645a410
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Excel_UI/Caller/CallerFormula_Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
using System.Collections;
using ExcelDna.Integration;
using Microsoft.Office.Interop.Excel;

using System.Xml.Linq;
using BH.oM.UI;

namespace BH.UI.Excel.Templates
{
Expand Down Expand Up @@ -57,6 +58,7 @@ public virtual object Run(object[] inputs)
// Log usage
Application app = ExcelDnaUtil.Application as Application;
Workbook workbook = app.ActiveWorkbook;
SetProjectID(workbook);
Engine.UI.Compute.LogUsage("Excel", app?.Version, InstanceId, Caller.GetType().Name, Caller.SelectedItem, Engine.Base.Query.CurrentEvents(), AddIn.WorkbookId(workbook), workbook.FullName);

// Return result
Expand All @@ -81,6 +83,20 @@ public virtual object RunWithOutputConfig(object[] inputs, bool includeOutputNam
}

/*******************************************/

private static void SetProjectID(Workbook workbook)
{
string projectId = workbook.Title;

if (!string.IsNullOrEmpty(projectId))
{
BH.Engine.Base.Compute.RecordEvent(new ProjectIDEvent
{
Message = "The project ID for this file is now set to " + projectId,
ProjectID = projectId
});
}
}
}
}

Expand Down

0 comments on commit 645a410

Please sign in to comment.