public ActionResult Caller(int showId, int showDetailsId, int ringId, int showClassId) { var tmp = new CallingListModel { CallingList = new List<DogClassDetails>(), QueueList = new List<DogClassDetails>(), CourseDetails = new Domain.Managers.ClassManager().GetCourseDetails(showClassId) }; var callingList = new ShowClasses().GetCallingList(showId, showClassId); foreach (var item in callingList) { var us = new UserShows(item.UserId, showId); tmp.CallingList.Add(new DogClassDetails { ClassId = showClassId, DogId = item.DogId, HandlerType = us.HandlerType, RO = item.Ro, Status = item.Status, HandlerName = Utils.TitleCaseString(item.Name), DogName = Utils.TitleCaseString(item.KcName), Lho = item.Lho, Grade = item.Grade, Veteran = item.Veteran }); } var queued = new Fpp.Domain.Managers.QueueManager().GetQueued(showClassId); foreach(var item in queued ) { var details = tmp.CallingList.First(x => x.DogId == item.DogId); tmp.QueueList.Add(new DogClassDetails { ClassId= showClassId, DogId = item.DogId, RO = details.RO, DogName = details.DogName, HandlerName = details.HandlerName, HandlerType = details.HandlerType, Position = item.Position, Grade = details.Grade, Lho = details.Lho, Veteran = details.Veteran }); } var show = new Shows(showId); var showDetails = new ShowDetails(showDetailsId); var showClass = new ShowClasses(showClassId); ViewBag.ShowName = show.ShowName; ViewBag.Day = showDetails.ShowDate.ToString("ddd, dd MMM"); ViewBag.ClassName = showClass.NormalName(); ViewBag.ClassId = showClassId; ViewBag.RingId = ringId; ViewBag.ShowId = showId; return View(tmp); }
public static AdminTotals getAdminTotals(int ShowID, int EnteredBy) { var us = new UserShows(); var ds = us.getAllUsersForShow(ShowID); var adminTotals = new AdminTotals(); foreach (DataRow row in ds.Tables[0].Rows) { var usdetails = new UserShows(row); var trans = new Transaction(usdetails.Userid, ShowID); if (EnteredBy != trans.EnteredBy) continue; adminTotals.Entries++; adminTotals.Runs += DogClasses.countDogsInClassForShow(usdetails.Userid, ShowID); } return adminTotals; }
public static void ChangeClasses(int showId, int userId, int dogId, int[] newClsIds) { AppException.LogEvent($"Change Classes Dog (UserId={userId}, DogId={dogId}) showid={showId}"); try { var dc = new DogClasses(dogId, showId); dc.Save(dogId, showId, newClsIds.ToList(), null, dc.Lho); var us = new UserShows(userId, showId); var comms = new EmailManager(); comms.SendEntryEmail(showId, userId, us.RefCode); } catch (Exception e) { AppException.LogError($"Error:ChangeClasses:{e.Message}, {e.StackTrace}"); } }
public static List<ShowEntered> GetEnteredShows(int Id) { List<Shows> shows = Shows.GetAllEnteredShows(Id); List<ShowEntered> list = new List<ShowEntered>(); foreach (var show in shows) { var us = new UserShows(Id, show.ID); decimal totals = 0; ProcessEntry.ProcessEntry.GetTransactionDetails(us.ID, ref totals); list.Add(new ShowEntered { Show = show, PaymentRequired = totals< 0, Cancelled = show.Cancelled }); } return list; }
public UserShows SendMessage(EmailMessage emailMessage) { UserShows us = null; try { // if entered show, send email saying entered show us = new UserShows(emailMessage.UserShowId); User user = new User(us.Userid); if (user.EmailAddress.Length < 5) { throw new Exception("NoEmai"); } var thisShow = new Shows(us.ShowID); var htmlContents = readTemplate("AdminEmailHandler", "html", thisShow, null); var plainContents = readTemplate("AdminEmailHandler", "txt", thisShow, null); htmlContents = htmlContents.Replace("[BODY]", emailMessage.body.Replace("\n", "<br>")); plainContents = plainContents.Replace("[BODY]", emailMessage.body); var mm = new MailMessage(); var htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); var plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.Body = plainContents; mm.AlternateViews.Add(htmlView); SmtpClient client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(user.EmailAddress, user.Name)); mm.Subject = emailMessage.Subject; client.Send(mm); us.ContactStatus = 1; us.ContactDate = DateTime.Now; us.SaveContactDetails(); } catch (Exception e) { AppException.LogEvent("SendMessage: " + e.Message + " " + e.StackTrace); } return us; }
public static UserShows SaveEntry(ShowEntry showEntry) { DogClasses dc = new DogClasses(); String[] dogs = new String[] { }; if (showEntry.EnterData != null) { dogs = showEntry.EnterData.Split(','); } else { AppException.LogEvent(string.Format("SaveEntry: data length = 0, {0}{1}", showEntry.ShowId, showEntry.UserId)); } var altHandlersList = new string[] { }; if (showEntry.AltHandlersList != null) { altHandlersList = showEntry.AltHandlersList.Split(','); } // // Multidog format is packed as // <dogid>@<clsid>:<handlername>.<dogname>[;<handlername>.<dogname>][,<dogid>#<clsid>:<handlername>.<dogname>[;<handlername>.<dogname>]](captain$$teamname) // MultiDog.DeleteUserFromShow(showEntry.UserId, showEntry.ShowId); if (!string.IsNullOrEmpty(showEntry.PairsTeams)) { var spt = Regex.Split(showEntry.PairsTeams, "[|]"); var captain = ""; var teamName = ""; if (spt.Length > 1) { var s = Regex.Split(spt[1], "[$]"); captain = s[0]; teamName = s[1]; if (captain.Length > 0 && teamName.Length > 0) { MultiDog.AddTeamPairsDetails(showEntry.ShowId, showEntry.UserId, captain, teamName,1,-1); } } var pairTeams = spt[0].Split(','); foreach (String pairTeam in pairTeams) { String[] pt = pairTeam.Split(';'); int DogID = -1; int ClsID = -1; ; foreach (String p in pt) { String[] dogcls; String[] otherHandlerDog; if (p.IndexOf(':') > 0) { dogcls = p.Split(':')[0].Split('@'); DogID = Convert.ToInt32(dogcls[0]); ClsID = Convert.ToInt32(dogcls[1]); otherHandlerDog = p.Split(':')[1].Split('.'); String[] handlerDetails = otherHandlerDog[0].Split('-'); if (handlerDetails.Length > 1) { String handlerName = handlerDetails[0]; int handlerID = -1; int.TryParse(handlerDetails[1], out handlerID); String[] dogDetails = otherHandlerDog[1].Split('-'); String dogName = dogDetails[0]; int dogID = -1; int.TryParse(dogDetails[1], out dogID); MultiDog.Add(1, showEntry.UserId, DogID, ClsID, showEntry.ShowId, handlerName, dogName, handlerID, dogID,1); } else { MultiDog.Add(showEntry.UserId, DogID, ClsID, showEntry.ShowId, otherHandlerDog[0], otherHandlerDog[1]); } } else { otherHandlerDog = p.Split('.'); String[] handlerDetails = otherHandlerDog[0].Split('-'); if (handlerDetails.Length > 1) { String handlerName = handlerDetails[0]; int handlerID = -1; int.TryParse(handlerDetails[1], out handlerID); String[] dogDetails = otherHandlerDog[1].Split('-'); String dogName = dogDetails[0]; int dogID = -1; int.TryParse(dogDetails[1], out dogID); MultiDog.Add(1, showEntry.UserId, DogID, ClsID, showEntry.ShowId, handlerName, dogName, handlerID, dogID,1); } } } } } foreach (String dog in dogs) { String[] details = dog.Split(':'); int dogid = Convert.ToInt32(details[0]); String[] clslist = details[1].Split('.'); List<int> classes = new List<int>(); List<int> altHandlers = new List<int>(); foreach (String clsid in clslist) { if (clsid.Length > 0) { int altid = 0; classes.Add(Convert.ToInt32(clsid)); for (int ii = 0; ii < altHandlersList.Length; ii++) { String[] kvPairs = altHandlersList[ii].Split(':'); if (kvPairs[0] == clsid && kvPairs[2] == details[0]) { altid = Convert.ToInt32(kvPairs[1]); } } altHandlers.Add(altid); } } dc.Save(dogid, showEntry.ShowId, classes, altHandlers, -1); } UserShows us = new UserShows(showEntry.UserId, showEntry.ShowId); us.Status = us.Status = (int)UserShows.UserStatus.STATUS_SAVED; // // add check to see if this person is on the judging list. if (showEntry.HandlerType != (int)UserShows.HandlerTypes.MEMBER && Judge.isJudgeAtShow(showEntry.UserId, showEntry.ShowId)) { us.HandlerType = (int)UserShows.HandlerTypes.JUDGE; } else { us.HandlerType = showEntry.HandlerType; } us.Optout = showEntry.OptOut; us.DogsMeasured = showEntry.DogsMeasured; us.Save(); Camping camping = new Camping(showEntry.ShowId); if (camping.ID > -1) { if (!string.IsNullOrEmpty(showEntry.CampingDays)) { UserCamping.DeleteForUser(us.ID); for (var i = 0; i < showEntry.Plots; i++) { UserCamping.Add(us.ID, showEntry.CampingParty, showEntry.CampComments, showEntry.CampingDays, showEntry.PitchSize); } } } if (showEntry.WaitingList == 1) { WaitingList.Add(us.ShowID, us.Userid); } return us; }
private PdfPCell userHelpingDetails(UserShows userShow) { User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); PdfPCell panelCell = new PdfPCell(); panelCell.BorderWidth = 1; panelCell.Padding = 4; PdfPTable panelTable = new PdfPTable(new float[] { 150, 150, 400}); panelCell.AddElement(panelTable); var cell = new PdfPCell(new Phrase(new Chunk("Helper Details", headerFont))); cell.BorderWidth = 0; cell.Colspan = 3; cell.PaddingBottom = 10; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Help Date", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Ring No", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Job", judgeFont))) {BorderWidth = 0}; panelTable.AddCell(cell); var helpers = Business.Helpers.HelperForShow(userShow.ShowID, userShow.Userid); if (helpers.Any() && helpers.FirstOrDefault().RingNo > -1) { foreach(var h in helpers) { cell = new PdfPCell(new Phrase(new Chunk($"{h.HelpDate:ddd dd MMM}", judgeFont))) {BorderWidth = 0}; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk($"{h.RingNo}", judgeFont))) {BorderWidth = 0}; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk($"{h.JobDetails}", judgeFont))) {BorderWidth = 0}; panelTable.AddCell(cell); } } else { panelCell = new PdfPCell(); panelCell.BorderWidth = 0; } return panelCell; }
private PdfPCell userCampingDetails(UserShows userShow) { User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); PdfPCell panelCell = new PdfPCell(); panelCell.BorderWidth = 1; panelCell.Padding = 4; PdfPTable panelTable = new PdfPTable(new float[] { 500}); panelCell.AddElement(panelTable); PdfPCell cell; var campingSummary = new UserCamping(userShow.ID); if (campingSummary != null && campingSummary.PitchDetails.Any()) { cell = new PdfPCell(new Phrase(new Chunk("Camping Details", headerFont))); cell.BorderWidth = 0; cell.PaddingBottom = 10; panelTable.AddCell(cell); var camp = campingSummary.PitchDetails[0]; if (!string.IsNullOrEmpty(camp.PartyName)) { cell = new PdfPCell(new Phrase(new Chunk(string.Format("Party Name:{0}", camp.PartyName), judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } var para = new Paragraph() { new Phrase("Camping Pitch:", judgeFont) }; foreach (var pitch in campingSummary.PitchDetails ) { para.Add(new Phrase(pitch.PitchNo.ToString() + " ", judgeFont)); } cell = new PdfPCell(para); cell.BorderWidth = 0; panelTable.AddCell(cell); var tmp = ""; foreach(var day in camp.CampingDays.Split(',') ) { if (tmp.Length > 0) tmp += ", "; DateTime dt; DateTime.TryParseExact(day, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt); tmp += dt.ToString("ddd dd MMM"); } cell = new PdfPCell(new Phrase(new Chunk(tmp, judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } else { panelCell = new PdfPCell(); panelCell.BorderWidth = 0; } return panelCell; }
private void printRingForUser(UserShows userShow, int UserID, Document doc, ref List<int> defaultUsers, ref int pageCount) { float[] ringColumns = new float[] { 300, 300, 300, 300 }; User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); List<ShowDetails> showDetailsList = ShowDetails.GetShowDetails(userShow.ShowID); Rings r = new Rings(); DataSet ringList = r.GetAllRingsForShow(userShow.ShowID, "ShowDate"); Dogs d = new Dogs(); DogClasses dc = new DogClasses(); DateTime dt = DateTime.Now; string currentJudge = ""; int currentRingID = 0; int ShowDetailsID = -1; int PrevShowDetailsID = -1; PdfPTable rings = new PdfPTable(ringColumns); int ringCnt = 0; PdfPCell cell = null; PdfPTable ringDetails = null; PdfPTable classDetailsTable = null; List<int> dogsRunningToday = new List<int>(); PdfPTable headerPage = null; List<TeamPairsTrioDto> pairsTeams = new List<TeamPairsTrioDto>(); try { foreach (DataRow ringRow in ringList.Tables[0].Rows) { Rings ring = new Rings(ringRow); int RingID = Convert.ToInt32(ringRow["RingID"]); int EntryType = Convert.ToInt32(ringRow["EntryType"]); int Lho = Convert.ToInt32(ringRow["Lho"]); ShowDetailsID = Convert.ToInt32(ringRow["ShowDetailsID"]); if (ringRow.IsNull("ClassID")) { continue; } int ClassID = Convert.ToInt32(ringRow["ClassID"]); int ClassNo = Convert.ToInt32(ringRow["ClsNo"]); DateTime rowDT = Convert.ToDateTime(ringRow["ShowDate"]); if (rowDT != dt) { if (currentRingID != 0) { if (ringCnt % MaxColumns != 0) { var remind = ringCnt % MaxColumns; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } } if (dogsRunningToday.Count() > 0 || UserID == -1) { doc.Add(headerPage); doc.Add(rings); if (UserID > -1) { if (currentUser.UserID != UserID) { User defaultHandler = new User(UserID); } } doc.NewPage(); pageCount++; } } dogsRunningToday.Clear(); if (UserID > -1) { if (currentUser.UserID == UserID) { headerPage = DrawHeader(show, rowDT, currentUser, userShow); } else { User defaultHandler = new User(UserID); headerPage = DrawHeader(show, rowDT, defaultHandler, userShow); } } else { headerPage = DrawHeader(show, rowDT, null, null); } dt = rowDT; rings = new PdfPTable(ringColumns); rings.WidthPercentage = 100; ringCnt = 0; } if (currentRingID != RingID) { currentJudge = ""; ringCnt++; ringDetails = new PdfPTable(1); rings.AddCell(new PdfPCell(ringDetails)); //List<Judge> judgeList = Judge.getJudgesForRingList(RingID); string JudgeName = Judge.getJudgeForClass(ClassID).Name; int ClsCount = DogClasses.GetDogsInRing(RingID); cell = new PdfPCell(new Phrase(new Chunk(string.Format("Ring No {0} ({1})", ringRow["RingNo"].ToString(), ClsCount), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); if (currentJudge != JudgeName) { cell = new PdfPCell(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(JudgeName), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); currentJudge = JudgeName; } currentRingID = RingID; classDetailsTable = new PdfPTable(DetailsColWidths); classDetailsTable.DefaultCell.BorderWidth = 0; ringDetails.AddCell(classDetailsTable); } else { string JudgeName = Judge.getJudgeForClass(ClassID).Name; if (currentJudge != JudgeName) { cell = new PdfPCell(new Phrase(new Chunk(" ", judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(JudgeName), judgeFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_CENTER; ringDetails.AddCell(cell); classDetailsTable = new PdfPTable(DetailsColWidths); classDetailsTable.DefaultCell.BorderWidth = 0; ringDetails.AddCell(classDetailsTable); currentJudge = JudgeName; } } DataSet dogsList = d.GetDogsInClass(userShow.Userid, ClassID); int dogsInClass = d.dogsInClassCount(ClassID); List<DogClassCount> dcCounts = DogClasses.GetEntryCountsByClassId(userShow.ShowID, ClassID); String clsName; var part = Convert.ToInt32(ringRow["Part"]); var lhoInd = ""; var dogsInClassDisplay = ""; if (dcCounts.Count > 1) { if (Lho == 1) { dogsInClassDisplay = String.Format("({0}/{1})", dcCounts[0].Count, dcCounts[1].Count); } else { dogsInClassDisplay = String.Format("({0}/{1})", dcCounts[1].Count, dcCounts[0].Count); } } else { dogsInClassDisplay = String.Format("({0})", dogsInClass); } if (Lho == 1) { lhoInd = "(FH 1st)"; } else if (Lho == 2) { lhoInd = "(LHO 1st)"; } if (EntryType != 10) { clsName = new ShowClasses(ClassID).NormalName(withClassNo:false, useAbbrFlag:true); } else { clsName = String.Format("{0} {1} {2} ", ShowClasses.expandHeight(ringRow), ringRow["LongName"].ToString().Trim(), ringRow["name"].ToString().Trim()); } clsName = clsName.Replace("(Special Class", "S"); clsName = clsName.Replace("(Money Class", "Money"); clsName = clsName.Replace("First Place Processing", "FPP"); clsName = clsName.Replace("First Contact", "FC"); clsName = clsName.Replace("Qualifier", "Q"); if (part > 0 && EntryType != 10) { clsName += "Pt " + part; } if (dogsList.Tables[0].Rows.Count > 0) { /* Combined 1-7 All Allsorts Agility sponsored by paws for a walk Combined 6-7 Medium Agility * */ var WrapClassDescription = clsName.Length > 45; Phrase[] tmpCells = new Phrase[3]; tmpCells[0] = new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogInClass)); tmpCells[1] = new Phrase(new Chunk(clsName, dogInClass)); tmpCells[2] = new Phrase(new Chunk(dogsInClassDisplay, dogNotInClass )); int countDogs = 0; int DefaultHandler; Paragraph p = new Paragraph(); List<Paragraph> allDogsInClass = new List<Paragraph>(); foreach (DataRow dogRow in dogsList.Tables[0].Rows) { var dogLho = Convert.ToInt32(dogRow["Lho"]); int DogID = Convert.ToInt32(dogRow["DogID"]); DefaultHandler = Convert.ToInt32(dogRow["DefaultHandler"]); if (DefaultHandler == 0) DefaultHandler = -1; if ((DefaultHandler == -1 && currentUser.UserID == UserID) || (DefaultHandler == UserID) ) { if (countDogs == 0) { cell = new PdfPCell(tmpCells[0]); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); var namePara = new Paragraph(); namePara.Add(tmpCells[1]); namePara.Add(new Phrase(new Chunk(lhoInd, lhoFontBold))); p.Add(namePara); } if (!dogsRunningToday.Contains(DogID)) { dogsRunningToday.Add(DogID); } String dogName = dogRow["DogName"].ToString(); if (dogName.Length == 0) { dogName = dogRow["KCName"].ToString(); } var chunk = new Chunk(" ", dogDetailsInClass); chunk.SetBackground(new Color(System.Drawing.ColorTranslator.FromHtml(dogRow["DogColour"].ToString()))); var dogPara = new Paragraph(); dogPara.Add(new Phrase(chunk)); if (TeamPairsManager.isMultiDog( EntryType )) { pairsTeams.Add(new TeamPairsTrioDto { ClassId = ClassID, ClassNo = ClassNo, DogId = DogID, DogName = dogName, RO = -1 }); } dogPara.Add(new Phrase(new Chunk(String.Format(" [{1}] {0}", Fpp.Core.Utils.TitleCaseString(dogName), dogRow["RO"]), dogDetailsInClass))); dogPara.Add(new Phrase(new Chunk(String.Format("{0}", (dogLho == 0 ? "" : " (LHO)")), font8))); dogPara.Add(Chunk.NEWLINE); int AltHandler = Convert.ToInt32(dogRow["AltHandler"]); String HandlerName = ""; if (AltHandler > 0) { User u = new User(AltHandler); HandlerName = u.Name; dogPara.Add(new Phrase(new Chunk(String.Format("Handler:{0}", Fpp.Core.Utils.TitleCaseString(HandlerName)), dogInClass))); } allDogsInClass.Add(dogPara); countDogs++; } else { if (defaultUsers != null && defaultUsers.IndexOf(DefaultHandler) == -1) { defaultUsers.Add(DefaultHandler); } } } if (countDogs == 0) { cell = new PdfPCell(new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); var namePara = new Paragraph(); namePara.Add(new Phrase(new Chunk(clsName, dogNotInClass))); namePara.Add(new Phrase(new Chunk(lhoInd, lhoFontBold))); p.Add(namePara); cell = new PdfPCell(p); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dogsInClassDisplay, dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); } else { cell = new PdfPCell(p); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); cell = new PdfPCell(tmpCells[2]); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", dogDetailsInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); var tbl4Dogs = new PdfPTable(1); foreach (var item in allDogsInClass) { cell = new PdfPCell(new Phrase(item)); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; tbl4Dogs.AddCell(cell); } cell = new PdfPCell(); cell.BorderWidth = 0; cell.FixedHeight = 4f; tbl4Dogs.AddCell(cell); cell = new PdfPCell(tbl4Dogs); cell.BorderWidth = 0; cell.Colspan = 2; classDetailsTable.AddCell(cell); } } else { cell = new PdfPCell(new Phrase(new Chunk(ringRow["ClsNo"].ToString(), dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); var namePara = new Paragraph(); namePara.Add(new Phrase(new Chunk(clsName, dogNotInClass))); namePara.Add(new Phrase(new Chunk(lhoInd, lhoFontBold))); cell = new PdfPCell(namePara); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; cell.NoWrap = false; classDetailsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dogsInClassDisplay, dogNotInClass))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; classDetailsTable.AddCell(cell); } PrevShowDetailsID = ShowDetailsID; } if (dogsRunningToday.Count() > 0 || UserID == -1) { if (ringCnt % MaxColumns != 0) { var remind = ringCnt % MaxColumns; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } doc.Add(headerPage); doc.Add(rings); } if (UserID > -1) { if (currentUser.UserID != UserID) { User defaultHandler = new User(UserID); } } doc.NewPage(); pageCount++; } else { if (dogsRunningToday.Count() > 0) { if (ringCnt % MaxColumns != 0) { var remind = ringCnt % MaxColumns; while (remind-- > 0) { cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; rings.AddCell(cell); } doc.Add(headerPage); doc.Add(rings); } if (UserID > -1) { if (currentUser.UserID != UserID) { User defaultHandler = new User(UserID); } } doc.NewPage(); pageCount++; } } } catch (Exception e) { AppException.LogError($"Error Running Plan:{e.Message},{e.StackTrace}"); } }
private PdfPCell getShowDetailsInfo(UserShows userShow) { User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); PdfPCell panelCell = new PdfPCell(); panelCell.BorderWidth = 1; panelCell.Padding = 4; PdfPTable panelTable = new PdfPTable(new float[] { 135, 200 }); panelCell.AddElement(panelTable); PdfPCell cell; cell = new PdfPCell(new Phrase(new Chunk("Account Name:", headerFont))); cell.NoWrap = true; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; cell.PaddingBottom = 10; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(currentUser.Name, headerFont))); cell.BorderWidth = 0; cell.PaddingBottom = 10; panelTable.AddCell(cell); panelTable.AddCell(new PdfPCell(new Phrase("Show Name:", headerFont)) { BorderWidth = 0, NoWrap = true, HorizontalAlignment = Element.ALIGN_LEFT }); panelTable.AddCell(new PdfPCell(new Phrase(show.ShowName, headerFont)) { BorderWidth = 0 }); panelTable.AddCell(new PdfPCell(new Phrase("Venue:", headerFont)) { BorderWidth = 0, NoWrap = true, HorizontalAlignment = Element.ALIGN_LEFT }); panelTable.AddCell(new PdfPCell(new Paragraph() { new Phrase(show.Venue), new Phrase(Chunk.NEWLINE), new Phrase(show.VenuePostcode) }) { BorderWidth = 0 }); if (userShow.ID > -1) { cell = new PdfPCell(new Phrase(new Chunk("Show Ref:", headerFont))); cell.NoWrap = true; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(userShow.ID.ToString(), headerFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } return panelCell; }
public static decimal costOfEntry(int ShowId, int UserId) { var us = new UserShows(UserId, ShowId); var userCamping = new UserCamping(us.ID); if (userCamping.ID == -1 ) return 0M; var cost = 0M; var showCamping = new Camping(ShowId); var maxShowNights = (showCamping.Enddate - showCamping.Startdate).Days + 1; var userShowNight = userCamping.PitchDetails[0].CampingDays.Split(',').Count(); switch (showCamping.ChargeType) { case 0: case 1: if (maxShowNights == userShowNight) { cost = showCamping.Costpershow ; } else { cost = showCamping.Costpernight * userShowNight ; } break; case 2: cost = showCamping.Costpershow; break; } return cost * userCamping.PitchDetails.Count; }
private StringBuilder PrintReport(string ReportName, List<Transaction> list) { StringBuilder bld = new StringBuilder(); bld.AppendFormat("{0}\n\rPayment Date,Show Ref,Account Name,Amount\n\r", ReportName); decimal total = 0; foreach (var row in list) { var u = new User(row.Userid); var name = u.Name; var us = new UserShows(Convert.ToInt32(row.RefCode)); if (us.HandlerType == 1) { name += " (M)"; } if (us.HandlerType == 2) { name += " (J)"; } bld.Append(string.Format("{0:dd MMM yyyy},{1},{2},{3:0.00}\n\r", row.TransactionDate, row.RefCode, u.Name, row.Amount)); total += row.Amount; } bld.AppendFormat("\n\r,,,,Total {0:0.00}\n\r\n\r", total); return bld; }
public static List<Dogs> GetAllDogsForHandlerAtShow(int ShowID, int HandlerID) { Shows thisShow = new Shows(ShowID); String moduleSettings = ModuleConfig.GetSettings(); Fpp.Data.Dogs dogData = new Fpp.Data.Dogs(moduleSettings); List<Dogs> dogList = new List<Dogs>(); UserShows us = new UserShows(HandlerID, ShowID); if (us.ID != -1) { DataSet ds = dogData.GetAllDogsForHandler(HandlerID, thisShow.ShowDate); foreach (DataRow row in ds.Tables[0].Rows) { dogList.Add(new Dogs(row)); } } return dogList; }
public static void Cancel(User currentUser, Shows show) { DogClasses dc = new DogClasses(); UserShows us = new UserShows(currentUser.ID, show.ID); var showTransactions = Transaction.getTransactionForShowUser(us.RefCode); var refundAmount = showTransactions.Where(x => x.TransactionType == TransactionTypes.ShowEntryPayment ).Sum(x => x.Amount); var entryAmount = Math.Abs(showTransactions.Where(x => x.TransactionType == TransactionTypes.ShowEntry || x.TransactionType == TransactionTypes.TransactionCharge).Sum(x => x.Amount)); DogClasses.deleteUserDogs(currentUser.ID, show.ID); MultiDog.DeleteUserFromShow(currentUser.ID, show.ID); UserCamping.DeleteForUser(us.ID); Helpers.DeleteFromShow(show.ID, currentUser.ID); String refcode = us.ID.ToString("000000"); us.Delete(); //us.Status =(int) UserShows.UserStatus.STATUS_PENDING_REFUND; //us.Save(); if (showTransactions.Any()) { String htmlContents = readTemplate("CancelledEntry", "html", show, refcode); String plainContents = readTemplate("CancelledEntry", "txt", show, refcode); if (us.Status == (int)UserShows.UserStatus.STATUS_ENTERED_NOT_PAID || us.Status == (int)UserShows.UserStatus.STATUS_SAVED) { htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", ""); plainContents = plainContents.Replace("[PAYMENT_NOTE]", ""); } Transaction.Add(refcode, TransactionTypes.EntryCancelled, -entryAmount, "Entry Fee Cancelled", show.ID, currentUser.ID, DateTime.Now); if (refundAmount > 0) { // // if handler is cancelling the show and they have paid, then // mark in their account history that there have a refund htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days"); plainContents = plainContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days"); var allDiscounts = ShowDiscounts.getClassChargeDetails(show.ID); var onlineCharge = allDiscounts.FirstOrDefault(x => x.DiscountName == "Transaction Charge"); int transid = Transaction.Add(refcode, TransactionTypes.RefundRequest, -refundAmount, "Refund Requested", show.ID, currentUser.ID, DateTime.Now); PendingRefunds.Add(us.ID, refundAmount, us.ShowID, us.Userid); Transaction.SetEnteredBy(transid, Transaction.ENTERED_BY.ONLINE_ENTRY); } else { htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", ""); plainContents = plainContents.Replace("[PAYMENT_NOTE]", ""); } MailMessage mm = new MailMessage(); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); LinkedResource logoImage = new LinkedResource(HttpContext.Current.Server.MapPath("~/Assets/logo.gif"), MediaTypeNames.Image.Gif); logoImage.ContentId = "LogoImage"; //htmlView.LinkedResources.Add(logoImage); AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.AlternateViews.Add(plainView); mm.AlternateViews.Add(htmlView); SmtpClient client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(currentUser.EmailAddress, currentUser.Name)); mm.Subject = String.Format("Entry Cancellation {0} ({1:dd MMM yyyy})", show.ShowName, show.ShowDate); client.Send(mm); if (us.Status == (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID) { mm = new MailMessage(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress("*****@*****.**", "First Place Processing")); mm.Subject = "Entry Cancellation Request"; mm.Body = String.Format("Refund Request from {0}\r\n\r\nRefcode: {1}\r\n\r\nEmail: {2}\r\n\r\nShow: {3}\r\n", currentUser.Name, refcode, currentUser.EmailAddress, show.ShowName); client.Send(mm); } } }
public void CancelOffLineEntry(Shows thisShow, User thisUser) { DogClasses.deleteUserDogs(thisUser.ID, thisShow.ID); UserShows.DeleteEntry(thisUser.ID, thisShow.ID); UserShows us = new UserShows(thisUser.ID, thisShow.ID); var showTransactions = Transaction.getTransactionForShowUser(us.RefCode); Decimal whatHasBeenPaid = showTransactions .Where(x => x.TransactionType == TransactionTypes.ShowEntryPayment) .Sum(x => x.Amount); String UserRefNo = us.ID.ToString("000000"); int transID = Transaction.Add(UserRefNo, TransactionTypes.RefundRequest, whatHasBeenPaid, "Entry Cancelled, Refund Requested by Admin", thisShow.ID, thisUser.ID, DateTime.Now, 0); Transaction.SetEnteredBy(transID, Transaction.ENTERED_BY.SHOW_ADMIN_ENTRY); PendingRefunds.Add(us.ID, whatHasBeenPaid, us.ShowID, us.Userid); // if entered show, send email saying entered show String htmlContents = readTemplate("AdminCancelledEntry", "html", thisShow, UserRefNo); String plainContents = readTemplate("AdminCancelledEntry", "txt", thisShow, UserRefNo); if (thisUser.EmailAddress.Length > 0) { // // This needs to be pulled from the show costs table and not hard coded. // String underPayment_html = ""; String underPayment_plain = ""; //Decimal cheque = trans.Cheque - 3.00m; //underPayment_html = String.Format("<h2>Your refund will be £{0:0.00} after adminstration costs.</h2>", cheque); //underPayment_plain = String.Format("Your refund will be £{0:0.00} after adminstration costs.", cheque); underPayment_html = String.Format("<h2>Your cheque will be destroy and your enter will be remove from the show.</h2>"); underPayment_plain = String.Format("Your cheque will be destroy and your enter will be remove from the show."); htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", underPayment_html); plainContents = plainContents.Replace("[PAYMENT_NOTE]", underPayment_plain); MailMessage mm = new MailMessage(); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); LinkedResource logoImage = new LinkedResource(HttpContext.Current.Server.MapPath("~/Assets/logo.gif"), MediaTypeNames.Image.Gif); logoImage.ContentId = "LogoImage"; htmlView.LinkedResources.Add(logoImage); AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.Body = "this is a body of a message"; mm.AlternateViews.Add(plainView); mm.AlternateViews.Add(htmlView); SmtpClient client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(thisUser.EmailAddress, thisUser.Name)); mm.Subject = String.Format("Show Cancellation- {0} ({1:dd MMM yyyy})", thisShow.ShowName, thisShow.ShowDate); client.Send(mm); } }
private PdfPTable DrawHeader(Shows show, DateTime rowDT, User currentUser, UserShows userShow) { var headerPage = new PdfPTable(new float[] { 300, 100, 300 }); headerPage.WidthPercentage = 100; var p = new Paragraph(); p.Add(new Phrase(new Chunk(show.ShowName, pageFont))); p.Add(new Phrase(Chunk.NEWLINE)); p.Add(new Phrase(new Chunk(rowDT.ToString("dddd d MMM"), headerFont))); var cell = new PdfPCell(p); cell.BorderWidth = 0; cell.PaddingBottom = 5; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; headerPage.AddCell(cell); cell = new PdfPCell(); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; headerPage.AddCell(cell); p = new Paragraph(); if (currentUser != null) { p.Add(new Chunk(String.Format("Handler Name:{0}", Fpp.Core.Utils.TitleCaseString(currentUser.Name)), headerFont)); p.Add(Chunk.NEWLINE); p.Add(new Chunk(String.Format("Show Ref:{0,6}", userShow.ID), headerFont)); } cell = new PdfPCell(p); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_RIGHT; headerPage.AddCell(cell); return headerPage; }
private void drawTeamPairs(Document doc, UserShows userShow) { var multiDogClasses = new List<MultiDogClasses>(); var multiDogEntries = new List<MultiDogEntry>(); Shows thisShow = new Shows(userShow.ShowID); User currentUser = new User(userShow.Userid); List<ShowClasses> classList = ShowClasses.GetAllClassesForShow(userShow.ShowID).Where(sc => sc.Part == 0).ToList(); multiDogClasses = TeamPairsManager.GetTeamPairClasses(userShow.ShowID); multiDogEntries = TeamPairsManager.GetTeamPairs(userShow.ShowID, userShow.Userid, multiDogClasses); doc.NewPage(); var container = new PdfPTable(new float[] { 200, 200 }); PdfPTable teamPairsTable = new PdfPTable(new float[] { 200, 200 });; int lastClassId = 0; int teamCnt = 0 ; PdfPCell cell; foreach (var entry in multiDogEntries) { if (lastClassId != entry.ClassId) { if (lastClassId != 0) { if (teamCnt % 2 > 0) { cell = new PdfPCell(new Phrase(new Chunk("", dogDetailsInClass))); cell.BorderWidth = 0; container.AddCell(cell); } teamCnt = 0; } lastClassId = entry.ClassId; var classDetails = multiDogClasses.First(x => x.ClassId == entry.ClassId); teamPairsTable = new PdfPTable(new float[] { 200, 200 }); cell = new PdfPCell(new Phrase(new Chunk(string.Format("Class No:{0} - {1}", classDetails.ClassNo, classDetails.ClassName), headerFont))); cell.Colspan = 2; cell.BorderWidth = 0; cell.FixedHeight = 25f; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); cell = new PdfPCell(teamPairsTable); cell.Colspan = 2; cell.BorderWidth = 0; container.AddCell(cell); } teamPairsTable = new PdfPTable(new float[] { 200, 200 }); var teamPairsHeader = new PdfPTable(new float[] { 200, 200, 100 }); var p = new Paragraph(); p.Add(new Phrase(new Chunk("Captain", inClassFont))); p.Add(new Phrase(Chunk.NEWLINE)); p.Add(new Phrase(new Chunk(entry.TeamDetails.Captain.Replace("'", "'"), fontBold))); cell = new PdfPCell(p); cell.BorderWidth = 0; cell.FixedHeight = 30; cell.BorderWidthBottom = 2; teamPairsHeader.AddCell(cell); p = new Paragraph(); p.Add(new Phrase(new Chunk("Team Name", inClassFont))); p.Add(new Phrase(Chunk.NEWLINE)); p.Add(new Phrase(new Chunk(entry.TeamDetails.TeamName.Replace("'", "'"), fontBold))); cell = new PdfPCell(p); cell.BorderWidth = 0; cell.BorderWidthBottom = 2; cell.FixedHeight = 30; teamPairsHeader.AddCell(cell); p = new Paragraph(); p.Add(new Phrase(new Chunk(string.Format(" RO: {0}", entry.RO), inClassFontBold))); cell = new PdfPCell(p); cell.BorderWidth = 0; cell.BorderWidthBottom = 2; cell.BorderWidthLeft = 2; cell.FixedHeight = 30; teamPairsHeader.AddCell(cell); cell = new PdfPCell(teamPairsHeader); cell.Colspan = 2; cell.BorderWidth = 0; teamPairsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Members", dogDetailsInClass))); cell.Colspan = 2; cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); int memcnt = 0; foreach (var members in entry.Members) { if (memcnt == entry.DogCount) { cell = new PdfPCell(); cell.Colspan = 2; cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Reserves", dogDetailsInClass))); cell.Colspan = 2; cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); } cell = new PdfPCell(new Phrase(new Chunk(members.HandlerName.Replace("'","'"), font))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(members.DogName.Replace("'", "'"), font))); cell.BorderWidth = 0; cell.HorizontalAlignment = PdfPCell.ALIGN_LEFT; teamPairsTable.AddCell(cell); memcnt++; } container.AddCell(new PdfPCell(teamPairsTable)); teamCnt++; } if (teamCnt % 2 > 0) { cell = new PdfPCell(new Phrase(new Chunk("", dogDetailsInClass))); cell.BorderWidth = 0; container.AddCell(cell); } doc.Add(container); }
private void PrintReport(string ReportName, List<Transaction> list, decimal fee, bool removeFee) { PdfPCell cell; float[] colWidths = { 100, 140, 200, 150 }; ptable = new PdfPTable(colWidths); cell = new PdfPCell(new Phrase(new Chunk("Payment Date", headerFont))); cell.BorderWidth = 0; ptable.AddCell(cell); ptable = new PdfPTable(colWidths); cell = new PdfPCell(new Phrase(new Chunk("Show Ref", headerFont))); cell.BorderWidth = 0; ptable.AddCell(cell); ptable = new PdfPTable(colWidths); cell = new PdfPCell(new Phrase(new Chunk("Account Name", headerFont))); cell.BorderWidth = 0; ptable.AddCell(cell); cell = new PdfPCell(new Phrase("Amount", headerFont)); cell.BorderWidth = 0; ptable.AddCell(cell); doc.Add(ptable); Color altLine = new Color(224, 224, 224); decimal total = 0; foreach (var row in list) { var amount = row.Amount - fee; Color altColor = Color.WHITE; ptable = new PdfPTable(colWidths); cell = new PdfPCell(new Phrase(new Chunk(string.Format("{0:dd MMM yyyy}", row.TransactionDate), normalFont))); cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.BackgroundColor = altColor; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(row.RefCode, normalFont))); cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); var u = new User(row.Userid); var name = u.Name; var us = new UserShows(Convert.ToInt32(row.RefCode)); if (us.HandlerType == 1) { name += " (M)"; } if (us.HandlerType == 2) { name += " (J)"; } cell = new PdfPCell(new Phrase(new Chunk(name, (us.HandlerType == 0 ? normalFont : normalFontBold)))); cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(string.Format("£{0:0.00}", amount , normalFont)))); cell.BorderWidth = 0; cell.HorizontalAlignment = Element.ALIGN_RIGHT; cell.BackgroundColor = altColor; ptable.AddCell(cell); doc.Add(ptable); total += amount; } ptable = new PdfPTable(colWidths); cell = new PdfPCell(new Phrase(new Chunk(" ", normalFont))); cell.BorderWidth = 0; ptable.AddCell(cell); ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(string.Format("{1} Total £{0:0.00}", total, ReportName), ClassTitleFont))); cell.BorderWidth = 0; cell.Colspan = 3; cell.HorizontalAlignment = Element.ALIGN_RIGHT; ptable.AddCell(cell); doc.Add(ptable); doc.NewPage(); }
private PdfPCell paymentDetailsSummary(UserShows userShow) { Paragraph p = new Paragraph(); RunningPlanDto tt = new RunningPlanDto(); if (userShow.Userid == -1) { } else { Decimal amount = ProcessEntry.ProcessEntry.GetOutstandingBalance(userShow); tt = Transaction.GetUserTransactions(userShow.ShowID, userShow.RefCode); } p = new Paragraph(); if (tt.Amount < 0) { p.Add(new Phrase(Chunk.NEWLINE)); p.Add(new Phrase(new Chunk(String.Format("*** £{0:0.00} Money Due. (Please pay at show)", Math.Abs(tt.Amount)), headerFont))); p.Add(new Phrase(Chunk.NEWLINE)); } var cell = new PdfPCell(p); cell.BorderWidth = 0; cell.Colspan = 3; return cell; }
public static bool discount100Percent(int ShowId, int UserId, string discountType) { var us = new UserShows(UserId, ShowId); var list = ShowDiscounts.getDiscountsByType(ShowId, us.HandlerType); if (list.Count > 0) { foreach (ShowDiscounts sd in list) { if (sd.DiscountType == (int)DiscountTypes.Member || sd.DiscountType == (int)DiscountTypes.Judge) { if (discountType == "entry") { if (sd.Subtype == (int)CHARGES_SUBTYPES.percentOff) { return sd.Amount == 100; } } } } } return false; }
public byte[] ProcessRequest(int ShowId, int[] UserIds) { Shows show = new Shows(ShowId); Document doc = new Document(PageSize.A4.Rotate(), 10, 10, 0, 10); Stream output = new MemoryStream(); var writer = PdfWriter.GetInstance(doc, output); writer.PageEvent = new RPPageEvents(); StyleSheet sheet = new StyleSheet(); doc.Open(); int pageCount = 0; foreach (int UserId in UserIds) { printedOnPage = true; List<int> defaultUsers = new List<int>(); UserShows userShow = new UserShows(UserId, ShowId); coverPage(userShow, doc); if (_fromAdmin) { PdfPCell cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; doc.Add(cell); doc.NewPage(); } printRingForUser(userShow, UserId, doc, ref defaultUsers, ref pageCount); List<int> tmp = null; foreach (int defid in defaultUsers) { if (pageCount % 2 != 0) { PdfPCell cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; doc.Add(cell); printedOnPage = false; doc.NewPage(); } pageCount = 0; printedOnPage = true; printRingForUser(userShow, defid, doc, ref tmp, ref pageCount); } drawTeamPairs(doc, userShow); if (pageCount % 2 != 0) { PdfPCell cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; doc.Add(cell); printedOnPage = false; doc.NewPage(); } pageCount = 0; } doc.Close(); return (output as MemoryStream).ToArray(); }
public static DiscountValue getDiscountFor(int ShowId, int UserId, string discountType, int maxItems, List<EntryCost> showEntries = null, decimal itemCost = 0) { DiscountValue dv = new DiscountValue { Amount = 0, Type = 0 }; var us = new UserShows(UserId, ShowId); var list = ShowDiscounts.getDiscountsByType(ShowId, us.HandlerType); if (list.Count > 0) { var showCharges = ShowCharges.getShowCharges(ShowId); var standardClassAmount = showCharges[0].ChargeRate; foreach (ShowDiscounts sd in list) { decimal val = 0; if (sd.DiscountType == (int)DiscountTypes.Fixed) { val = sd.Amount; dv.Type = sd.Subtype; } else if (sd.DiscountType == (int)DiscountTypes.Member || sd.DiscountType == (int)DiscountTypes.Judge) { if (discountType == "entry") { var hasEntry = showEntries.SingleOrDefault(x => x.ChargeTypeId == sd.ChargeType); if (hasEntry != null) { if (sd.Subtype == (int)CHARGES_SUBTYPES.n_RunsFree) { if (sd.Amount < maxItems) val = -(sd.Amount * standardClassAmount); else val = -(maxItems * standardClassAmount); dv.Type = sd.Subtype; } if (sd.Subtype == (int)CHARGES_SUBTYPES.percentOff) { var chg = showCharges.SingleOrDefault(x => x.ID == sd.ChargeType); if (chg != null) { var tmp = showEntries.SingleOrDefault(x => x.ChargeTypeId == sd.ChargeType); if (tmp != null) { val = (chg.ChargeRate * tmp.Count) * sd.Amount / 100; } } dv.Type = sd.Subtype; } } } if (discountType == "camping") { if (sd.Subtype == (int)CHARGES_SUBTYPES.n_NightsCamping) { if (sd.Amount < maxItems) val = sd.Amount; else val = maxItems; dv.Type = sd.Subtype; } if (sd.Subtype == (int)CHARGES_SUBTYPES.percentCamping) { val = itemCost * (sd.Amount / 100); dv.Type = sd.Subtype; } } } dv.Amount += val; } } return dv; }
private PdfPCell userDogsDetails(UserShows userShow) { User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); PdfPCell panelCell = new PdfPCell(); panelCell.BorderWidth = 1; panelCell.Padding = 4; PdfPTable panelTable = new PdfPTable(new float[] { 150, 100, 300, 100 }); panelCell.AddElement(panelTable); PdfPCell cell = new PdfPCell(new Phrase(new Chunk("Dogs Entered", headerFont))); cell.Colspan = 4; cell.BorderWidth = 0; cell.PaddingBottom = 10; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Dog Ring No", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Grade", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("Dog Name", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); var dogs = DogManager.GetDogInfoForShow(userShow.ShowID, userShow.Userid); foreach (var dog in dogs) { cell = new PdfPCell(new Phrase(new Chunk(dog.RingNumber.ToString(), judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dog.Grade.ToString(), judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dog.KCName, judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk(dog.Lho ? "LHO" : "", judgeFont))); cell.BorderWidth = 0; panelTable.AddCell(cell); } return panelCell; }
public int CallingSheets(Document doc, int showId, int ringId, PdfWriter writer, int position = -1) { doc.Open(); var font = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK); var fontBold = new Font(Font.COURIER, 10, Font.BOLD, Color.BLACK); var sc = new ShowClasses(); var currentRing = new Rings(ringId); var showClasses = ShowClasses.GetAllClassesForShowRing(showId, ringId, position); var ret = showClasses.Count; float[] colWidthsStandard = { 35, 35, 50, 200, 200 }; float[] colWidthsTeam = { 35, 200, 200 }; PdfPTable callingListTbl = null; var currentClassNo = 0; var multiClasses = TeamPairsManager.GetTeamPairClasses(showId); var multiTeams = TeamPairsManager.GetTeamPairsForShow(showId, multiClasses); foreach (var showClass in showClasses) { var colWidths = (TeamPairsManager.isMultiDog(showClass.EntryType) ? colWidthsTeam : colWidthsStandard); if (currentClassNo != showClass.ClassNo) { if (currentClassNo != 0) { } callingListTbl = new PdfPTable(colWidths) { HeaderRows = 2 }; } string tmp; if (TeamPairsManager.isMultiDog(showClass.EntryType) || showClass.EntryType == 10) { tmp = $"Ring No:{currentRing.RingNo} Class No:{showClass.ClassNo} {showClass.longHeight} {showClass.LongClassName} {showClass.ClassName}"; } else { // tmp = String.Format("Ring No:{5} Class No:{0} {1} {2} {3} {6} {7} {4}", showClass.ClassNo, showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, currentRing.RingNo, showClass.ClassName, (showClass.Part > 0 ? "Part " + showClass.Part : "")); tmp = $"Ring No:{currentRing.RingNo} Class No:{showClass.NormalName()}"; tmp += $" {(showClass.Part > 0 ? "Part " + showClass.Part : "")}"; } var cell = new PdfPCell(new Phrase(new Chunk(tmp, ClassTitleFont))) { Colspan = colWidths.Length, BorderWidth = 0, FixedHeight = 40F }; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", ClassTitleFont))) { Colspan = colWidths.Length, BorderWidth = 0 }; callingListTbl.AddCell(cell); doc.Add(callingListTbl); callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk("RO", headerFont))) { BorderWidth = 0, HorizontalAlignment = Element.ALIGN_RIGHT}); if (!TeamPairsManager.isMultiDog(showClass.EntryType)) { callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk(" ", headerFont))) { BorderWidth = 0 }); callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk("Ring No", headerFont))) { BorderWidth = 0, HorizontalAlignment = Element.ALIGN_RIGHT}); } callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk("Handler", headerFont))) { BorderWidth = 0 }); callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk("Dog Name", headerFont))) { BorderWidth = 0 }); doc.Add(callingListTbl); int altFlag = 0; Color altLine = Color.LIGHT_GRAY; callingListTbl = new PdfPTable((TeamPairsManager.isMultiDog(showClass.EntryType) ? colWidthsTeam : colWidths)); if (TeamPairsManager.isMultiDog(showClass.EntryType)) { var teamsForClass = multiTeams.Where(t => t.ClassId == showClass.ID).OrderBy(t => t.RO); foreach (var team in teamsForClass) { var altColor = Color.WHITE; if (altFlag % 2 == 0 && showClass.EntryType != 5) { altColor = altLine; } cell = new PdfPCell(new Phrase(new Chunk(team.RO.ToString(), headerHFont))) { BorderWidth = 0, BackgroundColor = altColor }; callingListTbl.AddCell(cell); if (TeamPairsManager.isTeam(showClass.EntryType)) { cell = new PdfPCell( new Phrase(new Chunk("Team Name:" + team.TeamDetails.TeamName.Replace("'", "'"), headerHFont))) { BackgroundColor = altColor, BorderWidth = 0 }; callingListTbl.AddCell(cell); cell = new PdfPCell( new Phrase(new Chunk("Captain:" + team.TeamDetails.Captain.Replace("'", "'"), headerHFont))) { BackgroundColor = altColor, BorderWidth = 0 }; callingListTbl.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", headerHFont))) { BackgroundColor = altColor, BorderWidth = 0 }; callingListTbl.AddCell(cell); } var dogCnt = 0; var handlerPara = new Paragraph(); var dogPara = new Paragraph(); foreach (var member in team.Members) { if (dogCnt < team.DogCount) { if (dogCnt > 0) { handlerPara.Add(new Phrase(Chunk.NEWLINE)); dogPara.Add(new Phrase(Chunk.NEWLINE)); } handlerPara.Add(new Phrase(new Chunk(Utils.TitleCaseString(member.HandlerName).Replace("'", "'"), font))); dogPara.Add(new Phrase(new Chunk(Utils.TitleCaseString(member.DogName).Replace("'", "'"), font))); } dogCnt++; } cell = new PdfPCell(handlerPara) { BorderWidth = 0, BorderWidthTop = 0, BackgroundColor = altColor }; callingListTbl.AddCell(cell); cell = new PdfPCell(dogPara) { BorderWidth = 0, BorderWidthTop = 0, BackgroundColor = altColor }; callingListTbl.AddCell(cell); doc.Add(callingListTbl); altFlag++; callingListTbl = new PdfPTable((TeamPairsManager.isMultiDog(showClass.EntryType) ? colWidthsTeam : colWidths)); var lineLeft = writer.GetVerticalPosition(false) - doc.BottomMargin; if (lineLeft < 50) { doc.NewPage(); } } } else { var callingList = sc.GetCallingList(showId, showClass.ID); foreach (var item in callingList) { Color altColor = Color.WHITE; if (altFlag % 2 == 0 && showClass.EntryType != 5) { altColor = altLine; } callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk($"{item.Ro}", font))) { BorderWidth = 0, BackgroundColor = altColor, HorizontalAlignment = Element.ALIGN_RIGHT }); var borderWidth = 0; callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk(item.Lho == 0 ? "" : "LHO", font))) { HorizontalAlignment = Element.ALIGN_RIGHT, BackgroundColor = altColor, BorderWidth = borderWidth }); callingListTbl.AddCell(new PdfPCell(new Phrase(new Chunk($"{item.RingNumber}", font))) { HorizontalAlignment = Element.ALIGN_CENTER, BackgroundColor = altColor, BorderWidth = borderWidth }); var handlerName = Utils.TitleCaseString(item.Name); User user; var namePhrase = new Phrase(); var us = new UserShows(item.UserId, showId); if (item.DefaultHandlerId > 0) { user = new User(item.DefaultHandlerId); handlerName = user.Name; } if (item.AltHandlerId > 0) { user = new User(item.AltHandlerId); handlerName = user.Name; } if (us.HandlerType == (int)Core.Enums.DiscountTypes.Member) { namePhrase.Add(new Chunk("(M)", fontBold)); namePhrase.Add(new Chunk(Utils.TitleCaseString(handlerName), fontBold)); } else { namePhrase.Add(new Chunk(Utils.TitleCaseString(handlerName), font)); } cell = new PdfPCell(namePhrase) { BackgroundColor = altColor, BorderWidth = borderWidth }; callingListTbl.AddCell(cell); cell = new PdfPCell( new Phrase(new Chunk(Fpp.Core.Utils.TitleCaseString(item.KcName), font))) { BackgroundColor = altColor, BorderWidth = borderWidth }; callingListTbl.AddCell(cell); altFlag++; } doc.Add(callingListTbl); } doc.NewPage(); } return ret; }
public static UserShows SaveEntryv2(UserShowEntry showEntry) { DogClasses dc = new DogClasses(); var altHandlersList = new string[] { }; UserShows us = new UserShows(showEntry.UserId, showEntry.ShowId); try { MultiDog.DeleteUserFromShow(showEntry.UserId, showEntry.ShowId); try { if (showEntry.MultiDogEntries != null && showEntry.MultiDogEntries.Any()) { var idx = 1; var teamPairsId = 0; foreach (var md in showEntry.MultiDogEntries) { teamPairsId = MultiDog.AddTeamPairsDetails(showEntry.ShowId, showEntry.UserId, md.TeamDetails.Captain, md.TeamDetails.TeamName, idx, md.ClassId); foreach (var member in md.Members) { MultiDog.Add(teamPairsId, showEntry.UserId, member.DogId, md.ClassId, showEntry.ShowId, member.HandlerName ?? "", member.DogName ?? "", member.HandlerId, member.DogId, idx); } idx++; } } } catch (Exception e) { AppException.Log(string.Format("SaveEntryv2 Error MultiDogs (ShowId={0}, UserId={1} [{2}][{3}]", showEntry.ShowId, showEntry.UserId, e.Message, e.StackTrace), ""); } foreach (DogsModel dog in showEntry.Dogs) { dc.Save(showEntry.ShowId, dog); if (dog.ClassNo != null) { var ykc = dog.ClassNo.Where(y => y.Juniors != null); if (ykc.Any()) { var y = ykc.First(); if (y.Juniors.Id == 0) { Juniors.AddJunior(dog.Id, y.Id, y.Juniors.DoB, y.Juniors.YKCNumber); } else { var jnr = new Juniors(y.Juniors.Id); jnr.DogId = dog.Id; jnr.ClassId = y.Id; jnr.YKCNumber = y.Juniors.YKCNumber; jnr.DoB = y.Juniors.DoB; jnr.Save(); } } var g7dogs = dog.ClassNo.Where(x => x.ChampWins != null && x.ChampWins.Any()); foreach (var d in g7dogs) { foreach (var win in d.ChampWins) { if (!string.IsNullOrEmpty(win.ShowName) && !string.IsNullOrEmpty(win.ShowClass)) { DateTime parsedDate = DateTime.MinValue; if (!DateTime.TryParseExact(win.ShowDate, "dd-MM-yy", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedDate)) { DateTime.TryParseExact(win.ShowDate, "dd-MM-yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out parsedDate); } Fpp.Business.DogHistory.AddChampWins(new Core.Views.UpgradeDogView { Id = win.Id, ShowName = win.ShowName, ClassWon = win.ShowClass, WinDate = parsedDate, UserId = showEntry.UserId, DogId = dog.Id, NewGrade = 7, Comments = "Win towards grade 7", UpgradeType = win.UpgradeType, DateOfWin = win.ShowDate }); } } } } } if (us.Status != (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID) { us.Status = us.Status = (int)UserShows.UserStatus.STATUS_SAVED; } // // add check to see if this person is on the judging list. if (showEntry.HandlerType != (int)UserShows.HandlerTypes.MEMBER && Judge.isJudgeAtShow(showEntry.UserId, showEntry.ShowId)) { us.HandlerType = (int)UserShows.HandlerTypes.JUDGE; } else { us.HandlerType = showEntry.HandlerType; } us.Optout = showEntry.OptOut; us.DogsMeasured = showEntry.DogsMeasured; us.Save(); Camping camping = new Camping(showEntry.ShowId); if (camping.ID > -1) { var oldcamp = new UserCamping(us.ID); UserCamping.DeleteForUser(us.ID); if (showEntry.UserCamping != null) { for (var i = 0; i < showEntry.UserCamping.Plots; i++) { UserCamping.Add(us.ID, showEntry.UserCamping); } var uc = new UserCamping(us.ID); if (oldcamp.ID > -1 && oldcamp.PitchDetails.Any() ) { UserCamping.SetCode(uc.PitchDetails[0].ID, oldcamp.PitchDetails[0].CampingCode); UserCamping.SetComments(uc.PitchDetails[0].ID, oldcamp.PitchDetails[0].Comments); UserCamping.SetPitchNo(uc.PitchDetails[0].ID, oldcamp.PitchDetails[0].PitchNo); if (uc.PitchDetails.Count > 1 && oldcamp.PitchDetails.Count > 1) { UserCamping.SetCode(uc.PitchDetails[1].ID, oldcamp.PitchDetails[1].CampingCode); UserCamping.SetComments(uc.PitchDetails[1].ID, oldcamp.PitchDetails[1].Comments); UserCamping.SetPitchNo(uc.PitchDetails[1].ID, oldcamp.PitchDetails[1].PitchNo); } } } } if (showEntry.UserCamping != null && showEntry.UserCamping.WaitingList == 1) { WaitingList.Add(showEntry.ShowId, showEntry.UserId); } } catch (Exception e) { AppException.Log( string.Format("SaveEntryv2 Error (ShowId={0}, UserId={1} [{2}][{3}]", showEntry.ShowId, showEntry.UserId, e.Message, e.StackTrace), ""); } return us; }
public void ProcessRequest(HttpContext context) { int ShowID = Convert.ToInt32(context.Request["showid"]); Shows show = new Shows(ShowID); String sortby = Convert.ToString(context.Request["sortby"]); Document doc = new Document(PageSize.A4, -50, -50, 2, 2); Stream output = new MemoryStream(); var writer = PdfWriter.GetInstance(doc, output); StyleSheet sheet = new StyleSheet(); doc.Open(); 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 = { 150, 65, 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); List<Dogs> userDogs = null; 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 { if (userDogs != null) { altColor = (altColor == Color.WHITE ? altLine : Color.WHITE); foreach (Dogs di in userDogs.Where(x => x.Status != -1).ToList()) { List<DogClasses> dcList = DogClasses.Retrieve(di.ID, ShowID); cell = new PdfPCell(new Phrase(new Chunk("", normalFont))); cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); cell = new PdfPCell(new Phrase(new Chunk("", normalFont))); cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); ptable.AddCell(AddDogDetails(di, dcList, altColor, false)); cell = new PdfPCell(new Phrase(new Chunk("", normalFont))); cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); count++; altColor = (count % 2 == 0 ? altLine : Color.WHITE); } count++; } topBorder = true; tmp = masterListItem.Name; //if (masterListItem.AltHandler > 0) //{ // User u = new User(masterListItem.AltHandler); // tmp = u.Name; //} var adminInd = ""; var us = new UserShows(masterListItem.UserId, ShowID); var trans = Transaction.GetTransactionForShowUser(us.ID); if (trans.Any() && trans.FirstOrDefault().EnteredBy == (int) Transaction.ENTERED_BY.SHOW_ADMIN_ENTRY) { adminInd = "(A) "; } User u = new User(masterListItem.UserId); userDogs = Dogs.GetAllDogsForHandler(masterListItem.UserId, show.ShowDate); Paragraph para = new Paragraph(); para.Add(new Chunk(adminInd + tmp + Environment.NewLine, normalFont)); para.Add(new Chunk(u.Address + Environment.NewLine , normalFont)); para.Add(new Chunk(u.Postcode, normalFont)); para.Add(new Chunk(Environment.NewLine, normalFont)); if (!string.IsNullOrEmpty(u.EmailAddress)) { para.Add(new Chunk("Email " + u.EmailAddress + Environment.NewLine, normalFont)); } if (!string.IsNullOrEmpty(u.HomePhone)) { para.Add(new Chunk("Home Phone " + u.HomePhone + Environment.NewLine, normalFont)); } if (!string.IsNullOrEmpty(u.Mobile)) { para.Add(new Chunk("Mobile Phone " + u.Mobile + Environment.NewLine, normalFont)); } cell = new PdfPCell(para); 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); var d = userDogs.FirstOrDefault(x => x.ID == masterListItem.DogID); if (d != null) { List<DogClasses> dcList = DogClasses.Retrieve(masterListItem.DogID, ShowID); ptable.AddCell(AddDogDetails(d, dcList, altColor, topBorder)); d.Status = -1; PdfPTable classDetailsTbl = new PdfPTable(1); var p = new Paragraph(); bool first = true; int champClass = -1; 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; if (sc.EntryType == (int)Fpp.Core.Enums.EntryTypes.Championship) { champClass = d.ID; } } 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); if (champClass > -1) { cell = new PdfPCell(); cell.BorderWidth = 0; cell.BackgroundColor = altColor; cell.Colspan = 2; ptable.AddCell(cell); p = new Paragraph(); var champWins = DogHistory.GetRecordedWins(champClass); p.Add(new Phrase(new Chunk("Grade 6 Wins" + Environment.NewLine, normalFontBold) )); foreach (var win in champWins) { p.Add(new Chunk(String.Format("{0:dd-MM-yyyy} {1} {2} {3} ", win.WinDate, win.ShowName, win.ClassWon, win.Comments) + Environment.NewLine, normalFont)); } cell = new PdfPCell(p); cell.Colspan = 2; cell.FixedHeight = 100; cell.BorderWidth = 0; cell.BackgroundColor = altColor; ptable.AddCell(cell); } } else { } 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=MasterList.pdf")); context.Response.BinaryWrite((output as MemoryStream).ToArray()); }
public void SendForRefund(int ShowID, int UserID) { Shows show = new Shows(ShowID); User user = new User(UserID); UserShows us = new UserShows(UserID, ShowID); var refcode = us.ID.ToString("000000"); String htmlContents = readTemplate("Refund", "html", show, refcode); String plainContents = readTemplate("Refund", "txt", show, refcode); htmlContents = htmlContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days"); plainContents = plainContents.Replace("[PAYMENT_NOTE]", "Your payment will be refunded in the next 5 working days"); MailMessage mm = new MailMessage(); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlContents, null, MediaTypeNames.Text.Html); //LinkedResource logoImage = new LinkedResource(HttpContext.Current.Server.MapPath("~/Assets/logo.gif"), MediaTypeNames.Image.Gif); //logoImage.ContentId = "LogoImage"; //htmlView.LinkedResources.Add(logoImage); AlternateView plainView = AlternateView.CreateAlternateViewFromString(plainContents, null, MediaTypeNames.Text.Plain); mm.AlternateViews.Add(plainView); mm.AlternateViews.Add(htmlView); SmtpClient client = new SmtpClient(); mm.From = new MailAddress("*****@*****.**", "First Place Processing"); mm.To.Add(new MailAddress(user.EmailAddress, user.Name)); mm.Bcc.Add(new MailAddress("*****@*****.**", "Accounts")); mm.Subject = String.Format("Refund of entry {0} ({1:dd MMM yyyy})", show.ShowName, show.ShowDate); client.Send(mm); if (us.Status == (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID) { mm = new MailMessage { From = new MailAddress("*****@*****.**", "First Place Processing") }; mm.To.Add(new MailAddress("*****@*****.**", "First Place Processing")); mm.Subject = "Entry Refund Request"; mm.Body = $"Refund Request from {user.Name}\r\n\r\nRefcode: {refcode}\r\n\r\nEmail: {user.EmailAddress}\r\n\r\nShow: {show.ShowName}\r\n"; client.Send(mm); } }
public JsonResult QueueUpdate(int showId, int showClassId) { var tmp = new ScrimerModel { CallingList = new List<DogClassDetails>(), QueueList = new List<DogClassDetails>() }; var callingList = new ShowClasses().GetCallingList(showId, showClassId); foreach (var item in callingList) { var us = new UserShows(item.UserId, showId); tmp.CallingList.Add(new DogClassDetails { ClassId = showClassId, DogId = item.DogId, HandlerType = us.HandlerType, RO = item.Ro, Status = item.Status, HandlerName = Utils.TitleCaseString(item.Name), DogName = Utils.TitleCaseString(item.KcName), Lho = item.Lho, Grade = item.Grade }); } var queued = new Fpp.Domain.Managers.QueueManager().GetQueued(showClassId); foreach (var item in queued) { var details = tmp.CallingList.First(x => x.DogId == item.DogId); tmp.QueueList.Add(new DogClassDetails { ClassId = showClassId, DogId = item.DogId, RO = details.RO, DogName = details.DogName, HandlerName = details.HandlerName, HandlerType = details.HandlerType, Lho = details.Lho, Grade = details.Grade }); } return Json(new { CallingList = tmp.CallingList, QueueList = queued, Status = 0, }); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var referrerURL = ConfigurationManager.AppSettings["ReferrerURL"]; if (context.Request.UrlReferrer == null) { if (referrerURL != "") { AppException.LogEvent(string.Format("UPG.Callback:UrlReferrer invalid {0} ", referrerURL)); context.Response.Write("success"); return; } } else if (context.Request.UrlReferrer.ToString() != referrerURL) { AppException.LogEvent(string.Format("UPG.Callback:UrlReferrer invalid {0} " ,referrerURL)); context.Response.Write("success"); return; } String ttt = context.Request.QueryString.ToString(); AppException.LogEvent("FPMS:Callback:" + ttt); String item_number = getValue(ttt, "userrefno"); String transactiontime = getValue(ttt, "transactiontime"); String transactionnumber = getValue(ttt, "transactionnumber"); String transactiontype = getValue(ttt, "transcationtype"); String sh_reason = getValue(ttt, "sh_reason"); String showentry = getValue(ttt, "showentry"); if (transactionnumber == "-1") { String reason = getValue(ttt, "failurereason"); AppException.LogEvent(string.Format("UPG.Callback:ProcessRequest:Card failed for {0}, reason:{1}" , item_number, reason)); } else { var currentEntryCost = 0M; try { currentEntryCost = Convert.ToDecimal(showentry); } catch (Exception ex) { AppException.LogEvent("UPG.Callback:ProcessRequest:" + ex.Message + "," + ex.StackTrace); } UserShows us = null; int itemNo = -1; try { itemNo = Convert.ToInt32(item_number); us = new UserShows(itemNo); } catch (Exception ex) { AppException.LogEvent(string.Format("UPG.Callback:Getting UserShow Details({2}) :{0},{1}", ex.Message,ex.StackTrace, itemNo)); } if (us != null) { if (us.ID == itemNo) { us.Status = (int)UserShows.UserStatus.STATUS_ENTERED_AND_PAID; us.Save(); Transaction.Add(item_number, TransactionTypes.ShowEntryPayment, currentEntryCost, transactionnumber, us.ShowID, us.Userid, ConvertUGPDate(transactiontime)); AuditManager.TrackUserEvent(us.Userid, "Payment Received", string.Format("item no={0}", item_number)); try { var comms = new EmailManager(); comms.SendEntryEmail(us.ShowID, us.Userid, us.ID.ToString("000000")); } catch (Exception e) { AppException.LogEvent(string.Format("UPG.Callback:ProcessRequest: Failed sending payment confirmation. {0}", e.Message)); AuditManager.TrackUserEvent(us.Userid, "Payment Sending Email", string.Format("item no={0}", itemNo)); } } else { AuditManager.TrackUserEvent(us.Userid, "Payment Storage failure (us.Id != item_no)", string.Format("item no={0}", itemNo)); } } else { AuditManager.TrackUserEvent(us.Userid, "Payment Failed", string.Format("item no={0}", item_number)); } } context.Response.Write("success"); }
private void coverPage(UserShows userShow, Document doc) { float[] panelColumns = new float[] { 300,10, 300 }; User currentUser = new User(userShow.Userid); Shows show = new Shows(userShow.ShowID); var panel = new PdfPTable(panelColumns); panel.WidthPercentage = 100; PdfPCell cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.PaddingTop = 15; cell.Colspan = 3; cell.BorderWidth = 0; panel.AddCell(cell); panel.AddCell(getShowDetailsInfo(userShow)); cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; panel.AddCell(cell); if (userShow.Userid > -1) { panel.AddCell(userDogsDetails(userShow)); } panel.AddCell(userCampingDetails(userShow)); cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; panel.AddCell(cell); panel.AddCell(userHelpingDetails(userShow)); panel.AddCell(paymentDetailsSummary(userShow)); cell = new PdfPCell(new Phrase(new Chunk(" ", pageFont))); cell.BorderWidth = 0; cell.Colspan = 3; cell.PaddingTop = 25; panel.AddCell(cell); var s = new Shows(userShow.ShowID); cell = new PdfPCell(new Phrase(new Chunk(s.RunningPlanMessage, headerFont))); cell.BorderWidth = 0; cell.Colspan = 3; panel.AddCell(cell); doc.Add(panel); doc.NewPage(); }