public ActionResult TagEdit(string navSlug, TagEditorModel model, int tagId) { try { // get nav Nav nav = AdminManager.GetNav(navSlug); BlogApp.UpdateTag(nav, tagId, model.TagName, model.Description); return RedirectToAction("Tags", "Blog"); } catch (SiteException ex) { model.Message = ex.Message; return View("TagEditor", model); } }
private async void Page_MenuItem_Click(object sender, RoutedEventArgs e) { MenuItem item = sender as MenuItem; if (item != null) { switch (item.Tag.ToString()) { case "Refresh": string query = searchComboBox.Text; try { pBar.Visibility = System.Windows.Visibility.Visible; await _model.FindPagesAsync(query, scopeSelect.SelectedScope); searchComboBox.SelectedValue = query; pBar.Visibility = System.Windows.Visibility.Hidden; } catch (System.Exception ex) { TraceLogger.Log(TraceCategory.Error(), "search for '{0}' failed: {1}", query, ex); TraceLogger.ShowGenericErrorBox(Properties.Resources.TagSearch_Error_Find, ex); } break; case "ClearSelection": foundPagesList.UnselectAll(); break; case "SelectAll": foundPagesList.SelectAll(); break; case "TagSelection": var pagesToTag = from mp in _model.Pages where mp.IsSelected && !mp.IsInRecycleBin select mp.PageID; if (pagesToTag.Count() == 0) { MessageBox.Show(Properties.Resources.TagSearch_NoPagesSelectedWarning, Properties.Resources.TagEditor_WarningMessageBox_Title, MessageBoxButton.OK); } else { AddInDialogManager.ShowDialog <TagEditor, TagEditorModel>(() => { var mdl = new TagEditorModel(_model.OneNoteApp); // configure the model mdl.Scope = TaggingScope.SelectedNotes; mdl.PagesToTag = pagesToTag; return(mdl); }); } break; case "MarkSelection": string[] marker = new string[] { "-✩-" }; int pagesTagged = 0; foreach (var mdl in _model.Pages.Where((p) => p.IsSelected && !p.IsInRecycleBin)) { _model.OneNoteApp.TaggingService.Add(new Tagger.TaggingJob(mdl.PageID, marker, Tagger.TagOperation.UNITE)); pagesTagged++; } tagsPanel.Notification = pagesTagged == 0 ? Properties.Resources.TagEditor_Popup_NothingTagged : string.Format(Properties.Resources.TagEditor_Popup_TaggingInProgress, pagesTagged); break; case "CopyLinks": pBarCopy.Visibility = System.Windows.Visibility.Visible; string clip = await Task <string> .Run(() => { string header = @"Version:0.9 StartHTML:{0:D6} EndHTML:{1:D6} StartFragment:{2:D6} EndFragment:{3:D6} StartSelection:{4:D6} EndSelection:{5:D6}"; string htmlpre = @"<HTML> <BODY> <!--StartFragment-->"; StringBuilder links = new StringBuilder(); foreach (var mdl in _model.Pages.Where(p => p.IsSelected && !p.IsInRecycleBin)) { string pageTitle = mdl.LinkTitle; try { if (links.Length > 0) { links.Append("<br />"); } links.Append(@"<a href="""); links.Append(mdl.PageLink); links.Append(@""">"); links.Append(mdl.LinkTitle); links.Append("</a>"); } catch (Exception ex) { TraceLogger.Log(TraceCategory.Error(), "Link to page '{0}' could not be created: {1}", pageTitle, ex); TraceLogger.ShowGenericErrorBox(Properties.Resources.TagSearch_Error_CopyLink, ex); } } string htmlpost = @"<!--EndFragment--> </BODY> </HTML>"; string strLinks = links.ToString(); return(string.Format(header, header.Length, header.Length + htmlpre.Length + strLinks.Length + htmlpost.Length, header.Length + htmlpre.Length, header.Length + htmlpre.Length + strLinks.Length, header.Length + htmlpre.Length, header.Length + htmlpre.Length + strLinks.Length) + htmlpre + strLinks + htmlpost); }); Clipboard.SetText(clip, TextDataFormat.Html); pBarCopy.Visibility = System.Windows.Visibility.Hidden; break; } e.Handled = true; } }
public ActionResult TagCreate(string navSlug, TagEditorModel model) { try { // get nav Nav nav = AdminManager.GetNav(navSlug); // exe BlogApp.AddTag(nav, model.TagName, model.Description); // view return RedirectToAction("Tags", "Blog"); } catch (SiteException ex) { model.Message = ex.Message; return View("TagEditor", model); } }