// using Comal.Classes; // using Comal.Stores; // using InABox.Core; // using InABox.Database; // using PRSStores; // using System; // using System.Collections.Generic; // using System.Linq; // using System.Text; // using System.Threading.Tasks; // // namespace PRS.Shared.Database_Update_Scripts.Utils; // // public static class JobRequisitionItemUtils // { // public static void RefreshStatuses(IStore store) // { // Logger.Send(LogType.Information, "", $"Refreshing JobRequisitionItem statuses"); // var jobRequiItems = store.Provider.Query( // null, // JobRequisitionItemStore.StatusRequiredColumns().Add(x => x.Status)) // .ToObjects() // .ToList(); // // var statusUpdates = new Dictionary, List>(); // // var i = 0; // foreach(var item in jobRequiItems) // { // if(i % 50 == 0) // { // Logger.Send(LogType.Information, "", $"Refreshing statuses: {(((double)i) / (double)jobRequiItems.Count * 100):F0}%"); // } // if (JobRequisitionItemStore.CalculateStatus(store, item)) // { // var key = new Tuple(item.GetOriginalValue(x=>x.Status), item.Status); // if(!statusUpdates.TryGetValue(key, out var list)) // { // list = new List(); // statusUpdates.Add(key, list); // } // list.Add(item.ID); // //item.Issues += $"Updated status from {item.GetOriginalValue(x=>x.Status)} to {item.Status}"; // // } // ++i; // } // // foreach(var ((from, to), list) in statusUpdates) // { // Logger.Send(LogType.Information, "", $"{from} -> {to}: {list.Count} entries"); // } // // new BaseStore // { // UserGuid = Guid.Empty, // UserID = "", // Platform = Platform.Server, // Version = CoreUtils.GetVersion(), // Provider = DbFactory.NewProvider(Logger.Main) // }.Save(jobRequiItems, ""); // } // }