public static bool AddRestoreJournalItem(TransferJournalItem item) { return AddRestoreJournalItemInternal(item, MainTransferJournalPath); }
static bool AddRestoreJournalItemInternal(TransferJournalItem item, string fileName) { try { CommonHelper.RunInMutex(TransferConst.PortableTransferJournalMutex, delegate { using (FileStream fs = new FileStream(fileName, FileMode.Append, FileAccess.Write)) { using (BinaryWriter bw = new BinaryWriter(fs)) { byte[] nextItemSign = Encoding.UTF8.GetBytes(TransferConst.PortableTransferJournalNextItemSign); using (MemoryStream ms = new MemoryStream()) { using (GZipStream ds = new GZipStream(ms, CompressionMode.Compress, true)) { BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(ds, item); ds.Close(); } byte[] body = ms.ToArray(); bw.Write(nextItemSign, 0, nextItemSign.Length); bw.Write(body.Length); bw.Write(body); } } } }); return true; } catch (Exception ex) { TransferLog.LogException(ex); } return false; }
public FormJournal(TransferJournalItem[] source, ComputerNameInfo[] computerNames) { InitializeComponent(); computerNameDict = CollectionHelper.CollectionToDictionary<Guid, ComputerNameInfo>(computerNames, k => { return k.Guid; }); transferJournalItemBindingSource.DataSource = source; }