public void RaiseCallbackEvent(string eventArgument) { result = ""; try { string[] tmp = eventArgument.Split(':'); if (tmp.Length == 2) { int contestID; if (int.TryParse(tmp[0], out contestID)) { if (!string.IsNullOrEmpty(everyproblemname)) { ContestTime c = (ContestTime)Enum.Parse(typeof(ContestTime), tmp[1]); if ((c & everytype) != 0) { result = string.Format("{0}^{1}|", everyproblemname, 0); } } foreach (Problem p in Problem.GetProblems(contestID)) { result += string.Format("Задача {0}. {1}^{2}|", p.ShortName, p.Name, p.ID); } } else { result = "Ошибка в обработке Callback^1"; } } } catch { result = "Ошибка в обработке Callback^1"; } }
protected void Page_Load(object sender, EventArgs e) { //TODO: Test !IsPostBack - unsuccessful if (!IsPostBack) { cont = "document.getElementById('" + contestsDDL.ClientID + "').options[0].value"; //contestID == 0 && problemID == 0 prob = "0"; if (contestID != 0) { cont = String.Format("{0}:{1}", contestID, Contest.GetContest(contestID).Time); prob = problemID.ToString(); } ContestTime type = ContestTime.None; if (current) { type |= ContestTime.Current; } if (past) { type |= ContestTime.Past; } if (forthcoming) { type |= ContestTime.Forthcoming; } foreach (Contest c in Contest.GetContests(type)) { contestsDDL.Items.Add(new ListItem(c.Name, String.Format("{0}:{1}", c.ID, c.Time))); } if (contestID != 0) { contestsDDL.SelectedValue = cont; } } if (contestsDDL.Items.Count != 0) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "selc", "function SelectedContestChanged(arg, context){" + Page.ClientScript.GetCallbackEventReference(this, "arg", "ProcessCallbackResult", "context", true) + ";" + fcalling + ";}", true); string script = "SelectedContestChanged("; if (contestID != 0) { script += "\"" + cont + "\",'ddl');"; } else { script += cont + ",'ddl');"; } Page.ClientScript.RegisterStartupScript(GetType(), "initproblemsDDL", script, true); contestsDDL.Attributes.Add("onchange", "javascript:SelectedContestChanged(this.options[this.selectedIndex].value,'ddl');"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "check", "CheckContestLack()", true); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ContestTime type = ContestTime.None; if (current) { type |= ContestTime.Current; } if (past) { type |= ContestTime.Past; } if (forthcoming) { type |= ContestTime.Forthcoming; } contestsDDL.DataSource = Contest.GetContests(type); contestsDDL.DataBind(); if (contestsDDL.Items.Count == 0) { errmessTR.Visible = true; ddlTR.Visible = false; } } }
public static Contest[] GetContests(ContestTime time) { if (time != ContestTime.None) { return(DataProvider.Provider.ContestManager.GetContests(time)); } else { return new Contest[] {} }; }
public override Contest[] GetContests(ContestTime type) { string[] conds = new string[] { "(Beginning <= GETDATE() AND Ending >= GETDATE())", "Ending < GETDATE()", "Beginning > GETDATE()" }; string command = "SELECT * FROM Contests WHERE "; bool first = true; int[] inds = new int[] { 1, 2, 4 }; for (int i = 0; i < 3; i++) { if (((int)type & inds[i]) != 0) { if (!first) { command += " OR "; } first = false; command += conds[i]; } } List <Contest> ret = new List <Contest>(); using (MsSqlQuery q = new MsSqlQuery(_connectionString)) using (SqlDataReader rdr = q.ExecuteReader(command, null, null)) { while (rdr.Read()) { ret.Add(FromReader(rdr)); } } ret.Sort(delegate(Contest a, Contest b) { if (a.Time > b.Time) { return(1); } if (a.Time < b.Time) { return(-1); } return(0); }); return(ret.ToArray()); }
public abstract Contest[] GetContests(ContestTime type);