private void SetRepeaterStatuses(alertprogress ap) { foreach (RepeaterItem r in this.RepeaterStudents.Items) { Label sidLabel = (Label)r.FindControl("LabelStudentId"); Image status = (Image)r.FindControl("ImageStatus"); foreach (string sid in ap.sent) { if (sidLabel.Text == sid) { status.ImageUrl = "~/img/ok.png"; status.ToolTip = "Sent!"; } } foreach (KeyValuePair <string, string> kvp in ap.error) { if (sidLabel.Text == kvp.Key) { status.ImageUrl = "~/img/error.png"; status.ToolTip = kvp.Value; } } } }
public alertprogress CreateSendingOrderIdList(datasethas hasData) { alertprogress ap = new alertprogress(new List <string>(), new List <string>()); foreach (System.Data.DataRow dr in hasData.student.Rows) { ap.unsent.Add(dr["id"].ToString()); } return(ap); }
protected void Page_Load(object sender, EventArgs e) { bool cancel = new tools().SessionCheck(Session); if (cancel) { Response.Redirect("Default.aspx"); } int aid = int.Parse(Session[constants.SESSION_MODE_SEND_AID].ToString()); dataaccess da = new dataaccess(); _hasData = da.GetAlertClassAndStudentsByAlertId(aid); labelClassId.Text = _hasData._class[0].id.ToString(); labelClassnumber.Text = _hasData._class[0].classnumber.ToString(); this.RepeaterStudents.DataSource = _hasData.student; this.RepeaterStudents.DataBind(); this.imageButtonSend.ToolTip = "Start Sending Alerts"; if (Session[constants.SESSION_MODE].ToString() == constants.SESSION_MODE_SENDING) { tools t = new tools(); alertprogress ap = (alertprogress)Session[constants.SESSION_MODE_SENDING_PROGRESS]; this.imageButtonSend.ImageUrl = "~/img/sending.gif"; this.imageButtonSend.ToolTip = "Sending Alerts~ (Please Wait)"; this.SetRepeaterStatuses(ap); //Verify script isn't already registered if (!ClientScript.IsClientScriptBlockRegistered("waitScript")) { string js = "\n<script type=\"text/javascript\" language=\"Javascript\" id=\"waitScript\">\n"; js += "wait(2000);"; js += "\n\n </script>"; ClientScript.RegisterClientScriptBlock(this.GetType(), "waitScript", js); } t.Alerting(Session, ap); } if (Session[constants.SESSION_MODE].ToString() == constants.SESSION_MODE_SENDING_FINISHED) { alertprogress ap = (alertprogress)Session[constants.SESSION_MODE_SENDING_PROGRESS]; this.imageButtonSend.ImageUrl = "~/img/ok.png"; this.imageButtonSend.ToolTip = "Finished Sending! Click to return to class~ ^^"; this.SetRepeaterStatuses(ap); da.UpdateAlertStatus(aid); } }
protected void imageButtonSend_Click(object sender, ImageClickEventArgs e) { if (Session[constants.SESSION_MODE].ToString() == constants.SESSION_MODE_SENDING_FINISHED) { //revert to class edit mode and leave Session[constants.SESSION_MODE] = constants.SESSION_MODE_EDIT_CLASS; Response.Redirect("alerts.aspx"); } else { tools t = new tools(); alertprogress ap = t.CreateSendingOrderIdList(_hasData); this.imageButtonSend.ImageUrl = "~/img/sending.gif"; Session[constants.SESSION_MODE] = constants.SESSION_MODE_SENDING; t.Alerting(Session, ap); Response.Redirect("sendalert.aspx"); } }
public void Alerting(System.Web.SessionState.HttpSessionState session, alertprogress ap) { homeworkAlertSystem has = new homeworkAlertSystem(ap.unsent[0], session[constants.SESSION_MODE_SEND_AID].ToString()); if (has.isSent) { ap.sent.Add(ap.unsent[0]); } else { ap.error.Add(ap.unsent[0], has.errorMessage); } ap.unsent.Remove(ap.unsent[0]); session.Remove(constants.SESSION_MODE_SENDING_PROGRESS); session.Add(constants.SESSION_MODE_SENDING_PROGRESS, ap); if (ap.unsent.Count == 0) { session[constants.SESSION_MODE] = constants.SESSION_MODE_SENDING_FINISHED; } }