private void ConvertData() { /// memoinfo { var file = MemopadConstsV1.MemoInfosFilePath; var text = File.ReadAllText(file); _memoAccessor.InsertTextData("MemoInfo", text); } /// removed memoinfo { var file = MemopadConstsV1.RemovedMemoInfosFilePath; var text = File.ReadAllText(file); _memoAccessor.InsertTextData("RemovedMemoInfo", text); } /// removed embedded file { var file = MemopadConstsV1.RemovedEmbeddedFileIdsFilePath; var text = File.ReadAllText(file); _memoAccessor.InsertTextData("RemovedEmbeddedFileId", text); } /// memento var files = Directory.GetFiles(MemopadConstsV1.MementoRoot); foreach (var file in files) { var id = Path.GetFileNameWithoutExtension(file); var bytes = File.ReadAllBytes(file); _memoAccessor.InsertMemento(id, bytes); } }
internal static void SaveIdsToSdf(MemoIdCollection ids, string tableName, SqlServerAccessor accessor) { var buf = new StringBuilder(); using (var writer = XmlWriter.Create(buf)) { var serializer = new DataContractSerializer(typeof(MemoIdCollection)); serializer.WriteObject(writer, ids); } var xml = buf.ToString(); if (accessor.IsTextDataExists(tableName)) { accessor.UpdateTextData(tableName, xml); } else { accessor.InsertTextData(tableName, xml); } }
internal static void SaveRemovedMemoInfos(MemoInfoCollection removedMemoInfos, SqlServerAccessor accessor) { var buf = new StringBuilder(); using (var writer = XmlWriter.Create(buf)) { var serializer = new DataContractSerializer(typeof(MemoInfoCollection)); serializer.WriteObject(writer, removedMemoInfos); } var xml = buf.ToString(); if (accessor.IsTextDataExists("RemovedMemoInfo")) { accessor.UpdateTextData("RemovedMemoInfo", xml); } else { accessor.InsertTextData("RemovedMemoInfo", xml); } }