示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.Url.AbsoluteUri.Contains("localhost") && !Request.IsSecureConnection)
            {
                string absoluteUri = Request.Url.AbsoluteUri;
                Response.Redirect(absoluteUri.Replace("http://", "https://"));
            }

            if (Request.QueryString["action"] == "logout")
            {
                AuthAdmin authAdmin = new AuthAdmin(db);
                authAdmin.Logout();
            }

            if (!Page.IsPostBack)
            {
                if (!String.IsNullOrEmpty(Request.QueryString["verify"]))
                {
                    CRM.Code.Models.Admin admin = db.Admins.FirstOrDefault(a => a.ResetLink.Contains(Request.RawUrl) && a.ResetLink != String.Empty);

                    if (admin != null)
                    {
                        if (((DateTime)admin.LastReset).AddMinutes(5) < UKTime.Now)
                        {
                            mvLogin.SetActiveView(viewLogin);
                        }

                        mvLogin.SetActiveView(viewReset);
                    }
                }
                lnkForgotten.Visible = true;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request.QueryString["attend"]) && Request.QueryString["attend"] == "true")
            {
                CanAttend = true;
            }

            ucNavCal.Entity          = Entity;
            btnSendRSVP.EventHandler = btnSendRSVP_Click;
            myInvite = Entity.CRM_CalendarAdmins.FirstOrDefault(f => f.AdminID == AdminUser.ID);

            if (!Page.IsPostBack)
            {
                ddlStatus.DataSource = Enumeration.GetAll <CRM_CalendarAdmin.StatusTypes>();
                ddlStatus.DataBind();

                if (CanAttend)
                {
                    ddlStatus.SelectedValue = ((byte)CRM_CalendarAdmin.StatusTypes.Attending).ToString();
                }
                else
                {
                    ddlStatus.SelectedValue = ((byte)CRM_CalendarAdmin.StatusTypes.NotAttending).ToString();
                }
            }

            if (myInvite == null)
            {
                NoticeManager.SetMessage("You are no longer tagged on this event to RSVP, or are not logged in as the person who received this email", "/admin");
            }
            else
            {
                Admin = db.Admins.Single(c => c.ID == myInvite.CRM_Calendar.CreatedByAdminID);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                using (MainDataContext db = new MainDataContext())
                {
                    AdminPage             CurrentPage  = (AdminPage)Page;
                    CRM.Code.Models.Admin currentAdmin = CurrentPage.AdminUser;

                    CRM_NavHistory History = new CRM_NavHistory()
                    {
                        FriendlyName = CurrentPage.GetPageTitle().Trim(),
                        AdminID      = currentAdmin.ID,
                        LastAccessed = UKTime.Now,
                        URL          = Request.RawUrl,
                        ContextName  = CurrentPage.CRMContext != null ? CurrentPage.CRMContext.DisplayName : ""
                    };

                    db.CRM_NavHistories.InsertOnSubmit(History);
                    db.SubmitChanges();


                    var oldHistories = db.CRM_NavHistories.Where(a => a.AdminID == currentAdmin.ID).OrderByDescending(o => o.LastAccessed).Skip(8);
                    db.CRM_NavHistories.DeleteAllOnSubmit(oldHistories);
                    db.SubmitChanges();


                    rptHistory.DataSource = currentAdmin.CRM_NavHistories.OrderByDescending(o => o.LastAccessed).Take(8);
                    rptHistory.DataBind();

                    db.Dispose();
                }
            }
        }
示例#4
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();
        }
示例#5
0
        protected void btnReset_Click(object sender, EventArgs e)
        {
            CRM.Code.Models.Admin admin = db.Admins.First(a => a.ResetLink.Contains(Request.RawUrl));
            admin.Password = AuthAdmin.GetHashedString(txtNewPassword.Text);
            db.SubmitChanges();

            mvLogin.SetActiveView(viewDone);
        }
示例#6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RunSecurity(CRM.Code.Models.Admin.AllowedSections.AdminUsers);

            int adminUserID = 0;

            if (Int32.TryParse(Request.QueryString["id"], out adminUserID) && adminUserID > 0)
            {
                Entity = db.Admins.SingleOrDefault(a => a.ID == adminUserID);
                if (Entity == null)
                {
                    Response.Redirect("/admin/adminuser/list.aspx");
                }
            }

            btnSubmitChangesTop.EventHandler    = btnSubmitChanges_Click;
            btnSubmitChangesBottom.EventHandler = btnSubmitChanges_Click;
            btnSubmit.EventHandler = btnSubmit_Click;

            if (!Page.IsPostBack)
            {
                bool newAdded = false;
                foreach (CRM_SystemAccess access in db.CRM_SystemAccesses)
                {
                    CRM_SystemAccessAdmin adminAccess = db.CRM_SystemAccessAdmins.SingleOrDefault(s => s.CRM_SystemAccessID == access.ID && s.AdminID == adminUserID);

                    if (adminAccess == null)
                    {
                        adminAccess = new CRM_SystemAccessAdmin()
                        {
                            AdminID            = adminUserID,
                            CRM_SystemAccessID = access.ID,
                            IsAdd    = false,
                            IsDelete = false,
                            IsRead   = false,
                            IsWrite  = false
                        };

                        db.CRM_SystemAccessAdmins.InsertOnSubmit(adminAccess);
                        db.SubmitChanges();
                        newAdded = true;
                    }
                }


                if (newAdded)
                {
                    Response.Redirect(Request.RawUrl);
                }

                rptItems.DataSource = from saa in db.Admins.SingleOrDefault(a => a.ID == adminUserID).CRM_SystemAccessAdmins
                                      where saa.CRM_SystemAccessID == null
                                      orderby saa.BespokeName
                                      select saa;
                rptItems.DataBind();
            }
        }
示例#7
0
        public void SendResetLink(CRM.Code.Models.Admin admin)
        {
            System.IO.StringWriter htmlStringWriter = new System.IO.StringWriter();
            HttpContext.Current.Server.Execute("/app_emails/resetlink.aspx", htmlStringWriter);

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

            htmlOutput = htmlOutput.Replace("@DISPLAYNAME@", admin.DisplayName);
            htmlOutput = htmlOutput.Replace("@EXPIRY@", ((DateTime)admin.LastReset).AddMinutes(5).ToString("dd/MM/yyyy HH:mm"));
            htmlOutput = htmlOutput.Replace("@RESETLINK@", admin.ResetLink);

            Email.SendTemplateEmail(htmlOutput.ToString(), "Your Password Reset Link", mailTo, mailCc, mailBcc, attachments);
        }
        protected void btnSendRSVP_Click(object sender, EventArgs e)
        {
            byte status = Convert.ToByte(ddlStatus.SelectedValue);

            myInvite.Status = status;
            db.SubmitChanges();

            EmailManager manager = new EmailManager();

            manager.SendRSVP(txtMessageToTags.Text, myInvite, db, AdminUser);

            CRM.Code.Models.Admin admin = db.Admins.Single(c => c.ID == myInvite.CRM_Calendar.CreatedByAdminID);
            NoticeManager.SetMessage("RSVP Sent to " + admin.DisplayName);
        }
示例#9
0
        public void Initialize()
        {
            db = new MainDataContext();

            if (HttpContext.Current.CurrentHandler is AdminPage)
            {
                AdminPage adminPage = (AdminPage)HttpContext.Current.CurrentHandler;
                CurrentAdmin = adminPage.AdminUser;
            }
            else
            {
                AuthAdmin AuthAdmin = new AuthAdmin(db);
                CurrentAdmin = AuthAdmin.Authorise();
            }
        }
示例#10
0
        protected void btnForgotten_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                CRM.Code.Models.Admin admin = db.Admins.First(a => a.Username.ToLower().Trim() == txtEmailUsername.Text.ToLower().Trim() || a.Email.ToLower().Trim() == txtEmailUsername.Text.ToLower().Trim());
                admin.LastReset = UKTime.Now;
                litEmail.Text   = admin.Email;
                admin.ResetLink = Constants.DomainName + "admin/login.aspx?verify=" + Guid.NewGuid();

                db.SubmitChanges();

                EmailManager manager = new EmailManager();
                manager.AddTo(admin.Email);
                manager.SendResetLink(admin);

                mvLogin.SetActiveView(viewSent);
            }
        }
        public bool Login(string username, string password)
        {
            bool result = false;

            string encryptedPassword = GetHashedString(password);

            CRM.Code.Models.Admin admin = db.Admins.SingleOrDefault(p => p.Password == encryptedPassword && p.Username == username);

            if (admin != null)
            {
                CreateSession(admin.ID, CookieAuthTypes.Admin);
                result = true;

                admin.LastLogin = DateTime.UtcNow;
                db.SubmitChanges();
            }

            return(result);
        }
示例#12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Entity = db.Admins.SingleOrDefault(a => a.ID.ToString() == Request.QueryString["id"]);

            RunSecurity(CRM.Code.Models.Admin.AllowedSections.AdminUsers);


            // buttons //

            btnSubmit.EventHandler        = btnSubmit_Click;
            btnSubmitChanges.EventHandler = btnSubmitChanges_Click;

            // Security //

            btnSubmitChanges.Visible = PermissionManager.CanUpdate;
            if (!PermissionManager.CanAdd && Entity == null)
            {
                Response.Redirect("/admin/adminuser/list.aspx");
            }

            // confirmations //

            confirmationDelete.StandardDeleteHidden("item", btnRealDelete_Click);

            // process //

            if (!IsPostBack)
            {
                if (Entity != null)
                {
                    PopulateFields();
                }
            }
            if (Entity == null)
            {
                txtPassword.Required = true;
            }
        }
        protected void SaveRecord(bool newRecord)
        {
            // new record / exiting record //

            if (newRecord)
            {
                Entity = new CRM.Code.Models.Admin();
                db.Admins.InsertOnSubmit(Entity);
            }

            Entity.Username  = txtUsername.Text;
            Entity.Email     = txtEmail.Text;
            Entity.FirstName = txtFirstName.Text;
            Entity.Surname   = txtSurname.Text;

            if (!String.IsNullOrEmpty(txtPassword.Text))
            {
                Entity.Password = Auth.GetHashedString(txtPassword.Text);
            }


            db.SubmitChanges();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            RunSecurity(CRM.Code.Models.Admin.AllowedSections.AdminUsers);

            Entity     = AdminUser;
            CRMContext = Entity;
            // buttons //

            btnSubmit.EventHandler        = btnSubmit_Click;
            btnSubmitChanges.EventHandler = btnSubmitChanges_Click;

            // Security //

            btnSubmitChanges.Visible = PermissionManager.CanUpdate;
            if (Entity == null)
            {
                Response.Redirect("/admin/adminuser/list.aspx");
            }

            // confirmations //

            confirmationDelete.StandardDeleteHidden("item", btnRealDelete_Click);

            // process //

            if (!IsPostBack)
            {
                if (Entity != null)
                {
                    PopulateFields();
                }
            }
            if (Entity == null)
            {
                txtPassword.Required = true;
            }
        }
        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);
        }
示例#16
0
 public AdminList(DateTime Time, CRM.Code.Models.Admin Admin)
 {
     CRM_CalendarAdmins = Admin.CRM_CalendarAdmins.Where(c => c.CRM_Calendar.StartDateTime >= Time && c.CRM_Calendar.StartDateTime < Time.AddHours(1));
 }