protected void Page_Load(object sender, EventArgs e) { String cmd = Request["cmd"]; int showid = Convert.ToInt32(Request["showid"]); int showDetailsID = -1; if (!String.IsNullOrEmpty(Request["ShowDetailsID"])) showDetailsID = Convert.ToInt32(Request["ShowDetailsID"]); ShowDetails showDetails = new ShowDetails(); showDetails.ShowID = showid; DataTable showDays = showDetails.GetDays(); foreach (DataRow showDayRow in showDays.Rows) { showDetailsID = Convert.ToInt32(showDayRow["ShowDetailID"]); DateTime showDate = Convert.ToDateTime(showDayRow["ShowDate"]); Response.Write( showDate.ToString("<h2>ddd, dd MMM yyyy</h2>")); ShowDetails currentShowDate = new ShowDetails(showDetailsID); Rings rings = new Rings(); DataSet ringsTable = rings.GetRingsForShowDay(showDetailsID); int lastRingNo = 0; foreach (DataRow row in ringsTable.Tables[0].Rows) { int ringID = Convert.ToInt32(row["RingID"]); if (ringID > -1 && lastRingNo != Convert.ToInt32(row["RingNo"])) { lastRingNo = Convert.ToInt32(row["RingNo"]); Response.Write(String.Format("<p>Ring: {0}</p>", lastRingNo)); DataSet judgesDS = rings.GetJudgesForRing(ringID); if (judgesDS.Tables.Count > 0) { foreach (DataRow judgeRow in judgesDS.Tables[0].Rows) { Response.Write(String.Format("<p>Judge: {0}</p>", judgeRow["Name"])); Judge judge = new Judge(judgeRow); DataSet classesDS = judge.getClassesForJudge(); if (classesDS.Tables.Count > 0) { foreach (DataRow classRow in classesDS.Tables[0].Rows) { Response.Write(String.Format(" {2,-5} {3} {4} {7} {5} {6} ({1})<br>", classRow["ClassID"], CalcDogsInCalc(classRow), classRow["ClsNo"], ShowClasses.expandHeight(classRow), ShowClasses.expandCatagory(classRow), classRow["LongName"], classRow["Name"], ShowClasses.shortenGrades(classRow) )); } } } } //ringContainer.InnerHtml += String.Format(ringTemplate, lastRingNo, 1, judges, classes, ringID, helperList); Response.Write("<br><br>"); } } Response.Write("<br><hr><br>"); } }
protected void Page_Load(object sender, EventArgs e) { int ShowDetailsID = Convert.ToInt32(Request["showdetailsid"]); int ShowDayID = Convert.ToInt32(Request["dayid"]); ShowDetails _showDetails = new ShowDetails(ShowDayID); DataRowCollection getDayRowData = _showDetails.GetDayData(ShowDayID, true); String res = "<table id='classDetails' showDetailsID='" + ShowDetailsID.ToString() + "'>"; String tmp = ""; tmp += "<tr>"; String dateThing = getDateOrdinalSuffix(_showDetails.ShowDate.Day); tmp += "<td class='classHeader' colspan='5'>" + _showDetails.ShowDate.ToString("dddd MMM d").ToUpper() + dateThing + " CLASSES</td>"; tmp += "<td>"; tmp += "<tr class='tableHeader'>"; tmp += "<td class='clsno'></td>"; tmp += "<td class='name'> </td>"; tmp += "<td class='grades'></td>"; tmp += "<td class='cat'></td>"; tmp += "<td class='height'></td>"; tmp += "</tr>"; res += tmp; foreach (DataRow row in getDayRowData) { ShowClasses sc = new ShowClasses(row); tmp = "<tr id='" + sc.ID + "' class='tableItem' >"; String grades = ""; grades = "<table class='gradeTable' style='border:none'><tr>"; String str = sc.Grades; for (int i = 1; i <= 7; i++) { grades += "<td grade='" + i.ToString() + "' >"; if (str.IndexOf((char)(i + 48)) > -1) { grades += i.ToString(); } grades += "</td>"; } grades += "</tr></table>"; tmp += String.Format("<td class='clsno'>Class {0}</td>", sc.ClassNo); tmp += String.Format("<td class='name'><div >{0} {1} {2} </div></td>", ShowClasses.expandHeight(row), sc.LongClassName, sc.ClassName); tmp += String.Format("<td class='cat'>{0}</td>", ShowClasses.expandCatagory(row) ); tmp += String.Format("<td class='grades'>{0}</td>", grades); tmp += "</tr>"; res += tmp; } res += "</table>"; previewArea.InnerHtml = res; }
public void ProcessRequest(HttpContext context) { int ShowID = Convert.ToInt32(context.Request["showid"]); int RingID = Convert.ToInt32(context.Request["ringid"]); String cmd = context.Request["doc"].ToString(); Shows show = new Shows(ShowID); ShowDetails sd = new ShowDetails(); DataTable table = sd.GetShowDetails(ShowID).Tables[0]; String pdfPath = context.Server.MapPath(cmd + ".pdf"); Boolean publish = false; if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true; Document doc = new Document(PageSize.A4, -50, -50, 2, 2); Stream output; if (publish) { String path = context.Server.MapPath(@"..\schedules\"); path += DateTime.Today.ToString("yyyy"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName); output = new FileStream(path, FileMode.Create); } else { output = new MemoryStream(); } var writer = PdfWriter.GetInstance(doc, output); StyleSheet sheet = new StyleSheet(); doc.Open(); Font smallFont = new Font(Font.COURIER, 8, Font.NORMAL, Color.BLACK); Font normalFont = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK); Font headerFont = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK); Font ClassTitleFont = new Font(Font.HELVETICA, 16, Font.NORMAL, Color.BLACK); Font bigFont = new Font(Font.HELVETICA, 25, Font.NORMAL, Color.BLACK); Font mediumFont = new Font(Font.HELVETICA, 20, Font.NORMAL, Color.BLACK); ShowClasses sc = new ShowClasses(); Rings currentRing = new Rings(RingID); List<ShowClasses> showClasses = ShowClasses.GetAllClassesForShowRing(ShowID, RingID); PdfPTable callingListTbl = null; foreach (ShowClasses showClass in showClasses) { List<int> resultCnts = ShowClasses.getDogsInClass(showClass.ID, (showClass.Catagory == 0)); int gradeidx = 0; foreach (int dogCounts in resultCnts) { PdfPTable ptable = new PdfPTable(3); PdfPCell cell; String grades; String subTitle; if (showClass.Catagory == 0) { if (gradeidx < showClass.Grades.Length) { grades = "Grade " + showClass.Grades[gradeidx]; } else { grades = showClass.Grades; } subTitle = String.Format("{0} {1} {2} {3} - Judge: {4}", showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, Judge.getJudgeForClass(showClass.ID)); } else { if (showClass.Grades.Length == 1) { grades = showClass.Grades; } else { grades = showClass.Grades[0] + " - " + showClass.Grades[showClass.Grades.Length - 1]; } subTitle = String.Format("{0} {1} {3} {2} - Judge: {4}", showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, Judge.getJudgeForClass(showClass.ID)); } String tmp = String.Format("Result Sheet - Ring No:{0}", currentRing.RingNo); cell = new PdfPCell(new Phrase(new Chunk(tmp, bigFont))); cell.Colspan = 2; cell.BorderWidth = 0; ptable.AddCell(cell); tmp = String.Format("Class No:{0}", showClass.ClassNo); cell = new PdfPCell(new Phrase(new Chunk(tmp, bigFont))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BorderWidth = 2; cell.Padding = 5; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(subTitle, mediumFont))); cell.Colspan = 3; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", ClassTitleFont))); cell.Colspan = 3; cell.BorderWidth = 0; ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); doc.Add(ptable); float[] colWidths = { 75, 75, 200, 200, 50, 75 }; callingListTbl = new PdfPTable(colWidths); cell = new PdfPCell(new Phrase(new Chunk("Place", headerFont))); cell.BorderWidth = 1; cell.BorderWidthBottom = 0; cell.FixedHeight = 35f; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Ring Number", headerFont))); cell.BorderWidth = 1; cell.BorderWidthBottom = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Handler", headerFont))); cell.BorderWidth = 1; cell.BorderWidthBottom = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Dog Name", headerFont))); cell.BorderWidth = 1; cell.BorderWidthBottom = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Clear/ Faults", headerFont))); cell.BorderWidth = 1; cell.BorderWidthBottom = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Time", headerFont))); cell.BorderWidth = 1; cell.BorderWidthBottom = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); int maxRosettes = calcRosettes(dogCounts); int maxTrophies = calcTrophies(dogCounts); float rowHeight = 25f; if (showClass.EntryType == 4) { rowHeight = 65f; } else if (showClass.EntryType == 5) { rowHeight = 120f; } for (int resultRow = 0; resultRow < maxRosettes; resultRow++) { int bwb = 0; if (resultRow == maxRosettes - 1) { bwb = 1; } Color background = Color.WHITE; if (maxTrophies > 0) { background = Color.LIGHT_GRAY; } maxTrophies--; cell = new PdfPCell(new Phrase(new Chunk(calcPlace(resultRow + 1), normalFont))); cell.BorderWidth = 1; cell.BorderWidthBottom = bwb; cell.FixedHeight = rowHeight; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BackgroundColor = background; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", normalFont))); cell.BorderWidth = 1; cell.BackgroundColor = background; cell.BorderWidthBottom = bwb; callingListTbl.AddCell(cell); callingListTbl.AddCell(cell); callingListTbl.AddCell(cell); callingListTbl.AddCell(cell); callingListTbl.AddCell(cell); } doc.Add(callingListTbl); doc.NewPage(); gradeidx++; } } doc.Close(); if (publish) { } else { context.Response.ClearContent(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf")); context.Response.BinaryWrite((output as MemoryStream).ToArray()); } }
private String generateClassesForDay(int ShowDetailsID, DataTable showDayTable) { ShowDetails _showDetails = new ShowDetails(ShowDetailsID); String res = "<table id='classDetails' style='font-family:Verdana; font-size:16pt;'>"; String tmp = ""; String dateThing = getDateOrdinalSuffix(_showDetails.ShowDate.Day); tmp += "<tr><td class='classHeader' colspan='5'>" + _showDetails.ShowDate.ToString("dddd MMM d").ToUpper() + dateThing + " CLASSES</td></tr>"; tmp += "</table>"; res += tmp; //tmp += "<tr><th>Class No</th><th>Class Name</th><th>Classes</th><th>Judge</th></tr>"; foreach (DataRow row in showDayTable.Rows) { tmp = "<table border='1' id='classDetails' style='font-family:Verdana; font-size:10pt;'>"; tmp += "<tr class='tableItem' >"; String grades = ""; grades = "<table class='gradeTable' style='border:dotted 1px #000000'><tr>"; String str = row["grades"].ToString(); for (int i = 1; i <= 7; i++) { grades += "<td grade='" + i.ToString() + "' >"; if (str.IndexOf((char)(i + 48)) > -1) { grades += i.ToString(); } grades += "</td>"; } grades += "</tr></table>"; tmp += String.Format("<td style='width:50px' class='clsno'>{0}</td>", row["ClsNo"]); tmp += String.Format("<td class='name'>{0}</td>", row["Name"]); tmp += String.Format("<td class='grades'>{0}</td>", grades); tmp += String.Format("<td class='judge'>{0}</td>", row["JudgeName"]); tmp += "</tr></table>"; res += tmp; } return res; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { JumpHeights = ""; foreach (String s in ShowClasses.HEIGHTNAMES) { if (JumpHeights.Length > 0) JumpHeights += ","; JumpHeights += String.Format("'{0}'", s); } JumpHeights = "[" + JumpHeights + "]"; String cmd = Request["cmd"]; if (Session["showid"] != null) { _showid = Convert.ToInt32(Session["showid"]); } else { _showid = Convert.ToInt32(Request["showid"]); Session["showid"] = _showid.ToString(); } _orgID = Convert.ToInt32(Session["OrgID"]); ShowID.Value = _showid.ToString(); if (cmd == "edit") { Shows show = new Shows(_showid); _showStatus = show.Status; ShowDetails showDetails = new ShowDetails(); showDetails.GetFrom(_showid); ShowDetailsID.Value = showDetails.ShowDetailsID.ToString(); edtClosingDate.Value = "(not set)"; DateTime tmp = new DateTime(); if (show.ClosingDate.CompareTo(tmp) != 0) { edtClosingDate.Value = show.ClosingDate.ToString("dd MMM yyyy"); } edtShowDate.Value = show.ShowDate.ToString("dd MMM yyyy"); dspShowDate.Value = edtShowDate.Value; edtVenue.Value = (!DBNull.Value.Equals(show.Venue) ? show.Venue : ""); edtVenuePostcode.Value = (!DBNull.Value.Equals(show.VenuePostcode) ? show.VenuePostcode : ""); edtShowName.Value = show.ShowName; initialShowDate.Value = String.Format("{0:dd MMM yyyy}", show.ShowDate); System.Web.UI.HtmlControls.HtmlTableRow row = new HtmlTableRow(); System.Web.UI.HtmlControls.HtmlTableCell cell = new HtmlTableCell(); row.Attributes.Add("class", "tableHeader"); cell.InnerHtml = "Show Day"; cell.Attributes.Add("class", "showDate"); row.Cells.Add(cell); cell = new HtmlTableCell(); cell.InnerHtml = "Classes"; cell.Attributes.Add("class", "classSummary"); row.Cells.Add(cell); cell = new HtmlTableCell(); cell.InnerHtml = "<input id='btnNewDay' type='button' value='New Day' /><input id='btnRenumber' type='button' value='Renumber' />"; row.Cells.Add(cell); summaryDetails.Rows.Add(row); DataTable table = showDetails.GetAllShows().Tables[0]; if (table != null) { foreach (DataRow dataRow in table.Rows) { row = new HtmlTableRow(); row.Attributes.Add("class", "tableDetails"); row.Attributes.Add("showdate", String.Format("{0:yyyy-MM-dd}", dataRow["ShowDate"])); row.Attributes.Add("id", String.Format("day_{0}", dataRow["ShowDetailID"])); row.Attributes.Add("classdaylimit", String.Format("{0}", dataRow["ClassLimit"])); cell = new HtmlTableCell(); cell.InnerHtml = String.Format("{0:dddd, dd MMM}", dataRow["ShowDate"]); cell.Attributes.Add("class", "showDate"); row.Cells.Add(cell); cell = new HtmlTableCell(); cell.InnerHtml = String.Format("({0} Classes)", dataRow["Classes"]); cell.Attributes.Add("class", "classNumber"); row.Cells.Add(cell); cell = new HtmlTableCell(); cell.Attributes.Add("class", "classControls"); cell.InnerHtml = "<span class='del'>Del</span><span class='copy'>Copy</span>"; row.Cells.Add(cell); summaryDetails.Rows.Add(row); } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { String cmd = Request["cmd"]; int showid = Convert.ToInt32(Request["showid"]); int showDetailsID = -1; if (!String.IsNullOrEmpty(Request["ShowDetailsID"])) showDetailsID = Convert.ToInt32(Request["ShowDetailsID"]); ShowID.Value = showid.ToString(); ShowDetails showDetails = new ShowDetails(); showDetails.ShowID = showid; DataTable showDays = showDetails.GetDays(); foreach ( DataRow row in showDays.Rows) { int currentShowDetailsID = Convert.ToInt32(row["ShowDetailID"]); if (showDetailsID == -1) showDetailsID = currentShowDetailsID; DateTime showDate = Convert.ToDateTime(row["ShowDate"]); selShowDays.Items.Add(new ListItem(showDate.ToString("ddd, dd MMM yyyy"), row["ShowDetailID"].ToString() )) ; if (showDetailsID == currentShowDetailsID) { selShowDays.SelectedIndex = selShowDays.Items.Count - 1; } } ShowDetails currentShowDate = new ShowDetails(showDetailsID); ShowDetailsID.Value = showDetailsID.ToString(); String tmp = ""; DataRowCollection unallocatedClasses = showDetails.getUnallocatedClassFoDay(showDetailsID); foreach (DataRow row in unallocatedClasses) { tmp += String.Format("<li class='ui-state-default classDetails'><div clsid='{0}' dogsinclass='{1}' judgeid='{7}' class='clsDetails' ><div class='clsNo'>{2}</div><div class='clsName'>{3} {4} {8} {5} {6}</div></div></li>", row["ClassID"], row["DogsInClass"], row["ClsNo"], ShowClasses.expandHeightShort(row), ShowClasses.expandCatagoryShort(row), row["ShortName"], row["Name"], row["JudgeID"], ShowClasses.shortenGrades(row) ); } classesAvailable.InnerHtml = tmp; Rings rings = new Rings(); DataSet ringsTable = rings.GetRingsForShowDay(showDetailsID); //DataSet judgesTable = rings.GetJudgesRingsForShow(showid); //DataSet helpersTable = rings.GetHelpersRingsForShow(showid); String ringTemplate = "<div class='ring ui-droppable ui-sortable' ringid='{0}' ringno='{1}' dogsinclass='0' judges='' helpers=''><h1 class='ui-widget-header'>Ring {1} (<span class='dogtotal'>0</span>)<span class='delthing'>X</span></h1>"; String ringJudgeClassTemplate = "<div class='judgeAndClasses'><h2 class='judgeInfo'><span class='judgeName'>{0}</span></h2><div class='classListArea'><ul class='ui-sortable fpp_sort'>{1}</ul><ul class='ui-sortable helperlist' style='display:none'>{2}</ul></div></div>"; int lastRingNo = 0; foreach (DataRow ringTableRow in ringsTable.Tables[0].Rows) { Rings ring = new Rings(ringTableRow); if (ring.ID> -1 && lastRingNo != ring.RingNo ) { lastRingNo = ring.RingNo; String ringTmp = String.Format(ringTemplate, ring.ID, ring.RingNo); DataSet judgesDS = rings.GetJudgesForRing(ring.ID); if (judgesDS.Tables[0].Rows.Count > 0) { foreach (DataRow judgeRow in judgesDS.Tables[0].Rows) { Judge judge = new Judge(judgeRow); ringTmp += CreateRing(currentShowDate, ring, judge, ringJudgeClassTemplate, lastRingNo); } } else { ringTmp += CreateRing(currentShowDate, ring, new Judge(), "", lastRingNo); } ringTmp += "</div>"; ringContainer.InnerHtml += ringTmp; } } tmp = ""; DataSet ds = Judge.GetAllFreeJudgesForShow(showDetailsID); foreach (DataRow row in ds.Tables[0].Rows) { tmp += String.Format("<li class='ui-state-default judgeDetails'><div judgeid='{0}' class='judgeDetails'>{1}</div></li>", row["JudgeID"], row["Name"] ); } judgesAvailable.InnerHtml = tmp; tmp = ""; Helpers helpers = new Helpers(); ds = helpers.GetAllFreeHelpersForShow(showid, currentShowDate.ShowDate); if (ds.Tables.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { Helpers h = new Helpers(row); String job = expandJob(h.Job, h.JobDetails); tmp += String.Format("<li class='ui-state-default'><div helperid='{0}' judgeid='{2}' class='helperDetails'>{1} ({3})</div></li>", h.ID, h.Name, row["judgeid"], job ); } } helpersAvailable.InnerHtml = tmp; } }
private String CreateRing(ShowDetails currentShowDate, Rings ring, Judge judge, String ringTemplate, int lastRingNo) { DataSet helperDS; String judges; String classes = ""; String helperList = ""; judges = String.Format("<p judgeid='{0}'>{1}</p>", judge.ID.ToString(), judge.Name); //helperDS = rings.GetHelpersForJudge(currentShowDate, Convert.ToInt32(judgeRow["JudgeID"])); //if (helperDS.Tables.Count > 0) //{ // foreach (DataRow helperRow in helperDS.Tables[0].Rows) // { // Helpers h = new Helpers(helperRow); // helperList += String.Format("<li class='ui-draggable' ><div helperid='{0}' class='helperDetails'>{1} ({2})</div></li>", h.ID, h.Name, h.JobName); // } //} helperDS = Helpers.GetHelpersForRing(currentShowDate, ring.ID); if (helperDS.Tables.Count > 0) { foreach (DataRow helperRow in helperDS.Tables[0].Rows) { Helpers h = new Helpers(helperRow); String job = expandJob(h.Job, h.JobDetails); helperList += String.Format("<li class='ui-draggable' ><div helperid='{0}' class='helperDetails'>{1} ({2})</div></li>", h.ID, h.Name, job); } } DataSet classesDS = Rings.GetClassesForRing(ring.ID); classesDS = judge.getClassesForJudge(); if (classesDS.Tables.Count > 0) { foreach (DataRow classRow in classesDS.Tables[0].Rows) { classes += String.Format("<li><div clsid='{0}' dogsinclass='{1}' class='clsDetails'><div class='clstotal'>({1})</div><div class='clsNo'>{2}</div><div class='clsName'>{3} {4} {7} {5} {6}</div></div></li>", classRow["ClassID"], CalcDogsInCalc(classRow), classRow["ClsNo"], ShowClasses.expandHeightShort(classRow), ShowClasses.expandCatagoryShort(classRow), classRow["ShortName"], classRow["Name"], ShowClasses.shortenGrades(classRow) ); } if (classes.Length == 0) { classes = "<li class='blank'></li>"; } } return String.Format(ringTemplate, judges, classes, helperList); }
public void ProcessRequest(HttpContext context) { //PDFBuilder.HtmlToPdfBuilder builder = new HtmlToPdfBuilder(PageSize.A4); //builder.AddPage(); //builder.ImportStylesheet(context.Server.MapPath("pdfstylesheet.css")); int ShowID = Convert.ToInt32(context.Request["showid"]); Shows show = new Shows(ShowID); ShowDetails sd = new ShowDetails(); DataTable table = sd.GetShowDetails(ShowID).Tables[0]; String pdfPath = context.Server.MapPath("PreviewSchedule.pdf"); String contents = File.ReadAllText(context.Server.MapPath("schedule1FrontPage.html")); Boolean publish = false; if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true; String logoImg = context.Server.MapPath("FirstContactAgility.png") ; contents = contents.Replace("[CLUBLOGO]", "src='" + logoImg + "'"); contents = contents.Replace("[SHOWDATES]", show.ShowDate.ToString("dddd, dd MMM yyyy")); contents = contents.Replace("[CLUBNAME]", show.ShowName); contents = contents.Replace("[SHOWVENUE]", show.Venue + ", " + show.VenuePostcode); contents = contents.Replace("[OPENTIME]", "8:00am"); contents = contents.Replace("[BRIEFING]", "8:15am"); contents = contents.Replace("[JUDGINGSTARTS]", "8:30am"); contents = contents.Replace("[SdHOWVENUE]", show.Venue + "," + show.VenuePostcode); contents = contents.Replace("[CLOSINGDATE]", show.ClosingDate.ToString("dd MMM yyyy")); contents = contents.Replace("[CHAIRMANNAME]", show.Chairman.Name); contents = contents.Replace("[CHAIRMANADDRESS]", show.Chairman.AddressDetails); contents = contents.Replace("[SECRETARYNAME]", show.Secretary.Name); contents = contents.Replace("[SECRETARYADDRESS]", show.Secretary.AddressDetails); contents = contents.Replace("[TREASURERNAME]", show.Treasurer.Name); contents = contents.Replace("[TREASURERADDRESS]", show.Treasurer.AddressDetails); contents = contents.Replace("[SHOWSECNAME]", show.ShowSec.Name); contents = contents.Replace("[SHOWSECADDRESS]", show.ShowSec.AddressDetails); contents = contents.Replace("[SHOWMANAGERNAME]", show.ShowManager.Name); contents = contents.Replace("[SHOWMANAGERADDRESS]", show.ShowManager.AddressDetails); contents = contents.Replace("[EQUIPMENTNAME]", show.Equipment.Name); contents = contents.Replace("[EQUIPMENTADDRESS]", show.Equipment.AddressDetails); contents = contents.Replace("[VETNAME]", show.Vet.Name); contents = contents.Replace("[VETADDRESS]", show.Vet.AddressDetails); contents = contents.Replace("[SHOWENTRIESNAME]", show.ShowEntries.Name); contents = contents.Replace("[SHOWENTRIESADDRESS]", show.ShowEntries.AddressDetails); contents = contents.Replace("[PAYABLENAME]", show.Payable.Name); contents = contents.Replace("[PAYABLEADDRESS]", show.Payable.AddressDetails); Document doc = new Document(PageSize.A4, 25, 10, 10, 10); Stream output ; if (publish) { String path = context.Server.MapPath(@"..\schedules\"); path += DateTime.Today.ToString("yyyy"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path += String.Format("\\{0:yyyyMMM}_{1}.pdf", show.ShowDate, show.ShowName); output = new FileStream(path, FileMode.Create); show.setStatus(Shows.SHOW_STATUS.PUBLISHED); } else { output = new MemoryStream(); } var writer = PdfWriter.GetInstance(doc, output); StyleSheet sheet = new StyleSheet(); doc.Open(); var parsedHTML = HTMLWorker.ParseToList(new StringReader(contents), sheet); foreach (var htmlElement in parsedHTML) { doc.Add(htmlElement as IElement); } doc.NewPage(); foreach (DataRow row in table.Rows) { ShowDetails _showDetails = new ShowDetails(row); DataTable showDayTable = _showDetails.GetDayData(true); String dayHtml = generateClassesForDay(_showDetails.ShowDetailsID, showDayTable); doc.NewPage(); var dayClasses = HTMLWorker.ParseToList(new StringReader(dayHtml), sheet); foreach (var htmlElement in dayClasses) { doc.Add(htmlElement as IElement); } }; doc.NewPage(); contents = File.ReadAllText(context.Server.MapPath("schedule2RulesNRegs.html")); parsedHTML = HTMLWorker.ParseToList(new StringReader(contents), sheet); foreach (var htmlElement in parsedHTML) { doc.Add(htmlElement as IElement); } #if TEST foreach (DataRow row in table.Rows) { PdfPTable pdfTable = new PdfPTable(5); ShowDetails _showDetails = new ShowDetails(row); DataTable showDayTable = _showDetails.GetDayData(true); String dateThing = getDateOrdinalSuffix(_showDetails.ShowDate.Day); String datestr = _showDetails.ShowDate.ToString("dddd MMM d").ToUpper() + dateThing; PdfPCell pdfCell = new PdfPCell(); pdfCell = new PdfPCell(new Phrase(datestr )); pdfCell.Colspan = 5; pdfTable.AddCell(pdfCell); pdfTable.AddCell("ClsNo"); pdfCell = new PdfPCell(new Phrase("Name")); pdfCell.Colspan = 3; pdfTable.AddCell(pdfCell); pdfTable.AddCell("Grades"); pdfTable = new PdfPTable(5); foreach (DataRow clsRow in showDayTable.Rows) { PdfPTable grades = new PdfPTable(7); String str = clsRow["grades"].ToString(); for (int i = 1; i <= 7; i++) { if (str.IndexOf((char)(i + 48)) > -1) { grades.AddCell(i.ToString()); } else { grades.AddCell(" "); } } pdfTable.AddCell(clsRow["ClsNo"].ToString() ); pdfCell = new PdfPCell(new Phrase(clsRow["Name"].ToString())); pdfCell.Colspan = 3; pdfTable.AddCell(pdfCell); pdfTable.AddCell(grades); doc.Add(pdfTable); } doc.NewPage(); } #endif doc.Close(); if (publish) { } else { context.Response.ClearContent(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf")); context.Response.BinaryWrite( (output as MemoryStream).ToArray()); } }
public void ProcessRequest(HttpContext context) { int ShowID = Convert.ToInt32(context.Request["showid"]); int RingID = Convert.ToInt32(context.Request["ringid"]); String cmd = context.Request["doc"].ToString(); Shows show = new Shows(ShowID); ShowDetails sd = new ShowDetails(); DataTable table = sd.GetShowDetails(ShowID).Tables[0]; String pdfPath = context.Server.MapPath(cmd + ".pdf"); Boolean publish = false; if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true; Document doc = new Document(PageSize.A4, -50, -50, 2, 2); Stream output; if (publish) { String path = context.Server.MapPath(@"..\schedules\"); path += DateTime.Today.ToString("yyyy"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName); output = new FileStream(path, FileMode.Create); } else { output = new MemoryStream(); } var writer = PdfWriter.GetInstance(doc, output); StyleSheet sheet = new StyleSheet(); doc.Open(); Font font = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK); Font resFont = new Font(Font.COURIER, 9, Font.ITALIC, Color.BLACK); Font headerFont = new Font(Font.COURIER, 10, Font.BOLD, Color.BLACK); Font headerFont2 = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK); Font ClassTitleFont = new Font(Font.HELVETICA, 16, Font.NORMAL, Color.BLACK); ShowClasses sc = new ShowClasses(); Rings currentRing = new Rings(RingID); List<ShowClasses> showClasses = ShowClasses.GetAllClassesForShowRing(ShowID, RingID); foreach (ShowClasses showClass in showClasses) { PdfPTable ptable = new PdfPTable(3); PdfPCell cell; String grades = showClass.Grades; if (grades.Length == 1) { grades = "Grade " + grades; } else { grades = "Grades " + grades[0] + "-" + grades[grades.Length - 1]; } String tmp = String.Format("Ring No:{5} Class No:{0} {1} {2} {3} ({4})", showClass.ClassNo, showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, currentRing.RingNo); cell = new PdfPCell(new Phrase(new Chunk(tmp, ClassTitleFont))); cell.Colspan = 3; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", ClassTitleFont))); cell.Colspan = 3; cell.BorderWidth = 0; ptable.AddCell(cell); ptable.AddCell(cell); ptable.AddCell(cell); doc.Add(ptable); DataSet callingList = sc.getCallingList(ShowID, showClass.ID); float[] colWidths = { 35, 50, 200, 200 }; PdfPTable callingListTbl = new PdfPTable(colWidths); cell = new PdfPCell(new Phrase(new Chunk("RO", headerFont))); cell.BorderWidth = 0; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Ring No", headerFont))); cell.BorderWidth = 0; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Handler", headerFont))); cell.BorderWidth = 0; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Dog Name", headerFont))); cell.BorderWidth = 0; callingListTbl.AddCell(cell); int altFlag = 0; Color altLine = Color.LIGHT_GRAY; foreach (DataRow row in callingList.Tables[0].Rows) { Color altColor = Color.WHITE; if (altFlag % 2 == 0 && showClass.EntryType != 5) { altColor = altLine; } cell = new PdfPCell(new Phrase(new Chunk(row["RO"].ToString(), font))); cell.BorderWidth = 0; cell.BorderWidth = 2; cell.BorderColor = Color.RED; cell.BackgroundColor = altColor; cell.HorizontalAlignment = Element.ALIGN_RIGHT; callingListTbl.AddCell(cell); if (showClass.EntryType == 5) { cell = new PdfPCell(new Phrase(new Chunk("Team Name:", headerFont2))); cell.BackgroundColor = altColor; cell.BorderWidth = 1; cell.Colspan = 2; cell.FixedHeight = 30F; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(ShowClasses.expandHeight(row), headerFont2))); cell.BackgroundColor = altColor; cell.BorderWidth = 1; cell.FixedHeight = 30F; cell.HorizontalAlignment = Element.ALIGN_RIGHT; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", font))); cell.BackgroundColor = altColor; cell.Colspan = 1; cell.BorderWidth = 0; cell.FixedHeight = 30F; callingListTbl.AddCell(cell); } int borderWidth = 0; if (showClass.EntryType == 5) borderWidth = 1; cell = new PdfPCell(new Phrase(new Chunk(row["RingNumber"].ToString(), font))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BackgroundColor = altColor; cell.BorderWidth = borderWidth; callingListTbl.AddCell(cell); int DefaultHandler = Convert.ToInt32(row["DefaultHandler"]); int AltHandler = Convert.ToInt32(row["AltHandler"]); String handlerName = row["Name"].ToString(); User user; if (DefaultHandler > 0) { user = new User(DefaultHandler); handlerName = user.Name; } if (AltHandler > 0) { user = new User(AltHandler); handlerName = user.Name; } cell = new PdfPCell(new Phrase(new Chunk(handlerName, font))); cell.BackgroundColor = altColor; cell.BorderWidth = borderWidth; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(row["KCName"].ToString(), font))); cell.BackgroundColor = altColor; cell.BorderWidth = borderWidth; callingListTbl.AddCell(cell); if (showClass.EntryType == 4 || showClass.EntryType == 5) { int UserID = Convert.ToInt32(row["UserID"]); int DogID = Convert.ToInt32(row["DogID"]); //MultiDog md = new MultiDog(UserID, DogID, showClass.ID); List<MultiDog> otherHandlers = MultiDog.getMultiDog(UserID, DogID, showClass.ID); String reserves = ""; int dogCnt = 0; foreach (MultiDog md in otherHandlers) { String res = ""; if (dogCnt > 2 && md.Handlername.Length > 0) { if (reserves.Length > 0) reserves += "; "; reserves += String.Format("{0} & {1}", md.Handlername, md.Dogname); } if (dogCnt < 3) { cell = new PdfPCell(new Phrase(new Chunk("", font))); cell.BorderWidth = 0; cell.BackgroundColor = altColor; cell.HorizontalAlignment = Element.ALIGN_RIGHT; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(res, font))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BackgroundColor = altColor; cell.BorderWidth = 1; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(md.Handlername, font))); cell.BackgroundColor = altColor; cell.BorderWidth = 1; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(md.Dogname, font))); cell.BackgroundColor = altColor; cell.BorderWidth = 1; callingListTbl.AddCell(cell); } dogCnt++; } cell = new PdfPCell(new Phrase(new Chunk("", font))); cell.BackgroundColor = altColor; cell.BorderWidth = 0; cell.FixedHeight = 30F; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Reserves: " + reserves, resFont))); cell.BackgroundColor = altColor; cell.Colspan = 3; cell.BorderWidth = 1; cell.FixedHeight = 30F; callingListTbl.AddCell(cell); } altFlag++; } doc.Add(callingListTbl); doc.NewPage(); } doc.Close(); if (publish) { } else { context.Response.ClearContent(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf")); context.Response.BinaryWrite((output as MemoryStream).ToArray()); } }
public void ProcessRequest(HttpContext context) { int ShowID = Convert.ToInt32(context.Request["showid"]); Shows show = new Shows(ShowID); String sortby = Convert.ToString(context.Request["sortby"]); ShowDetails sd = new ShowDetails(); DataTable table = sd.GetShowDetails(ShowID).Tables[0]; Document doc = new Document(PageSize.A4, -10, -50, 2, 2); Stream output = new MemoryStream(); var writer = PdfWriter.GetInstance(doc, output); StyleSheet sheet = new StyleSheet(); doc.Open(); Font smallFont = new Font(Font.COURIER, 8, Font.NORMAL, Color.BLACK); Font normalFont = new Font(Font.COURIER, 8, Font.NORMAL, Color.BLACK); Font normalFontBold = new Font(Font.COURIER, 8, Font.BOLD, Color.BLACK); Font headerFont = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK); Font ClassTitleFont = new Font(Font.HELVETICA, 16, Font.NORMAL, Color.BLACK); Font bigFont = new Font(Font.HELVETICA, 25, Font.NORMAL, Color.BLACK); Font mediumFont = new Font(Font.HELVETICA, 20, Font.NORMAL, Color.BLACK); PdfPTable ptable = new PdfPTable(1); PdfPCell cell; cell = new PdfPCell(); cell.FixedHeight = 150; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Master List", bigFont))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BorderWidth = 0; cell.FixedHeight = 100; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(show.ShowName, bigFont))); cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(show.ShowDate.ToString("dd MMM yyyy"), bigFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; ptable.AddCell(cell); doc.Add(ptable); doc.NewPage(); float[] colWidths = { 100, 40, 175, 200}; int count = 0; String lastName = ""; DataSet masterList = DogClasses.getMasterList(ShowID, sortby); String tmp = ""; ptable = new PdfPTable(colWidths); cell = new PdfPCell(new Phrase(new Chunk("Handler Name", headerFont))); cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase("Ring No", headerFont)); cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase("Dog Name", headerFont)); cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase("Class Details", headerFont)); cell.BorderWidth = 0; ptable.AddCell(cell); doc.Add(ptable); bool topBorder = false; Color altLine = new Color(224, 224, 224); foreach (DataRow row in masterList.Tables[0].Rows) { Color altColor = Color.WHITE; if (count % 2 == 0 ) { altColor = altLine; } MasterList masterListItem = new MasterList(row); ptable = new PdfPTable(colWidths); if (lastName == masterListItem.Name) { cell = new PdfPCell(new Phrase(new Chunk("", normalFont))); topBorder = false; } else { topBorder = true; tmp = masterListItem.Name; //if (masterListItem.AltHandler > 0) //{ // User u = new User(masterListItem.AltHandler); // tmp = u.Name; //} cell = new PdfPCell(new Phrase(new Chunk(tmp, normalFont))); cell.BorderColorTop = Color.BLACK; cell.BorderWidthTop = 1; } cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(masterListItem.RingNumber.ToString(), normalFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BackgroundColor = altColor; if (topBorder) { cell.BorderColorTop = Color.BLACK; cell.BorderWidthTop = 1; } ptable.AddCell(cell); Paragraph p = new Paragraph(); Phrase ph = new Phrase(); ph.Add(new Chunk(masterListItem.KCName, normalFont)); ph.Add(Chunk.NEWLINE); ph.Add(new Chunk(masterListItem.KCNumber, normalFont)); cell = new PdfPCell(ph); cell.BorderWidth = 0; cell.BackgroundColor = altColor; if (topBorder) { cell.BorderColorTop = Color.BLACK; cell.BorderWidthTop = 1; } ptable.AddCell(cell); PdfPTable classDetailsTbl = new PdfPTable(1); List<DogClasses> dcList = DogClasses.Retrieve(masterListItem.DogID, ShowID); p = new Paragraph(); bool first = true; foreach (DogClasses dc in dcList) { ShowClasses sc = new ShowClasses(dc.Classid); if (!first) { p.Add(new Chunk(String.Format(", {0,3}:", sc.ClassNo), normalFont)); } else { p.Add(new Chunk(String.Format("{0,3}:", sc.ClassNo), normalFont)); } p.Add(new Chunk(String.Format("{0,3}", dc.RO), normalFontBold)); first = false; } cell = new PdfPCell(p); cell.BorderWidth = 0; classDetailsTbl.AddCell(cell); cell = new PdfPCell(classDetailsTbl); cell.BorderWidth = 0; cell.BackgroundColor = altColor; if (topBorder) { cell.BorderColorTop = Color.BLACK; cell.BorderWidthTop = 1; } ptable.AddCell(cell); doc.Add(ptable); lastName = masterListItem.Name; count++; //if (count > 100 ) break; } doc.Close(); context.Response.ClearContent(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf")); context.Response.BinaryWrite((output as MemoryStream).ToArray()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity; // get the forms authetication ticket of the user FormsAuthenticationTicket ticket = identity.Ticket; // get the roles stored as UserData into the ticket String[] userData = ticket.UserData.Split(':'); String[] roles = userData[0].Split(','); int id = Convert.ToInt32(userData[1]); Fpp.WebModules.Business.User currentUser = new User(id); UserID.Value = currentUser.ID.ToString(); UserName.Value = currentUser.Name; String cmd = Request["cmd"]; int showid = Convert.ToInt32(Request["showid"]); ShowID.Value = showid.ToString(); if (cmd == "edit") { Shows show = new Shows(showid); ShowDetails showDetails = new ShowDetails(); showDetails.GetFrom(showid); ShowDetailsID.Value = showDetails.ShowDetailsID.ToString(); edtClosingDate.Value = show.ClosingDate.ToString("dd MMM yyyy"); edtShowDate.Value = show.ShowDate.ToString("dd MMM yyyy"); edtVenue.Value = show.Venue; edtVenuePostcode.Value = show.VenuePostcode; edtShowName.Value = show.ShowName; initialShowDate.Value = String.Format("{0:dd MMM yyyy}", showDetails.ShowDate); System.Web.UI.HtmlControls.HtmlTableRow row = new HtmlTableRow(); System.Web.UI.HtmlControls.HtmlTableCell cell = new HtmlTableCell(); row.Attributes.Add("class", "tableHeader"); cell.InnerHtml = "Show Day"; cell.Attributes.Add("class", "showDate"); row.Cells.Add(cell); cell = new HtmlTableCell(); cell.InnerHtml = "Classes"; cell.Attributes.Add("class", "classSummary"); row.Cells.Add(cell); cell = new HtmlTableCell(); cell.InnerHtml = "<input id='btnNewDay' type='button' value='New Day' />"; row.Cells.Add(cell); classSummary.Rows.Add(row); DataTable table = showDetails.GetAllShows().Tables[0]; if (table != null) { foreach (DataRow dataRow in table.Rows) { row = new HtmlTableRow(); row.Attributes.Add("class", "tableDetails"); row.Attributes.Add("showdate", String.Format("{0:yyyy-MM-dd}", dataRow["ShowDate"])); row.Attributes.Add("id", String.Format("{0}", dataRow["ShowDetailID"])); cell = new HtmlTableCell(); cell.InnerHtml = String.Format("{0:dddd, dd MMM}", dataRow["ShowDate"]); cell.Attributes.Add("class", "showDate"); row.Cells.Add(cell); cell = new HtmlTableCell(); cell.InnerHtml = String.Format("({0} Classes)", dataRow["Classes"]); cell.Attributes.Add("class", "classNumber"); row.Cells.Add(cell); cell = new HtmlTableCell(); cell.Attributes.Add("class", "classControls"); cell.InnerHtml = "<span class='del'>DEL</span>"; row.Cells.Add(cell); classSummary.Rows.Add(row); } } } } }
public static DataSet GetHelpersForRing(ShowDetails showDetails, int RingID) { String moduleSettings = ModuleConfig.GetSettings(); Data.Helpers helpr = new Fpp.WebModules.Data.Helpers(moduleSettings); return helpr.GetHelpersForRing(showDetails.ShowDate.ToString("yyyy-MM-dd"), RingID); }
public DataSet GetHelpersForJudge(ShowDetails showDetails, int JudgeID) { return _ring.GetHelpersForJudge(showDetails.ShowDate.ToString("yyyy-MM-dd"), JudgeID); }
public void ProcessRequest(HttpContext context) { //PDFBuilder.HtmlToPdfBuilder builder = new HtmlToPdfBuilder(PageSize.A4); //builder.AddPage(); //builder.ImportStylesheet(context.Server.MapPath("pdfstylesheet.css")); int ShowID = Convert.ToInt32(context.Request["showid"]); Shows show = new Shows(ShowID); ShowDetails sd = new ShowDetails(); DataTable table = sd.GetShowDetails(ShowID).Tables[0]; String pdfPath = context.Server.MapPath("PreviewSchedule.pdf"); Boolean publish = false; if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true; Document doc = new Document(PageSize.A4, 25, 10, 10, 10); Stream output ; if (publish) { String path = context.Server.MapPath(@"..\schedules\"); path += DateTime.Today.ToString("yyyy"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName); output = new FileStream(path, FileMode.Create); } else { output = new MemoryStream(); } var writer = PdfWriter.GetInstance(doc, output); StyleSheet sheet = new StyleSheet(); doc.Open(); int clsNo = 0; ShowClasses sc = new ShowClasses(); DataSet callingList = sc.getCallingList(ShowID); foreach (DataRow row in callingList.Tables[0].Rows) { if (clsNo > 0 && clsNo != Convert.ToInt32( row["ClsNo"])) { doc.NewPage(); } var dayClasses = HTMLWorker.ParseToList(new StringReader(dayHtml), sheet); foreach (var htmlElement in dayClasses) { doc.Add(htmlElement as IElement); } }; doc.NewPage(); contents = File.ReadAllText(context.Server.MapPath("schedule2RulesNRegs.html")); parsedHTML = HTMLWorker.ParseToList(new StringReader(contents), sheet); foreach (var htmlElement in parsedHTML) { doc.Add(htmlElement as IElement); } doc.Close(); if (publish) { } else { context.Response.ClearContent(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf")); context.Response.BinaryWrite( (output as MemoryStream).ToArray()); } }
public void ProcessRequest(HttpContext context) { int ShowID = Convert.ToInt32(context.Request["showid"]); int RingID = Convert.ToInt32(context.Request["ringid"]); String cmd = context.Request["doc"].ToString(); Shows show = new Shows(ShowID); ShowDetails sd = new ShowDetails(); DataTable table = sd.GetShowDetails(ShowID).Tables[0]; String pdfPath = context.Server.MapPath(cmd + ".pdf"); Boolean publish = false; if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true; Document doc = new Document(PageSize.A6, 35, 0, 20, 2); Stream output; if (publish) { String path = context.Server.MapPath(@"..\schedules\"); path += DateTime.Today.ToString("yyyy"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName); output = new FileStream(path, FileMode.Create); } else { output = new MemoryStream(); } var writer = PdfWriter.GetInstance(doc, output); StyleSheet sheet = new StyleSheet(); doc.Open(); Font font = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.BLACK); Font smallFont = new Font(Font.HELVETICA, 8, Font.NORMAL, Color.BLACK); Font notSoBigFont = new Font(Font.HELVETICA, 11, Font.BOLD, Color.BLACK); Font fontWhite = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.WHITE); Font headerFont = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK); Font spaceFont = new Font(Font.HELVETICA, 40, Font.BOLD, Color.WHITE); Font totalsFont = new Font(Font.HELVETICA, 14, Font.BOLD, Color.BLACK); Font bigBoyFont = new Font(Font.HELVETICA, 20, Font.BOLD, Color.BLACK); Font bigBoyFont2 = new Font(Font.HELVETICA, 25, Font.BOLD, Color.BLACK); PdfPCell blankCell = new PdfPCell(new Phrase(new Chunk("", font))); ShowClasses sc = new ShowClasses(); Rings currentRing = new Rings(RingID); List<ShowClasses> showClasses = ShowClasses.GetAllClassesForShowRing(ShowID, RingID); String tmp; foreach (ShowClasses showClass in showClasses) { PdfPCell cell; DataSet callingList = sc.getCallingList(ShowID, showClass.ID); String grades = showClass.Grades; if (grades.Length == 1) { grades = "Grade " + grades; } else { grades = "Grades " + grades[0] + "-" + grades[grades.Length - 1]; } PdfPTable ptable = new PdfPTable(1); tmp = String.Format("Class {0}", showClass.ClassNo); cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont2))); cell.BorderWidth = 0; cell.Padding = 5; cell.HorizontalAlignment = Element.ALIGN_MIDDLE; cell.VerticalAlignment = Element.ALIGN_CENTER; ptable.AddCell(cell); tmp = String.Format("{0} {1} {2} {3}", showClass.longHeight, showClass.longCatagory, showClass.LongClassName, showClass.ClassName); cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont))); cell.BorderWidth = 0; cell.Padding = 5; cell.HorizontalAlignment = Element.ALIGN_MIDDLE; cell.VerticalAlignment = Element.ALIGN_CENTER; ptable.AddCell(cell); tmp = String.Format("{0}", grades); cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont))); cell.BorderWidth = 0; cell.Padding = 5; cell.FixedHeight = 100f; cell.HorizontalAlignment = Element.ALIGN_MIDDLE; cell.VerticalAlignment = Element.ALIGN_CENTER; ptable.AddCell(cell); tmp = String.Format("Ring {0}", currentRing.RingNo); cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont))); cell.BorderWidth = 0; cell.Padding = 5; cell.FixedHeight = 30f; cell.HorizontalAlignment = Element.ALIGN_MIDDLE; ptable.AddCell(cell); tmp = String.Format("Ring Order = {0}", showClass.Position + 1); cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont))); cell.BorderWidth = 0; cell.Padding = 5; cell.FixedHeight = 30f; cell.HorizontalAlignment = Element.ALIGN_MIDDLE; ptable.AddCell(cell); doc.Add(ptable); doc.NewPage(); foreach (DataRow row in callingList.Tables[0].Rows) { int Cat = Convert.ToInt32(row["Catagory"]); if (Cat == 0) { PdfPTable tbl = new PdfPTable(1); int dogGrade = Convert.ToInt32(row["Grade"]); if (dogGrade == 99 ) { tmp = "Veteran"; } else { tmp = String.Format("Grade {0}", row["Grade"]); } cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont2))); cell.BackgroundColor = CMYKColor.LIGHT_GRAY; cell.BorderWidth = 2; cell.Padding = 9; cell.PaddingTop = 4; cell.HorizontalAlignment = Element.ALIGN_RIGHT; tbl.AddCell(cell); doc.Add(tbl); } float[] colWidths = { 300, 150 }; PdfPTable callingListTbl = new PdfPTable(colWidths); tmp = String.Format("Class {0}: {1} {2} {3} {4}", showClass.ClassNo, showClass.longHeight, showClass.LongClassName, grades, showClass.ClassName); cell = new PdfPCell(new Phrase(new Chunk(tmp, notSoBigFont))); cell.BorderWidth = 2; cell.BorderColorRight = Color.BLACK; cell.BorderColorBottom = Color.BLACK; cell.Padding = 5; cell.PaddingTop = 1; cell.PaddingLeft = 2; cell.FixedHeight = 50f; callingListTbl.AddCell(cell); tmp = String.Format("{0}", row["RO"]); cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont))); cell.BorderWidth = 2; cell.BorderColorLeft = Color.BLACK; cell.BorderColorBottom = Color.BLACK; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.Padding = 5; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Course Time", notSoBigFont))); cell.BorderWidth = 2; cell.Padding = 5; cell.BorderColorRight = Color.BLACK; cell.HorizontalAlignment = Element.ALIGN_RIGHT; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", notSoBigFont))); cell.BorderWidth = 2; cell.Padding = 5; cell.BorderColorBottom = Color.BLACK; callingListTbl.AddCell(cell); int DefaultHandler = Convert.ToInt32(row["DefaultHandler"]); int AltHandler = Convert.ToInt32(row["AltHandler"]); String handlerName = row["Name"].ToString(); User user; if (DefaultHandler > 0) { user = new User(DefaultHandler); handlerName = user.Name; } if (AltHandler > 0) { user = new User(AltHandler); handlerName = user.Name; } if (showClass.EntryType == 5) { cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", handlerName), smallFont))); cell.BorderWidth = 0; cell.Colspan = 1; cell.HorizontalAlignment = Element.ALIGN_LEFT; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10}", row["KCName"]), smallFont))); cell.Colspan = 1; cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; } else { cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", handlerName), notSoBigFont))); cell.BorderWidth = 0; cell.Colspan = 2; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10} {1}", row["RingNumber"], row["KCName"]), notSoBigFont))); cell.BorderWidth = 0; } if (showClass.EntryType < 4) { cell.FixedHeight = 170f; } cell.Colspan = 2; callingListTbl.AddCell(cell); if (showClass.EntryType == 4 || showClass.EntryType == 5 ) { int UserID = Convert.ToInt32(row["UserID"]); int DogID = Convert.ToInt32(row["DogID"]); List<MultiDog> otherHandlers = MultiDog.getMultiDog(UserID, DogID, showClass.ID); int dogCnt = 0; foreach (MultiDog md in otherHandlers) { if (dogCnt < 3) { //html += String.Format("<div class='dogInClass'><div style='width:8px;height:10px;' class='dogIcon'></div>[{1}] {0}</div>", md.Dogname, dogRow["RO"]); if (showClass.EntryType == 4) { cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", md.Handlername), notSoBigFont))); cell.BorderWidth = 0; cell.Colspan = 2; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10} {1}", "", md.Dogname), notSoBigFont))); cell.BorderWidth = 0; cell.FixedHeight = 160f; cell.Colspan = 2; } else { cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", md.Handlername), smallFont))); cell.BorderWidth = 0; cell.Colspan = 1; cell.HorizontalAlignment = Element.ALIGN_LEFT; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10} {1}", "", md.Dogname), smallFont))); cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BorderWidth = 0; cell.Colspan = 1; } callingListTbl.AddCell(cell); } dogCnt++; } if (showClass.EntryType == 5) { cell = new PdfPCell(new Phrase(new Chunk("", smallFont))); cell.BorderWidth = 0; cell.FixedHeight = 140f; cell.Colspan = 2; callingListTbl.AddCell(cell); } } cell = new PdfPCell(new Phrase(new Chunk("Time", notSoBigFont))); cell.BorderWidth = 2; cell.BorderColorRight = Color.BLACK; cell.BorderColorBottom = Color.BLACK; cell.Padding = 5; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); callingListTbl.AddCell(blankCell); cell = new PdfPCell(new Phrase(new Chunk("Course Faults", notSoBigFont))); cell.BorderWidth = 2; cell.BorderColorRight = Color.BLACK; cell.BorderColorBottom = Color.BLACK; cell.Padding = 5; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); callingListTbl.AddCell(blankCell); cell = new PdfPCell(new Phrase(new Chunk("Time Faults", notSoBigFont))); cell.BorderWidth = 2; cell.BorderColorRight = Color.BLACK; cell.BorderColorBottom = Color.BLACK; cell.Padding = 5; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); callingListTbl.AddCell(blankCell); cell = new PdfPCell(new Phrase(new Chunk("Totals Faults", notSoBigFont))); cell.BorderWidth = 2; cell.BorderColorRight = Color.BLACK; cell.BorderColorBottom = Color.BLACK; cell.Padding = 5; cell.HorizontalAlignment = Element.ALIGN_CENTER; callingListTbl.AddCell(cell); callingListTbl.AddCell(blankCell); doc.Add(callingListTbl); doc.NewPage(); } } doc.Close(); if (publish) { } else { context.Response.ClearContent(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf")); context.Response.BinaryWrite((output as MemoryStream).ToArray()); } }