1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using Comal.Classes;
- using InABox.Core;
- using InABox.Database;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace PRS.Shared.Database_Update_Scripts;
- internal class Update_8_32 : DatabaseUpdateScript
- {
- public override VersionNumber Version => new(8, 32);
- public override bool Update()
- {
- var provider = DbFactory.NewProvider(Logger.Main);
- Logger.Send(LogType.Information, "", $"Process Kanban Notes");
- var tasks = provider.Query<Kanban>(
- null,
- Columns.None<Kanban>().Add(x => x.ID).Add(x => x.Notes))
- .ToArray<Kanban>();
- Utils.Utils.ProcessInChunks(tasks, chunk =>
- {
- foreach(var kanban in chunk)
- {
- if (kanban.Notes is not null && kanban.Notes.Any(x => x?.Contains("===================================") != false))
- {
- var notes = new List<List<string>>() { new() };
- foreach (var line in kanban.Notes)
- {
- if(line is not null)
- {
- if (line.Equals("==================================="))
- {
- notes.Add(new());
- }
- else
- {
- notes[^1].Add(line);
- }
- }
- else
- {
- notes[^1].Add("");
- }
- }
- kanban.Notes = notes.Select(x => string.Join('\n', x)).Where(x => !x.IsNullOrWhiteSpace()).ToArray();
- }
- }
- provider.Save(chunk.Where(x => x.IsChanged()));
- }, 1000, percent =>
- {
- Logger.Send(LogType.Information, "", $"Processing Kanban Notes: {percent:F2}%");
- });
- Logger.Send(LogType.Information, "", $"Processing Kanban Notes complete");
- return true;
- }
- }
|