Ejemplo n.º 1
0
        public void DisplayResource(IResource resource, WordPtr[] wordsToHighlight)
        {
            _displayedResource = resource;
            if (resource.HasProp(Core.Props.LongBodyIsRTF))
            {
                _rtfDisplayPane.GetControl().Visible = true;
                Core.WebBrowser.Visible = false;
                _rtfDisplayPane.DisplayResource(resource);

                if (wordsToHighlight != null)
                {
                    HighlightWords(wordsToHighlight);
                }
            }
            else
            {
                // Ensure the Web browser is hosted on our pane
                _panel.Controls.Add(Core.WebBrowser);
                Core.WebBrowser.Dock            = DockStyle.Fill;
                Core.WebBrowser.Visible         = true;
                Core.WebBrowser.ContextProvider = this;
                _rtfDisplayPane.GetControl().Visible = false;
                WebSecurityContext context           = WebSecurityContext.Restricted;
                context.WorkOffline = false;
                Core.WebBrowser.ShowHtml(resource.GetPropText(Core.Props.LongBody), context,
                                         DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creats document section with table and graph
        /// </summary>
        /// <param name="sectionTitle">Title of the section</param>
        /// <param name="resultsInPoints"> Result in point collection</param>
        /// <param name="resultTypes">The type of results that will be displayed in the diagram and in the table.</param>
        /// <param name="document">Active Revit document</param>
        /// <param name="elementType">Structural element type</param>
        /// <param name="addTable">Enabling/disabling inserting a table</param>
        /// <param name="addDiagram">Enabling/disabling inserting a graph</param>
        /// <param name="tableTitle"> Title of the table</param>
        /// <param name="diagramTitle"> Title of the graph</param>
        /// <param name="reversedAxis">Sets the direction of the Y axis on the graph</param>
        /// <returns>Returns section of document with diagram and table</returns>
        private DocumentSection CreateSectionTableAndDiagramForLinearElements(ICollection <ResultInPointLinear> resultsInPoints, List <ResultTypeLinear> resultTypes, Autodesk.Revit.DB.Document document, ElementType elementType, bool addTable = true, bool addDiagram = true, bool reversedAxis = false, String sectionTitle = "", String tableTitle = "", String diagramTitle = "")
        {
            DocumentSection newDocumentSection = null;

            if (addTable || addDiagram)
            {
                newDocumentSection       = new DocumentSection(sectionTitle, 5);
                newDocumentSection.Level = DetailLevel.Medium;
                if (addTable)
                {
                    DocumentSection tableSection = new DocumentSection(tableTitle, 6);
                    DocumentTable   resultTable  = CreateResultTableForLinearElements(resultsInPoints, resultTypes, document);
                    resultTable.Level = DetailLevel.Medium;
                    newDocumentSection.Body.Elements.Add(resultTable);
                }
                if (addDiagram)
                {
                    DocumentSection diagramSection = new DocumentSection();
                    DocumentDiagram resultDiagram  = CreateResultDiagramForLinearElements(diagramTitle, resultsInPoints, resultTypes, document, elementType, reversedAxis);
                    resultDiagram.Level = DetailLevel.Detail;
                    newDocumentSection.Body.Elements.Add(new DocumentLineBreak(2));
                    newDocumentSection.Body.Elements.Add(resultDiagram);
                }
            }
            return(newDocumentSection);
        }
Ejemplo n.º 3
0
        public string GetFormattedBody(IResource res, string body, string replyToBody,
                                       ref WordPtr[] offsets, string fontFace, int fontSize)
        {
            string formattedText;
            string subject        = res.GetPropText(Core.Props.Subject);
            bool   needFormatting = res.HasProp("NoFormat");

            // If no offsets passed, default to the simple processing
            if ((offsets == null) || (offsets.Length == 0))
            {
                formattedText = GetFormattedText(needFormatting, body, replyToBody, subject, null, fontFace, fontSize);
            }
            else
            {
                // Save offsets, format text, retrieve offsets.
                using (MarkerInjector injector = new MarkerInjector())
                {
                    WordPtr[] modOffs = DocumentSection.RestrictResults(offsets, DocumentSection.BodySection);
                    body          = injector.InjectMarkers(body, modOffs);
                    formattedText = GetFormattedText(needFormatting, body, replyToBody, subject, injector, fontFace, fontSize);
                    formattedText = injector.CollectMarkers(formattedText, out modOffs);
                }
            }
            return(formattedText);
        }
Ejemplo n.º 4
0
        public void Section1()
        {
            var section1 = new DocumentSection("Individual Needs")
            {
                Title = "Present Levels of Performance and Individual needs"
            };


            _doc.Sections.Add(section1);
            section1.Fields.Add(new TextField("Evaluation Results"));
            section1.Fields.Add(new FieldSet("Academic Acheivement", new[]
            {
                new TextField("LEVELS OF KNOWLEDGE AND DEVELOPMENT IN SUBJECT AND SKILL AREAS INCLUDING ACTIVITIES OF DAILY LIVING, LEVEL OF INTELLECTUAL FUNCTIONING, ADAPTIVE BEHAVIOR, EXPECTED RATE OF PROGRESS IN ACQUIRING SKILLS AND INFORMATION, AND LEARNING STYLE:"),
                new TextField("STUDENT STRENGTHS, PREFERENCES, INTERESTS:"),
                new TextField("ACADEMIC, DEVELOPMENTAL AND FUNCTIONAL NEEDS OF THE STUDENT, INCLUDING CONSIDERATION OF STUDENT NEEDS THAT ARE OF CONCERN TO THE PARENT:")
            }));
            section1.Fields.Add(new FieldSet("Social Development", new[]
            {
                new TextField("THE DEGREE (EXTENT) AND QUALITY OF THE STUDENT'S RELATIONSHIP WITH PEERS AND ADULTS; FEELINGS ABOUT SELF; AND SOCIAL ADJUSTMENTS "),
                new TextField("STUDENT STRENGTHS:"),
                new TextField("SOCIAL DEVELOPMENT NEEDS OF THE STUDENT, INCLUDING CONSIDERATION OF STUDENT NEEDS THAT ARE OF CONCERN TO THE PARENT:")
            }));

            section1.Fields.Add(new FieldSet("Physical Development", new[]
            {
                new TextField("THE DEGREE (EXTENT) AND QUALITY OF THE STUDENT'S MOTOR AND SENSORTY DEVELOPMENT, HEALTH, VITALITY AND PHYSICAL SKILLS OR LIMITS PERTAN TO THE LEARNING PROCESS:"),
                new TextField("STUDENT STRENGTHS"),
                new TextField("PHYSICAL DEVELOPMENT NEEDS OF THE STUDENT, INCLUDING CONSIDERATION OF STUDENT NEEDS THAT ARE OF CONCERN TO THE PARENT:")
            }));

            section1.Fields.Add(new TextField("Management Needs"));
            section1.Fields.Add(new TextField("Effects of student needs"));
        }
Ejemplo n.º 5
0
        /**
         * This method is called by IEBrowserDisplayPane to display the specified resource
         * in the browser.
         */

        private void DisplayConversation(IResource resource, AbstractWebBrowser browser, WordPtr[] wordsToHighlight)
        {
            // Ask ConversationManager to format the conversation as HTML and
            // feed it into IEBrowser.
            string htmlString = _convManager.ToHtmlString(resource, _propNick);

            browser.ShowHtml(htmlString, WebSecurityContext.Restricted, DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
        }
Ejemplo n.º 6
0
        /**
         * Shows the text of the currently displayed conversation in IEBrowser.
         */

        private void DisplayCurrentConversation()
        {
            if (_currentConvList != null)
            {
                string htmlString = _convManager.ToHtmlString(_currentConvList[0], _propNickName);
                Core.WebBrowser.ShowHtml(htmlString, WebSecurityContext.Restricted, DocumentSection.RestrictResults(_wordsToHighlight, DocumentSection.BodySection));
            }
        }
Ejemplo n.º 7
0
        public void Section5()
        {
            var section5 = new DocumentSection("Reporting progress to parents");

            section5.Fields.Add(new TextField("Identify when periodic reports on the student's progress toward meeting........."));

            _doc.Sections.Add(section5);
        }
Ejemplo n.º 8
0
 protected void ShowSubject(string text, WordPtr[] toHighlight)
 {
     _editSubject.Text = text;
     if (toHighlight != null)
     {
         WordPtr[] restrictedWords = DocumentSection.RestrictResults(toHighlight, DocumentSection.SubjectSection);
         _editSubject.HighlightWords(restrictedWords);
     }
 }
Ejemplo n.º 9
0
        public void ParseCanHandleSingleLineItem()
        {
            string text = @"This is an item  ";

            var results = DocumentSection.Parse(text);

            Assert.AreEqual(1, results.Length);
            Assert.AreEqual(0, results[0].IndentSize);
            Assert.AreEqual("This is an item", results[0].Contents);
        }
Ejemplo n.º 10
0
        public void ParseCanHandleMultipleItems()
        {
            string text = @"    hey 

            
    hey2     
       child1

       child2
        
  Last hey   ";

            var results = DocumentSection.Parse(text);
            //Assert.AreEqual(6, results.Length);

            var itemIndex = 0;
            var item      = results[itemIndex++];

            Assert.AreEqual(0, item.Children.Count);
            Assert.AreEqual(4, item.IndentSize);
            Assert.AreEqual("hey", item.Contents);

            item = results[itemIndex++];
            Assert.AreEqual(0, item.Children.Count);
            Assert.AreEqual(0, item.IndentSize);
            Assert.AreEqual("", item.Contents);

            item = results[itemIndex++];
            Assert.AreEqual(0, item.Children.Count);
            Assert.AreEqual(0, item.IndentSize);
            Assert.AreEqual("", item.Contents);

            item = results[itemIndex++];
            Assert.AreEqual(3, item.Children.Count);
            Assert.AreEqual(4, item.IndentSize);
            Assert.AreEqual("hey2", item.Contents);
            foreach (var child in item.Children)
            {
                Assert.AreEqual(0, child.Children.Count);
                Assert.AreEqual(7, child.IndentSize);
            }
            Assert.AreEqual("child1", item.Children[0].Contents);
            Assert.AreEqual("", item.Children[1].Contents);
            Assert.AreEqual("child2", item.Children[2].Contents);

            item = results[itemIndex++];
            Assert.AreEqual(0, item.Children.Count);
            Assert.AreEqual(0, item.IndentSize);
            Assert.AreEqual("", item.Contents);

            item = results[itemIndex++];
            Assert.AreEqual(0, item.Children.Count);
            Assert.AreEqual(2, item.IndentSize);
            Assert.AreEqual("Last hey", item.Contents);
        }
Ejemplo n.º 11
0
        public void Section6()
        {
            var section6    = new DocumentSection("Recommended special education programs and services");
            var tableField  = new TableField("");
            var specEdTable = new TableField("Special Education Program:");

            specEdTable.Fields.Add(new TextField(""));

            tableField.Fields.Add(specEdTable);
            _doc.Sections.Add(section6);
        }
Ejemplo n.º 12
0
 private static void DisplayHTML(IResource resource, AbstractWebBrowser browser, WordPtr[] wordsToHighlight)
 {
     try
     {
         StreamReader reader = Core.FileResourceManager.GetStreamReader(resource);
         if (reader != null)
         {
             string sourceUrl = "";
             string htmlText  = Utils.StreamReaderReadToEnd(reader);
             reader.BaseStream.Close();
             IResource source = FileResourceManager.GetSource(resource);
             if (source != null)
             {
                 string url = string.Empty;
                 if (Core.ResourceStore.PropTypes.Exist("URL"))
                 {
                     url = source.GetPropText("URL");
                 }
                 if (url.Length > 0)
                 {
                     sourceUrl = url;
                     htmlText  = HtmlTools.FixRelativeLinks(htmlText, url);
                 }
                 else
                 {
                     string directory = source.GetPropText("Directory");
                     if (directory.Length > 0)
                     {
                         if ((!directory.EndsWith("/")) && (!directory.EndsWith("\\")))
                         {
                             directory += "/";
                         }
                         htmlText = HtmlTools.FixRelativeLinks(htmlText, directory);
                     }
                 }
             }
             try
             {
                 WebSecurityContext context = WebSecurityContext.Restricted;
                 context.WorkOffline = false;
                 browser.ShowHtml(htmlText, context,
                                  DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
                 browser.CurrentUrl = sourceUrl;
             }
             catch (Exception e)
             {
                 Trace.WriteLine(e.ToString(), "Html.Plugin");
             }
         }
     }
     catch (ObjectDisposedException) {}
 }
Ejemplo n.º 13
0
        public void Section3()
        {
            var section3 = new DocumentSection("Measurable Postsecondary goals");

            section3.Fields.Add(new FieldSet("", new[]
            {
                new TextField("Education/Training"),
                new TextField("Employment"),
                new TextField("Independent living skills (when appropriate"),
            }));

            section3.Fields.Add(new TextField("Transitional Needs"));
        }
Ejemplo n.º 14
0
/*
 *      protected void ShowPlainTextAsRtf( string text, WordPtr[] wordsToHighlight )
 *      {
 *          _editRtfBody.Show();
 *          _ieBrowser.Hide();
 *          _editRtfBody.Select();
 *          _editRtfBody.Clear();
 *          _editRtfBody.Text = text;
 *          _editRtfBody.Font = new Font("Courier New", 10F, FontStyle.Regular, GraphicsUnit.Point, 204);
 *          if ( wordsToHighlight != null )
 *          {
 *              _editRtfBody.HighlightWords( DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection ));
 *          }
 *      }
 *
 */
        public void HighlightWords(WordPtr[] wordsToHighlight)
        {
            Guard.NullArgument(wordsToHighlight, "wordsToHighlight");
            _editSubject.HighlightWords(DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.SubjectSection));
            if (_ieBrowser.Visible)
            {
                _ieBrowser.HighlightWords(DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection), 0);
            }
            else if (_editRtfBody.Visible)
            {
                _editRtfBody.HighlightWords(DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
            }
        }
Ejemplo n.º 15
0
 public void HighlightWords(WordPtr[] words)
 {
     words = DocumentSection.RestrictResults(words, DocumentSection.BodySection);
     if (_richTextBox.Visible)
     {
         _richTextBox.HighlightWords(words);
     }
     else
     {
         Core.WebBrowser.HighlightWords(words, 0);
         _wordsToHighlight = words;
     }
 }
Ejemplo n.º 16
0
        public void Section2()
        {
            var section2 = new DocumentSection("Special Factors")
            {
                Title = "Student Needs Relating to Special Factors"
            };

            _doc.Sections.Add(section2);

            section2.Fields.Add(new FieldSet("", new[]
            {
                new SelectOptionField(
                    "Does the student need strategies, including positive behavioral interventions, support and other strategies to address behaviors that impedes the student's learning or that of others",
                    new[] { "Yes", "No" }),
                new SelectOptionField(
                    "Does the student need a behavioral intervention plan?",
                    new[] { "No", "Yes" })
            }));

            section2.Fields.Add(
                new SelectOptionField(
                    "For a student with limited English proficiency, doe he/she need a special education service to address his.her language needs as they relate to the IEP?",
                    new[] { "Yes", "No", "Not Applicable" }));

            section2.Fields.Add(
                new SelectOptionField(
                    "For a student who is blind or visually impaired, does he/she need instruction in Braille and the use of Braille?",
                    new[] { "Yes", "No", "Not Applicable" }));

            section2.Fields.Add(new FieldSet("", new[]
            {
                new SelectOptionField(
                    "Does the student need a perticular device or service to address his.her communication needs?",
                    new[] { "Yes", "No" }),
                new SelectOptionField(
                    "In the case of a student who is deaf or hard of hearing, does the student need a perticualr device or service consideration........?",
                    new[] { "Yes", "No", "Not Applicable" })
            }));

            var c = new ConditionalField(
                new SelectOptionField(
                    "Does the student need an assistive technology device and/or service?",
                    new[] { "Yes", "No" }))
            {
                True = new SelectOptionField(
                    "If yes, does the Committee recommend that the device(s) be used in the student's home?",
                    new[] { "Yes", "No" })
            };

            section2.Fields.Add(c);
        }
Ejemplo n.º 17
0
        public void Section4()
        {
            var section4       = new DocumentSection("Measurable annual goals");
            var tableField     = new TableField("Masurable annual goals");
            var shortTermTable = new TableField("Short-Term intrucinal......");

            tableField.Fields.Add(new TextField("Annual Goals"));
            tableField.Fields.Add(new TextField("Criteria"));
            tableField.Fields.Add(new TextField("Method"));
            tableField.Fields.Add(new TextField("Schedule"));

            shortTermTable.Fields.Add(new TextField(""));
            tableField.Fields.Add(shortTermTable);

            section4.Fields.Add(tableField);
            _doc.Sections.Add(section4);
        }
Ejemplo n.º 18
0
 protected void ShowRtf(string rtf, WordPtr[] wordsToHighlight)
 {
     _editRtfBody.Show();
     _ieBrowser.Hide();
     try
     {
         _editRtfBody.Rtf = rtf;
         if (wordsToHighlight != null)
         {
             _editRtfBody.HighlightWords(DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
         }
     }
     catch (ArgumentException exc)
     {
         Core.ReportBackgroundException(exc);
         _editRtfBody.Text = "Cannot display this message. Error occured while reading RTF format.";
     }
 }
Ejemplo n.º 19
0
        /**********************************************************************/

        private void SectionizeNodes(HtmlNode node, ref List <DocumentSection> documentSections)
        {
            foreach (HtmlAttribute hat in node.Attributes)
            {
                if (hat.Name == "id" && !string.IsNullOrEmpty(hat.Value))
                {
                    DocumentSection ds = new DocumentSection();
                    ds.SectionNode = node.CloneNode(true);
                    ;
                    ds.title = hat.Value;
                    documentSections.Add(ds);
                }
            }

            foreach (HtmlNode child in node.ChildNodes)
            {
                SectionizeNodes(child, ref documentSections);
            }
        }
Ejemplo n.º 20
0
        public string GetFormattedHtmlBody(IResource res, string body, ref WordPtr[] offsets)
        {
            string formattedText;
            string subject = res.GetPropText(Core.Props.Subject);

            // If no offsets passed, default to the simple processing
            if ((offsets == null) || (offsets.Length == 0))
            {
                formattedText = InsertHeaderWithStyle(body, subject);
            }
            else
            {
                // Save offsets, format text, retrieve offsets.
                using (MarkerInjector injector = new MarkerInjector())
                {
                    WordPtr[] modOffs = DocumentSection.RestrictResults(offsets, DocumentSection.BodySection);
                    body          = injector.InjectMarkers(body, modOffs);
                    formattedText = InsertHeaderWithStyle(body, subject);
                    formattedText = injector.CollectMarkers(formattedText, out modOffs);
                }
            }
            return(formattedText);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// RetrieveTOC
        /// </summary>
        /// <param name="fileStream">stream containing the docx file contents</param>
        /// <returns>List of DocumentSection objects</returns>
        public IList <DocumentSection> RetrieveTOC(Stream fileStream, string requestId = "")
        {
            _logger.LogInformation($"RequestId: {requestId} - RetrieveTOC called.");

            const string TOCHEADING = "TOCHeading";
            const string TOC        = "Table of Contents";

            try
            {
                var documentSections = new List <DocumentSection>();

                using (var document = WordprocessingDocument.Open(fileStream, false))
                {
                    var docPart = document.MainDocumentPart;
                    var doc     = docPart.Document;

                    OpenXmlElement block = doc.Descendants <DocPartGallery>().
                                           Where(b => b.Val.HasValue &&
                                                 (b.Val.Value.Equals(TOC, StringComparison.InvariantCultureIgnoreCase))).FirstOrDefault();

                    if (block == null)
                    {
                        throw new InvalidOperationException("The document doesn't contain a Table of Contents.");
                    }

                    // Extract the Table of Contents section information and create the list
                    DocumentSection parent = null;
                    foreach (var tocPart in document.MainDocumentPart.Document.Body.Descendants <SdtContentBlock>().First())
                    {
                        var styles = tocPart.Descendants <ParagraphStyleId>();

                        if (styles.Count() == 0 || styles.First().Val.Value.Equals(TOCHEADING, StringComparison.InvariantCultureIgnoreCase))
                        {
                            continue;
                        }

                        var tocStyle = styles.First().Val.Value;
                        var level    = int.Parse(tocStyle.Last().ToString());

                        var section = new DocumentSection()
                        {
                            Id    = Guid.NewGuid().ToString(),
                            Level = level,
                            LastModifiedDateTime = DateTimeOffset.MinValue,
                            DisplayName          = tocPart.Descendants <Text>().ToArray()[0].InnerText,
                            Owner = new UserProfile
                            {
                                Id          = string.Empty,
                                DisplayName = string.Empty,
                                Fields      = new UserProfileFields()
                            },
                            SectionStatus = ActionStatus.NotStarted
                        };

                        if (level == 1)
                        {
                            section.SubSectionId = string.Empty;
                        }
                        else if (level > parent.Level)
                        {
                            section.SubSectionId = parent.Id;
                        }
                        else if (level == parent.Level)
                        {
                            section.SubSectionId = parent.SubSectionId;
                        }
                        else // search for parent level
                        {
                            var copy = new DocumentSection[documentSections.Count];
                            documentSections.CopyTo(copy);
                            var reversed = copy.Reverse().ToArray();

                            string parentId = null;

                            for (int i = 0; i < reversed.Length; i++)
                            {
                                if (reversed[i].Level == level)
                                {
                                    parentId = reversed[i].SubSectionId;
                                    break;
                                }
                            }

                            section.SubSectionId = parentId;
                        }

                        documentSections.Add(section);
                        parent = section;
                    }
                }

                // Return the list of DocumentSections
                return(documentSections);
            }
            catch (Exception ex)
            {
                _logger.LogError($"RequestId: {requestId} - RetrieveTOC Service Exception: {ex}");
                throw new ResponseException($"RequestId: {requestId} - RetrieveTOC Service Exception: {ex}");
            }
        }
Ejemplo n.º 22
0
        /**********************************************************************/
        private void SectionizeNodes(HtmlNode node, ref List<DocumentSection> documentSections)
        {
            foreach (HtmlAttribute hat in node.Attributes)
            {
                if (hat.Name == "id" && !string.IsNullOrEmpty(hat.Value))
                {
                    DocumentSection ds = new DocumentSection();
                    ds.SectionNode = node.CloneNode(true);
                    ;
                    ds.title = hat.Value;
                    documentSections.Add(ds);
                }
            }

            foreach (HtmlNode child in node.ChildNodes)
            {
                SectionizeNodes(child, ref documentSections);
            }
        }
Ejemplo n.º 23
0
        public void ParseCanHandleComments()
        {
            string text = @"IGNORE+ Junk after this is a comment
    lalala  
IGNORE-  Junk after this is still a comment
    An Item
## A comment
== Another comment
        ## Not a comment
        IGNORE+ Not a comment
IGNORE+
this is acomment
IGNORE-

-------- Alfred Settings --------------------------------------------------
--Alfred:CommentTag=##
--Alfred:CommentTag===
--Alfred:IgnoreSectionStartTag=IGNORE+
--Alfred:IgnoreSectionEndTag=IGNORE-
";

            var results = DocumentSection.Parse(text);

            //Assert.AreEqual(15, results.Length);

            Assert.AreEqual(true, results[0].IsComment);
            Assert.AreEqual(true, results[1].IsComment);
            Assert.AreEqual(true, results[2].IsComment);
            Assert.AreEqual(true, results[3].IsComment);
            Assert.AreEqual(true, results[4].IsComment);
            Assert.AreEqual("IGNORE+ Junk after this is a comment", results[0].Contents);
            Assert.AreEqual("    lalala  ", results[1].Contents);
            Assert.AreEqual("IGNORE-  Junk after this is still a comment", results[2].Contents);
            Assert.AreEqual("## A comment", results[3].Contents);
            Assert.AreEqual("== Another comment", results[4].Contents);

            var item = results[5];

            Assert.AreEqual(false, item.IsComment);
            Assert.AreEqual(4, item.IndentSize);
            Assert.AreEqual("An Item", item.Contents);
            Assert.AreEqual(2, item.Children.Count);
            Assert.AreEqual("## Not a comment", item.Children[0].Contents);
            Assert.AreEqual("IGNORE+ Not a comment", item.Children[1].Contents);
            Assert.AreEqual(false, item.Children[0].IsComment);
            Assert.AreEqual(false, item.Children[1].IsComment);

            Assert.AreEqual(true, results[6].IsComment);
            Assert.AreEqual(true, results[7].IsComment);
            Assert.AreEqual(true, results[8].IsComment);
            Assert.AreEqual("IGNORE+", results[6].Contents);
            Assert.AreEqual("this is acomment", results[7].Contents);
            Assert.AreEqual("IGNORE-", results[8].Contents);

            item = results[9];
            Assert.AreEqual(false, item.IsComment);
            Assert.AreEqual(0, item.IndentSize);
            Assert.AreEqual("", item.Contents);

            Assert.AreEqual(true, results[10].IsComment);
            Assert.AreEqual(true, results[11].IsComment);
            Assert.AreEqual(true, results[12].IsComment);
            Assert.AreEqual(true, results[13].IsComment);
            Assert.AreEqual(true, results[14].IsComment);
            Assert.AreEqual("-------- Alfred Settings --------------------------------------------------", results[10].Contents);
            Assert.AreEqual("--Alfred:CommentTag=##", results[11].Contents);
            Assert.AreEqual("--Alfred:CommentTag===", results[12].Contents);
            Assert.AreEqual("--Alfred:IgnoreSectionStartTag=IGNORE+", results[13].Contents);
            Assert.AreEqual("--Alfred:IgnoreSectionEndTag=IGNORE-", results[14].Contents);
        }
Ejemplo n.º 24
0
 public void HighlightWords(WordPtr[] words)
 {
     words = DocumentSection.RestrictResults(words, DocumentSection.BodySection);
     Core.WebBrowser.HighlightWords(words, 0);
     _wordsToHighlight = words;
 }
Ejemplo n.º 25
0
 public void DisplayResource(IResource resource, WordPtr[] wordsToHighlight)
 {
     _wordsToHighlight = DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection);
     DisplayResource(resource);
 }
Ejemplo n.º 26
0
 public void AddSection(DocumentSection section)
 {
     sections.Add(section);
 }
Ejemplo n.º 27
0
 public void HighlightWords(WordPtr[] words)
 {
     _richTextBox.HighlightWords(DocumentSection.RestrictResults(words, DocumentSection.BodySection));
 }
 private static DocumentSection ModelToEntity(SignDocumentSectionModel model)
 {
     var entity = new DocumentSection { 
         IdDocumentModel = model.IdDocumentModel, 
         NameKey = model.NameKey, 
         DateCreated = model.DateCreated 
     };
     if (model.IdDocumentSection != null) entity.IdDocumentSection = model.IdDocumentSection.GetValueOrDefault();
     return entity;
 }
 private static SignDocumentSectionModel EntityToModel(DocumentSection entity) 
 {
     return new SignDocumentSectionModel { 
         IdDocumentSection = entity.IdDocumentSection, 
         IdDocumentModel = entity.IdDocumentModel , 
         NameKey = entity.NameKey, 
         Label = entity.NameKey,
         DateCreated = entity.DateCreated//,
         //IsComplete = entity.IsComplete
     };
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Method shows html-formatted text in the browser. Offsets for highlighting are
 /// restricted to the <see cref="DocumentSection.BodySection">BodySection</see> section.
 /// </summary>
 protected void ShowHtml(string html, WebSecurityContext securityContext, WordPtr[] toHighlight)
 {
     AttachWebBrowser();
     WordPtr[] restrictedWords = DocumentSection.RestrictResults(toHighlight, DocumentSection.BodySection);
     _ieBrowser.ShowHtml(html, securityContext, restrictedWords);    // Use the updated offsets
 }
Ejemplo n.º 31
0
 /**
  * displays conversation as auto-generated html text
  */
 private void DisplayConversation(IResource resource, AbstractWebBrowser browser, WordPtr[] wordsToHighlight)
 {
     try
     {
         browser.ShowHtml(_conversationManager.ToHtmlString(resource, _propNickName), WebSecurityContext.Restricted, DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
     }
     catch (Exception e)
     {
         Trace.WriteLine(e.ToString(), "ICQ.Plugin");
         return;
     }
     _displayedResource = resource.ToResourceListLive();
     _displayedResource.ResourceChanged += ConversationChangedHandler;
 }
Ejemplo n.º 32
0
        internal static void ProcessBookmarksPart(IDictionary <string, string> values, DocumentSection documentSection, object section)
        {
            IEnumerable <BookmarkStart> bookmarks = null;

            switch (documentSection)
            {
            case DocumentSection.Main:
            {
                bookmarks = ((MainDocumentPart)section).Document.Body.Descendants <BookmarkStart>();
                break;
            }

            case DocumentSection.Header:
            {
                bookmarks = ((HeaderPart)section).RootElement.Descendants <BookmarkStart>();
                break;
            }

            case DocumentSection.Footer:
            {
                bookmarks = ((FooterPart)section).RootElement.Descendants <BookmarkStart>();
                break;
            }
            }
            if (bookmarks == null)
            {
                return;
            }
            foreach (var bmStart in bookmarks)
            {
                //If the bookmark name is not in our list. Just continue with the loop
                if (!values.ContainsKey(bmStart.Name))
                {
                    continue;
                }
                BookmarkEnd bmEnd = null;
                switch (documentSection)
                {
                case DocumentSection.Main:
                {
                    bmEnd = (((MainDocumentPart)section).Document.Body.Descendants <BookmarkEnd>().Where(b => b.Id == bmStart.Id.ToString())).FirstOrDefault();
                    break;
                }

                case DocumentSection.Header:
                {
                    bmEnd = (((HeaderPart)section).RootElement.Descendants <BookmarkEnd>().Where(b => b.Id == bmStart.Id.ToString())).FirstOrDefault();
                    break;
                }

                case DocumentSection.Footer:
                {
                    bmEnd = (((FooterPart)section).RootElement.Descendants <BookmarkEnd>().Where(b => b.Id == bmStart.Id.ToString())).FirstOrDefault();
                    break;
                }
                }
                //If we did not find anything just continue in the loop
                if (bmEnd == null)
                {
                    continue;
                }
                var rProp = bmStart.Parent.Descendants <Run>().Where(rp => rp.RunProperties != null).Select(rp => rp.RunProperties).FirstOrDefault();
                if (bmStart.PreviousSibling <Run>() == null && bmEnd.ElementsAfter().Count(e => e.GetType() == typeof(Run)) == 0)
                {
                    bmStart.Parent.RemoveAllChildren <Run>();
                }
                else
                {
                    var list  = bmStart.ElementsAfter().Where(r => r.IsBefore(bmEnd)).ToList();
                    var trRun = list.Where(rp => rp.GetType() == typeof(Run) && ((Run)rp).RunProperties != null).Select(rp => ((Run)rp).RunProperties).FirstOrDefault();
                    if (trRun != null)
                    {
                        rProp = (RunProperties)trRun.Clone();
                    }
                    for (var n = list.Count(); n > 0; n--)
                    {
                        list[n - 1].Remove();
                    }
                }
                var bmText = values[bmStart.Name];
                if (!string.IsNullOrEmpty(bmText) && bmText.Contains(Environment.NewLine))
                {
                    var insertElement = bmStart.Parent.PreviousSibling();
                    var rows          = bmText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                    foreach (var row in rows)
                    {
                        var np   = new Paragraph();
                        var nRun = new Run();
                        if (rProp != null)
                        {
                            nRun.RunProperties = (RunProperties)rProp.Clone();
                        }
                        nRun.AppendChild(new Text(row));
                        np.AppendChild(nRun);
                        if (insertElement.Parent != null)
                        {
                            insertElement.InsertAfterSelf(np);
                        }
                        else
                        {
                            insertElement.Append(np);
                        }
                        insertElement = np;
                    }
                }
                else
                {
                    var nRun = new Run();
                    if (rProp != null)
                    {
                        nRun.RunProperties = (RunProperties)rProp.Clone();
                    }
                    nRun.Append(new Text(bmText));
                    bmStart.InsertAfterSelf(nRun);
                }
            }
        }
Ejemplo n.º 33
0
        private async Task <ProposalDocument> ProposalDocumentToEntityAsync(OpportunityViewModel viewModel, ProposalDocument proposalDocument, string requestId = "")
        {
            try
            {
                Guard.Against.Null(proposalDocument, "ProposalDocumentToEntityAsync", requestId);
                var entity = proposalDocument;
                var model  = viewModel.ProposalDocument;

                entity.Id          = model.Id ?? String.Empty;
                entity.DisplayName = model.DisplayName ?? String.Empty;
                entity.Reference   = model.Reference ?? String.Empty;
                entity.Version     = model.Version ?? String.Empty;

                if (entity.Content == null)
                {
                    entity.Content = ProposalDocumentContent.Empty;
                }


                // Storing previous section lists to compare and trigger notification if assigment changes
                var currProposalSectionList = entity.Content.ProposalSectionList.ToList();

                // Proposal sections are always overwritten
                entity.Content.ProposalSectionList = new List <DocumentSection>();

                if (model.Content.ProposalSectionList != null)
                {
                    var OwnerSendList      = new List <UserProfile>(); //receipients list for notifications
                    var AssignedToSendList = new List <UserProfile>(); //receipients list for notifications
                    // LIST: ProposalSectionList
                    foreach (var item in model.Content.ProposalSectionList)
                    {
                        var documentSection = new DocumentSection();
                        documentSection.DisplayName          = item.DisplayName ?? String.Empty;
                        documentSection.Id                   = item.Id ?? String.Empty;
                        documentSection.LastModifiedDateTime = item.LastModifiedDateTime;
                        documentSection.Owner                = await _userProfileHelpers.UserProfileToEntityAsync(item.Owner ?? new UserProfileViewModel(), requestId);

                        documentSection.SectionStatus = ActionStatus.FromValue(item.SectionStatus.Value);
                        documentSection.SubSectionId  = item.SubSectionId ?? String.Empty;
                        documentSection.AssignedTo    = await _userProfileHelpers.UserProfileToEntityAsync(item.AssignedTo ?? new UserProfileViewModel(), requestId);

                        documentSection.Task = item.Task ?? String.Empty;

                        // Check values to see if notification trigger is needed
                        var prevSectionList = currProposalSectionList.Find(x => x.Id == documentSection.Id);
                        if (prevSectionList != null)
                        {
                            if (prevSectionList.Owner.Id != documentSection.Owner.Id)
                            {
                                OwnerSendList.Add(documentSection.Owner);
                            }

                            if (prevSectionList.AssignedTo.Id != documentSection.AssignedTo.Id)
                            {
                                AssignedToSendList.Add(documentSection.AssignedTo);
                            }
                        }

                        entity.Content.ProposalSectionList.Add(documentSection);
                    }

                    // AssignedToSendList notifications
                    // Section owner changed / assigned
                    try
                    {
                        if (OwnerSendList.Count > 0)
                        {
                            _logger.LogInformation($"RequestId: {requestId} - ProposalDocumentToEntityAsync sendNotificationCardAsync for owner changed notification.");
                            var notificationOwner = await _cardNotificationService.sendNotificationCardAsync(
                                viewModel.DisplayName,
                                viewModel.OpportunityChannelId,
                                OwnerSendList,
                                $"Section(s) in the proposal document for opportunity {viewModel.DisplayName} has new/updated owners ",
                                requestId);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError($"RequestId: {requestId} - ProposalDocumentToEntityAsync sendNotificationCardAsync for owner error: {ex}");
                    }

                    // Section AssignedTo changed / assigned
                    try
                    {
                        if (AssignedToSendList.Count > 0)
                        {
                            _logger.LogInformation($"RequestId: {requestId} - ProposalDocumentToEntityAsync sendNotificationCardAsync for AssigedTo changed notification.");
                            var notificationAssignedTo = await _cardNotificationService.sendNotificationCardAsync(
                                viewModel.DisplayName,
                                viewModel.OpportunityChannelId,
                                AssignedToSendList,
                                $"Task(s) in the proposal document for opportunity {viewModel.DisplayName} has new/updated assigments ",
                                requestId);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError($"RequestId: {requestId} - ProposalDocumentToEntityAsync sendNotificationCardAsync for AssignedTo error: {ex}");
                    }
                }


                // Metadata
                if (entity.Metadata == null)
                {
                    entity.Metadata = DocumentMetadata.Empty;
                }

                entity.Metadata.DocumentUri = model.DocumentUri;
                entity.Metadata.Tags        = model.Tags;
                if (entity.Metadata.Category == null)
                {
                    entity.Metadata.Category = new Category();
                }

                entity.Metadata.Category.Id   = model.Category.Id ?? String.Empty;
                entity.Metadata.Category.Name = model.Category.Name ?? String.Empty;

                if (entity.Metadata.Notes == null)
                {
                    entity.Metadata.Notes = new List <Note>();
                }

                if (model.Notes != null)
                {
                    // LIST: Notes
                    foreach (var item in model.Notes)
                    {
                        entity.Metadata.Notes.Add(await NoteToEntityAsync(item, requestId));
                    }
                }

                return(entity);
            }
            catch (Exception ex)
            {
                //_logger.LogError(ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 34
0
 public Document()
 {
     Sections = new DocumentSection[0];
 }