public PublishingResult Publish( PublisherSettings settings, PublishingRecord record, AttachmentFunc createAttachments) { Space selectedSpace = null; bool uploadAttachmentToDropbox = false; var selectedSpaceLock = new object(); // open submission screen Context.ExecuteOnUIThread(() => { var view = new SpacePromptView { IsConnectedToDropbox = Context.IsDropboxConnected, Spaces = new ObservableCollection <Space>(AssemblaUtils.LoadSpaces(settings)) }; lock (selectedSpaceLock) { if (view.ShowDialog() == true) { selectedSpace = view.SelectedSpace; uploadAttachmentToDropbox = view.UploadAttachmentToDropbox; } } }); if (selectedSpace == null) { return(null); } Context.ShowProgressIndicator(message: "Starting..."); try { var attachments = new Dictionary <string, bool>(); // Generate the attachments before starting background thread if (uploadAttachmentToDropbox) { foreach (var file in ExportAttachmentToDropbox(createAttachments)) { attachments.Add(file, true); } } else { foreach (var file in createAttachments()) { attachments.Add(file, false); } } // Automate browser in a worker thread Task.Factory.StartNew(() => AssemblaUtils.Automate(settings, record, attachments, selectedSpace.Id)); } finally { Context.HideProgressIndicator(); } return(null); }
public PublishingResult Publish( PublisherSettings settings, PublishingRecord record, AttachmentFunc createAttachments) { Space selectedSpace = null; bool uploadAttachmentToDropbox = false; var selectedSpaceLock = new object(); // open submission screen Context.ExecuteOnUIThread(() => { var view = new SpacePromptView { IsConnectedToDropbox = Context.IsDropboxConnected, Spaces = new ObservableCollection<Space>(AssemblaUtils.LoadSpaces(settings)) }; lock (selectedSpaceLock) { if (view.ShowDialog() == true) { selectedSpace = view.SelectedSpace; uploadAttachmentToDropbox = view.UploadAttachmentToDropbox; } } }); if (selectedSpace == null) return null; Context.ShowProgressIndicator(message: "Starting..."); try { var attachments = new Dictionary<string, bool>(); // Generate the attachments before starting background thread if (uploadAttachmentToDropbox) { foreach (var file in ExportAttachmentToDropbox(createAttachments)) { attachments.Add(file, true); } } else { foreach(var file in createAttachments()) { attachments.Add(file, false); } } // Automate browser in a worker thread Task.Factory.StartNew(() => AssemblaUtils.Automate(settings, record, attachments, selectedSpace.Id)); } finally { Context.HideProgressIndicator(); } return null; }