private bool ValidateAuthorComments(out string ErrMsg) { ErrMsg = string.Empty; try { ; bool result = true; if (AuthorNUM == 0 || string.IsNullOrEmpty(AuthorPAGE) || string.IsNullOrEmpty(AuthorCOMMENT)) { result = false; ErrMsg = "Page,NUM,Comments are manadatory to Save TanComments"; } else if (S.CommentParameters.Any(x => AuthorNUM.ToString().ToLower().Contains(x)) || S.CommentParameters.Any(x => AuthorPAGE.ToString().ToLower().Contains(x)) || S.CommentParameters.Any(x => AuthorLINE.ToString().ToLower().Contains(x)) || S.CommentParameters.Any(x => AuthorPARA.ToString().ToLower().Contains(x)) || S.CommentParameters.Any(x => AuthorCOLUMN.ToString().ToLower().Contains(x)) || (!string.IsNullOrEmpty(AuthorTABLE) && S.CommentParameters.Any(x => AuthorTABLE.ToLower().Contains(x))) || (!string.IsNullOrEmpty(AuthorFIGURE) && S.CommentParameters.Any(x => AuthorFIGURE.ToLower().Contains(x))) || (!string.IsNullOrEmpty(AuthorSCHEMES) && S.CommentParameters.Any(x => AuthorSCHEMES.ToLower().Contains(x))) || (!string.IsNullOrEmpty(AuthorSHEET) && S.CommentParameters.Any(x => AuthorSHEET.ToLower().Contains(x))) || (!string.IsNullOrEmpty(AuthorFOOTNOTE) && S.CommentParameters.Any(x => AuthorFOOTNOTE.ToLower().Contains(x))) || (!string.IsNullOrEmpty(AuthorCOMMENT) && S.CommentParameters.Any(x => AuthorCOMMENT.ToLower().Contains(x))) || !CommentRegExp.IsMatch(AuthorCOMMENT)) { result = false; ErrMsg = "Comment parameters are not allowed"; } ; return(result); } catch (Exception ex) { Log.This(ex); return(false); } }
private void AddAuthorComment(object obj) { try { string ErrMsg = string.Empty; if (ValidateAuthorComments(out ErrMsg)) { string Author = ("NUM " + AuthorNUM) + (IsAuthorNumCorrected ? " (corrected)" : string.Empty) + (!string.IsNullOrEmpty(AuthorPAGE) ? ",Page " + AuthorPAGE : string.Empty) + (!string.IsNullOrEmpty(AuthorLINE) ? ",Line " + AuthorLINE : string.Empty) + (!string.IsNullOrEmpty(AuthorPARA) ? ",Para " + AuthorPARA : string.Empty) + (!string.IsNullOrEmpty(AuthorCOLUMN) ? ",Column " + AuthorCOLUMN : string.Empty) + (!string.IsNullOrEmpty(AuthorTABLE) ? ",Table " + AuthorTABLE : string.Empty) + (!string.IsNullOrEmpty(AuthorFIGURE) ? ",Figure " + AuthorFIGURE : string.Empty) + (!string.IsNullOrEmpty(AuthorSCHEMES) ? ",Scheme " + AuthorSCHEMES : string.Empty) + (!string.IsNullOrEmpty(AuthorSHEET) ? ",Sheet " + AuthorSHEET : string.Empty) + (!string.IsNullOrEmpty(AuthorFOOTNOTE) ? ",Footnote " + AuthorFOOTNOTE : string.Empty) + "," + AuthorCOMMENT; if (EditingComment == null) { if (TanComments.Where(tc => tc.Num != 0 && tc.Num == AuthorNUM).Count() == 0) { AddTanComment(AuthorCOMMENT, CommentType.AUTHOR, AuthorCOLUMN, AuthorFIGURE, AuthorFOOTNOTE, AuthorLINE, AuthorNUM, AuthorPAGE, AuthorPARA, AuthorSCHEMES, AuthorSHEET, AuthorTABLE, Author); ClearVM(null); } else { MessageBox.Show($"Num {AuthorNUM} comments already added. Duplicate Comments are not Allowed", "Reactions", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (EditingComment.CommentType == CommentType.AUTHOR) { Comments comment = (from c in TanComments.ToList() where c.Id == EditingComment.Id select c).FirstOrDefault(); if (comment != null) { comment.Comment = AuthorCOMMENT; comment.CommentType = CommentType.INDEXING; comment.Length = Author.Length; comment.Column = AuthorCOLUMN; comment.Figure = AuthorFIGURE; comment.FootNote = AuthorFOOTNOTE; comment.Line = AuthorLINE; comment.Num = AuthorNUM; comment.Page = AuthorPAGE; comment.Para = AuthorPARA.ToString(); comment.Schemes = AuthorSCHEMES; comment.Sheet = AuthorSHEET; comment.Table = AuthorTABLE; comment.TotalComment = Author; } ClearVM(null); } else { MessageBox.Show("You Do Not Add New Comment in Edit Mode. Please Update " + EditingComment.CommentType + " First.", "Reactions", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Page,NUM,Comments are manadatory to Save TanComments", "Reactions", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Log.This(ex); } }