Beispiel #1
0
 public Form1()
 {
     InitializeComponent();
     logException = new clsDiskLogging();
     noteHelper   = new NoteHelper();
     syncHelper   = new SyncHelper();
     //Calls sub-routine to log exception to disk file
     logException.LogExceptionToDisk("calling LoadNotes...");
     LoadNotes();
     tmSyncTimer.Start();
 }
Beispiel #2
0
 private void LoadNotes()
 {
     try
     {
         logException.LogExceptionToDisk("Inside LoadNotes...");
         DirectoryInfo info  = new DirectoryInfo(ConfigurationManager.AppSettings["localPath"]);
         FileInfo[]    files = info.GetFiles("*.txt").OrderBy(p => p.LastWriteTime).ToArray();
         foreach (FileInfo fileInfo in files)
         {
             ListViewItem lstItem = new ListViewItem();
             lstItem.Name = Path.GetFileNameWithoutExtension(fileInfo.Name);
             lstItem.Tag  = fileInfo;
             lstNotes.Items.Add(lstItem);
         }
         lstNotes.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         logException.LogExceptionToDisk(ex.ToString());
     }
 }
Beispiel #3
0
        public bool SyncNotes()
        {
            logException.LogExceptionToDisk("Inside Sync Notes...");
            string localPath  = ConfigurationManager.AppSettings["localPath"];  //@"C:\Users\rpoondla\Documents\Visual Studio 2015\Projects\OneNoteApplication\OneNoteApplication\bin\Debug"; //args[0];
            string remotePath = ConfigurationManager.AppSettings["RemotePath"]; //@"\\10.213.154.154\f\Ravali"; //args[1];

            logException.LogExceptionToDisk("localPath: " + localPath + "RemotePath: " + remotePath);

            try
            {
                // Set options for the synchronization operation
                FileSyncOptions options = FileSyncOptions.ExplicitDetectChanges |
                                          FileSyncOptions.RecycleDeletedFiles |
                                          FileSyncOptions.RecyclePreviousFileOnUpdates |
                                          FileSyncOptions.RecycleConflictLoserFiles;

                FileSyncScopeFilter filter = new FileSyncScopeFilter();
                filter.FileNameIncludes.Add("*.txt");  //FileNameExcludes.Add("*.lnk"); // Exclude all *.lnk files

                // Explicitly detect changes on both replicas upfront, to avoid two change
                // detection passes for the two-way synchronization

                DetectChangesOnFileSystemReplica(
                    localPath, filter, options);
                DetectChangesOnFileSystemReplica(
                    remotePath, filter, options);

                // Synchronization in both directions
                SyncFileSystemReplicasOneWay(localPath, remotePath, null, options);
                SyncFileSystemReplicasOneWay(remotePath, localPath, null, options);
            }
            catch (Exception e)
            {
                logException.LogExceptionToDisk("\nException from File Synchronization Provider:\n" + e.ToString());
                return(false);
            }
            return(true);
        }