private void CreateDescription(IGlymaNode node, ref Paragraph paragraph)
        {
            //paragraph.Inlines.Add(new Span(FormattingSymbolLayoutBox.LINE_BREAK));

            if (node.NodeDescription.Type == "Iframe")
            {
                if (ShowDescriptionIcon)
                {
                    var descriptionIcon = new ImageInline(DescriptionIconStream, new Size(20, 15), "png");
                    paragraph.Inlines.Add(descriptionIcon);
                    paragraph.Inlines.Add(new Span("  "));
                }
                else
                {
                    paragraph.Inlines.Add(new Span("Link: ") { FontSize = 12 });
                }

                CreateLink(node.NodeDescription.Link, ref paragraph);
            }
            else
            {
                if (ShowDescriptionIcon)
                {
                    var descriptionIcon = new ImageInline(DescriptionIconStream, new Size(20, 15), "png");
                    paragraph.Inlines.Add(descriptionIcon);
                    paragraph.Inlines.Add(new Span("  "));
                }
                else
                {
                    paragraph.Inlines.Add(new Span("Description: ") { FontSize = 12 });
                }

                var htmlFormatProvider = new HtmlFormatProvider();
                var description = htmlFormatProvider.Import(node.NodeDescription.Description);
                foreach (var item in description.Sections)
                {
                    var section = item.CreateDeepCopy() as Section;
                    if (section != null)
                    {
                        foreach (var block in section.Blocks)
                        {
                            var para = block as Paragraph;
                            if (para != null)
                            {
                                foreach (Span span in para.EnumerateChildrenOfType<Span>())
                                {
                                    span.FontSize = 12;
                                }

                                foreach (var inline in para.Inlines)
                                {
                                    var theNewInLineItem = inline.CreateDeepCopy() as Inline;
                                    paragraph.Inlines.Add(theNewInLineItem);
                                }
                            }
                            else
                            {
                                CurrentBlockCollection.Add(block.CreateDeepCopy() as Block);
                            }
                        }
                    }
                }
            }
        }
示例#2
0
        public ActionResult SaveNew(string bodyContentUA, string bodyContentEN, string fileNamePhoto, string mainName, string mainNameEn,
                                    string phone1, string phone2, string phone3, string email, string fbUrl, string googleUrl, string twUrl, string instUrl, string city, string cityEn)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                db.TeamMembers.Add(new TeamMember
                {
                    City          = city,
                    CityEn        = cityEn,
                    Description   = htmlProvider.Export(document),
                    DescriptionEn = htmlProvider.Export(documentEn),
                    Email         = email,
                    Fb            = fbUrl,
                    Inst          = instUrl,
                    Google        = googleUrl,
                    Name          = mainName,
                    NameEn        = mainNameEn,
                    Phone1        = phone1,
                    Phone2        = phone2,
                    Phone3        = phone3,
                    Tw            = twUrl,
                    Photo         = fileNamePhoto,
                });
                db.SaveChanges();
            }
            return(null);
        }
示例#3
0
        public ActionResult SaveEdit(int id, string bodyContentUA, string bodyContentEN, string fileNamePhoto, string mainName, string mainNameEn,
                                     string phone1, string phone2, string phone3, string email, string fbUrl, string googleUrl, string twUrl, string instUrl, string city, string cityEn)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);
            var curMamber = context.TeamMembers.FirstOrDefault(x => x.Id == id);

            if (curMamber != null)
            {
                curMamber.City          = city;
                curMamber.CityEn        = cityEn;
                curMamber.Description   = htmlProvider.Export(document);
                curMamber.DescriptionEn = htmlProvider.Export(documentEn);
                curMamber.Email         = email;
                curMamber.Fb            = fbUrl;
                curMamber.Inst          = instUrl;
                curMamber.Google        = googleUrl;
                curMamber.Name          = mainName;
                curMamber.NameEn        = mainNameEn;
                curMamber.Phone1        = phone1;
                curMamber.Phone2        = phone2;
                curMamber.Phone3        = phone3;
                curMamber.Tw            = twUrl;
                curMamber.Photo         = fileNamePhoto;

                context.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
示例#4
0
        public ActionResult Save(string titleUa, string titleEn, string body, string bodyEn, string detailUrl, string videoUrl, string pic)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(body);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyEn);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                db.Newses.Add(new News
                {
                    Title     = titleUa,
                    TitleEn   = titleEn,
                    DateNews  = DateTime.Now,
                    Body      = htmlProvider.Export(document),
                    BodyEn    = htmlProvider.Export(documentEn),
                    DetailUrl = detailUrl,
                    Video     = videoUrl,
                    Picture   = pic
                });
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
示例#5
0
        public ActionResult SaveEdit(int id, string titleUa, string titleEn, string body, string bodyEn, string detailUrl, string videoUrl, string pic)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(body);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyEn);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                var news = db.Newses.FirstOrDefault(x => x.NewsId == id);
                if (news != null)
                {
                    news.Title     = titleUa;
                    news.TitleEn   = titleEn;
                    news.DateNews  = DateTime.Now;
                    news.Body      = htmlProvider.Export(document);
                    news.BodyEn    = htmlProvider.Export(documentEn);
                    news.DetailUrl = detailUrl;
                    news.Video     = videoUrl;
                    news.Picture   = pic;
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("Index"));
        }
示例#6
0
 //***************************************************
 //*********Show data on grid views and docs**********
 private void UpdateDataOnGridViews()
 {
     ShowItemsOnGridView();
     ShowAimsOnGridView();
     ShowPersonsOnGridView();
     ShowEventsOnGridView();
     rtbRules.Document      = htmlProvider.Import(rules.writtenText);
     rtbPrehistory.Document = htmlProvider.Import(prehistory.writtenText);
 }
        private void PrepareDocument()
        {
            Patient patient = new PatientData().GetPatientById(_patientid);

            StringBuilder content = new StringBuilder();
            content.Append("<p>");
            content.Append("<b>Patient Name : </b>" + patient.FirstName.ToUpper() + " " + patient.LastName.ToUpper());
            content.Append("<br/>");
            content.Append("<b>Patient Id : </b>" + _patientid.ToString());
            content.Append("<br/>");
            content.Append("<b>Age : </b>" + Utility.GetAgeFromDob(patient.DOB).ToString());
            content.Append("<br/>");
            content.Append("<b>Address : </b>" + patient.Address.ToUpper());
            content.Append("<br/>");
            content.Append("<b>Hospital : </b>");
            content.Append("<br/>");
            content.Append("<b>IP Number : </b>");
            content.Append("<br/>");
            content.Append("<b>Date : </b>");
            content.Append("<br/>");
            content.Append("</p>");


            HtmlFormatProvider provider = new HtmlFormatProvider();
            Telerik.WinControls.RichTextBox.Model.RadDocument document = provider.Import(content.ToString());
            this.docPrintVisit.Document = document;

            this.docPrintVisit.InsertImage((Bitmap)Resources.letterhead);
            docPrintVisit.InsertLineBreak();
            docPrintVisit.InsertLineBreak();
        }
        /// <summary>
        /// Convert the HTML string to a file, download the generated file in the browser
        /// </summary>
        /// <param name="htmlContent">The HTML content to export</param>
        /// <param name="fileName">The FileName of the downloaded file, its extension is used to fetch the exprot provider</param>
        /// <returns>Returns true if the operation succeeded, false if there was an exception</returns>
        public async Task <bool> ExportAndDownloadHtmlContent(string htmlContent, string fileName)
        {
            try
            {
                // prepare a document with the HTML content that we can use for conversion
                HtmlFormatProvider provider = new HtmlFormatProvider();
                RadFlowDocument    document = provider.Import(htmlContent);

                // get the provider to export and then download the file
                string mimeType;
                IFormatProvider <RadFlowDocument> exportProvider = GetExportFormatProvider(fileName, out mimeType);
                byte[] exportFileBytes = null;
                using (MemoryStream ms = new MemoryStream())
                {
                    exportProvider.Export(document, ms);
                    exportFileBytes = ms.ToArray();
                }

                // download the file in the browser
                await FileDownloader.Save(_js, exportFileBytes, mimeType, fileName);
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
示例#9
0
        private void KnowledgeChanged()
        {
            //Title = _knowledge.Title;
            var provider = new HtmlFormatProvider();

            boxEditor.Document = provider.Import(_knowledge.GetKnowledgeHtml());
        }
        public override RadDocument Import(Stream input)
        {
            using (StreamReader reader = new StreamReader(input))
            {
                // Performs the first stage of the conversion - parses block elements from the source
                // and created the syntax tree.
                var blockDoc = CommonMarkConverter.ProcessStage1(reader);

                //Performs the second stage of the conversion - parses block element contents into
                //inline elements.
                CommonMarkConverter.ProcessStage2(blockDoc);

                string       tempFileName = System.IO.Path.GetTempFileName();
                StreamWriter writer       = new StreamWriter(tempFileName);
                using (writer)
                {
                    // Performs the last stage of the conversion - converts the syntax tree to HTML
                    // representation.
                    CommonMarkConverter.ProcessStage3(blockDoc, writer);
                }

                RadDocument document;
                using (FileStream stream = File.OpenRead(tempFileName))
                {
                    document = htmlProvider.Import(stream);
                }
                File.Delete(tempFileName);

                return(document);
            }
        }
示例#11
0
 private void ImportFromString()
 {
     #region radwordsprocessing-formats-and-conversion-html-htmlformatprovider_1
     string             html     = "<p>hello world!</p>";
     HtmlFormatProvider provider = new HtmlFormatProvider();
     RadFlowDocument    document = provider.Import(html);
     #endregion
 }
        private static void SaveDocumentCore(string htmlText, Stream outputStream, DocumentType documentType)
        {
            var importProvider = new HtmlFormatProvider();
            var exportProvider = CreateFormatProvider(documentType);
            var flowDocument   = importProvider.Import(htmlText);

            exportProvider.Export(flowDocument, outputStream);
        }
示例#13
0
        public ActionResult SaveNew(string bodyContentUA, string bodyContentEN, string fileNameBLogo, string fileNamePhoto, string mainName, string mainNameEn, string address,
                                    string addressEn, string phone1, string phone2, string phone3, string email, string siteUrl, string fbUrl, string googleUrl, string twUrl, string instUrl, string mapUrl,
                                    int category, string videoUrl, string city, string cityEn)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                var cat = db.CategoryBusnesses.FirstOrDefault(x => x.IdCategory == category);
                db.Businesses.Add(new Business
                {
                    Address       = address,
                    AddressEn     = addressEn,
                    City          = city,
                    CityEn        = cityEn,
                    DateAdd       = DateTime.Now,
                    Description   = htmlProvider.Export(document),
                    DescriptionEn = htmlProvider.Export(documentEn),
                    Email         = email,
                    Fb            = fbUrl,
                    Inst          = instUrl,
                    Google        = googleUrl,
                    MainName      = mainName,
                    MainNameEn    = mainNameEn,
                    Phone1        = phone1,
                    Phone2        = phone2,
                    Phone3        = phone3,
                    Site          = siteUrl,
                    Map           = mapUrl,
                    Tw            = twUrl,
                    Video         = videoUrl,
                    Logo          = fileNameBLogo,
                    Photo         = fileNamePhoto,
                    Category      = cat
                });
                db.SaveChanges();
            }
            return(null);
        }
示例#14
0
 private void ImportFromFile()
 {
     #region radwordsprocessing-formats-and-conversion-html-htmlformatprovider_0
     using (Stream input = File.Create(@"Sample.html"))
     {
         HtmlFormatProvider provider = new HtmlFormatProvider();
         RadFlowDocument    document = provider.Import(input);
     }
     #endregion
 }
示例#15
0
        public ActionResult Save(int id, string bodyContentUA, string bodyContentEN, string fileNameBLogo, string fileNamePhoto, string mainName, string mainNameEn, string address,
                                 string addressEn, string phone1, string phone2, string phone3, string email, string siteUrl, string fbUrl, string googleUrl, string twUrl, string instUrl, string mapUrl,
                                 int category, string videoUrl, string city, string cityEn)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);
            var curBuisnes = db.Businesses.FirstOrDefault(x => x.BusinessId == id);

            if (curBuisnes != null)
            {
                var cat = db.CategoryBusnesses.FirstOrDefault(x => x.IdCategory == category);
                curBuisnes.Address       = address;
                curBuisnes.AddressEn     = addressEn;
                curBuisnes.City          = city;
                curBuisnes.CityEn        = cityEn;
                curBuisnes.Description   = htmlProvider.Export(document);
                curBuisnes.DescriptionEn = htmlProvider.Export(documentEn);
                curBuisnes.Email         = email;
                curBuisnes.Fb            = fbUrl;
                curBuisnes.Inst          = instUrl;
                curBuisnes.Google        = googleUrl;
                curBuisnes.MainName      = mainName;
                curBuisnes.MainNameEn    = mainNameEn;
                curBuisnes.Phone1        = phone1;
                curBuisnes.Phone2        = phone2;
                curBuisnes.Phone3        = phone3;
                curBuisnes.Site          = siteUrl;
                curBuisnes.Map           = mapUrl;
                curBuisnes.Tw            = twUrl;
                curBuisnes.Video         = videoUrl;
                curBuisnes.Logo          = fileNameBLogo;
                curBuisnes.Photo         = fileNamePhoto;
                curBuisnes.Category      = cat;

                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
        public void LoadHtml(string description)
        {
            var html = new HtmlAgilityPack.HtmlDocument();

            html.LoadHtml(description);

            var doc = HtmlFormatProvider.Import(description);

            SetupNewDocument(doc);
            RadRichTextBox.Document = doc;
        }
示例#17
0
        public ActionResult SaveNew(string bodyContentUA, string bodyContentEN, string fileNameBLogo, string address,
                                    string addressEn, string phone1, string phone2, string phone3, string siteUrl, string fbUrl, string googleUrl, string twUrl, string instUrl, string mapUrl,
                                    string city, string cityEn, string name, string nameEn, string email)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);

            using (Context db = new Context())
            {
                db.Jobses.Add(new Jobs
                {
                    Address           = address,
                    AddressEn         = addressEn,
                    City              = city,
                    CityEn            = cityEn,
                    DateAdd           = DateTime.Now,
                    DescriptionJobs   = htmlProvider.Export(document),
                    DescriptionEnJobs = htmlProvider.Export(documentEn),
                    Fb          = fbUrl,
                    Inst        = instUrl,
                    Google      = googleUrl,
                    Phone1      = phone1,
                    Phone2      = phone2,
                    Phone3      = phone3,
                    Site        = siteUrl,
                    Map         = mapUrl,
                    Tw          = twUrl,
                    LogoJobs    = fileNameBLogo,
                    TitleJobs   = name,
                    TitleEuJobs = nameEn,
                    EmailJobs   = email
                });
                db.SaveChanges();
            }
            return(null);
        }
示例#18
0
        public ActionResult Save(int id, string bodyContentUA, string bodyContentEN, string phone1, string phone2, string phone3, string email)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);
            var cur = db.AboutUses.FirstOrDefault(x => x.Id == id);

            if (cur != null)
            {
                cur.Description   = htmlProvider.Export(document);
                cur.DescriptionEn = htmlProvider.Export(documentEn);
                cur.Email         = email;
                cur.Phone1        = phone1;
                cur.Phone2        = phone2;
                cur.Phone3        = phone3;
                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
示例#19
0
        public ActionResult Save(int id, string bodyContentUA, string bodyContentEN, string fileNameBLogo, string address,
                                 string addressEn, string phone1, string phone2, string phone3, string siteUrl, string fbUrl, string googleUrl, string twUrl, string instUrl, string mapUrl,
                                 string city, string cityEn, string name, string nameEn, string email)
        {
            string             bodyHtml     = HttpUtility.HtmlDecode(bodyContentUA);
            string             bodyHtmlEn   = HttpUtility.HtmlDecode(bodyContentEN);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    document     = htmlProvider.Import(bodyHtml);
            RadFlowDocument    documentEn   = htmlProvider.Import(bodyHtmlEn);
            var curJob = db.Jobses.FirstOrDefault(x => x.JobsId == id);

            if (curJob != null)
            {
                curJob.Address         = address;
                curJob.AddressEn       = addressEn;
                curJob.City            = city;
                curJob.TitleJobs       = name;
                curJob.TitleEuJobs     = nameEn;
                curJob.CityEn          = cityEn;
                curJob.DescriptionJobs = htmlProvider.Export(document);
                curJob.DescriptionJobs = htmlProvider.Export(documentEn);
                curJob.Fb        = fbUrl;
                curJob.Inst      = instUrl;
                curJob.Google    = googleUrl;
                curJob.Phone1    = phone1;
                curJob.Phone2    = phone2;
                curJob.Phone3    = phone3;
                curJob.Site      = siteUrl;
                curJob.Map       = mapUrl;
                curJob.Tw        = twUrl;
                curJob.LogoJobs  = fileNameBLogo;
                curJob.EmailJobs = email;

                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
示例#20
0
        public ActionResult ExportDocx(string content)
        {
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadFlowDocument    htmlDocument = htmlProvider.Import(content);

            DocxFormatProvider docxProvider = new DocxFormatProvider();

            using (Stream output = System.IO.File.OpenWrite(Server.MapPath("~/App_Data/Sample.docx")))
            {
                docxProvider.Export(htmlDocument, output);
            }

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
示例#21
0
        private void Initialize()
        {
            InitializeComponent();


            RadMenuInsertTableItem insertTableBoxItem = new RadMenuInsertTableItem();

            this.radDropDownButtonElementTables.Items.Insert(0, insertTableBoxItem);
            insertTableBoxItem.SelectionChanged += new EventHandler <TableSelectionChangedEventArgs>(OnInsertTableSelectionChanged);

            this.radMenuItemInsertTable.Click += new EventHandler(radMenuItemInsertTable_Click);

            this.radRibbonBar1.RibbonBarElement.ApplicationButtonElement.Text         = "File";
            this.radRibbonBar1.RibbonBarElement.ApplicationButtonElement.ForeColor    = Color.White;
            this.radRibbonBar1.RibbonBarElement.ApplicationButtonElement.DisplayStyle = DisplayStyle.Text;

            this.radDropDownListFontSize.DropDownStyle = RadDropDownStyle.DropDownList;
            this.radDropDownListFont.DropDownStyle     = RadDropDownStyle.DropDownList;

            //this.radPageView1.SelectedPage = this.radPageViewPageSaveAsWord;

            Stream             stream       = new FileStream(path, FileMode.Open);
            HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
            RadDocument        document     = htmlProvider.Import(stream);

            this.AttachDocument(document);
            this.radRichTextBox1.Document      = document;
            this.radBtnPrintLayout.ToggleState = ToggleState.On;
            this.radRichTextBox1.CurrentEditingStyleChanged += new EventHandler(radRichTextBox1_CurrentEditingStyleChanged);


            this.BtnSaveAsHTML.Click  += new EventHandler(this.radBtnSave_Click);
            this.BtnSaveAsPDF.Click   += new EventHandler(this.radBtnSave_Click);
            this.BtnSaveAsRTF.Click   += new EventHandler(this.radBtnSave_Click);
            this.BtnSaveAsPLAIN.Click += new EventHandler(this.radBtnSave_Click);
            this.BtnSaveAsWORD.Click  += new EventHandler(this.radBtnSave_Click);
            this.BtnSaveAsXAML.Click  += new EventHandler(this.radBtnSave_Click);

            this.radDropDownListFont.DropDownAnimationEnabled     = false;
            this.radDropDownListFontSize.DropDownAnimationEnabled = false;



            /*AttachSignal();
             * this.closeTimer = new System.Windows.Forms.Timer();
             * this.closeTimer.Interval = 3000;
             * this.closeTimer.Tick += new EventHandler(closeTimer_Tick);
             * this.closeTimer.Start();*/
        }
        protected override void SetContentCore(object value)
        {
            try
            {
                this.editor.Value = Convert.ToString(value);

                if (this.Value != null && this.Value != DBNull.Value && this.Value.ToString() != "")
                {
                    RichTextEditorElement element  = (RichTextEditorElement)this.editor.EditorElement;
                    RadRichTextEditor     textBox  = (RadRichTextEditor)element.HostedControl;
                    HtmlFormatProvider    provider = new HtmlFormatProvider();

                    RadDocument document = provider.Import(this.Value.ToString());
                    textBox.Document    = document;
                    document.LayoutMode = DocumentLayoutMode.Flow;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(null, ex.ToString(), "EXCEPTION", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#23
0
        public ActionResult UploadResumeDoc(HttpPostedFileBase customDocument)
        {
            ResultModel result = new ResultModel();
            IFormatProvider <RadFlowDocument> fileFormatProvider = null;
            RadFlowDocument document = null;
            string          mimeType = String.Empty;

            fileFormatProvider = new HtmlFormatProvider();
            if (customDocument != null && Regex.IsMatch(Path.GetExtension(customDocument.FileName), ".docx|.rtf|.html|.txt"))
            {
                document = fileFormatProvider.Import(customDocument.InputStream);
                HtmlFormatProvider provider = new HtmlFormatProvider();
                string             html     = provider.Export(document);
                UserResumeDocModel sd       = new UserResumeDocModel()
                {
                    UserID = SessionItems.CurrentUser.Id, DocText = html
                };
                result = sd.SaveOrUpDate();
                if (result.BooleanResult)
                {
                    result.BooleanResult = true;
                    result.StringResult  = "Upload Successfully!";
                }
                else
                {
                    result.BooleanResult = false;
                    result.StringResult  = "Upload fail! Please try again!";
                }
            }
            else
            {
                //invalid files
                result.BooleanResult = false;
                result.StringResult  = "Invalid document! Please try again.";
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
示例#24
0
        private void compileDocument()
        {
            //doc.LineSpacing = 12;

            /*
             * Paragraph paragraph1 = new Paragraph();
             * Stream stream = Application.GetResourceStream(new Uri(@"/RadRichTextBox-Getting-Started;component/Images/RadRichTextBox.png", UriKind.RelativeOrAbsolute)).Stream;
             * Size size = new Size(236, 50);
             * ImageInline imageInline = new ImageInline(stream, size, "png");
             * paragraph1.Inlines.Add(imageInline);
             * section.Blocks.Add(paragraph1);
             */
            // вид документа:
            // предыстория, на отдельной странице (потом разрыв)
            // имя персонажа большими буквами посередине страницы
            // описание, сюжет
            // список целей, ненумерованным списком
            // список предметов (если есть), нумерованным списком
            // правила игры


            doc = new RadDocument();
            doc.MergeSpansWithSameStyles();
            doc.ParagraphDefaultSpacingAfter  = 0;
            doc.ParagraphDefaultSpacingBefore = 0;
            Padding padding = new System.Windows.Forms.Padding(0, 20, 100, 60);

            doc.SectionDefaultPageMargin = padding;
            //doc.SectionDefaultPageMargin.
            //doc.DefaultPageLayoutSettings.Width = 200;
            //doc.DefaultPageLayoutSettings.Height = 250;
            RadDocument tempDoc = new RadDocument();

            // **** Prehistory***********
            tempDoc = htmlProvider.Import(prehistory.writtenText);
            mergeDocuments(tempDoc);
            doc.CaretPosition.MoveToLastPositionInDocument();
            doc.InsertPageBreak();

            // **** Person Name ***********
            Section   section    = new Section();
            Paragraph paragraph1 = new Paragraph();

            paragraph1.TextAlignment = Telerik.WinControls.RichTextBox.Layout.RadTextAlignment.Center;
            Span span1 = new Span(chosenPerson.getName());

            span1.FontSize      = 24;
            span1.FontStyle     = TextStyle.Bold;
            span1.UnderlineType = Telerik.WinControls.RichTextBox.UI.UnderlineType.Wave;
            paragraph1.Inlines.Add(span1);
            section.Blocks.Add(paragraph1);
            doc.Sections.Add(section);

            // **** Person's description***********
            tempDoc = htmlProvider.Import(chosenPerson.description);
            mergeDocuments(tempDoc, section);

            // **** Aim list***********
            BulletedList aimList  = new BulletedList(char.ConvertFromUtf32(0x25CF)[0], doc);
            Section      section2 = new Section();
            Paragraph    par2     = new Paragraph();

            doc.CaretPosition.MoveToLastPositionInDocument();
            doc.InsertLineBreak();
            Span span2 = new Span("Your Aims:");

            par2.Inlines.Add(span2);
            section2.Blocks.Add(par2);

            foreach (int aimID in chosenPerson.aimsId)
            {
                CAim      aim  = aimManager.getAim(aimID);
                Paragraph par  = new Paragraph();
                Span      span = new Span(aim.getName());
                if (aim.description != "")
                {
                    span.Text += " (" + aim.description + ")";
                }
                par.Inlines.Add(span);
                par.LineSpacingType = LineSpacingType.AtLeast;
                aimList.AddParagraph(par);
                section2.Blocks.Add(par);
            }
            doc.Sections.Add(section2);

            // **** Item list***********
            if (chosenPerson.itemsId.Count > 0)
            {
                NumberedList itemList = new NumberedList(doc);
                Section      section3 = new Section();
                Paragraph    par3     = new Paragraph();
                Span         span3    = new Span("Your Items:");
                par3.Inlines.Add(span3);
                section3.Blocks.Add(par3);

                foreach (int itemID in chosenPerson.itemsId)
                {
                    CItem     item = itemManager.getItem(itemID);
                    Paragraph par  = new Paragraph();
                    Span      span = new Span(item.getName());
                    if (item.description != "")
                    {
                        span.Text += " (" + item.description + ")";
                    }
                    par.Inlines.Add(span);
                    par.LineSpacingType = LineSpacingType.AtLeast;
                    itemList.AddParagraph(par);
                    section3.Blocks.Add(par);
                }
                doc.Sections.Add(section3);
            }

            // **** Rules***********
            doc.CaretPosition.MoveToLastPositionInDocument();
            doc.InsertLineBreak();
            tempDoc = htmlProvider.Import(rules.writtenText);
            mergeDocuments(tempDoc, doc.Sections.Last);
        }
示例#25
0
        private void CreateDescription(IGlymaNode node, ref Paragraph paragraph)
        {
            //paragraph.Inlines.Add(new Span(FormattingSymbolLayoutBox.LINE_BREAK));

            if (node.NodeDescription.Type == "Iframe")
            {
                if (ShowDescriptionIcon)
                {
                    var descriptionIcon = new ImageInline(DescriptionIconStream, new Size(20, 15), "png");
                    paragraph.Inlines.Add(descriptionIcon);
                    paragraph.Inlines.Add(new Span("  "));
                }
                else
                {
                    paragraph.Inlines.Add(new Span("Link: ")
                    {
                        FontSize = 12
                    });
                }

                CreateLink(node.NodeDescription.Link, ref paragraph);
            }
            else
            {
                if (ShowDescriptionIcon)
                {
                    var descriptionIcon = new ImageInline(DescriptionIconStream, new Size(20, 15), "png");
                    paragraph.Inlines.Add(descriptionIcon);
                    paragraph.Inlines.Add(new Span("  "));
                }
                else
                {
                    paragraph.Inlines.Add(new Span("Description: ")
                    {
                        FontSize = 12
                    });
                }

                var htmlFormatProvider = new HtmlFormatProvider();
                var description        = htmlFormatProvider.Import(node.NodeDescription.Description);
                foreach (var item in description.Sections)
                {
                    var section = item.CreateDeepCopy() as Section;
                    if (section != null)
                    {
                        foreach (var block in section.Blocks)
                        {
                            var para = block as Paragraph;
                            if (para != null)
                            {
                                foreach (Span span in para.EnumerateChildrenOfType <Span>())
                                {
                                    span.FontSize = 12;
                                }

                                foreach (var inline in para.Inlines)
                                {
                                    var theNewInLineItem = inline.CreateDeepCopy() as Inline;
                                    paragraph.Inlines.Add(theNewInLineItem);
                                }
                            }
                            else
                            {
                                CurrentBlockCollection.Add(block.CreateDeepCopy() as Block);
                            }
                        }
                    }
                }
            }
        }
示例#26
0
        private Field GetField(string processSystemName, PropertyInfo property, IDynamicObject self, bool isGsUpdate, CultureInfo culture = null)
        {
            var containsNumbers = false;
            var temp = property.GetValue(self, null);

            if (typeof(DateTime?).IsAssignableFrom(property.PropertyType))
            {
                containsNumbers = true;
                var attrib = (DateTimeFormatAttribute[])property.GetCustomAttributes(typeof(DateTimeFormatAttribute), false);
                var displayType = attrib.Select(x => x.Value).FirstOrDefault();
                var propValue = (DateTime?)property.GetValue(self, null);
                if (propValue != null)
                {
                    switch (displayType)
                    {
                        case "Date":
                            temp = propValue.Value.ToString(Constants.DefaultShortDateFormat, CultureInfo.InvariantCulture);
                            break;
                        case "Time":
                            temp = propValue.Value.ToString(Constants.DefaultShortTimeFormat, CultureInfo.InvariantCulture);
                            break;
                        case "DateTime":
                            temp = propValue.Value.ToString(Constants.DefaultShortDateTimeFormat, CultureInfo.InvariantCulture);
                            break;
                        default:
                            throw new VeyronException("Not definited time : " + displayType);
                    }
                }
            }

            var crossRefAtrib = (CrossRefFieldAttribute[])property.GetCustomAttributes(typeof(CrossRefFieldAttribute), false);
            if (crossRefAtrib.Count() != 0)
            {
                var enumerable = temp as IEnumerable<object>;
                if (enumerable != null)
                {
                    var items = enumerable.ToArray();

                    var fieldName = crossRefAtrib.Select(x => x.RefFieldName).FirstOrDefault();
                    if (items.Any())
                    {
                        var firstItemType = items[0].GetType();
                        var fieldProperty = firstItemType.GetPropertyByName(fieldName);
                        if (fieldProperty != null)
                        {
                            var list = items.Select(item => (fieldProperty.GetValue(item, null) ?? string.Empty).ToString()).ToList();
                            temp = list.Any() ? list.Aggregate((a, b) => a + ", " + b) : null;
                        }
                    }
                    else
                    {
                        temp = string.Empty;
                    }
                }
                else
                {
                    if (!isGsUpdate)
                    {
                        var crossRefId = temp as int?;
                        if (crossRefId != null)
                        {
                            var crossRefValue = TheDynamicTypeManager.GetCrossReferenceItem(processSystemName, property.Name, (int)crossRefId);
                            if (crossRefValue != null)
                            {
                                temp = crossRefValue.__DisplayName;
                            }
                        }
                    }
                }
            }

            var fieldEditorAtribute = (FieldEditorAttribute[])property.GetCustomAttributes(typeof(FieldEditorAttribute), false);
            if (fieldEditorAtribute.Count() != 0)
            {
                var atribute = fieldEditorAtribute.FirstOrDefault();
                if (atribute.DataType == "Checkbox")
                {
                    var checkBoxValue = temp as bool?;

                    var isSwithTogle = (IsSwitchToggleAttribute[])property.GetCustomAttributes(typeof(IsSwitchToggleAttribute), false);
                    if (isSwithTogle.Count() != 0)
                    {
                        var switchTogleValue = (isSwithTogle.FirstOrDefault().Value as bool?).Value;
                        if (switchTogleValue)
                        {
                            if (!checkBoxValue.HasValue)
                            {
                                temp =
                                    ((UndefinedLabelAttribute[])property.GetCustomAttributes(typeof(UndefinedLabelAttribute), false))
                                        .FirstOrDefault().Value.ToString();
                            }
                            else if (checkBoxValue.Value)
                            {
                                temp =
                                    ((TrueLabelAttribute[])property.GetCustomAttributes(typeof(TrueLabelAttribute), false)).FirstOrDefault()
                                                                                                                           .Value.ToString();
                            }
                            else
                            {
                                temp =
                                    ((FalseLabelAttribute[])property.GetCustomAttributes(typeof(FalseLabelAttribute), false)).FirstOrDefault()
                                                                                                                             .Value.ToString();
                            }
                        }
                        else
                        {
                            if (!checkBoxValue.HasValue)
                            {
                                temp = null;
                            }
                            else if (checkBoxValue.Value)
                            {
                                temp = "True";
                            }
                            else
                            {
                                temp = "False";
                            }
                        }
                    }
                }

                if (atribute.DataType == "Approval")
                {
                    var result = temp as string;
                    var approval = temp as IApprovalEdit;
                    if (approval != null)
                    {
                        result = approval.ApprovalState;
                    }

                    temp = result.ToApprovalState().GetDisplayName();
                }

                if (atribute.DataType == "RichText")
                {
                    var richText = temp as string;

                    if (!string.IsNullOrEmpty(richText))
                    {
                        var htmlProvider = new HtmlFormatProvider();
                        var document = htmlProvider.Import(richText);

                        var textProvider = new TxtFormatProvider();
                        temp = textProvider.Export(document);
                    }
                }

                if (atribute.DataType == "FileProcess")
                {
                    var file = temp as IFileProcess;
                    if (file != null)
                    {
                        temp = file.OriginalFileName;
                    }
                }
            }

            string value = temp == null ? null : temp.ToString();
            if (!containsNumbers && IsNumber(value))
            {
                containsNumbers = true;
            }

            if (value == null || string.IsNullOrWhiteSpace(value))
            {
                return null;
            }

            var field = culture != null ? GetLocalizedFieldName(property.Name, culture) : property.Name;

            return new Field(field, value, Field.Store.YES, containsNumbers ? Field.Index.NOT_ANALYZED : Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS);
        }
示例#27
0
        public RadDocument ImportHtml(string content)
        {
            HtmlFormatProvider provider = new HtmlFormatProvider();

            return(provider.Import(content));
        }
        private void LoadPrescription(int visitid)
        {

            Patient patient = new PatientData().GetPatientById(_patientid);

            StringBuilder content = new StringBuilder();
            content.Append("<p>");
            content.Append("<b>Patient Name : </b>" + patient.FirstName.ToUpper() + " " + patient.LastName.ToUpper());
            content.Append("<br/>");
            content.Append("<b>Patient Id : </b>" + _patientid.ToString());
            content.Append("<br/>");
            content.Append("<b>Age : </b>" + Utility.GetAgeFromDob(patient.DOB).ToString());
            content.Append("<br/>");
            content.Append("<b>Address : </b>" + patient.Address.ToUpper());
            content.Append("<br/>");
            content.Append("<b>Hospital : </b>");
            content.Append("<br/>");
            content.Append("<b>IP Number : </b>");
            content.Append("<br/>");
            content.Append("<b>Date : </b>");
            content.Append("<br/>");
            content.Append("</p>");

            VisitData db = new VisitData();

            PatientVisit visit = db.GetVisitById(visitid);
            if (visit != null)
            {
                content.Append("<p>");

                content.Append("<br/>");
                content.Append("<b>Presenting complaint and relevant history : </b>");
                content.Append("<br/>");
                content.Append(visit.ComplaintHistory);
                content.Append("<br/>");

                content.Append("<br/>");
                content.Append("<b>Clinical findings : </b>");
                content.Append("<br/>");
                content.Append(visit.ExaminationNotes);
                content.Append("<br/>");

                content = AddLabData(db.GetLabData(visitid), content);

                AddImagingData(db.GetImagingData(visitid), content);

                content.Append("<br/>");
                content.Append("<b>Diagnosis : </b>");
                content.Append("<br/>");
                content.Append(visit.Diagnosis);
                content.Append("<br/>");

                AddPrescriptionData(db.GetPrescriptionData(visitid), content);

                content.Append("<br/>");
                content.Append("<b>Other Advise : </b>");
                content.Append("<br/>");
                content.Append(visit.OtherAdvise);
                content.Append("<br/>");

                content.Append("<br/>");
                content.Append("<b>Follow Up Date : </b>");
                content.Append("<br/>");
                if (visit.IsFolowUpRequired)
                {
                    content.Append(visit.FollowUpDate.ToShortDateString());
                }
                content.Append("<br/>");

                content.Append("</p>");
            }

            HtmlFormatProvider provider = new HtmlFormatProvider();
            Telerik.WinControls.RichTextBox.Model.RadDocument document = provider.Import(content.ToString());
            this.docPrintVisit.Document = document;

            this.docPrintVisit.InsertImage((Bitmap)Resources.letterhead);
            docPrintVisit.InsertLineBreak();
            docPrintVisit.InsertLineBreak();
        }
示例#29
0
        public void FilterDiaries(List <string> FSymbols, DateTime FBegin, DateTime FEnd)
        {
            try
            {
                string   name_file;
                string[] name_file_split;
                string   date = "";
                string   time = "";
                string   symbol;
                string   html_string;


                DateTime     date_time;
                StreamWriter html_writer =
                    new StreamWriter(Directory.GetCurrentDirectory() + "\\Base\\TRADEDIARY\\TRADEDIARY.html");
                StreamReader  html_reader;
                DirectoryInfo di      = new DirectoryInfo(Directory.GetCurrentDirectory() + "\\Base\\TRADEDIARY");
                FileInfo[]    rgFiles = di.GetFiles("*.html");
                ParentControl.DiaryCurrentSymbols = FSymbols;
                foreach (FileInfo fi in rgFiles)
                {
                    name_file       = fi.Name;
                    name_file_split = name_file.Split(new char[] { '_' });
                    if (name_file_split.Length == 7)
                    {
                        symbol = name_file_split[0].Trim();
                        time   = name_file_split[4].Trim() + ":" + name_file_split[5].Trim() + ":" +
                                 name_file_split[6].Replace(".html", "").Trim();
                        date = name_file_split[3].Trim() + "/" + name_file_split[2].Trim() + "/" +
                               name_file_split[1].Trim();
                        date_time = new DateTime(Convert.ToInt32(name_file_split[1]),
                                                 Convert.ToInt32(name_file_split[2]),
                                                 Convert.ToInt32(name_file_split[3]));
                        if ((date_time.Date >= FBegin.Date) && (date_time.Date <= FEnd.Date) &&
                            (FSymbols.Contains(symbol)))
                        {
                            html_reader =
                                new StreamReader(Directory.GetCurrentDirectory() + "\\Base\\TRADEDIARY\\HEADER.html");
                            html_string = html_reader.ReadToEnd();
                            html_reader.Close();
                            html_string = html_string.Replace("SYMBOL", symbol);
                            html_string = html_string.Replace("TIME", time);
                            html_string = html_string.Replace("DATE", date);
                            html_string = html_string.Replace("EDIT",
                                                              "EDIT: " + Directory.GetCurrentDirectory() +
                                                              "\\Base\\TRADEDIARY\\" + name_file);
                            html_string = html_string.Replace("DELETE",
                                                              "DELETE: " + Directory.GetCurrentDirectory() +
                                                              "\\Base\\TRADEDIARY\\" + name_file);
                            html_string = html_string.Replace("CREATED",
                                                              "CREATED: " + Directory.GetCurrentDirectory() +
                                                              "\\Base\\TRADEDIARY\\" + name_file);
                            html_writer.Write(html_string);
                            html_writer.Write("\n");
                            html_reader =
                                new StreamReader(Directory.GetCurrentDirectory() + "\\Base\\TRADEDIARY\\" + name_file);
                            html_string = html_reader.ReadToEnd();
                            html_reader.Close();
                            html_writer.Write(html_string);
                            html_writer.Write("\n");
                        }
                    }
                }
                html_writer.Close();
                using (Stream stream = new FileStream(path, FileMode.Open))
                {
                    HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
                    document = htmlProvider.Import(stream);
                    stream.Close();
                    this.radRichTextBox1.Document = document;
                    radRichTextBox1.Refresh();
                    this.radRichTextBox1.HyperlinkClicked       += new System.EventHandler <Telerik.WinControls.RichTextBox.Model.HyperlinkClickedEventArgs>(this.HyperlinkClicked);
                    this.radRichTextBox1.HyperlinkNavigationMode =
                        Telerik.WinControls.RichTextBox.HyperlinkNavigationMode.Click;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#30
0
 private void PrepareDocument(string content)
 {
     HtmlFormatProvider provider = new HtmlFormatProvider();
     RadDocument document = provider.Import(content);
     this.docCertificate.Document = document;
 }