public ActionResult CreateNewMeeting(NewMeetingInfo model) { if (!ModelState.IsValid) return View("MeetingInfo", model); var organization = DbUtil.Db.LoadOrganizationById(Util2.CurrentOrganization.Id); if (organization == null) return Content("error: no org"); var mt = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingDate == model.MeetingDate && m.OrganizationId == organization.OrganizationId); if (mt != null) return Redirect("/Meeting/" + mt.MeetingId); mt = new Meeting { CreatedDate = Util.Now, CreatedBy = Util.UserId1, OrganizationId = organization.OrganizationId, GroupMeetingFlag = model.ByGroup, Location = organization.Location, MeetingDate = model.MeetingDate, AttendCreditId = model.AttendCredit.Value.ToInt() }; DbUtil.Db.Meetings.InsertOnSubmit(mt); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity($"Creating new meeting for {organization.OrganizationName}"); return Redirect("/Meeting/" + mt.MeetingId); }
public static Meeting FetchOrCreateMeeting(CMSDataContext Db, int OrgId, DateTime dt, bool? noautoabsents = null) { var meeting = (from m in Db.Meetings where m.OrganizationId == OrgId && m.MeetingDate == dt select m).FirstOrDefault(); if (meeting == null) { var acr = (from s in Db.OrgSchedules where s.OrganizationId == OrgId where s.SchedTime.Value.TimeOfDay == dt.TimeOfDay where s.SchedDay == (int)dt.DayOfWeek select s.AttendCreditId).SingleOrDefault(); meeting = new Meeting { OrganizationId = OrgId, MeetingDate = dt, CreatedDate = Util.Now, CreatedBy = Util.UserId1, GroupMeetingFlag = false, AttendCreditId = acr ?? 1, NoAutoAbsents = noautoabsents }; Db.Meetings.InsertOnSubmit(meeting); Db.SubmitChanges(); } return meeting; }
public ActionResult CreateMeetings(DateTime dt, OrgSearchModel model) { foreach (var o in model.FetchOrgs()) { var mt = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingDate == dt && m.OrganizationId == o.OrganizationId); if (mt != null) { continue; } mt = new CmsData.Meeting { CreatedDate = Util.Now, CreatedBy = Util.UserId1, OrganizationId = o.OrganizationId, Location = o.Location, MeetingDate = dt, }; DbUtil.Db.Meetings.InsertOnSubmit(mt); DbUtil.Db.SubmitChanges(); } DbUtil.LogActivity("Creating new meetings from OrgSearch"); return(Content("done")); }
private static void RecordAttend2Extracted(int id, int PeopleId, bool Present, DateTime dt, User u) { var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == id && m.MeetingDate == dt); if (meeting == null) { meeting = new CmsData.Meeting { OrganizationId = id, MeetingDate = dt, CreatedDate = Util.Now, CreatedBy = u.UserId, GroupMeetingFlag = false, }; DbUtil.Db.Meetings.InsertOnSubmit(meeting); DbUtil.Db.SubmitChanges(); var acr = (from s in DbUtil.Db.OrgSchedules where s.OrganizationId == id where s.SchedTime.Value.TimeOfDay == dt.TimeOfDay where s.SchedDay == (int)dt.DayOfWeek select s.AttendCreditId).SingleOrDefault(); meeting.AttendCreditId = acr; } Attend.RecordAttendance(PeopleId, meeting.MeetingId, Present); DbUtil.Db.UpdateMeetingCounters(id); DbUtil.LogActivity("Mobile RecAtt o:{0} p:{1} u:{2} a:{3}".Fmt(meeting.OrganizationId, PeopleId, Util.UserPeopleId, Present)); // var n = DbUtil.Db.Attends.Count(a => a.MeetingId == meeting.MeetingId && a.AttendanceFlag == true); // if (n == 0) // { // DbUtil.Db.Meetings.DeleteOnSubmit(meeting); // DbUtil.Db.SubmitChanges(); // } }
public RollListResult(Meeting meeting, int? PeopleId = null) { MeetingId = meeting.MeetingId; NewPeopleId = PeopleId; if (meeting.MeetingDate != null) people = RollsheetModel.RollList(MeetingId, meeting.OrganizationId, meeting.MeetingDate.Value); }
public RollListResult(CmsData.Meeting meeting, int?PeopleId = null) { MeetingId = meeting.MeetingId; OrgId = meeting.OrganizationId; MeetingDate = meeting.MeetingDate.Value; NewPeopleId = PeopleId; }
public ActionResult CreateMeeting(string id) { var n = id.ToCharArray().Count(c => c == 'M'); if (n > 1) { return(RedirectShowError("More than one barcode string found({0})".Fmt(id))); } var a = id.SplitStr("."); var orgid = a[1].ToInt(); var organization = DbUtil.Db.LoadOrganizationById(orgid); if (organization == null) { return(RedirectShowError("Cannot interpret barcode orgid({0})".Fmt(id))); } var re = new Regex(@"\A(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])([0-9]{2})([012][0-9])([0-5][0-9])\Z"); if (!re.IsMatch(a[2])) { return(RedirectShowError("Cannot interpret barcode datetime({0})".Fmt(id))); } var g = re.Match(a[2]); var dt = new DateTime( g.Groups[3].Value.ToInt() + 2000, g.Groups[1].Value.ToInt(), g.Groups[2].Value.ToInt(), g.Groups[4].Value.ToInt(), g.Groups[5].Value.ToInt(), 0); var newMtg = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == orgid && m.MeetingDate == dt); if (newMtg == null) { var attsch = organization.OrgSchedules.SingleOrDefault(ss => ss.MeetingTime.Value.TimeOfDay == dt.TimeOfDay && ss.MeetingTime.Value.DayOfWeek == dt.DayOfWeek); int?attcred = null; if (attsch != null) { attcred = attsch.AttendCreditId; } newMtg = new CmsData.Meeting { CreatedDate = Util.Now, CreatedBy = Util.UserId1, OrganizationId = orgid, GroupMeetingFlag = false, Location = organization.Location, MeetingDate = dt, AttendCreditId = attcred, }; DbUtil.Db.Meetings.InsertOnSubmit(newMtg); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("Creating new meeting for {0}".Fmt(dt)); } return(Redirect("/Meeting/Index/{0}?showall=true".Fmt(newMtg.MeetingId))); }
public MeetingModel(int id) { var i = (from m in DbUtil.Db.Meetings where m.MeetingId == id select new { org = m.Organization, m, }).Single(); meeting = i.m; org = i.org; }
public MeetingModel(int id) { var i = (from m in DbUtil.Db.Meetings where m.MeetingId == id select new { org = m.Organization, m }).Single(); meeting = i.m; org = i.org; }
public CmsData.Meeting meeting() { if (_meeting == null) { var q = from m in DbUtil.Db.Meetings where m.Organization.OrganizationId == Orgid where m.MeetingDate > Util.Now.AddHours(-12) orderby m.MeetingDate select m; _meeting = q.FirstOrDefault(); } return(_meeting); }
public MeetingModel(int id) { var i = (from m in DbUtil.Db.Meetings where m.MeetingId == id select new { org = m.Organization, m, }).SingleOrDefault(); if (i == null) return; meeting = i.m; org = i.org; }
public ClassResult(int OrgId, int thisday) { var mid = DbUtil.Db.GetTodaysMeetingId(OrgId, thisday); if (mid != null) { meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingId == mid); if (meeting != null) { var q = from a in meeting.Attends where a.AttendanceFlag == true orderby a.Person.Name2 select a.Person.Name; items = q.ToList(); } } }
public void RecordAttend(int PeopleId, int OrgId, bool Present, int thisday) { var q = from o in DbUtil.Db.Organizations where o.OrganizationId == OrgId let p = DbUtil.Db.People.Single(pp => pp.PeopleId == PeopleId) select new { MeetingId = DbUtil.Db.GetTodaysMeetingId(OrgId, thisday), MeetingTime = DbUtil.Db.GetTodaysMeetingHours(OrgId, thisday).First().Hour, o.Location, OrgEntryPoint = o.EntryPointId, p.EntryPointId, }; var info = q.Single(); var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingId == info.MeetingId); if (info.EntryPointId == null) { var p = DbUtil.Db.LoadPersonById(PeopleId); if (info.OrgEntryPoint > 0) { p.EntryPointId = info.OrgEntryPoint; } } if (meeting == null) { var acr = (from s in DbUtil.Db.OrgSchedules where s.OrganizationId == OrgId where s.SchedTime.Value.TimeOfDay == info.MeetingTime.Value.TimeOfDay where s.SchedDay == thisday select s.AttendCreditId).SingleOrDefault(); meeting = new CmsData.Meeting { OrganizationId = OrgId, MeetingDate = info.MeetingTime, CreatedDate = Util.Now, CreatedBy = Util.UserId1, GroupMeetingFlag = false, Location = info.Location, AttendCreditId = acr }; DbUtil.Db.Meetings.InsertOnSubmit(meeting); DbUtil.Db.SubmitChanges(); } Attend.RecordAttendance(PeopleId, meeting.MeetingId, Present); DbUtil.Db.UpdateMeetingCounters(meeting.MeetingId); }
public MeetingModel(int id) { var i = (from m in DbUtil.Db.Meetings where m.MeetingId == id select new { org = m.Organization, m, }).SingleOrDefault(); if (i == null) { return; } meeting = i.m; org = i.org; }
public ActionResult CreateMeeting(string id) { var n = id.ToCharArray().Count(c => c == 'M'); if (n > 1) return RedirectShowError("More than one barcode string found({0})".Fmt(id)); var a = id.SplitStr("."); var orgid = a[1].ToInt(); var organization = DbUtil.Db.LoadOrganizationById(orgid); if (organization == null) return RedirectShowError("Cannot interpret barcode orgid({0})".Fmt(id)); var re = new Regex(@"\A(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])([0-9]{2})([012][0-9])([0-5][0-9])\Z"); if (!re.IsMatch(a[2])) return RedirectShowError("Cannot interpret barcode datetime({0})".Fmt(id)); var g = re.Match(a[2]); var dt = new DateTime( g.Groups[3].Value.ToInt() + 2000, g.Groups[1].Value.ToInt(), g.Groups[2].Value.ToInt(), g.Groups[4].Value.ToInt(), g.Groups[5].Value.ToInt(), 0); var newMtg = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == orgid && m.MeetingDate == dt); if (newMtg == null) { var attsch = organization.OrgSchedules.SingleOrDefault(ss => ss.MeetingTime.Value.TimeOfDay == dt.TimeOfDay && ss.MeetingTime.Value.DayOfWeek == dt.DayOfWeek); int? attcred = null; if (attsch != null) attcred = attsch.AttendCreditId; newMtg = new CmsData.Meeting { CreatedDate = Util.Now, CreatedBy = Util.UserId1, OrganizationId = orgid, GroupMeetingFlag = false, Location = organization.Location, MeetingDate = dt, AttendCreditId = attcred, }; DbUtil.Db.Meetings.InsertOnSubmit(newMtg); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("Creating new meeting for {0}".Fmt(dt)); } return Redirect("/Meeting/Index/{0}?showall=true".Fmt(newMtg.MeetingId)); }
public ActionResult NewMeeting(string d, string t, int AttendCredit, bool group) { var organization = DbUtil.Db.LoadOrganizationById(Util2.CurrentOrgId); if (organization == null) { return(Content("error: no org")); } DateTime dt; if (!DateTime.TryParse(d + " " + t, out dt)) { return(Content("error: bad date")); } var mt = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingDate == dt && m.OrganizationId == organization.OrganizationId); if (mt != null) { return(Content("/Meeting/Index/" + mt.MeetingId)); } mt = new CmsData.Meeting { CreatedDate = Util.Now, CreatedBy = Util.UserId1, OrganizationId = organization.OrganizationId, GroupMeetingFlag = group, Location = organization.Location, MeetingDate = dt, AttendCreditId = AttendCredit }; DbUtil.Db.Meetings.InsertOnSubmit(mt); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("Creating new meeting for {0}".Fmt(organization.OrganizationName)); return(Content("/Meeting/Index/" + mt.MeetingId)); }
public ActionResult CreateMeeting(string id) { var a = id.SplitStr("."); var orgid = a[1].ToInt(); var organization = DbUtil.Db.LoadOrganizationById(orgid); if (organization == null) return Content($"error:Bad Orgid ({id})"); var re = new Regex(@"\A(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])([0-9]{2})([012][0-9])([0-5][0-9])\Z"); if (!re.IsMatch(a[2])) return Content($"error:Bad Date and Time ({id})"); var g = re.Match(a[2]); var dt = new DateTime( g.Groups[3].Value.ToInt() + 2000, g.Groups[1].Value.ToInt(), g.Groups[2].Value.ToInt(), g.Groups[4].Value.ToInt(), g.Groups[5].Value.ToInt(), 0); var newMtg = DbUtil.Db.Meetings.FirstOrDefault(m => m.OrganizationId == orgid && m.MeetingDate == dt); if (newMtg == null) { var attsch = organization.OrgSchedules.SingleOrDefault(ss => ss.MeetingTime.Value.TimeOfDay == dt.TimeOfDay && ss.MeetingTime.Value.DayOfWeek == dt.DayOfWeek); int? attcred = null; if (attsch != null) attcred = attsch.AttendCreditId; newMtg = new Meeting { CreatedDate = Util.Now, CreatedBy = Util.UserId1, OrganizationId = orgid, GroupMeetingFlag = false, Location = organization.Location, MeetingDate = dt, AttendCreditId = attcred }; DbUtil.Db.Meetings.InsertOnSubmit(newMtg); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity($"Created new meeting for {organization.OrganizationName}"); } return Content($"/Meeting/{newMtg.MeetingId}?showall=true"); }
public ActionResult RecordAttend(string data) { // Authenticate first var authError = Authenticate(); if (authError != null) { return(authError); } // Check Role if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Attendance")) { return(BaseMessage.createErrorReturn("Attendance roles is required to take attendance for organizations")); } // Check to see if type matches BaseMessage dataIn = BaseMessage.createFromString(data); if (dataIn.type != BaseMessage.API_TYPE_ORG_RECORD_ATTEND) { return(BaseMessage.createTypeErrorReturn()); } // Everything is in order, start the return MobilePostAttend mpa = JsonConvert.DeserializeObject <MobilePostAttend>(dataIn.data); var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == mpa.orgID && m.MeetingDate == mpa.datetime); if (meeting == null) { meeting = new CmsData.Meeting { OrganizationId = mpa.orgID, MeetingDate = mpa.datetime, CreatedDate = Util.Now, CreatedBy = Util.UserPeopleId ?? 0, GroupMeetingFlag = false, }; DbUtil.Db.Meetings.InsertOnSubmit(meeting); DbUtil.Db.SubmitChanges(); var acr = (from s in DbUtil.Db.OrgSchedules where s.OrganizationId == mpa.orgID where s.SchedTime.Value.TimeOfDay == mpa.datetime.TimeOfDay where s.SchedDay == (int)mpa.datetime.DayOfWeek select s.AttendCreditId).SingleOrDefault(); meeting.AttendCreditId = acr; } Attend.RecordAttendance(mpa.peopleID, meeting.MeetingId, mpa.present); DbUtil.Db.UpdateMeetingCounters(mpa.orgID); DbUtil.LogActivity("Mobile RecAtt o:{0} p:{1} u:{2} a:{3}".Fmt(meeting.OrganizationId, mpa.peopleID, Util.UserPeopleId, mpa.present)); BaseMessage br = new BaseMessage(); br.error = 0; br.count = 1; br.type = BaseMessage.API_TYPE_ORG_RECORD_ATTEND; return(br); }
public override void ExecuteResult(ControllerContext context) { var Response = context.HttpContext.Response; CmsData.Meeting meeting = null; if (meetingid.HasValue) { meeting = CurrentDatabase.Meetings.Single(mt => mt.MeetingId == meetingid); if (meeting != null && meeting.MeetingDate.HasValue) { NewMeetingInfo.MeetingDate = meeting.MeetingDate.Value; orgid = meeting.OrganizationId; } else { Response.Write("no meeting found"); return; } } if (OrgSearchModel == null) { OrgSearchModel = new OrgSearchModel(CurrentDatabase); } var list1 = NewMeetingInfo.ByGroup == true?ReportList2() : ReportList(); if (!list1.Any()) { Response.Write("no data found"); return; } Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "filename=RallyRollSheet.pdf"); doc = new Document(PageSize.LETTER.Rotate(), 36, 36, 64, 64); var w = PdfWriter.GetInstance(doc, Response.OutputStream); w.PageEvent = pageEvents; doc.Open(); dc = w.DirectContent; box = new PdfPCell(); box.Border = PdfPCell.NO_BORDER; box.CellEvent = new CellEvent(); foreach (var o in list1) { t = StartPageSet(o); if (meeting != null) { var q = from at in meeting.Attends where at.AttendanceFlag == true || AttendCommitmentCode.committed.Contains(at.Commitment ?? 0) select at.Person; q = from p in q from fm in CurrentDatabase.People.Where(ff => ff.FamilyId == p.FamilyId) where (fm.PositionInFamilyId == 10 && p.PositionInFamilyId != 10) || (fm.PeopleId == p.PeopleId && p.PositionInFamilyId == 10) select fm; q = q.Distinct(); var q2 = from p in q orderby p.Name2 select new { p.Name2, p.PeopleId, p.BibleFellowshipClassId }; AddFirstRow(font); foreach (var a in q2) { AddRow(a.Name2, a.PeopleId, a.BibleFellowshipClassId, font); } } else { var Groups = NewMeetingInfo.ByGroup == true ? o.Groups : ""; var q = from om in CurrentDatabase.OrganizationMembers where om.OrganizationId == o.OrgId join m in CurrentDatabase.OrgPeople(o.OrgId, Groups) on om.PeopleId equals m.PeopleId where om.EnrollmentDate <= Util.Now orderby om.Person.LastName, om.Person.FamilyId, om.Person.Name2 let p = om.Person let ch = NewMeetingInfo.UseAltNames && p.AltName != null && p.AltName.Length > 0 select om.Person; q = from p in q from fm in CurrentDatabase.People.Where(ff => ff.FamilyId == p.FamilyId) where (fm.PositionInFamilyId == 10 && p.PositionInFamilyId != 10) || (fm.PeopleId == p.PeopleId && p.PositionInFamilyId == 10) select fm; q = q.Distinct(); var q2 = from p in q orderby p.Name2 select new { p.Name2, p.PeopleId, p.BibleFellowshipClassId }; AddFirstRow(font); foreach (var a in q2) { AddRow(a.Name2, a.PeopleId, a.BibleFellowshipClassId, font); } } doc.Add(t); } pageEvents.EndPageSet(); Response.Flush(); doc.Close(); }
public CmsData.Meeting meeting() { if (_meeting == null) { var q = from m in DbUtil.Db.Meetings where m.Organization.OrganizationId == Orgid where m.MeetingDate > Util.Now.AddHours(-12) orderby m.MeetingDate select m; _meeting = q.FirstOrDefault(); } return _meeting; }
public override void ExecuteResult(ControllerContext context) { var Response = context.HttpContext.Response; CmsData.Meeting meeting = null; if (meetingid.HasValue) { meeting = DbUtil.Db.Meetings.Single(mt => mt.MeetingId == meetingid); dt = meeting.MeetingDate; orgid = meeting.OrganizationId; } IEnumerable <OrgInfo> list1; if (bygroup == true) { list1 = ReportList2(orgid, pid, div, schedule, name, sgprefix); } else { list1 = ReportList(orgid, groups, pid, div, schedule, name); } if (list1.Count() == 0) { Response.Write("no data found"); return; } if (!dt.HasValue) { Response.Write("bad date"); return; } Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "filename=foo.pdf"); doc = new Document(PageSize.LETTER.Rotate(), 36, 36, 64, 64); var w = PdfWriter.GetInstance(doc, Response.OutputStream); w.PageEvent = pageEvents; doc.Open(); dc = w.DirectContent; box = new PdfPCell(); box.Border = PdfPCell.NO_BORDER; box.CellEvent = new CellEvent(); foreach (var o in list1) { t = StartPageSet(o); if (meeting != null) { var q = from at in meeting.Attends where at.AttendanceFlag == true || at.Commitment == AttendCommitmentCode.Attending select at.Person; q = from p in q from fm in DbUtil.Db.People.Where(ff => ff.FamilyId == p.FamilyId) where (fm.PositionInFamilyId == 10 && p.PositionInFamilyId != 10) || (fm.PeopleId == p.PeopleId && p.PositionInFamilyId == 10) select fm; q = q.Distinct(); var q2 = from p in q orderby p.Name2 select new { p.Name2, p.PeopleId, p.BibleFellowshipClassId }; AddFirstRow(font); foreach (var a in q2) { AddRow(a.Name2, a.PeopleId, a.BibleFellowshipClassId, font); } } else { var Groups = o.Groups; if (Groups == null) { Groups = new int[] { 0 } } ; var q = from om in DbUtil.Db.OrganizationMembers where om.OrganizationId == o.OrgId let gc = om.OrgMemMemTags.Count(mt => Groups.Contains(mt.MemberTagId)) where gc == Groups.Length || Groups[0] <= 0 where !Groups.Contains(-1) || (Groups.Contains(-1) && om.OrgMemMemTags.Count() == 0) where (om.Pending ?? false) == false where om.MemberTypeId != MemberTypeCode.InActive where om.EnrollmentDate <= Util.Now select om.Person; q = from p in q from fm in DbUtil.Db.People.Where(ff => ff.FamilyId == p.FamilyId) where (fm.PositionInFamilyId == 10 && p.PositionInFamilyId != 10) || (fm.PeopleId == p.PeopleId && p.PositionInFamilyId == 10) select fm; q = q.Distinct(); var q2 = from p in q orderby p.Name2 select new { p.Name2, p.PeopleId, p.BibleFellowshipClassId }; AddFirstRow(font); foreach (var a in q2) { AddRow(a.Name2, a.PeopleId, a.BibleFellowshipClassId, font); } } doc.Add(t); } pageEvents.EndPageSet(); Response.Flush(); doc.Close(); }
private void detach_Meetings(Meeting entity) { this.SendPropertyChanging(); entity.Organization = null; }
public void RecordAttend(int PeopleId, int OrgId, bool Present, int thisday) { var q = from o in DbUtil.Db.Organizations where o.OrganizationId == OrgId let p = DbUtil.Db.People.Single(pp => pp.PeopleId == PeopleId) select new { MeetingId = DbUtil.Db.GetTodaysMeetingId(OrgId, thisday), MeetingTime = DbUtil.Db.GetTodaysMeetingHours(OrgId, thisday).First().Hour, o.Location, OrgEntryPoint = o.EntryPointId, p.EntryPointId, }; var info = q.Single(); var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingId == info.MeetingId); if (info.EntryPointId == null) { var p = DbUtil.Db.LoadPersonById(PeopleId); if (info.OrgEntryPoint > 0) p.EntryPointId = info.OrgEntryPoint; } if (meeting == null) { var acr = (from s in DbUtil.Db.OrgSchedules where s.OrganizationId == OrgId where s.SchedTime.Value.TimeOfDay == info.MeetingTime.Value.TimeOfDay where s.SchedDay == thisday select s.AttendCreditId).SingleOrDefault(); meeting = new CmsData.Meeting { OrganizationId = OrgId, MeetingDate = info.MeetingTime, CreatedDate = Util.Now, CreatedBy = Util.UserId1, GroupMeetingFlag = false, Location = info.Location, AttendCreditId = acr }; DbUtil.Db.Meetings.InsertOnSubmit(meeting); DbUtil.Db.SubmitChanges(); } Attend.RecordAttendance(PeopleId, meeting.MeetingId, Present); DbUtil.Db.UpdateMeetingCounters(meeting.MeetingId); }
public override void ExecuteResult(ControllerContext context) { var Response = context.HttpContext.Response; CmsData.Meeting meeting = null; if (meetingid.HasValue) { meeting = DbUtil.Db.Meetings.Single(mt => mt.MeetingId == meetingid); dt = meeting.MeetingDate; orgid = meeting.OrganizationId; } var list1 = bygroup == true?ReportList2().ToList() : ReportList().ToList(); if (!list1.Any()) { Response.Write("no data found"); return; } if (!dt.HasValue) { Response.Write("bad date"); return; } Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "filename=foo.pdf"); doc = new Document(PageSize.LETTER.Rotate(), 36, 36, 64, 64); var w = PdfWriter.GetInstance(doc, Response.OutputStream); w.PageEvent = pageEvents; doc.Open(); dc = w.DirectContent; box = new PdfPCell(); box.Border = PdfPCell.NO_BORDER; box.CellEvent = new CellEvent(); PdfPTable table = null; OrgInfo lasto = null; foreach (var o in list1) { lasto = o; table = new PdfPTable(1); table.DefaultCell.Border = PdfPCell.NO_BORDER; table.DefaultCell.Padding = 0; table.WidthPercentage = 100; if (meeting != null) { var Groups = o.Groups; if (Groups[0] == 0) { var q = from at in meeting.Attends where at.AttendanceFlag == true || at.Commitment == AttendCommitmentCode.Attending || at.Commitment == AttendCommitmentCode.Substitute orderby at.Person.LastName, at.Person.FamilyId, at.Person.Name2 select new { at.MemberType.Code, Name2 = (altnames == true && at.Person.AltName != null && at.Person.AltName.Length > 0) ? at.Person.AltName : at.Person.Name2, at.PeopleId, at.Person.DOB, }; if (q.Any()) { StartPageSet(o); } foreach (var a in q) { table.AddCell(AddRow(a.Code, a.Name2, a.PeopleId, a.DOB, "", font)); } } else { var q = from at in meeting.Attends let om = at.Organization.OrganizationMembers.SingleOrDefault(mm => mm.PeopleId == at.PeopleId) let gc = om.OrgMemMemTags.Count(mt => Groups.Contains(mt.MemberTagId)) where gc == Groups.Length || Groups[0] <= 0 where gc > 0 where !Groups.Contains(-1) || (Groups.Contains(-1) && om.OrgMemMemTags.Count() == 0) where at.AttendanceFlag == true || at.Commitment == AttendCommitmentCode.Attending || at.Commitment == AttendCommitmentCode.Substitute orderby at.Person.LastName, at.Person.FamilyId, at.Person.Name2 select new { at.MemberType.Code, Name2 = (altnames == true && at.Person.AltName != null && at.Person.AltName.Length > 0) ? at.Person.AltName : at.Person.Name2, at.PeopleId, at.Person.DOB, }; if (q.Any()) { StartPageSet(o); } foreach (var a in q) { table.AddCell(AddRow(a.Code, a.Name2, a.PeopleId, a.DOB, "", font)); } } } else { var Groups = o.Groups; if (Groups == null) { Groups = new int[] { 0 } } ; var q = from om in DbUtil.Db.OrganizationMembers where om.OrganizationId == o.OrgId let gc = om.OrgMemMemTags.Count(mt => Groups.Contains(mt.MemberTagId)) where gc == Groups.Length || Groups[0] <= 0 where !Groups.Contains(-1) || (Groups.Contains(-1) && om.OrgMemMemTags.Count() == 0) where (om.Pending ?? false) == false where om.MemberTypeId != MemberTypeCode.InActive where om.MemberTypeId != MemberTypeCode.Prospect where om.EnrollmentDate <= Util.Now orderby om.Person.LastName, om.Person.FamilyId, om.Person.Name2 let p = om.Person let ch = altnames == true && p.AltName != null && p.AltName.Length > 0 select new { PeopleId = p.PeopleId, Name2 = ch ? p.AltName : p.Name2, BirthDate = Util.FormatBirthday( p.BirthYear, p.BirthMonth, p.BirthDay), MemberTypeCode = om.MemberType.Code, ch, highlight = om.OrgMemMemTags.Any(mm => mm.MemberTag.Name == highlightsg) ? highlightsg : "" }; if (q.Any()) { StartPageSet(o); } foreach (var m in q) { table.AddCell(AddRow(m.MemberTypeCode, m.Name2, m.PeopleId, m.BirthDate, m.highlight, m.ch ? china : font)); } } if (bygroup == false && groups[0] == 0 && meeting == null) { foreach (var m in RollsheetModel.FetchVisitors(o.OrgId, dt.Value, NoCurrentMembers: true, UseAltNames: altnames == true)) { if (table.Rows.Count == 0) { StartPageSet(o); } table.AddCell(AddRow(m.VisitorType, m.Name2, m.PeopleId, m.BirthDate, "", boldfont)); } } if (!pageSetStarted) { continue; } var col = 0; float gutter = 20f; float colwidth = (doc.Right - doc.Left - gutter) / 2; var ct = new ColumnText(w.DirectContent); ct.AddElement(table); int status = 0; while (ColumnText.HasMoreText(status)) { if (col == 0) { ct.SetSimpleColumn(doc.Left, doc.Bottom, doc.Left + colwidth, doc.Top); } else { ct.SetSimpleColumn(doc.Right - colwidth, doc.Bottom, doc.Right, doc.Top); } status = ct.Go(); ++col; if (col > 1) { col = 0; doc.NewPage(); } } // foreach (var li in list) // { // y = ct.YLine; // ct.AddElement(li); // status = ct.Go(true); // if (ColumnText.HasMoreText(status)) // { // ++col; // if (col > 1) // { // col = 0; // doc.NewPage(); // } // ct.SetSimpleColumn(cols[col]); // y = doc.Top; // } // ct.YLine = y; // ct.SetText(null); // ct.AddElement(li); // status = ct.Go(); // } } if (!hasRows) { if (!pageSetStarted) { StartPageSet(lasto); } doc.Add(new Paragraph("no members as of this meeting date and time to show on rollsheet")); } doc.Close(); }
public ActionResult NewMeeting(string d, string t, int AttendCredit, bool group) { var organization = DbUtil.Db.LoadOrganizationById(Util2.CurrentOrgId); if (organization == null) return Content("error: no org"); DateTime dt; if (!DateTime.TryParse(d + " " + t, out dt)) return Content("error: bad date"); var mt = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingDate == dt && m.OrganizationId == organization.OrganizationId); if (mt != null) return Content("/Meeting/" + mt.MeetingId); mt = new CmsData.Meeting { CreatedDate = Util.Now, CreatedBy = Util.UserId1, OrganizationId = organization.OrganizationId, GroupMeetingFlag = group, Location = organization.Location, MeetingDate = dt, AttendCreditId = AttendCredit }; DbUtil.Db.Meetings.InsertOnSubmit(mt); DbUtil.Db.SubmitChanges(); DbUtil.LogActivity("Creating new meeting for {0}".Fmt(organization.OrganizationName)); return Content("/Meeting/" + mt.MeetingId); }
public ActionResult RecordAttend(string data) { // Authenticate first var authError = Authenticate(); if (authError != null) return authError; // Check Role if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Attendance")) return BaseMessage.createErrorReturn("Attendance roles is required to take attendance for organizations"); // Check to see if type matches BaseMessage dataIn = BaseMessage.createFromString(data); if (dataIn.type != BaseMessage.API_TYPE_ORG_RECORD_ATTEND) return BaseMessage.createTypeErrorReturn(); // Everything is in order, start the return MobilePostAttend mpa = JsonConvert.DeserializeObject<MobilePostAttend>(dataIn.data); var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == mpa.orgID && m.MeetingDate == mpa.datetime); if (meeting == null) { meeting = new CmsData.Meeting { OrganizationId = mpa.orgID, MeetingDate = mpa.datetime, CreatedDate = Util.Now, CreatedBy = Util.UserPeopleId ?? 0, GroupMeetingFlag = false, }; DbUtil.Db.Meetings.InsertOnSubmit(meeting); DbUtil.Db.SubmitChanges(); var acr = (from s in DbUtil.Db.OrgSchedules where s.OrganizationId == mpa.orgID where s.SchedTime.Value.TimeOfDay == mpa.datetime.TimeOfDay where s.SchedDay == (int)mpa.datetime.DayOfWeek select s.AttendCreditId).SingleOrDefault(); meeting.AttendCreditId = acr; } Attend.RecordAttendance(mpa.peopleID, meeting.MeetingId, mpa.present); DbUtil.Db.UpdateMeetingCounters(mpa.orgID); DbUtil.LogActivity("Mobile RecAtt o:{0} p:{1} u:{2} a:{3}".Fmt(meeting.OrganizationId, mpa.peopleID, Util.UserPeopleId, mpa.present)); BaseMessage br = new BaseMessage(); br.error = 0; br.count = 1; br.type = BaseMessage.API_TYPE_ORG_RECORD_ATTEND; return br; }
public ActionResult CreateMeetings(DateTime dt, OrgSearchModel model) { foreach (var o in model.FetchOrgs()) { var mt = DbUtil.Db.Meetings.SingleOrDefault(m => m.MeetingDate == dt && m.OrganizationId == o.OrganizationId); if (mt != null) continue; mt = new CmsData.Meeting { CreatedDate = Util.Now, CreatedBy = Util.UserId1, OrganizationId = o.OrganizationId, Location = o.Location, MeetingDate = dt, }; DbUtil.Db.Meetings.InsertOnSubmit(mt); DbUtil.Db.SubmitChanges(); } DbUtil.LogActivity("Creating new meetings from OrgSearch"); return Content("done"); }
public ActionResult RecordAttend(string data) { // Authenticate first var result = AuthenticateUser(); if (!result.IsValid) return AuthorizationError(result); // Check Role if (!CMSRoleProvider.provider.IsUserInRole(AccountModel.UserName2, "Attendance")) return BaseMessage.createErrorReturn("Attendance roles is required to take attendance for organizations"); // Convert raw post to avoid "+" being converted to space for iOS timezone info. Remove this later when app has been updated. String rawPost = new StreamReader(this.Request.InputStream).ReadToEnd(); rawPost = Server.UrlDecode(rawPost).Substring(5); BaseMessage dataIn = BaseMessage.createFromString(rawPost); if (dataIn.device == BaseMessage.API_DEVICE_IOS && dataIn.version == BaseMessage.API_VERSION_2) { dataIn.data = dataIn.data.Replace(" ", "+"); } MobilePostAttend mpa = JsonConvert.DeserializeObject<MobilePostAttend>(dataIn.data); if (dataIn.device == BaseMessage.API_DEVICE_IOS && dataIn.version == BaseMessage.API_VERSION_2) { int tzOffset = 0; int.TryParse(DbUtil.Db.GetSetting("TZOffset", "0"), out tzOffset); if (tzOffset != 0) { mpa.changeHourOffset(tzOffset); } } var meeting = DbUtil.Db.Meetings.SingleOrDefault(m => m.OrganizationId == mpa.orgID && m.MeetingDate == mpa.datetime); if (meeting == null) { meeting = new Meeting { OrganizationId = mpa.orgID, MeetingDate = mpa.datetime, CreatedDate = Util.Now, CreatedBy = Util.UserPeopleId ?? 0, GroupMeetingFlag = false, }; DbUtil.Db.Meetings.InsertOnSubmit(meeting); DbUtil.Db.SubmitChanges(); var acr = (from s in DbUtil.Db.OrgSchedules where s.OrganizationId == mpa.orgID where s.SchedTime.Value.TimeOfDay == mpa.datetime.TimeOfDay where s.SchedDay == (int)mpa.datetime.DayOfWeek select s.AttendCreditId).SingleOrDefault(); meeting.AttendCreditId = acr; } Attend.RecordAttendance(mpa.peopleID, meeting.MeetingId, mpa.present); DbUtil.Db.UpdateMeetingCounters(mpa.orgID); DbUtil.LogActivity($"Mobile RecAtt o:{meeting.OrganizationId} p:{mpa.peopleID} u:{Util.UserPeopleId} a:{mpa.present}"); BaseMessage br = new BaseMessage(); br.setNoError(); br.count = 1; return br; }
private void detach_Meetings(Meeting entity) { this.SendPropertyChanging(); entity.AttendCredit = null; }