private void DaemonEntryPut(Daemon daemon, ref bool did_some_transfers) { StatusManager.Instance.ClearCancelled(StatusCodes.SYNC_DATA); while (daemon.StillRunning) { // Is there another fingerprint to process? int fingerprints_remaining; SyncQueueEntry sync_queue_entry = GetNextSyncQueueEntry(fingerprints_to_put, out fingerprints_remaining); if (null == sync_queue_entry) { break; } StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_DATA, String.Format("Uploading paper to your Web/Intranet Library ({0} to go)", fingerprints_remaining), 1, fingerprints_remaining, true); // Check if the user cancelled this download bool user_cancelled_transfer = StatusManager.Instance.IsCancelled(StatusCodes.SYNC_DATA); if (user_cancelled_transfer) { Logging.Info("User cancelled documents upload"); ClearSyncQueue(fingerprints_to_put); } try { // --- TODO: Replace this with a pretty interface class ------------------------------------------------ if (false) { } else if (sync_queue_entry.library.WebLibraryDetail.IsIntranetLibrary) { SyncQueues_Intranet.DaemonPut(sync_queue_entry.library, sync_queue_entry.fingerprint); } else { throw new Exception(String.Format("Did not understand how to transfer PDFs for library {0}", sync_queue_entry.library.WebLibraryDetail.Title)); } // ----------------------------------------------------------------------------------------------------- did_some_transfers = true; } catch (Exception ex) { Logging.Error(ex, "Exception while uploading paper {0}", sync_queue_entry); } StatusManager.Instance.UpdateStatus(StatusCodes.SYNC_DATA, "Uploaded papers to your Web/Intranet Library"); } }
private static SyncQueueEntry GetNextSyncQueueEntry(List <SyncQueueEntry> fingerprints, out int fingerprints_remaining) { SyncQueueEntry sync_queue_entry = null; lock (fingerprints) { fingerprints_remaining = fingerprints.Count; if (0 < fingerprints_remaining) { sync_queue_entry = fingerprints.First(); fingerprints.Remove(sync_queue_entry); --fingerprints_remaining; } } return(sync_queue_entry); }
private static SyncQueueEntry GetNextSyncQueueEntry(List <SyncQueueEntry> fingerprints, out int fingerprints_remaining) { SyncQueueEntry sync_queue_entry = null; // Utilities.LockPerfTimer l1_clk = Utilities.LockPerfChecker.Start(); lock (fingerprints) { // l1_clk.LockPerfTimerStop(); fingerprints_remaining = fingerprints.Count; if (0 < fingerprints_remaining) { sync_queue_entry = fingerprints.First(); fingerprints.Remove(sync_queue_entry); --fingerprints_remaining; } } return(sync_queue_entry); }
private SyncQueueEntry CreateEntry(string sourceFullPath, string targetFullPath, string sourcePath, string targetPath, ChangeType directoryChangeType, ChangeType fileChangeType) { try { var isDirectory = IsDirectory(sourceFullPath); var entry = new SyncQueueEntry { Location = ChangeLocation.Storage, SourcePath = sourcePath, TargetPath = targetPath, Type = isDirectory ? directoryChangeType : fileChangeType }; if (directoryChangeType == ChangeType.DeleteDirectory || fileChangeType == ChangeType.DeleteFile) { if (isDirectory) { entry.Hash = storageHashService.GetDirectoryHash(sourcePath); } else { entry.Hash = storageHashService.GetFileHash(sourcePath); } } else if (directoryChangeType == ChangeType.MoveDirectory || fileChangeType == ChangeType.MoveFile) { if (isDirectory) { storageHashService.RemoveDirectoryHash(sourcePath); entry.Hash = storageHashService.GetDirectoryHash(targetPath); } else { storageHashService.RemoveFileHash(sourcePath); entry.Hash = storageHashService.GetFileHash(targetPath); } } else { if (isDirectory) { entry.Hash = storageHashService.BuildDirectoryHash(sourcePath); } else { entry.Hash = storageHashService.BuildFileHash(sourcePath); } } return(entry); } catch (FileNotFoundException) { return(null); } catch (DirectoryNotFoundException) { return(null); } }
/// <summary> /// Save queue instance to database /// </summary> /// <param name="obj">Object to save</param> /// <returns>True if successfull</returns> public bool Save(SyncQueueEntry obj) { return(Save(obj)); }
/// <summary> /// Delete queue by object id /// </summary> /// <param name="obj">Object to delete</param> /// <returns>True if successfull</returns> public bool Delete(SyncQueueEntry obj) { return(Delete(obj)); }