Nick Thissen wrote:
IDriver inherits IEntity, so IDriver has the customer ID as well under the Id property.
Oops, completely missed that! Now that made things much easier and I've got it working. Thank you!
Here I'm posting the code, in case anybody would need it.
using System;
using System.Data;
using System.Linq;
using ATVO.ThemesSDK;
using ATVO.ThemesSDK.Data.Results;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
namespace Scripts
{
public class fastlap : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
ISessionResult fl = (ISessionResult) value;
int id = fl.FastestLapDriver.Id;
string name = "";
string team = "";
if (id != 0)
{
var sheet = item.Theme.Spreadsheets.Find("Drivers.csv");
foreach (var row in sheet.Table.Data.Rows.OfType<DataRow>())
{
int idcheck = Convert.ToInt32(row[0]);
if (idcheck == id)
{
name = row[2].ToString();
team = row[3].ToString();
}
}
}
string result = name + " - " + team;
return result;
}
}
}