Beispiel #1
0
        public void SendRSVP(string message, CRM_CalendarAdmin Invite, MainDataContext db, Models.Admin CurrentUser)
        {
            System.IO.StringWriter htmlStringWriter = new System.IO.StringWriter();
            HttpContext.Current.Server.Execute("/app_emails/invites/RSVP.aspx", htmlStringWriter);

            string htmlOutput = htmlStringWriter.GetStringBuilder().ToString();

            CRM.Code.Models.Admin admin = db.Admins.Single(c => c.ID == Invite.CRM_Calendar.CreatedByAdminID);
            htmlOutput = htmlOutput.Replace("@NAME@", admin.DisplayName);
            htmlOutput = htmlOutput.Replace("@RESPONDER@", Invite.Admin.DisplayName);
            htmlOutput = htmlOutput.Replace("@EVENTNAME@", Invite.CRM_Calendar.DisplayName);
            htmlOutput = htmlOutput.Replace("@DATETIME@", Invite.EventDate);
            htmlOutput = htmlOutput.Replace("@STATUS@", Invite.StatusOutput);
            htmlOutput = htmlOutput.Replace("@SENDERMESSAGE@", message);

            AddTo(admin.Email);
            Email.SendTemplateEmail(htmlOutput.ToString(), "An user has RSVP'd - " + Invite.EventName + " - " + Invite.EventDate, mailTo, mailCc, mailBcc, attachments);

            CRM_Note note = new CRM_Note();

            note.Body            = htmlOutput.ToString();
            note.Title           = "RSVP from " + admin.DisplayName;
            note.DateCreated     = UKTime.Now;
            note.TargetReference = Invite.CRM_Calendar.Reference;
            note.OwnerAdminID    = CurrentUser.ID;
            db.CRM_Notes.InsertOnSubmit(note);
            db.SubmitChanges();
        }
Beispiel #2
0
        public void SendNewInvite(string message, CRM_CalendarAdmin Invite, MainDataContext db, Models.Admin CurrentUser)
        {
            System.IO.StringWriter htmlStringWriter = new System.IO.StringWriter();
            HttpContext.Current.Server.Execute("/app_emails/invites/newinvite.aspx", htmlStringWriter);

            string htmlOutput = htmlStringWriter.GetStringBuilder().ToString();

            htmlOutput = htmlOutput.Replace("@NAME@", Invite.Admin.FirstName);
            htmlOutput = htmlOutput.Replace("@EVENTNAME@", Invite.CRM_Calendar.DisplayName);
            htmlOutput = htmlOutput.Replace("@DATETIME@", Invite.EventDate);
            htmlOutput = htmlOutput.Replace("@INVITED@", CurrentUser.DisplayName);
            htmlOutput = htmlOutput.Replace("@SENDERMESSAGE@", message);
            htmlOutput = htmlOutput.Replace("@ACCEPT@", Invite.CRM_Calendar.RSVPAttend);
            htmlOutput = htmlOutput.Replace("@DECLINE@", Invite.CRM_Calendar.RSVPNotAttend);

            AddTo(Invite.Admin.Email);
            Email.SendTemplateEmail(htmlOutput.ToString(), "You have been tagged to a new event - " + Invite.EventName + " - " + Invite.EventDate, mailTo, mailCc, mailBcc, attachments);

            CRM_Note note = new CRM_Note();

            note.Body            = htmlOutput.ToString();
            note.Title           = "Invite sent";
            note.DateCreated     = UKTime.Now;
            note.TargetReference = Invite.CRM_Calendar.Reference;
            note.OwnerAdminID    = CurrentUser.ID;
            db.CRM_Notes.InsertOnSubmit(note);
            db.SubmitChanges();
        }
Beispiel #3
0
        public void SendTimeChange(CRM_Calendar PreviousDateDetails, CRM_CalendarAdmin Invite, MainDataContext db, Models.Admin CurrentUser)
        {
            System.IO.StringWriter htmlStringWriter = new System.IO.StringWriter();
            HttpContext.Current.Server.Execute("/app_emails/invites/datetimechange.aspx", htmlStringWriter);

            string htmlOutput = htmlStringWriter.GetStringBuilder().ToString();

            htmlOutput = htmlOutput.Replace("@NAME@", Invite.Admin.FirstName);
            htmlOutput = htmlOutput.Replace("@EVENTNAME@", Invite.CRM_Calendar.DisplayName);
            htmlOutput = htmlOutput.Replace("@OLDDATETIME@", PreviousDateDetails.OutputDate);
            htmlOutput = htmlOutput.Replace("@NEWDATETIME@", Invite.EventDate);
            htmlOutput = htmlOutput.Replace("@CHANGED@", CurrentUser.DisplayName);

            AddTo(Invite.Admin.Email);
            Email.SendTemplateEmail(htmlOutput.ToString(), "An event you are tagged in has been rescheduled - " + Invite.EventName + " originally " + PreviousDateDetails.OutputDate, mailTo, mailCc, mailBcc, attachments);

            CRM_Note note = new CRM_Note();

            note.Body            = htmlOutput.ToString();
            note.Title           = "Reschedule sent";
            note.DateCreated     = UKTime.Now;
            note.TargetReference = Invite.CRM_Calendar.Reference;
            note.OwnerAdminID    = CurrentUser.ID;
            db.CRM_Notes.InsertOnSubmit(note);
            db.SubmitChanges();
        }
Beispiel #4
0
        protected void rptEntry_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            CRM_CalendarAdmin admin     = (CRM_CalendarAdmin)e.Item.DataItem;
            Repeater          rptVenues = (Repeater)e.Item.FindControl("rptVenues");

            rptVenues.DataSource = admin.CRM_Calendar.CRM_CalendarVenues.OrderBy(o => o.DateTimeFrom);
            rptVenues.DataBind();
        }
        protected void lvItems_ItemBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item is ListViewDataItem)
            {
                CRM_CalendarAdmin item      = (CRM_CalendarAdmin)((ListViewDataItem)e.Item).DataItem;
                LinkButton        lnkRemove = (LinkButton)e.Item.FindControl("lnkRemove");

                lnkRemove.CommandArgument = item.ID.ToString();
            }
        }
        protected void lnkRemove_Click(object sender, EventArgs e)
        {
            CRM_CalendarAdmin item = db.CRM_CalendarAdmins.Single(c => c.ID.ToString() == ((LinkButton)sender).CommandArgument);

            EmailManager manager = new EmailManager();

            manager.SendUserRemoved(txtMessage.Text, item, db, AdminUser);

            db.CRM_CalendarAdmins.DeleteOnSubmit(item);
            db.SubmitChanges();

            NoticeManager.SetMessage("User removed and informed");
        }
Beispiel #7
0
        public void SendVenueChange(string message, CRM_CalendarAdmin Invite, MainDataContext db, Models.Admin CurrentUser)
        {
            System.IO.StringWriter htmlStringWriter = new System.IO.StringWriter();
            HttpContext.Current.Server.Execute("/app_emails/invites/VenueChange.aspx", htmlStringWriter);

            string htmlOutput = htmlStringWriter.GetStringBuilder().ToString();

            htmlOutput = htmlOutput.Replace("@NAME@", Invite.Admin.FirstName);
            htmlOutput = htmlOutput.Replace("@EVENTNAME@", Invite.CRM_Calendar.DisplayName);
            htmlOutput = htmlOutput.Replace("@DATETIME@", Invite.EventDate);
            htmlOutput = htmlOutput.Replace("@AMENDED@", CurrentUser.DisplayName);
            htmlOutput = htmlOutput.Replace("@SENDERMESSAGE@", message);
            htmlOutput = htmlOutput.Replace("@VENUEDETAILS@", Invite.CRM_Calendar.VenueDetailsURL);

            AddTo(Invite.Admin.Email);
            Email.SendTemplateEmail(htmlOutput.ToString(), "An event's venues have been amended - " + Invite.EventName + " - " + Invite.EventDate, mailTo, mailCc, mailBcc, attachments);
        }
        protected void lnkAutoSearch(object sender, EventArgs e)
        {
            CRM.Code.Models.Admin Item = db.Admins.SingleOrDefault(c => c.ID.ToString() == acAdminUser.SelectedID);

            if (Item != null)
            {
                if (!Entity.CRM_CalendarAdmins.Any((a => a.AdminID == Item.ID)))
                {
                    CRM_CalendarAdmin CRM_CalendarAdmin = new CRM_CalendarAdmin();
                    CRM_CalendarAdmin.Timestamp      = UKTime.Now;
                    CRM_CalendarAdmin.AdminID        = Item.ID;
                    CRM_CalendarAdmin.CRM_CalendarID = Entity.ID;
                    CRM_CalendarAdmin.Status         = (byte)CRM_CalendarAdmin.StatusTypes.NotResponded;

                    db.CRM_CalendarAdmins.InsertOnSubmit(CRM_CalendarAdmin);
                    db.SubmitChanges();

                    EmailManager manager = new EmailManager();
                    manager.SendNewInvite(txtMessage.Text, CRM_CalendarAdmin, db, ((AdminPage)Page).AdminUser);
                }
            }

            NoticeManager.SetMessage(Item.DisplayName + " tagged to " + Entity.DisplayName);
        }
        public void ProcessRequest(HttpContext context)
        {
            byte   route     = Convert.ToByte(HttpContext.Current.Request.QueryString["route"]);
            string recordid  = HttpContext.Current.Request.QueryString["recordid"];
            string returnurl = HttpContext.Current.Request.QueryString["returnURL"];
            string message   = "Done";

            using (MainDataContext db = new MainDataContext())
            {
                AuthAdmin auth = new AuthAdmin(db);

                if (auth.Authorise() == null)
                {
                    context.Response.Write("Admin Auth Error");
                    context.Response.End();
                }
                db.Dispose();
            }
            DateTime timekey = DateTime.Parse(HttpUtility.UrlDecode(HttpContext.Current.Request.QueryString["timekey"]));

            if (UKTime.Now > timekey.AddMinutes(62))
            {
                NoticeManager.SetMessage("This action has expired for security reasons - did you use your browser back button?", HttpUtility.UrlDecode(returnurl));
            }
            else
            {
                bool disableNoticeManager = false;
                using (MainDataContext db = new MainDataContext())
                {
                    switch (route)
                    {
                    case (byte)ActionLink.Route.RemoveAdminFromCalendarItem:
                    {
                        CRM_CalendarAdmin calendarAdmin = db.CRM_CalendarAdmins.Single(c => c.ID.ToString() == recordid);

                        message = calendarAdmin.AdminName + " removed from " + calendarAdmin.CRM_Calendar.DisplayName;
                        db.CRM_CalendarAdmins.DeleteOnSubmit(calendarAdmin);
                        db.SubmitChanges();
                    }
                    break;

                    case (byte)ActionLink.Route.RemoveFamilyPerson:
                    {
                        CRM_FamilyPerson familyPerson = db.CRM_FamilyPersons.Single(f => f.ID.ToString() == recordid);
                        message = familyPerson.CRM_Person.Fullname + " removed from the " + familyPerson.CRM_Family.Name + " family";
                        db.CRM_FamilyPersons.DeleteOnSubmit(familyPerson);
                        db.SubmitChanges();
                    }
                    break;

                    case (byte)ActionLink.Route.ArchiveTaskParticipant:
                    {
                        CRM_TaskParticipant participant = db.CRM_TaskParticipants.Single(t => t.ID.ToString() == recordid);
                        participant.IsArchived = true;
                        db.SubmitChanges();
                        message = participant.Name + " archived.";
                    }
                    break;

                    case (byte)ActionLink.Route.ReinstateTaskParticipant:
                    {
                        CRM_TaskParticipant participant = db.CRM_TaskParticipants.Single(t => t.ID.ToString() == recordid);
                        participant.IsArchived = false;
                        db.SubmitChanges();
                        message = participant.Name + " reinstated.";
                    }
                    break;

                    case (byte)ActionLink.Route.ArchivePassPerson:
                    {
                        CRM_AnnualPassPerson person = db.CRM_AnnualPassPersons.Single(t => t.ID.ToString() == recordid);
                        person.IsArchived = true;
                        db.SubmitChanges();
                        message = person.DisplayName + " archived.";
                    }
                    break;

                    case (byte)ActionLink.Route.ReinstatePassPerson:
                    {
                        CRM_AnnualPassPerson person = db.CRM_AnnualPassPersons.Single(t => t.ID.ToString() == recordid);
                        person.IsArchived = false;
                        db.SubmitChanges();
                        message = person.DisplayName + " reinstanted.";
                    }
                    break;


                    case (byte)ActionLink.Route.ToggleReadStatus:
                    {
                        NoteManager manager = new NoteManager();
                        bool        IsRead  = manager.IsRead(Convert.ToInt32(recordid));
                        disableNoticeManager = true;
                        if (IsRead)
                        {
                            MarkAsUnread(recordid);
                            message = "Marked as unread.";
                        }
                        else
                        {
                            MarkAsRead(recordid);
                            message = "Marked as read.";
                        }
                    }
                    break;

                    case (byte)ActionLink.Route.MarkNoteAsRead:
                    {
                        MarkAsRead(recordid);
                        db.SubmitChanges();
                        message = "Marked as read.";
                    }
                    break;

                    case (byte)ActionLink.Route.MarkNoteAsUnread:
                    {
                        MarkAsUnread(recordid);
                        db.SubmitChanges();
                        message = "Marked as unread.";
                    }
                    break;

                    case (byte)ActionLink.Route.DeleteOrganisationSchool:
                    {
                        CRM_OrganisationSchool orgSchool = db.CRM_OrganisationSchools.FirstOrDefault(s => s.ID.ToString() == recordid);
                        if (orgSchool != null)
                        {
                            db.CRM_OrganisationSchools.DeleteOnSubmit(orgSchool);
                            db.SubmitChanges();
                            message = "Link removed";
                        }
                    }
                    break;

                    case (byte)ActionLink.Route.ToggleInviteIsAttended:
                    {
                        CRM_CalendarInvite invite = db.CRM_CalendarInvites.FirstOrDefault(s => s.ID.ToString() == recordid);
                        if (invite != null)
                        {
                            invite.IsAttended = !invite.IsAttended;
                            db.SubmitChanges();
                            message = "Invite Attendance Toggled";
                        }
                    }
                    break;

                    case (byte)ActionLink.Route.ToggleInviteIsBooked:
                    {
                        CRM_CalendarInvite invite = db.CRM_CalendarInvites.FirstOrDefault(s => s.ID.ToString() == recordid);
                        if (invite != null)
                        {
                            invite.IsBooked = !invite.IsBooked;
                            db.SubmitChanges();
                            message = "Invite Booked Toggled";
                        }
                    }
                    break;

                    case (byte)ActionLink.Route.ToggleInviteIsCancelled:
                    {
                        CRM_CalendarInvite invite = db.CRM_CalendarInvites.FirstOrDefault(s => s.ID.ToString() == recordid);
                        if (invite != null)
                        {
                            invite.IsCancelled = !invite.IsCancelled;
                            db.SubmitChanges();
                            message = "Invite Cancellation Toggled";
                        }
                    }
                    break;

                    case (byte)ActionLink.Route.ToggleInviteIsInvited:
                    {
                        CRM_CalendarInvite invite = db.CRM_CalendarInvites.FirstOrDefault(s => s.ID.ToString() == recordid);
                        if (invite != null)
                        {
                            invite.IsInvited = !invite.IsInvited;
                            db.SubmitChanges();
                            message = "Invite Toggled";
                        }
                    }
                    break;

                    case (byte)ActionLink.Route.DeleteInvite:
                    {
                        CRM_CalendarInvite invite = db.CRM_CalendarInvites.FirstOrDefault(s => s.ID.ToString() == recordid);
                        if (invite != null)
                        {
                            db.CRM_CalendarInvites.DeleteOnSubmit(invite);
                            db.SubmitChanges();
                            message = "Invite Removed";
                        }
                    }
                    break;

                    case (byte)ActionLink.Route.ToggleGiftAidRecord:
                    {
                        CRM_FundraisingGiftProfileLog log = db.CRM_FundraisingGiftProfileLogs.FirstOrDefault(f => f.ID.ToString() == recordid);
                        if (log != null)
                        {
                            if (!log.IsConfirmed)
                            {
                                log.TimestampConfirmed = UKTime.Now;
                                log.IsConfirmed        = true;
                            }
                            else
                            {
                                log.TimestampConfirmed = null;
                                log.IsConfirmed        = false;
                            }

                            db.SubmitChanges();
                            message = "Gift aid record toggled";
                        }
                    }
                    break;

                    case (byte)ActionLink.Route.DeleteGiftAidRecord:
                    {
                        CRM_FundraisingGiftProfileLog log = db.CRM_FundraisingGiftProfileLogs.FirstOrDefault(f => f.ID.ToString() == recordid);
                        if (log != null)
                        {
                            db.CRM_FundraisingGiftProfileLogs.DeleteOnSubmit(log);
                            db.SubmitChanges();
                            message = "Gift aid record deleted";
                        }
                    }
                    break;
                    }

                    db.Dispose();

                    if (!disableNoticeManager)
                    {
                        NoticeManager.SetMessage(message, HttpUtility.UrlDecode(returnurl));
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect(returnurl);
                    }
                }
            }
        }