|
@@ -0,0 +1,59 @@
|
|
|
+using Comal.Classes;
|
|
|
+using InABox.Core;
|
|
|
+using InABox.Database;
|
|
|
+
|
|
|
+namespace PRS.Shared.Database_Update_Scripts;
|
|
|
+
|
|
|
+public class Update_7_77 : DatabaseUpdateScript
|
|
|
+{
|
|
|
+ public override VersionNumber Version => new VersionNumber(7, 77);
|
|
|
+
|
|
|
+ public override bool Update()
|
|
|
+ {
|
|
|
+ var formtypes = CoreUtils.Entities
|
|
|
+ .Where(x => x.IsSubclassOfRawGeneric(typeof(EntityForm<,,>)))
|
|
|
+ .ToList();
|
|
|
+
|
|
|
+ int iType = 0;
|
|
|
+ foreach (var formtype in formtypes)
|
|
|
+ {
|
|
|
+ iType++;
|
|
|
+ Logger.Send(LogType.Information, "", $"Updating {formtype.Name} Descriptions ({iType}/{formtypes.Count})");
|
|
|
+ int iCount = 0;
|
|
|
+ List<Entity> updates = new();
|
|
|
+ var forms = DbFactory.Provider.Query(
|
|
|
+ formtype,
|
|
|
+ Filter.Create<ICoreDigitalFormInstance>(formtype,x=>x.Description).IsEqualTo(""),
|
|
|
+ Columns.Create<ICoreDigitalFormInstance>(formtype)
|
|
|
+ .Add<ICoreDigitalFormInstance>(x=>x.ID)
|
|
|
+ .Add<ICoreDigitalFormInstance>(x=>x.Description)
|
|
|
+ .Add<ICoreDigitalFormInstance>(x=>x.Form.Description)
|
|
|
+ ).ToObjects(formtype).ToList();
|
|
|
+ foreach (var form in forms)
|
|
|
+ {
|
|
|
+ if (form is ICoreDigitalFormInstance instance and Entity entity)
|
|
|
+ {
|
|
|
+ instance.Description = instance.Form.Description;
|
|
|
+ updates.Add(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (updates.Count >= 100)
|
|
|
+ {
|
|
|
+ iCount += 100;
|
|
|
+ Logger.Send(LogType.Information, "", $"- Updating {formtype.Name}s ({iCount}/{forms.Count})");
|
|
|
+ DbFactory.Provider.Save(formtype,updates);
|
|
|
+ updates.Clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (updates.Any())
|
|
|
+ {
|
|
|
+ iCount += updates.Count;
|
|
|
+ Logger.Send(LogType.Information, "", $"- Updating {formtype.Name}s ({iCount}/{forms.Count})");
|
|
|
+ DbFactory.Provider.Save(formtype,updates);
|
|
|
+ updates.Clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+}
|