コード例 #1
0
        public void LoadBored()
        {
            if (_board != null)
            {
                Cache[_board.Name] = _board;
            }
            else
            {
                string boredName = string.Empty;
                if (ViewState["boardName"] == null)
                {
                    ViewState["boardName"] = boredName = Request["cat"].ToString().URLDecodeToName();
                }
                else
                {
                    boredName = ViewState["boardName"].ToString();
                }

                _board = Cache[boredName] as ScoreBored;

                if (_board == null)
                {
                    try
                    {
                        Cache[boredName] = _board = ScoreBored.Load(boredName);
                    }
                    catch { }
                }
            }
        }
コード例 #2
0
        protected void btnGo_Click(object sender, EventArgs e)
        {
            string     cnString   = WebConfigurationManager.ConnectionStrings["LocalMySqlServer"].ToString();
            ScoreBored scoreBored = CreateBored();

            MembershipUser user = Membership.GetUser();

            bool success = false;

            try
            {
                if (Request["edit"] != null)
                {
                    string oldName = Request["edit"].ToString().URLDecodeToName();
                    scoreBored.Update(oldName);
                    Cache.Remove(oldName);
                }
                else
                {
                    scoreBored.Save();
                }
                success = true;
            }
            catch (Exception ex)
            {
                lblFeedback.Text = "Sorry the name you chose is already taken.  Try a new name";
            }

            if (success)
            {
                Response.Redirect("/bored/" + scoreBored.Name.URLEncodeName());
            }

            //}
        }
コード例 #3
0
        protected void EditBoard(string boardName)
        {
            ScoreBored board = ScoreBored.Load(boardName);

            MembershipUser user = Membership.GetUser();

            if (board != null && board.UserId == user.ProviderUserKey.ToString())
            {
                txtTheme.Text = board.Description;

                h1.InnerText  = "Edit Board";
                editWarn.Text = "Note:  Edits to the name of a Pros and Cons List or the Competitor Names in a Tournament will change the URL for the board.  This will invalidate social networking bookmarks and embedded mini-boards";

                rdoType.SelectedIndex = (board.IsProCon) ? 0 : 1;
                rdoType_SelectedIndexChanged(this, null);

                if (board.IsProCon)
                {
                    txtName.Text   = board.Name;
                    txtMatch1.Text = "Pro";
                    txtMatch2.Text = "Con";


                    txtPro3.Text = board.Phrases[-3];
                    txtPro2.Text = board.Phrases[-2];
                    txtPro1.Text = board.Phrases[-1];

                    txtCon1.Text = board.Phrases[1];
                    txtCon2.Text = board.Phrases[2];
                    txtCon3.Text = board.Phrases[3];

                    chkIs.Checked = board.PhraseIs;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "startup", "proConPre(); ", true);
                }
                else
                {
                    txtMatch1.Text = board.ProName;
                    txtMatch2.Text = board.ConName;

                    txtVSphrase1.Text = board.Phrases[1];
                    txtVSphrase2.Text = board.Phrases[2];
                    txtVSphrase3.Text = board.Phrases[3];
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "startup", "matchPre(); ", true);
                }
            }
            else
            {
                Response.Redirect(Request.AppRelativeCurrentExecutionFilePath);
            }
        }
コード例 #4
0
        protected ScoreBored CreateBored()
        {
            ScoreBored scoreBored = null;

            MembershipUser user = Membership.GetUser();

            //Contestants should be broken into their own table

            string boardName = (rdoType.SelectedIndex == 0) ?
                               (txtName.Text.Trim() == string.Empty)? "[Board Name]" : txtName.Text.MakeName() :
                               txtMatch1.Text + " vs " + txtMatch2.Text;


            scoreBored = new ScoreBored()
            {
                Name        = boardName,
                Description = txtTheme.Text,
                UserId      = user.ProviderUserKey.ToString(),
                ProName     = (rdoType.SelectedIndex == 0)? "Pro" : (txtMatch1.Text.Trim() == string.Empty) ? "[Contestant1]" : txtMatch1.Text.Trim(),
                ConName     = (rdoType.SelectedIndex == 0) ? "Con" : (txtMatch2.Text.Trim() == string.Empty) ? "[Contestant2]" : txtMatch2.Text.Trim(),
                PhraseIs    = chkIs.Checked,
                Phrases     = new Dictionary <short, string>()
            };

            //ProCon
            if (rdoType.SelectedIndex == 0)
            {
                scoreBored.Phrases.Add(-3, txtPro3.Text);
                scoreBored.Phrases.Add(-2, txtPro2.Text);
                scoreBored.Phrases.Add(-1, txtPro1.Text);

                scoreBored.Phrases.Add(0, this.txtConTie.Text);

                scoreBored.Phrases.Add(1, txtCon1.Text);
                scoreBored.Phrases.Add(2, txtCon2.Text);
                scoreBored.Phrases.Add(3, txtCon3.Text);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "startup", "proConPre(); ", true);
            }
            else
            {
                scoreBored.Phrases.Add(0, txtVStie.Text);
                scoreBored.Phrases.Add(1, txtVSphrase1.Text);
                scoreBored.Phrases.Add(2, txtVSphrase2.Text);
                scoreBored.Phrases.Add(3, txtVSphrase3.Text);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "startup", "matchPre(); ", true);
            }

            return(scoreBored);
        }
コード例 #5
0
        protected ScoreBored CreateBored()
        {
            ScoreBored scoreBored = null;

            MembershipUser user = Membership.GetUser();

            //Contestants should be broken into their own table

            string boardName = (rdoType.SelectedIndex == 0) ?
                (txtName.Text.Trim() == string.Empty)? "[Board Name]" : txtName.Text.MakeName() :
                txtMatch1.Text + " vs " + txtMatch2.Text;

            scoreBored = new ScoreBored()
            {
                Name = boardName,
                Description = txtTheme.Text,
                UserId = user.ProviderUserKey.ToString(),
                ProName = (rdoType.SelectedIndex == 0)? "Pro" : (txtMatch1.Text.Trim() == string.Empty) ? "[Contestant1]" : txtMatch1.Text.Trim(),
                ConName= (rdoType.SelectedIndex == 0) ? "Con" : (txtMatch2.Text.Trim() == string.Empty) ? "[Contestant2]" : txtMatch2.Text.Trim(),
                 PhraseIs = chkIs.Checked,
                  Phrases = new Dictionary<short,string>()
            };

            //ProCon
            if (rdoType.SelectedIndex == 0)
            {
                scoreBored.Phrases.Add(-3, txtPro3.Text);
                scoreBored.Phrases.Add(-2, txtPro2.Text);
                scoreBored.Phrases.Add(-1, txtPro1.Text);

                scoreBored.Phrases.Add(0, this.txtConTie.Text);

                scoreBored.Phrases.Add(1, txtCon1.Text);
                scoreBored.Phrases.Add(2, txtCon2.Text);
                scoreBored.Phrases.Add(3, txtCon3.Text);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "startup", "proConPre(); ", true);
            }
            else
            {
                scoreBored.Phrases.Add(0, txtVStie.Text);
                scoreBored.Phrases.Add(1, txtVSphrase1.Text);
                scoreBored.Phrases.Add(2, txtVSphrase2.Text);
                scoreBored.Phrases.Add(3, txtVSphrase3.Text);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "startup", "matchPre(); ", true);
            }

            return scoreBored;
        }
コード例 #6
0
        public static ScoreBored Load(string boredName)
        {
            ScoreBored frankenstein = null;

            Database db = DatabaseFactory.CreateDatabase("cnGrammit");

            //remove the "_" chars first
            using (IDataReader rdr = db.ExecuteReader("[usp_Z_Score_getBoard]", boredName))
            {
                if (rdr.Read())
                {
                    frankenstein = new ScoreBored()
                    {
                        ID          = Convert.ToInt32(rdr["ID"]),
                        UserId      = rdr["UserID"].ToString(),
                        UserName    = rdr["UserName"].ToString(),
                        ConName     = rdr["CON_NAME"].ToString(),
                        Cons        = new List <Score>(),
                        Created     = DateTime.Parse(rdr["DT_CREATED"].ToString()),
                        Description = rdr["DESCRIPTION"].ToString(),
                        Name        = rdr["NAME"].ToString(),
                        ProName     = rdr["PRO_NAME"].ToString(),
                        Pros        = new List <Score>(),
                        Phrases     = new Dictionary <short, string>(),
                        PhraseIs    = Convert.ToBoolean(rdr["IS_PHRASE"])
                    };
                }
                else
                {
                    return(null);
                }
                if (rdr.NextResult())
                {
                    while (rdr.Read())
                    {
                        Score score = new Score()
                        {
                            Created   = DateTime.Parse(rdr["DT_CREATED"].ToString()),
                            RatingRaw = Convert.ToInt32(rdr["SCORE"]),
                            Text      = rdr["WORDS"].ToString(),
                            UserId    = rdr["UserID"].ToString(),
                            ID        = Convert.ToInt32(rdr["ID"]),
                            Votes     = new List <Vote>(Convert.ToInt32(rdr["VOTES"])),
                            IsPro     = Convert.ToBoolean(rdr["IS_PRO"])
                        };

                        if (score.IsPro)
                        {
                            frankenstein.Pros.Add(score);
                        }
                        else
                        {
                            frankenstein.Cons.Add(score);
                        }
                    }
                }

                if (rdr.NextResult())
                {
                    while (rdr.Read())
                    {
                        frankenstein.Phrases.Add(Convert.ToInt16(rdr["MARGIN"]), rdr["PHRASE"].ToString());
                    }
                }

                if (rdr.NextResult())
                {
                    while (rdr.Read())
                    {
                        Score parentScore = frankenstein.FindScore(Convert.ToBoolean(rdr["IS_PRO"]), Convert.ToInt32(rdr["SCORE_ID"]));

                        Vote vote = new Vote()
                        {
                            ID       = Convert.ToInt32(rdr["ID"]),
                            Comment  = rdr["COMMENT"].ToString(),
                            UserId   = rdr["UserId"].ToString(),
                            UserName = rdr["UserName"].ToString(),
                            Weight   = Convert.ToInt16(rdr["WEIGHT"]),
                            Dt       = Convert.ToDateTime(rdr["DT_CREATED"]),
                            Parent   = parentScore
                        };
                        parentScore.Votes.Add(vote);
                    }
                }
            }

            if (frankenstein.Pros.Count == 0)
            {
                frankenstein.Pros.Add(
                    new Score()
                {
                    ID        = 0,
                    RatingRaw = 0,
                    Text      = "Vote to add points"
                });
            }
            if (frankenstein.Cons.Count == 0)
            {
                frankenstein.Cons.Add(
                    new Score()
                {
                    ID        = 0,
                    RatingRaw = 0,
                    Text      = "Vote to add points"
                });
            }

            return(frankenstein);
        }
コード例 #7
0
        public void LoadBored()
        {
            if (_board != null)
            {
                Cache[_board.Name] = _board;
            }
            else
            {
                string boredName = string.Empty;
                if (ViewState["boardName"] == null)
                {
                    ViewState["boardName"] = boredName = Request["cat"].ToString().URLDecodeToName();
                }
                else
                {
                    boredName = ViewState["boardName"].ToString();
                }

                _board = Cache[boredName] as ScoreBored;

                if (_board == null)
                {
                    try
                    {
                        Cache[boredName] = _board = ScoreBored.Load(boredName);
                    }
                    catch { }
                }
            }
        }
コード例 #8
-1
        public static ScoreBored Load(string boredName)
        {
            ScoreBored frankenstein = null;

            Database db = DatabaseFactory.CreateDatabase("cnGrammit");

            //remove the "_" chars first
            using (IDataReader rdr = db.ExecuteReader("[usp_Z_Score_getBoard]", boredName))
            {
                if (rdr.Read())
                {
                    frankenstein = new ScoreBored()
                    {
                        ID = Convert.ToInt32(rdr["ID"]),
                        UserId = rdr["UserID"].ToString(),
                        UserName = rdr["UserName"].ToString(),
                        ConName = rdr["CON_NAME"].ToString(),
                        Cons = new List<Score>(),
                        Created = DateTime.Parse(rdr["DT_CREATED"].ToString()),
                        Description = rdr["DESCRIPTION"].ToString(),
                        Name = rdr["NAME"].ToString(),
                        ProName = rdr["PRO_NAME"].ToString(),
                        Pros = new List<Score>(),
                        Phrases = new Dictionary<short, string>(),
                        PhraseIs = Convert.ToBoolean(rdr["IS_PHRASE"])

                    };
                }
                else
                {
                    return null;
                }
                if (rdr.NextResult())
                {
                    while (rdr.Read()){
                        Score score = new Score(){
                             Created = DateTime.Parse(rdr["DT_CREATED"].ToString()),
                              RatingRaw = Convert.ToInt32(rdr["SCORE"]),
                               Text =  rdr["WORDS"].ToString(),
                                UserId = rdr["UserID"].ToString(),
                                ID = Convert.ToInt32(rdr["ID"]),
                                 Votes = new List<Vote>(Convert.ToInt32(rdr["VOTES"])),
                                  IsPro = Convert.ToBoolean(rdr["IS_PRO"])
                        };

                        if (score.IsPro)
                        {
                            frankenstein.Pros.Add(score);
                        }
                        else
                            frankenstein.Cons.Add(score);
                    }
                }

                if (rdr.NextResult())
                {
                    while (rdr.Read())
                    {
                        frankenstein.Phrases.Add(Convert.ToInt16(rdr["MARGIN"]), rdr["PHRASE"].ToString());
                    }
                }

                if (rdr.NextResult())
                {
                    while (rdr.Read())
                    {
                        Score parentScore = frankenstein.FindScore(Convert.ToBoolean(rdr["IS_PRO"]), Convert.ToInt32(rdr["SCORE_ID"]));

                        Vote vote = new Vote()
                        {
                            ID = Convert.ToInt32(rdr["ID"]),
                            Comment = rdr["COMMENT"].ToString(),
                            UserId = rdr["UserId"].ToString(),
                            UserName = rdr["UserName"].ToString(),
                            Weight = Convert.ToInt16(rdr["WEIGHT"]),
                            Dt = Convert.ToDateTime(rdr["DT_CREATED"]),
                            Parent = parentScore
                        };
                        parentScore.Votes.Add(vote);
                    }
                }
            }

            if (frankenstein.Pros.Count == 0)
            {
                frankenstein.Pros.Add(
                    new Score()
                    {
                        ID = 0,
                        RatingRaw = 0,
                         Text="Vote to add points"
                    });
            }
            if (frankenstein.Cons.Count == 0)
            {
                frankenstein.Cons.Add(
                    new Score()
                    {
                        ID = 0,
                        RatingRaw = 0,
                        Text = "Vote to add points"
                    });
            }

            return frankenstein;
        }