예제 #1
0
        private List <DocumentCommentBEO> FetchComments(RVWDocumentBEO rVwDocumentBEO, Document currentDcbDocument,
                                                        DcbDocumentTags dcbDocumentTags)
        {
            List <DocumentCommentBEO> documentCommentBEOList = new List <DocumentCommentBEO>();

            try
            {
                foreach (NoteRecord2 dcbnotes in currentDcbDocument.Notes)
                {
                    DocumentCommentBEO comment = new DocumentCommentBEO
                    {
                        DocumentId            = rVwDocumentBEO.DocumentId,
                        CollectionId          = new Guid(DcbOpticonJobBEO.TargetDatasetId),
                        MatterId              = Convert.ToInt64(DcbOpticonJobBEO.MatterId),
                        MetadataTypeVersionId = Constants.One
                    };

                    FieldMapBEO fieldmap = DcbOpticonJobBEO.FieldMappings.Find(o => (o.SourceFieldID == dcbnotes.LinkFieldCode));

                    if (null != fieldmap)
                    {
                        comment.Comment.FieldId = fieldmap.DatasetFieldID;
                        comment.MetadataType    = MetadataType.TextLevelComments;
                        Field fld = currentDcbDocument.FieldItems.Find(o => o.Code == fieldmap.SourceFieldID);

                        int startindex = 0;
                        if (DcbOpticonJobBEO.ContentFields.Field.Contains(fld.Name))
                        {
                            foreach (string contentfld in DcbOpticonJobBEO.ContentFields.Field)
                            {
                                if (contentfld.Equals(fld.Name))
                                {
                                    break;
                                }
                                else
                                {
                                    if (!String.IsNullOrEmpty(fld.Value))
                                    {
                                        startindex = startindex + Regex.Replace(fld.Value, "\r\n", "\n").Length;
                                    }
                                }
                            }
                        }
                        JsonComment jscomment = new JsonComment
                        {
                            FieldId         = Convert.ToString(fieldmap.DatasetFieldID),
                            IndexInDocument =
                                Convert.ToString(startindex + dcbnotes.LinkOffset),
                            SelectedText =
                                Regex.Replace(fld.Value, Constants.ReturnAndNewLineFeed, Constants.NewLineFeed).Substring(
                                    dcbnotes.LinkOffset, dcbnotes.LinkLength)
                        };
                        jscomment.SelectedText = Regex.Replace(jscomment.SelectedText, Constants.NewLineFeed, Constants.HtmlBreakWithNewLine);
                        JavaScriptSerializer serializer = new JavaScriptSerializer();
                        comment.Comment.SelectedText = serializer.Serialize(jscomment);


                        comment.SequenceId       = 0;
                        comment.VersionId        = 0;
                        comment.Comment.Comment  = dcbnotes.Text;
                        comment.Comment.FontSize = int.Parse(ConfigurationManager.AppSettings.Get(Constants.DCBCommentsFontSize));
                        comment.Comment.FontName = ConfigurationManager.AppSettings.Get(Constants.DCBCommentsFont);
                        comment.Comment.Color    = ConfigurationManager.AppSettings.Get(Constants.DCBCommentsFontColor);
                        string createdByGuid = String.Empty;
                        if (null != ProfileBEO && null != ProfileBEO.CreatedBy)
                        {
                            createdByGuid = ProfileBEO.CreatedBy;
                        }
                        comment.CreatedBy  = createdByGuid;
                        comment.ModifiedBy = createdByGuid;

                        documentCommentBEOList.Add(comment);

                        if (DcbOpticonJobBEO.IncludeTags && (dcbnotes.Tags != null) && (dcbnotes.Tags.Count > 0))
                        {
                            dcbDocumentTags.compositeTagNames.AddRange(dcbnotes.Tags);
                        }
                    }
                    else
                    {
                        if (DcbOpticonJobBEO.IncludeTags && (dcbnotes.Tags != null) && (dcbnotes.Tags.Count > 0))
                        {
                            Field         fld    = currentDcbDocument.FieldItems.Find(o => o.Code == dcbnotes.LinkFieldCode);
                            StringBuilder sbTags = new StringBuilder();
                            foreach (string tag in dcbnotes.Tags)
                            {
                                sbTags.AppendFormat(" {0}, ", tag);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.Trace().Swallow();
            }

            return(documentCommentBEOList);
        }
예제 #2
0
        private List<DocumentCommentBEO> FetchComments(RVWDocumentBEO rVwDocumentBEO, Document currentDcbDocument,
            DcbDocumentTags dcbDocumentTags)
        {
            List<DocumentCommentBEO> documentCommentBEOList = new List<DocumentCommentBEO>();
            try
            {
                foreach (NoteRecord2 dcbnotes in currentDcbDocument.Notes)
                {
                    DocumentCommentBEO comment = new DocumentCommentBEO
                                                     {
                                                         DocumentId = rVwDocumentBEO.DocumentId,
                                                         CollectionId = new Guid(DcbOpticonJobBEO.TargetDatasetId),
                                                         MatterId = Convert.ToInt64(DcbOpticonJobBEO.MatterId),
                                                         MetadataTypeVersionId = Constants.One
                                                     };

                    FieldMapBEO fieldmap = DcbOpticonJobBEO.FieldMappings.Find(o => (o.SourceFieldID == dcbnotes.LinkFieldCode));

                    if (null != fieldmap)
                    {
                        comment.Comment.FieldId = fieldmap.DatasetFieldID;
                        comment.MetadataType = MetadataType.TextLevelComments;
                        Field fld = currentDcbDocument.FieldItems.Find(o => o.Code == fieldmap.SourceFieldID);

                        int startindex = 0;
                        if (DcbOpticonJobBEO.ContentFields.Field.Contains(fld.Name))
                        {
                            foreach (string contentfld in DcbOpticonJobBEO.ContentFields.Field)
                            {
                                if (contentfld.Equals(fld.Name))
                                {
                                    break;
                                }
                                else
                                {
                                    if (!String.IsNullOrEmpty(fld.Value))
                                        startindex = startindex + Regex.Replace(fld.Value, "\r\n", "\n").Length;
                                }
                            }
                        }
                        JsonComment jscomment = new JsonComment
                                                    {
                                                        FieldId = Convert.ToString(fieldmap.DatasetFieldID),
                                                        IndexInDocument =
                                                            Convert.ToString(startindex + dcbnotes.LinkOffset),
                                                        SelectedText =
                                                            Regex.Replace(fld.Value, Constants.ReturnAndNewLineFeed, Constants.NewLineFeed).Substring(
                                                                dcbnotes.LinkOffset, dcbnotes.LinkLength)
                                                    };
                        jscomment.SelectedText = Regex.Replace(jscomment.SelectedText, Constants.NewLineFeed, Constants.HtmlBreakWithNewLine);
                        JavaScriptSerializer serializer = new JavaScriptSerializer();
                        comment.Comment.SelectedText = serializer.Serialize(jscomment);


                        comment.SequenceId = 0;
                        comment.VersionId = 0;
                        comment.Comment.Comment = dcbnotes.Text;
                        comment.Comment.FontSize = int.Parse(ConfigurationManager.AppSettings.Get(Constants.DCBCommentsFontSize));
                        comment.Comment.FontName = ConfigurationManager.AppSettings.Get(Constants.DCBCommentsFont);
                        comment.Comment.Color = ConfigurationManager.AppSettings.Get(Constants.DCBCommentsFontColor);
                        string createdByGuid = String.Empty;
                        if (null != ProfileBEO && null != ProfileBEO.CreatedBy)
                        {
                            createdByGuid = ProfileBEO.CreatedBy;
                        }
                        comment.CreatedBy = createdByGuid;
                        comment.ModifiedBy = createdByGuid;

                        documentCommentBEOList.Add(comment);

                        if (DcbOpticonJobBEO.IncludeTags && (dcbnotes.Tags != null) && (dcbnotes.Tags.Count > 0))
                        {
                            dcbDocumentTags.compositeTagNames.AddRange(dcbnotes.Tags);
                        }
                    }
                    else
                    {
                        if (DcbOpticonJobBEO.IncludeTags && (dcbnotes.Tags != null) && (dcbnotes.Tags.Count > 0))
                        {
                            Field fld = currentDcbDocument.FieldItems.Find(o => o.Code == dcbnotes.LinkFieldCode);
                            StringBuilder sbTags = new StringBuilder();
                            foreach (string tag in dcbnotes.Tags)
                            {
                                sbTags.AppendFormat(" {0}, ", tag);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.Trace().Swallow();
            }

            return documentCommentBEOList;
        }