public void TerminateTask(int galleryId, string taskId) { ISynchronizationStatus synchStatus = SynchronizationStatus.GetInstance(galleryId); try { synchStatus.CancelSynchronization(taskId); } catch (Exception ex) { AppErrorController.LogError(ex); throw; } }
public SynchStatusWebEntity GetCurrentStatus(int galleryId) { ISynchronizationStatus synchStatus = SynchronizationStatus.GetInstance(galleryId); try { SynchStatusWebEntity synchStatusWeb = new SynchStatusWebEntity(); synchStatusWeb.SynchId = synchStatus.SynchId; synchStatusWeb.TotalFileCount = synchStatus.TotalFileCount; synchStatusWeb.CurrentFileIndex = synchStatus.CurrentFileIndex + 1; if ((synchStatus.CurrentFilePath != null) && (synchStatus.CurrentFileName != null)) { synchStatusWeb.CurrentFile = System.IO.Path.Combine(synchStatus.CurrentFilePath, synchStatus.CurrentFileName); } synchStatusWeb.Status = synchStatus.Status.ToString(); synchStatusWeb.StatusForUI = GetFriendlyStatusText(synchStatus.Status); synchStatusWeb.PercentComplete = CalculatePercentComplete(synchStatus); // Update the Skipped Files, but only when the synch is complete. lock (synchStatus) { if (synchStatus.Status == SynchronizationState.Complete) { if (synchStatus.SkippedMediaObjects.Count > GlobalConstants.MaxNumberOfSkippedObjectsToDisplayAfterSynch) { // We have a large number of skipped media objects. We don't want to send it all to the browsers, because it might take // too long or cause an error if it serializes to a string longer than int.MaxValue, so let's trim it down. synchStatus.SkippedMediaObjects.RemoveRange(GlobalConstants.MaxNumberOfSkippedObjectsToDisplayAfterSynch, synchStatus.SkippedMediaObjects.Count - GlobalConstants.MaxNumberOfSkippedObjectsToDisplayAfterSynch); } synchStatusWeb.SkippedFiles = synchStatus.SkippedMediaObjects; } } return(synchStatusWeb); } catch (Exception ex) { AppErrorController.LogError(ex, synchStatus.GalleryId); throw; } }