示例#1
0
文件: RateRank.cs 项目: d3x0r/xperdex
		public static void UpdateRanks( DateTime day_in_week, int session )
		{
			if( input_db != null )
			{
				long week_id = StateWriter.GetWeekID( day_in_week, session );
				input_db.KindExecuteNonQuery( "replace into called_game_player_rank (card,session,bingoday,week_id,pack_set_id,game_count,total_points)"
						+ " SELECT card,session,bingoday,"+week_id+",pack_set_id,count(*) as game_count,sum(total_points) as total_points"
						+ " FROM called_game_player_rank2 where "
					    //+ (true?"pack_set_id=1":"pack_set_id>0")
						+ " card<>'000000000000000000'"
						//+ " and session=" + playing_session.session_number
						+ " and " + String_Utilities.BuildSessionRangeCondition( null, day_in_week, session )
						//+ " and bingoday=" + MySQLDataTable.MakeDateOnly( playing_session.bingoday )
						+ " group by card,pack_set_id,session,bingoday order by bingoday,session,card,pack_set_id"
						);

				if( use_bonus_points )
				{
					MySQLDataTable table = new MySQLDataTable( input_db, "select * from rate_rank_bonus_points" );
					MySQLDataTable totals = new MySQLDataTable( input_db, "select * from called_game_player_rank where bingoday="+DsnSQLUtil.MakeDateOnly( input_db, day_in_week ) +" and session="+session+" order by total_points desc" );
					if( totals != null && ( totals.Rows.Count > 0 ) )
					{
						int place_num;
						foreach( DataRow row in table.Rows )
						{
							place_num = Convert.ToInt32( row["place_in_session"] );
							input_db.KindExecuteNonQuery( "replace into called_game_player_rank_bonus (card,week_id,bonus_points,bingoday,session)values("
								+ input_db.sql_value_quote_open + totals.Rows[place_num - 1]["card"] + input_db.sql_value_quote_close + "," 
								+ week_id + ","
								+ row["bonus_points"].ToString() + ","
								+ DsnSQLUtil.MakeDateOnly( input_db, day_in_week ) + ","
								+ session 
								+ ")" );
						}
					}
				}
				if( use_bonus_points )
				{
					input_db.KindExecuteNonQuery(
						"replace into called_game_player_rank_partial (card,session,bingoday,total_points,week_id)"
	+ "select a.card,a.session,a.bingoday,a.total_points+sum(IF(ISNULL(c.bonus_points),0,c.bonus_points)),a.week_id from called_game_player_rank as a left"
	+ " join called_game_player_rank as b on a.card=b.card and a.week_id=b.week_id and a.total_points<b.total_points"
	+ " left join called_game_player_rank_bonus as c on a.card=c.card "
	+ " where b.card is null and a.week_id=" + week_id
	+ " group by a.card,a.session,a.bingoday,a.total_points,a.week_id"
					);
				}
				else
				{
					input_db.KindExecuteNonQuery(
						"replace into called_game_player_rank_partial (card,session,bingoday,total_points,week_id)"
	+ "select a.card,a.session,a.bingoday,a.total_points,a.week_id from called_game_player_rank as a left"
	+ " join called_game_player_rank as b on a.card=b.card and a.week_id=b.week_id and a.total_points<b.total_points"
	+ " where b.card is null and a.week_id=" + week_id
					);
				}
#if asdfasdf	
					"replace into called_game_player_rank_partial(card,session,bingoday,week_id,total_points)"
								+ " select card,session,bingoday,week_id,max(total_points) as total_points"
								+ " from called_game_player_rank"
								+ " where week_id=" + week_id 
								+ " group by bingoday,session,card"
						);
#endif
			}
		}
示例#2
0
        // Add JMU
        /// <summary>
        /// Recursive Look for the value the last Node. Make Changes in the database.
        /// </summary>
        /// <param name="Parent_node_id"></param>
        /// <param name="p_Path"></param>
        /// <returns>The value of the Option searched for</returns>
        private string recursiveSetValueOptionTree(int Parent_node_id, string p_Path, string Default_value, string Default_Description)
        {
            string       path1, path2, sql, value;
            int          DelimeterSize, parent_id;
            DbDataReader OptionReader;

            DelimeterSize = p_Path.IndexOf("/");
            if (DelimeterSize == -1)
            {
                #region Search for value
                sql = " Select value.value_id " +
                      " FROM option_map map, option_name name, option_values value " +
                      " WHERE map.parent_node_id = " + Parent_node_id +
                      " AND   map.name_id = name.name_id " +
                      " AND   name.name = '" + p_Path + "'" +
                      " AND   map.value_id = value.value_id ";

                OptionReader = _dsn.KindExecuteReader(sql);
                if (!(OptionReader.HasRows))
                {
                    OptionReader.Close();
                    OptionReader = null;
                    int name_id  = GetNameID(p_Path);
                    int value_id = InsertValue(Default_value);
                    InsertOptionNode(Parent_node_id, name_id, Default_Description, value_id);
                    value = Default_value;
                }
                else
                {
                    value = OptionReader.GetString(OptionReader.GetOrdinal("value_id"));
                    OptionReader.Close();
                    OptionReader = null;

                    sql = " UPDATE option_values " +
                          " SET string = '" + Default_value + "' " +
                          " WHERE value_id = " + value;

                    _dsn.KindExecuteNonQuery(sql);
                }

                return(value);

                #endregion
            }
            else
            {
                #region Search Recursive ChildNode
                path1 = p_Path.Substring(0, DelimeterSize);
                path2 = p_Path.Substring(DelimeterSize + 1);

                sql = " Select map.node_id " +
                      " FROM option_map map, option_name name " +
                      " WHERE map.parent_node_id = " + Parent_node_id +
                      " AND   map.name_id = name.name_id " +
                      " AND   name.name = '" + path1 + "'";
                OptionReader = _dsn.KindExecuteReader(sql);
                if (!(OptionReader.HasRows))
                {
                    OptionReader.Close();
                    OptionReader = null;
                    int name_id = GetNameID(path1);
                    int node_id = InsertOptionNode(Parent_node_id, name_id, "", 0);
                    return(recursiveSetValueOptionTree(node_id, path2, Default_value, Default_Description));
                }
                else
                {
                    parent_id = OptionReader.GetInt32(OptionReader.GetOrdinal("node_id"));
                    OptionReader.Close();
                    OptionReader = null;
                    return(recursiveSetValueOptionTree(parent_id, path2, Default_value, Default_Description));
                }
                #endregion
            }
        }