| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | using InABox.Core;using InABox.Database;namespace PRS.Shared;/// <summary>/// Updating Wpf and Timebench fields to use Platform.DesktopVersion and Platform.MobileVersion/// </summary>public class Update_7_14 : DatabaseUpdateScript{    public override VersionNumber Version => new (7, 14);        public override bool Update()    {        Logger.Send(LogType.Information, "", "Converting User.Wpf, User.Timebench -> User.Platform.DesktopVersion, User.Platform.MobileVersion");        Logger.Send(LogType.Information, "", "Loading Wpf, Timebench properties");        var props = DbFactory.NewProvider(Logger.Main).Query<CustomProperty>(new Filter<CustomProperty>(x => x.Name).InList("Wpf", "TimeBench"))            .Rows.Select(x => x.ToObject<CustomProperty>()).ToArray();        DatabaseSchema.Load(props);        var columns = Columns.None<User>().Add(x => x.ID);        columns.Add("Wpf", "TimeBench");        var users = DbFactory.NewProvider(Logger.Main).Query<User>(            new Filter<User>().All(),            columns).ToObjects<User>().ToList();        foreach(var user in users)        {            if(user.UserProperties.Dictionary.TryGetValue("Wpf", out var wpf))            {                user.Platform.DesktopVersion = wpf?.Value?.ToString() ?? "";            }            if (user.UserProperties.Dictionary.TryGetValue("TimeBench", out var timebench))            {                user.Platform.MobileVersion = timebench?.Value?.ToString() ?? "";            }        }        DbFactory.NewProvider(Logger.Main).Save<User>(users);        Logger.Send(LogType.Information, "", "Finished updating user versions");        return true;    }    }
 |