private bool ValidateIndexComments(out string ErrMsg) { try { bool result = true; ErrMsg = string.Empty; if (IndexNUM == 0 || string.IsNullOrEmpty(IndexPAGE) || string.IsNullOrEmpty(IndexCOMMENT)) { result = false; ErrMsg = "Page,NUM,Comments are manadatory to Save TanComments"; } else if (S.CommentParameters.Any(x => IndexNUM.ToString().ToLower().Contains(x)) || S.CommentParameters.Any(x => IndexPAGE.ToString().ToLower().Contains(x)) || S.CommentParameters.Any(x => IndexLINE.ToString().ToLower().Contains(x)) || S.CommentParameters.Any(x => IndexPARA.ToString().ToLower().Contains(x)) || S.CommentParameters.Any(x => IndexCOLUMN.ToString().ToLower().Contains(x)) || (!string.IsNullOrEmpty(IndexTABLE) && S.CommentParameters.Any(x => IndexTABLE.ToLower().Contains(x))) || (!string.IsNullOrEmpty(IndexFIGURE) && S.CommentParameters.Any(x => IndexFIGURE.ToLower().Contains(x))) || (!string.IsNullOrEmpty(IndexSCHEMES) && S.CommentParameters.Any(x => IndexSCHEMES.ToLower().Contains(x))) || (!string.IsNullOrEmpty(IndexSHEET) && S.CommentParameters.Any(x => IndexSHEET.ToLower().Contains(x))) || (!string.IsNullOrEmpty(IndexFOOTNOTE) && S.CommentParameters.Any(x => IndexFOOTNOTE.ToLower().Contains(x))) || (!string.IsNullOrEmpty(IndexCOMMENT) && S.CommentParameters.Any(x => IndexCOMMENT.ToLower().Contains(x))) || !CommentRegExp.IsMatch(IndexCOMMENT)) { result = false; ErrMsg = "Comment parameters are not allowed"; } return(result); } catch (Exception ex) { Log.This(ex); throw; } }
private void AddIndexComment(object obj) { try { string ErrMsg = string.Empty; if (ValidateIndexComments(out ErrMsg)) { string Index = ("NUM " + IndexNUM) + (!string.IsNullOrEmpty(IndexPAGE) ? ",Page " + IndexPAGE : string.Empty) + (!string.IsNullOrEmpty(IndexLINE) ? ",Line " + IndexLINE : string.Empty) + (!string.IsNullOrEmpty(IndexPARA) ? ",Para " + IndexPARA : string.Empty) + (!string.IsNullOrEmpty(IndexCOLUMN) ? ",Column " + IndexCOLUMN : string.Empty) + (!string.IsNullOrEmpty(IndexTABLE) ? ",Table " + IndexTABLE : string.Empty) + (!string.IsNullOrEmpty(IndexFIGURE) ? ",Figure " + IndexFIGURE : string.Empty) + (!string.IsNullOrEmpty(IndexSCHEMES) ? ",Scheme " + IndexSCHEMES : string.Empty) + (!string.IsNullOrEmpty(IndexSHEET) ? ",Sheet " + IndexSHEET : string.Empty) + (!string.IsNullOrEmpty(IndexFOOTNOTE) ? ",Footnote " + IndexFOOTNOTE : string.Empty) + "," + IndexCOMMENT; if (EditingComment == null) { if (TanComments.Where(tc => tc.Num == IndexNUM).Count() == 0) { AddTanComment(IndexCOMMENT, CommentType.INDEXING, IndexCOLUMN, IndexFIGURE, IndexFOOTNOTE, IndexLINE, IndexNUM, IndexPAGE, IndexPARA, IndexSCHEMES, IndexSHEET, IndexTABLE, Index); ClearVM(null); } else { MessageBox.Show($"For Num {IndexNUM} comments already added. Duplicate Comments are not Allowed", "Reactions", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (EditingComment.CommentType == CommentType.INDEXING) { Comments comment = (from c in TanComments.ToList() where c.Id == EditingComment.Id select c).FirstOrDefault(); if (comment != null) { comment.Comment = IndexCOMMENT; comment.CommentType = CommentType.INDEXING; comment.Length = Index.Length; comment.Column = IndexCOLUMN; comment.Figure = IndexFIGURE; comment.FootNote = IndexFOOTNOTE; comment.Line = IndexLINE; comment.Num = IndexNUM; comment.Page = IndexPAGE; comment.Para = IndexPARA.ToString(); comment.Schemes = IndexSCHEMES; comment.Sheet = IndexSHEET; comment.Table = IndexTABLE; comment.TotalComment = Index; } 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(ErrMsg, "Reactions", MessageBoxButtons.OK, MessageBoxIcon.Information); } ; } catch (Exception ex) { Log.This(ex); } }