public static void RebuildRecordSummaryIndexes() { var db = new LocalDB3().DB; db.DeleteAll <RecordSummary>(); db.DropTable <RecordSummary>(); db.CreateTable <RecordSummary>(); var ppxKinds = Constants.PPX_KIND_DISPLAYNAMES.Keys; var vmmcKinds = Constants.VMMC_KIND_DISPLAYNAMES.Keys; var lspKinds = Constants.LSP_KIND_DISPLAYNAMES.Keys; var combined = new List <string>(); combined.AddRange(ppxKinds); combined.AddRange(vmmcKinds); combined.AddRange(lspKinds); var multiStore = new MultiTableStore() { Kinds = (from kind in combined select new KindName(kind)).ToList() }; var kindRecords = multiStore.getRecordBlobs(); var recordSummaries = new List <RecordSummary>(); foreach (var record in kindRecords) { var saveable = Newtonsoft.Json.JsonConvert .DeserializeObject <GeneralEntityDataset>(record.Value); var editDateObj = saveable.GetValue(Constants.FIELD_PPX_DATEOFVISIT); editDateObj = editDateObj ?? saveable.GetValue(Constants.FIELD_VMMC_DATEOFVISIT); editDateObj = editDateObj ?? saveable.GetValue(Constants.FIELD_LSP_DATEOFVISIT); DateTime dateEdited; if (editDateObj == null || string.IsNullOrWhiteSpace(editDateObj.Value)) { dateEdited = DateTime.MinValue; } else { if (!DateTime.TryParse(editDateObj.Value, out dateEdited)) { dateEdited = DateTime.MinValue; } } var recSummary = new RecordSummary() { Id = saveable.Id.Value, EntityId = saveable.EntityId == null ? saveable.Id.Value : saveable.EntityId.Value, VisitDate = dateEdited, KindName = saveable.FormName }; recordSummaries.Add(recSummary); } db.InsertAll(recordSummaries); }
public static void RebuildClientSummaryIndexes <T, U>(KindName name) where T : class, ILocalDbEntity, new() where U : ClientLookupProvider <T>, new() { var db = new LocalDB3().DB; db.DeleteAll <T>(); db.DropTable <T>(); db.CreateTable <T>(); var vmmcReg = new TableStore(name.Value).GetAllBlobs(); var allSummaries = new List <T>(); foreach (var reg in vmmcReg) { var entity = Newtonsoft.Json.JsonConvert.DeserializeObject <GeneralEntityDataset>(reg.Value); var mySummary = new T().Load(entity) as T; allSummaries.Add(mySummary); } new U().InsertOrReplace(allSummaries); }