예제 #1
0
 public static bool AddRestoreJournalItem(TransferJournalItem item) {
     return AddRestoreJournalItemInternal(item, MainTransferJournalPath);
 }
예제 #2
0
     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;
 }
예제 #3
0
 public FormJournal(TransferJournalItem[] source, ComputerNameInfo[] computerNames)
 {
     InitializeComponent();
     computerNameDict = CollectionHelper.CollectionToDictionary<Guid, ComputerNameInfo>(computerNames, k => { return k.Guid; });
     transferJournalItemBindingSource.DataSource = source;
 }