/// <summary> /// Ges the commentt view. /// </summary> /// <param name="commentAction">The comment action.</param> /// <param name="getCommentsMethod">The get comments method.</param> /// <param name="cp">The cp.</param> /// <param name="view">The view.</param> /// <returns></returns> private ManageCommentsView GeCommentView(CommentAction commentAction, Func <List <Comment> > getCommentsMethod, string cp, string view) { string message; if (commentAction.CommentActionType != "-1") { if (commentAction.CommentId != null && commentAction.CommentId.Length > 0) { CommentStatus commentStatus = commentAction.CommentActionType.ParseEnum <CommentStatus>(); _commentRepository.UpdateCommentStatus(commentStatus, commentAction.CommentId, Owner.Id); message = string.Format("Selected comments have been changed to {0}.", commentAction.CommentActionType); } else { message = "Please select one or more comments."; } } else { message = "Please select an action."; } ManageCommentsView commentView = GetManageCommentView(getCommentsMethod, cp, view); commentView.UIMessage = message; return(commentView); }
protected void menuComm_OnReloadData(object sender, EventArgs e) { string[] parameters = (menuComm.Parameter ?? string.Empty).Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (parameters.Length == 3) { // Parse identifier and document culture from library parameter int nodeId = ValidationHelper.GetInteger(parameters[0], 0); string cultureCode = ValidationHelper.GetString(parameters[1], string.Empty); string action = ValidationHelper.GetString(parameters[2], string.Empty); DocumentManager.Mode = FormModeEnum.Update; DocumentManager.ClearNode(); DocumentManager.DocumentID = 0; DocumentManager.NodeID = nodeId; DocumentManager.CultureCode = cultureCode; TreeNode node = DocumentManager.Node; string parameterScript = "GetContextMenuParameter('" + libraryMenuElem.MenuID + "')"; CommentAction comment = new CommentAction(Page, action); lblComment.Text = comment.Text; lblComment.RefreshText(); imgComment.ImageUrl = comment.SmallImageUrl; pnlComment.Attributes.Add("onclick", JavaScriptPrefix + "PerformAction(" + parameterScript + ", 'RefreshGridSimple');" + DocumentManager.GetJSFunction(ComponentEvents.COMMENT, string.Join("|", new string[] { "'" + action + "'", node.DocumentID.ToString() }), null) + ";"); } }
public ActionResult Approved(CommentAction commentAction, string cp) { const string approved = "approved"; ManageCommentsView view = GetCommentView(_commentRepository.RetrieveCommentByStatusAndUserId(Owner.Id, CommentStatus.Approved), cp, approved); IDictionary <string, string> crumbs = GetBreadCrumbs(approved); return(View("Index", view, crumbs)); }
public ActionResult Spam(CommentAction commentAction, string cp) { const string breadCrumbName = "spam"; ManageCommentsView view = GetCommentView(_commentRepository.RetrieveCommentByStatusAndUserId(Owner.Id, CommentStatus.Spam), cp, breadCrumbName); IDictionary <string, string> crumbs = GetBreadCrumbs(breadCrumbName); return(View("Index", view, crumbs)); }
/// <summary> /// Indexes the post. /// </summary> /// <param name="commentAction">The comment action.</param> /// <param name="cp">The cp.</param> /// <returns></returns> private ActionResult IndexPost(CommentAction commentAction, string cp) { IDictionary <string, string> crumbs = GetBreadCrumbs("all"); ManageCommentsView view = GeCommentView(commentAction, () => _commentRepository.RetrieveCommentsByUserId(Owner.Id), cp, "all"); // ReSharper disable Asp.NotResolved return(View("Index", view, crumbs)); // ReSharper restore Asp.NotResolved }
public async Task ValidateAsync(Comment entity, CommentAction action) { switch (action) { case CommentAction.Create: await ValidateCreateAsync(entity); break; default: throw new NotImplementedException(); } }
/// <summary> /// Adds comment action. /// </summary> /// <param name="name">Action name</param> /// <param name="action">Current action</param> /// <param name="objectName">Object name</param> private void AddCommentAction(string name, HeaderAction action, string objectName) { AutomationManager.RenderScript = true; CommentAction comment = new CommentAction(name) { Tooltip = string.Format(ResHelper.GetString("EditMenu.Comment" + name, ResourceCulture), objectName), OnClientClick = string.Format("AddComment_{0}('{1}',{2},'{0}');", ClientID, name, StateObject.StateID), }; action.AlternativeActions.Add(comment); }
/// <summary> /// Adds comment action. /// </summary> /// <param name="name">Action name</param> /// <param name="action">Current action</param> private void AddCommentAction(string name, HeaderAction action) { ObjectManager.RenderScript = true; AddAction(action); CommentAction comment = new CommentAction(name) { Text = ResHelper.GetString("ObjectEditMenu.Comment" + name, ResourceCulture), OnClientClick = string.Format("AddComment_{0}('{1}','{2}',{3},'{0}');", ClientID, name, InfoObject.TypeInfo.ObjectType, InfoObject.Generalized.ObjectID), }; action.AlternativeActions.Add(comment); }
private async Task CommentUncommentSelection(CommentAction action) { const string singleLineCommentString = "//"; var document = MainViewModel.RoslynHost.GetDocument(DocumentId); var selection = _getSelection(); var documentText = await document.GetTextAsync().ConfigureAwait(false); var changes = new List <TextChange>(); var lines = documentText.Lines.SkipWhile(x => !x.Span.IntersectsWith(selection)) .TakeWhile(x => x.Span.IntersectsWith(selection)).ToArray(); if (action == CommentAction.Comment) { foreach (var line in lines) { if (!string.IsNullOrWhiteSpace(documentText.GetSubText(line.Span).ToString())) { changes.Add(new TextChange(new TextSpan(line.Start, 0), singleLineCommentString)); } } } else if (action == CommentAction.Uncomment) { foreach (var line in lines) { var text = documentText.GetSubText(line.Span).ToString(); if (text.TrimStart().StartsWith(singleLineCommentString, StringComparison.Ordinal)) { changes.Add(new TextChange(new TextSpan( line.Start + text.IndexOf(singleLineCommentString, StringComparison.Ordinal), singleLineCommentString.Length), string.Empty)); } } } if (changes.Count == 0) { return; } MainViewModel.RoslynHost.UpdateDocument(document.WithText(documentText.WithChanges(changes))); if (action == CommentAction.Uncomment) { await FormatDocument().ConfigureAwait(false); } }
/// <summary> /// Adds comment action. /// </summary> /// <param name="name">Action name</param> /// <param name="action">Current action</param> /// <param name="step">Current step</param> /// <param name="objectName">Object name</param> private void AddCommentAction(string name, HeaderAction action, string objectName) { AutomationManager.RenderScript = true; CommentAction comment = new CommentAction(Page, name) { Tooltip = string.Format(ResHelper.GetString("EditMenu.Comment" + name, ResourceCulture), objectName), OnClientClick = string.Format("AddComment_{0}('{1}',{2},'{0}');", ClientID, name, StateObject.StateID), }; action.AlternativeActions.Add(comment); }
public ActionResult All(CommentAction commentAction, string cp) { return(IndexPost(commentAction, cp)); }
/// <summary> /// Adds comment action. /// </summary> /// <param name="name">Action name</param> /// <param name="action">Current action</param> private void AddCommentAction(string name, HeaderAction action) { DocumentManager.RenderScript = true; string resName = name; if ((name == DocumentComponentEvents.APPROVE) && (Step != null) && (Step.StepIsEdit)) { resName += "Submit"; } CommentAction comment = new CommentAction(resName) { Enabled = action.Enabled, Tooltip = ResHelper.GetString("EditMenu.Comment" + resName, ResourceCulture), OnClientClick = string.Format("AddComment_{0}('{1}',{2},'{0}');", ClientID, name, Node.DocumentID), ValidationGroup = ActionsValidationGroup, }; action.AlternativeActions.Add(comment); }