Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public VerificationResult Verify(PublisherSettings settings)
 {
     Context.ShowProgressIndicator(message: "Connecting to Assembla...");
     try {
         var request = AssemblaUtils.CreateLoadSpacesRequest(settings);
         using (request.GetResponse())
             return(new VerificationResult());
     }
     finally {
         Context.HideProgressIndicator();
     }
 }