예제 #1
0
        private static async void InvalidateOldData()
        {
            Log.Debug(TAG, "Starting full invalidation");

            var notesPath = Path.Combine(Global.APP_PATH, "notesdb");

            if (!File.Exists(notesPath))
            {
                File.Create(notesPath);
            }
            var notes = await DBAssist.DeserializeDBAsync <List <Note> >(notesPath);

            notes = notes ?? new List <Note>();
            for (int i = 0; i < newDB.Count; i++)
            {
                for (int j = 0; j < newDB[i].Items.Count; j++)
                {
                    var  newItem = newDB[i].Items[j];
                    var  oldItem = Global.Categories[i].Items.FirstOrDefault(x => x.Id == newItem.Id);
                    Note note    = null;
                    if (oldItem != null)
                    {
                        note = notes.FirstOrDefault(x => x.Title == oldItem.Title);
                        if (note != null)
                        {
                            Log.Debug(TAG, $"Note *{note.Title}*, found for old idea *{oldItem.Title}* placed at new idea *{newItem.Title}*");
                        }
                    }

                    newItem.Note  = note;
                    newItem.State = oldItem?.State;
                }
            }

            DBAssist.SerializeDBAsync(oldDBPath, newDB);
            DBAssist.SerializeDBAsync(newideastxtPath, newideastxt);
            Global.Categories   = newDB;
            Global.LockRequests = true;

            Log.Debug(TAG, "Invalidation completed.");
        }