async void publish(Object obj) { ListView lv = (ListView)obj; foreach (OnlinePublishEntry cmdlet in Cmdlets) { cmdlet.Status = OnlinePublishStatusEnum.Pending; cmdlet.StatusText = "Pending for publish"; } PbValue = 0; Blogger blogger = Utils.InitializeBlogger(module.Provider); if (blogger == null) { Utils.MsgBox("Warning", Strings.WarnBloggerNeedsMoreData, MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } Double duration = 100.0 / Cmdlets.Count; PbValue = 0; foreach (OnlinePublishEntry cmdlet in Cmdlets) { lv.ScrollIntoView(cmdlet); if (cmdlet.Cmdlet.Publish) { try { await MetaWeblogWrapper.PublishSingle(cmdlet.Cmdlet, module, blogger, true); cmdlet.Status = OnlinePublishStatusEnum.Succeed; cmdlet.StatusText = "The operation completed successfully."; } catch (Exception e) { cmdlet.Status = OnlinePublishStatusEnum.Failed; cmdlet.StatusText = e.Message; } } else { cmdlet.Status = OnlinePublishStatusEnum.Skipped; cmdlet.StatusText = "The item is not configured for publishing"; } PbValue += duration; } PbValue = 100; }
static async void PublishSingle(Object obj) { if (obj == null) { return; } working = true; var mwvm = (MainWindowVM)Application.Current.MainWindow.DataContext; try { await MetaWeblogWrapper.PublishSingle((CmdletObject)obj, mwvm.SelectedTab.Module, null, false); Utils.MsgBox("Success", "The operation completed successfully.", MessageBoxImage.Information); } catch (Exception e) { Utils.MsgBox("Error", e.Message); } working = false; }