コード例 #1
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
                return;

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // create new schedule
            Schedule schedule = new Schedule();

            // set schedule properties
            schedule.ID = Guid.NewGuid();
            schedule.AccountID = (Session["CurrentAccount"] as Common.Account).ID;
            schedule.Name = this.txtName.Text;
            schedule.Occurrence = CrontabSchedule.Parse(this.txtOccurrence.Text).ToString();
            schedule.NextOccurrence = CrontabSchedule.Parse(schedule.Occurrence).GetNextOccurrence(DateTime.UtcNow);
            schedule.Endpoint = this.txtEndpoint.Text;
            schedule.IsEnabled = true;
            schedule.CreatedDate = DateTime.UtcNow;

            // insert schedule to database
            db.Schedules.InsertOnSubmit(schedule);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to default page
            Response.Redirect("~/default.aspx");
        }
コード例 #2
0
ファイル: Edit.aspx.cs プロジェクト: mbmccormick/CronWebsite
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
                return;

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current schedule
            Schedule schedule = db.Schedules.SingleOrDefault(z => z.ID == new Guid(Request.QueryString["id"]));

            // set schedule properties
            schedule.Name = this.txtName.Text;
            schedule.Occurrence = CrontabSchedule.Parse(this.txtOccurrence.Text).ToString();
            schedule.NextOccurrence = CrontabSchedule.Parse(schedule.Occurrence).GetNextOccurrence(DateTime.UtcNow);
            schedule.Endpoint = this.txtEndpoint.Text;

            // update schedule in database
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // bind data to page
            this.BindData();
        }
コード例 #3
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
                return;

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // create new account
            Common.Account account = new Common.Account();

            // set account properties
            account.ID = Guid.NewGuid();
            account.EmailAddress = this.txtEmailAddress.Text;
            account.Password = Utilities.HashPassword(this.txtPassword.Text);
            account.Type = 1;
            account.CreatedDate = DateTime.UtcNow;

            // insert account to database
            db.Accounts.InsertOnSubmit(account);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to default page
            Response.Redirect("~/login.aspx?success=true");
        }
コード例 #4
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
                return;

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current account
            Common.Account account = db.Accounts.SingleOrDefault(z => z.ID == (Session["CurrentAccount"] as Common.Account).ID);

            // set schedule properties
            account.EmailAddress = this.txtEmailAddress.Text;
            if (this.txtPassword.Text.Length > 0)
            {
                account.Password = Utilities.HashPassword(this.txtPassword.Text);
            }

            // update schedule in database
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // update schedule in session
            Session["CurrentAccount"] = account;

            // bind data to page
            this.BindData();
        }
コード例 #5
0
        private void BindData()
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // bind schedules to display
            this.grdResults.DataSource = db.Schedules.Where(z => z.AccountID == (Session["CurrentAccount"] as Common.Account).ID).OrderBy(z => z.Name);
            this.grdResults.DataBind();

            // close connection
            db.Dispose();
        }
コード例 #6
0
        private void BindData()
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // bind schedules to display
            this.grdResults.DataSource = db.Informations.Where(z => z.ScheduleID == new Guid(Request.QueryString["id"])).OrderByDescending(z => z.CreatedDate);
            this.grdResults.DataBind();

            // close connection
            db.Dispose();
        }
コード例 #7
0
        private void BindData()
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current account
            Common.Account account = db.Accounts.SingleOrDefault(z => z.ID == (Session["CurrentAccount"] as Common.Account).ID);

            // set form properties
            this.txtEmailAddress.Text = account.EmailAddress;

            // close connection
            db.Dispose();
        }
コード例 #8
0
ファイル: Edit.aspx.cs プロジェクト: mbmccormick/CronWebsite
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current schedule
            Schedule schedule = db.Schedules.SingleOrDefault(z => z.ID == new Guid(Request.QueryString["id"]));

            // delete schedule from database
            db.Schedules.DeleteOnSubmit(schedule);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to default page
            Response.Redirect("~/default.aspx");
        }
コード例 #9
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current account
            Common.Account account = db.Accounts.SingleOrDefault(z => z.ID == (Session["CurrentAccount"] as Common.Account).ID);

            // delete account from database
            db.Accounts.DeleteOnSubmit(account);
            db.SubmitChanges();

            // close connection
            db.Dispose();

            // redirect to logout page
            Response.Redirect("~/logout.aspx");
        }
コード例 #10
0
ファイル: Login.aspx.cs プロジェクト: mbmccormick/CronWebsite
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            // validate input
            if (this.ValidateInput() == false)
                return;

            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // validate account credentials
            var account = db.Accounts.Where(z => z.EmailAddress == this.txtEmailAddress.Text &&
                                                 z.Password == Utilities.HashPassword(this.txtPassword.Text)).SingleOrDefault();

            if (account != null)
            {
                Session["CurrentAccount"] = account;
            }
            else
            {
                // show errors panel
                this.pnlErrors.Visible = true;

                // set errors text
                this.litErrors.Text = "<ul>\n";
                this.litErrors.Text += "<li>Your credentials could not be authenticated.</li>\n";
                this.litErrors.Text += "</ul>\n";

                // close connection
                db.Dispose();

                return;
            }

            // close connection
            db.Dispose();

            // redirect to default page
            Response.Redirect("~/dashboard.aspx");
        }
コード例 #11
0
ファイル: Edit.aspx.cs プロジェクト: mbmccormick/CronWebsite
        private void BindData()
        {
            // connect to database
            DatabaseDataContext db = new DatabaseDataContext();

            // fetch current schedule
            Schedule schedule = db.Schedules.SingleOrDefault(z => z.ID == new Guid(Request.QueryString["id"]));

            // set form properties
            this.txtName.Text = schedule.Name;
            this.txtOccurrence.Text = schedule.Occurrence;
            this.txtEndpoint.Text = schedule.Endpoint;
            this.txtNextOccurrence.Text = schedule.NextOccurrence.ToString();

            this.lnkInformation.NavigateUrl = "~/information.aspx?id=" + schedule.ID;

            // fetch last information
            Common.Information information = schedule.Informations.OrderByDescending(z => z.CreatedDate).FirstOrDefault();

            if (information != null)
            {
                // set form properties
                this.lblLastOccurrence.Text = "This job was last executed on " + information.CreatedDate.ToString();
                if (information.Result == 200)
                    this.lblLastStatus.Text = "succeeded with a status code of " + information.Result.ToString();
                else
                    this.lblLastStatus.Text = "failed with a status code of " + information.Result.ToString();
            }
            else
            {
                this.lblLastOccurrence.Text = "This job has not been excuted";
                this.lblLastStatus.Text = "does not have a status yet";
            }

            // close connection
            db.Dispose();
        }