public ActionResult PdfResultsView(string all) { using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) { Document document = new Document(PageSize.A4, 10, 10, 10, 10); PdfWriter writer = PdfWriter.GetInstance(document, memoryStream); document.Open(); Story modelStory = new Story(); DropdownModel model = new DropdownModel(); //Create a single column table var t = new PdfPTable(1); //Tell it to fill the page horizontally t.WidthPercentage = 100; //Create a single cell var c = new PdfPCell(); //Tell the cell to vertically align in the middle c.VerticalAlignment = Element.ALIGN_MIDDLE; //Tell the cell to fill the page vertically c.MinimumHeight = document.PageSize.Height - (document.BottomMargin + document.TopMargin); //Create a test paragraph //var p = new Paragraph(" EBook Custom Favorite Recipes from whatscookingtreasures.com"); //Add it a couple of times //c.AddElement(p); var imagePath1 = Server.MapPath("~/content/album.jpg"); iTextSharp.text.Image pic1 = iTextSharp.text.Image.GetInstance(imagePath1); //pic1.BorderWidth = 0; pic1.BorderColor = Color.WHITE; c.AddElement(pic1); //Add the cell to the paragraph t.AddCell(c); //Add the table to the document document.Add(t); document.NewPage(); string[] rowschosen = all.Split('|'); int length = rowschosen.Length; for (int i = 0; i < length; i++) { var jatakaID = Convert.ToInt16(rowschosen[i]); GetLookups myGetLookups = new GetLookups(); modelStory = myGetLookups.GetSpecificStory(jatakaID); var Stories = modelStory.Stories; Paragraph para = new Paragraph(Stories); para.Font = FontFactory.GetFont(FontFactory.HELVETICA, 14f); document.Add(para); if (i != length - 1) { document.NewPage(); } } document.Close(); byte[] bytes = memoryStream.ToArray(); memoryStream.Close(); Response.Clear(); Response.ContentType = "application/pdf"; string pdfName = "User"; Response.AddHeader("Content-Disposition", "attachment; filename=" + pdfName + ".pdf"); Response.ContentType = "application/pdf"; Response.Buffer = true; Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); Response.BinaryWrite(bytes); Response.End(); Response.Close(); } //using (MemoryStream ms = new MemoryStream()) //using (Document document = new Document(PageSize.A4, 25, 25, 30, 30)) //using (PdfWriter writer = PdfWriter.GetInstance(document, ms)) //{ // document.Open(); // document.NewPage(); // //Create a single column table // var t = new PdfPTable(1); // //Tell it to fill the page horizontally // t.WidthPercentage = 100; // //Create a single cell // var c = new PdfPCell(); // //Tell the cell to vertically align in the middle // c.VerticalAlignment = Element.ALIGN_MIDDLE; // //Tell the cell to fill the page vertically // c.MinimumHeight = document.PageSize.Height - (document.BottomMargin + document.TopMargin); // //Create a test paragraph // //var p = new Paragraph(" EBook Custom Favorite Recipes from whatscookingtreasures.com"); // //Add it a couple of times // //c.AddElement(p); // var imagePath1 = Server.MapPath("~/images/worldmap3.jpg"); // iTextSharp.text.Image pic1 = iTextSharp.text.Image.GetInstance(imagePath1); // c.AddElement(pic1); // //Add the cell to the paragraph // t.AddCell(c); // //Add the table to the document // document.Add(t); // var rows = all; // rows = all.Trim(); // if (rows.EndsWith("|")) // { // rows = rows.Remove(rows.Length - 1, 1); // } // //ViewData["all"] = rows; // Story modelStory = new Story(); // DropdownModel model = new DropdownModel(); // string[] rowschosen = rows.Split('|'); // int length = rowschosen.Length; // for (int i = 0; i < length; i++) // { // var jatakaID = Convert.ToInt16(rowschosen[i]); // GetLookups myGetLookups = new GetLookups(); // modelStory = myGetLookups.GetSpecificStory(jatakaID); // var Stories = modelStory.Stories; // document.NewPage(); // //define a bold font to be used // Font boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12); // var phrase = new Phrase(); // phrase.Add(new Chunk(s.Title, boldFont)); // Paragraph paragraph1 = new Paragraph(); // paragraph1.Add(phrase); // document.Add(paragraph1); // PdfPTable table = new PdfPTable(2); // table.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER; // Paragraph paragraphBreak = new Paragraph(); // paragraphBreak.Add(" "); // document.Add(paragraphBreak); // //document.Add(paragraphBreak); // string comments = Stories; // //comments = HttpUtility.HtmlDecode(comments); // if (comments.Length > 0) // { // StringWriter myWriter = new StringWriter(); // // Decode the encoded string. // HttpUtility.HtmlDecode(comments, myWriter); // comments = myWriter.ToString(); // MemoryStream memStream = new MemoryStream(); // TextReader xmlString = new StringReader(comments); // byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(comments); // MemoryStream msComments = new MemoryStream(byteArray); // XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, msComments, System.Text.Encoding.UTF8); // } // document.Add(paragraphBreak); // //document.Add(paragraphBreak); // document.Add(table); // //document.Add(new Paragraph(IngredHTML)); // } // } // document.Close(); // writer.Close(); // ms.Close(); // Response.ContentType = "pdf/application"; // Response.AddHeader("content-disposition", "attachment;filename=whatscookingtreasures_PDF_document.pdf"); // Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length); //} //return View("PdfResultsView"); return(View()); }
/// <summary> /// /// </summary> /// <param name="row"></param> /// <returns></returns> public ActionResult Update(int row) { Story myStory = new Story(); DropdownModel model = new DropdownModel(); GetLookups myGetLookups = new GetLookups(); Story modelStory = new Story(); modelStory = myGetLookups.GetSpecificStory(row); var ID1 = modelStory.ID.ToString(); ViewData["id"] = ID1; var JakataID = modelStory.JakataID; var JakataIDString = modelStory.JakataID.ToString(); ViewData["JakataID"] = JakataIDString; var Comments = modelStory.Comments; var Moraltype = modelStory.MoralType; var Stories = modelStory.Stories; var StoryCategorytName = modelStory.StoryCategorytName; var Title = modelStory.Title; ViewData["comments"] = Comments; ViewData["Stories"] = Stories; ViewData["searchResults"] = row; model = myGetLookups.GeLookupSpecificStoryDropdown(); //DropdownModel model = new DropdownModel(); model = myGetLookups.GeLookupAnimal(); var AnimalType = modelStory.AnimalType; AnimalType = AnimalType.Trim(); if (AnimalType.EndsWith(",")) { AnimalType = AnimalType.Remove(AnimalType.Length - 1, 1); } string[] Animalchosen = AnimalType.Split(','); //model = new DropdownModel(); model = myGetLookups.GeLookupAnimal(); for (int i = 0; i < Animalchosen.Length; i++) { var x = Animalchosen[i]; foreach (SelectListItem s in model.items) { if (s.Value == x) { s.Selected = true; } } } ViewData["animalTypeData"] = model.items; myStory.animalCombo = model; GetLookups myYouTubeGetLookups = new GetLookups(); model = myYouTubeGetLookups.GetYouTube(JakataID); //ViewData["youTubeData"] = model.items; myStory.youTubeCombo = model; //modelAnimal = model; DropdownModel modelMoral = new DropdownModel(); //modelMoral = myGetLookups.GeLookupMoral(); model = myGetLookups.GeLookupMoral(); var moral = Moraltype.ToString(); foreach (SelectListItem s in model.items) { if (s.Value == moral) { s.Selected = true; } } ViewData["moralTypeData1"] = model.items; model = myGetLookups.GeLookupStorySource(); ViewData["storySourceData"] = model.items; model = myGetLookups.GeLookupJakataMaster(); var title = JakataID.ToString(); foreach (SelectListItem s in model.items) { if (s.Value == title) { s.Selected = true; } } ViewData["jakataMasterData"] = model.items; // titles done model = myGetLookups.GetStatus(1); ViewData["Done"] = model.items; myStory.done = model; model = myGetLookups.GetStatus(0); myStory.toDo = model; ViewData["ToDo"] = model.items; return(View(myStory)); }
//[AcceptVerbs(HttpVerbs.Post)] public ActionResult SearchResults(String searchResults, string page, int userIdPost) { Story modelStory = new Story(); Story myStory = new Story(); if (searchResults == "") { return(View(myStory)); } ViewBag.Message = "Your app description page."; //page = "0"; //if (page == "0") //{ // page = "1"; //} //else //{ // int pagenum = Convert.ToInt16(page) * 10; // page = pagenum.ToString(); //} ViewData["currentPage"] = page; var rows = searchResults; rows = searchResults.Trim(); if (rows.EndsWith("|")) { rows = rows.Remove(rows.Length - 1, 1); } ViewData["searchResults"] = rows; string[] rowschosen = rows.Split('|'); string choosen = ""; try { choosen = rowschosen[Convert.ToInt16(page) - 1]; } catch (Exception ex) { choosen = rows; } //string choosen = rowschosen[Convert.ToInt16(page)]; int total1 = rowschosen.Count(); string total = total1.ToString(); int pages = 0; try { pages = total1; ViewData["total"] = pages; } catch { ViewData["total"] = 0; } int row = Convert.ToInt16(choosen); DropdownModel model = new DropdownModel(); GetLookups myGetLookups = new GetLookups(); modelStory = myGetLookups.GetSpecificStory(row); var ID1 = modelStory.ID.ToString(); ViewData["id"] = ID1; var JakataID = modelStory.JakataID; var JakataIDString = modelStory.JakataID.ToString(); ViewData["JakataID"] = JakataIDString; var Comments = modelStory.Comments; var Moraltype = modelStory.MoralType; var Stories = modelStory.Stories; var StoryCategorytName = modelStory.StoryCategorytName; var Title = modelStory.Title; ViewData["comments"] = Comments; ViewData["Stories"] = Stories; model = myGetLookups.GeLookupSpecificStoryDropdown(); //DropdownModel model = new DropdownModel(); model = myGetLookups.GeLookupAnimal(); var AnimalType = modelStory.AnimalType; if (AnimalType != null) { AnimalType = AnimalType.Trim(); if (AnimalType.EndsWith(",")) { AnimalType = AnimalType.Remove(AnimalType.Length - 1, 1); } string[] Animalchosen = AnimalType.Split(','); //model = new DropdownModel(); model = myGetLookups.GeLookupAnimal(); for (int i = 0; i < Animalchosen.Length; i++) { var x = Animalchosen[i]; foreach (SelectListItem s in model.items) { if (s.Value == x) { s.Selected = true; } } } } ViewData["animalTypeData"] = model.items; //Story myStory = new Story(); myStory.animalCombo = model; int userID = modelStory.UserID; //modelAnimal = model; DropdownModel modelMoral = new DropdownModel(); modelMoral = myGetLookups.GeLookupMoral(); var moral = Moraltype.ToString(); foreach (SelectListItem s in modelMoral.items) { if (s.Value == moral) { s.Selected = true; } } ViewData["moralTypeData"] = modelMoral.items; model = myGetLookups.GeLookupStorySource(); ViewData["storySourceData"] = model.items; model = myGetLookups.GeLookupJakataMaster(); var title = JakataID.ToString(); foreach (SelectListItem s in model.items) { if (s.Value == title) { s.Selected = true; } } ViewData["jakataMasterData"] = model.items; // titles done model = myGetLookups.GetStatus(1); ViewData["Done"] = model.items; myStory.done = model; model = myGetLookups.GetStatus(0); myStory.toDo = model; ViewData["ToDo"] = model.items; ViewData["myStory"] = myStory; myStory.Stories = (string)ViewData["Stories"]; model = myGetLookups.GeLookupCatUsers(2); myStory.ReadersCombo = model; foreach (SelectListItem s in model.items) { if (s.Value == userID.ToString()) { s.Selected = true; modelStory.UserName = s.Text; if (s.Value == "0") { modelStory.UserName = ""; } } } ViewData["userIdPost"] = userIdPost; GetLookups myYouTubeGetLookups = new GetLookups(); model = myYouTubeGetLookups.GetYouTube(JakataID, userIdPost); myStory.youTubeCombo = model; GetStories myGetstories = new GetStories(); //modelStory.StoryCategorytNameString =myGetstories.GetStoryCategoryNameByID(StoryCategorytName); modelStory.StoryCategorytNameString = myGetLookups.GetStoryCategoryNameByID(StoryCategorytName); return(View(modelStory)); }
public ActionResult Project(int row, int userID, string userName, string mode) { ViewBag.Title = "Project"; Story myStory = new Story(); myStory.userName = userName; myStory.userID = userID; ViewData["userID"] = userID; myStory.Mode = mode; ViewData["Mode"] = mode; DropdownModel model = new DropdownModel(); DropdownModel modelAnimal = new DropdownModel(); GetLookups myGetLookups = new GetLookups(); model = myGetLookups.GeLookupPosted(); myStory.Posted = model; myStory = myGetLookups.GetReaderstory(row, userID); //var title = JakataID.ToString(); foreach (SelectListItem s in model.items) { if (s.Value == myStory.PostedString) { s.Selected = true; } } ViewData["postedData"] = model.items; //ilustrators //model = myGetLookups.GeLookupCatUsers(1); model = myGetLookups.GeLookupCatUsers(1); if (mode == "edit") { var IllustrationType = myStory.Illustrations; IllustrationType = IllustrationType.Trim(); if (IllustrationType.EndsWith(",")) { IllustrationType = IllustrationType.Remove(IllustrationType.Length - 1, 1); } string[] Illustrationchosen = IllustrationType.Split(','); //model = new DropdownModel(); //model = myGetLookups.GeLookupAnimal(); for (int i = 0; i < Illustrationchosen.Length; i++) { var x = Illustrationchosen[i]; foreach (SelectListItem s in model.items) { if (s.Value == x) { s.Selected = true; } } } //ViewData["animalTypeData"] = model.items; myStory.IllustrationsCombo = model; } myStory.IllustrationsCombo = model; //ViewData["IllustrationsData"] = model.items; model = myGetLookups.GeLookupCatUsers(2); myStory.ReadersCombo = model; //ViewData["ReadersData"] = model.items; //model = myGetLookups.GeLookupCatUsers(3); model = myGetLookups.GeLookupCatUsers(3); if (mode == "edit") { var MusicType = myStory.Music; MusicType = MusicType.Trim(); if (MusicType.EndsWith(",")) { MusicType = MusicType.Remove(MusicType.Length - 1, 1); } string[] Musicchosen = MusicType.Split(','); //model = new DropdownModel(); //model = myGetLookups.GeLookupAnimal(); //model = myGetLookups.GeLookupCatUsers(3); for (int i = 0; i < Musicchosen.Length; i++) { var x = Musicchosen[i]; foreach (SelectListItem s in model.items) { if (s.Value == x) { s.Selected = true; } } } //ViewData["animalTypeData"] = model.items; myStory.MusicCombo = model; } myStory.MusicCombo = model; //ViewData["MusicData"] = model.items; model = myGetLookups.GeLookupCatUsers(4); if (mode == "edit") { myStory.DanceCombo = model; var DanceType = myStory.Dance; DanceType = DanceType.Trim(); if (DanceType.EndsWith(",")) { DanceType = DanceType.Remove(DanceType.Length - 1, 1); } string[] Dancechosen = DanceType.Split(','); //model = new DropdownModel(); //model = myGetLookups.GeLookupAnimal(); //model = myGetLookups.GeLookupCatUsers(1); for (int i = 0; i < Dancechosen.Length; i++) { var x = Dancechosen[i]; foreach (SelectListItem s in model.items) { if (s.Value == x) { s.Selected = true; } } } } //ViewData["animalTypeData"] = model.items; myStory.DanceCombo = model; //ViewData["DanceData"] = model.items; model = myGetLookups.GeLookupCatUsers(5); myStory.AdminCombo = model; //ViewData["AdminData"] = model.items; model = myGetLookups.GeLookupJakataMaster(); ViewData["jakataMasterData"] = model.items; model = myGetLookups.GeLookupStorySource(); ViewData["storySourceData"] = model.items; model = myGetLookups.GeLookupJakataMaster(); Story modelStory = new Story(); modelStory = myGetLookups.GetSpecificStory(row, "jakataID"); var ID1 = modelStory.ID.ToString(); ViewData["id"] = ID1; var JakataID = modelStory.JakataID; var JakataIDString = modelStory.JakataID.ToString(); ViewData["JakataID"] = JakataIDString; var title = JakataID.ToString(); foreach (SelectListItem s in model.items) { if (s.Value == title) { s.Selected = true; myStory.TitleString = s.Text; } } GetLookups myYouTubeGetLookups = new GetLookups(); model = myYouTubeGetLookups.GetYouTube(JakataID, userID); //ViewData["youTubeData"] = model.items; myStory.youTubeCombo = model; ViewData["jakataMasterData"] = model.items; //myStory.Posted = "0"; return(View(myStory)); }