public static Pattern Read(MySql.Data.MySqlClient.MySqlDataReader reader) { var pattern = new Pattern() { ID = reader.GetUInt32("ID"), Name = reader.GetString("Name"), Creator = reader.GetString("Creator"), Tags = reader.GetString("Tags").Split(',', StringSplitOptions.RemoveEmptyEntries), Code = reader.GetString("Code"), Type = reader.GetByte("Type"), }; string folder = System.IO.Path.Combine(pattern.Code.Substring(0, 2), pattern.Code.Substring(2, 2)); if (System.IO.Directory.Exists(folder)) { string file = System.IO.Path.Combine(folder, pattern.Code + ".acnh"); if (System.IO.File.Exists(file)) { pattern.Bytes = System.IO.File.ReadAllBytes(file); } } return(pattern); }
public void FromDatabase(MySqlDataReader reader) { cob_type.SelectedIndex = reader.GetInt32(2); pg_phases.SetPhaseValue(reader.GetUInt32(3)); tb_chance.Text = reader.GetString(4); SetFlags(reader.GetUInt32(5)); tb_param1.Text = reader.GetString(6); tb_param2.Text = reader.GetString(7); tb_param3.Text = reader.GetString(8); tb_param4.Text = reader.GetString(9); cb_action1.SelectedIndex = reader.GetInt32(10); tb_action1_param1.Text = reader.GetString(11); tb_action1_param2.Text = reader.GetString(12); tb_action1_param3.Text = reader.GetString(13); cb_action2.SelectedIndex = reader.GetInt32(14); tb_action2_param1.Text = reader.GetString(15); tb_action2_param2.Text = reader.GetString(16); tb_action2_param3.Text = reader.GetString(17); cb_action3.SelectedIndex = reader.GetInt32(18); tb_action3_param1.Text = reader.GetString(19); tb_action3_param1.Text = reader.GetString(20); tb_action3_param1.Text = reader.GetString(21); tb_comment.Text = reader.GetString(22); }
private UInt32 getRank(MySqlDataReader reader) { UInt32 rank = reader.GetUInt32(6); return rank; }
private UInt32 getPoints(MySqlDataReader reader) { UInt32 points = reader.GetUInt32(5); return points; }
private UInt32 getPlayTime(MySqlDataReader reader) { UInt32 playtime = reader.GetUInt32(9); return playtime; }
private UInt32 getMoney(MySqlDataReader reader) { UInt32 money = reader.GetUInt32(7); return money; }
private UInt32 getID(MySqlDataReader reader) { UInt32 id = reader.GetUInt32(0); return id; }
// 往 dr 填充 r 于 i 索引的值 public static void FillValue( DbRow dr, MySqlDataReader r, int i ) { switch( dr.parent.columns[ i ].dataType ) { case DbDataTypes.Boolean: dr[ i ].Assign( r.GetBoolean( i ) ); break; case DbDataTypes.Int8: dr[ i ].Assign( r.GetSByte( i ) ); break; case DbDataTypes.Int16: dr[ i ].Assign( r.GetInt16( i ) ); break; case DbDataTypes.Int32: dr[ i ].Assign( r.GetInt32( i ) ); break; case DbDataTypes.Int64: dr[ i ].Assign( r.GetInt64( i ) ); break; case DbDataTypes.UInt8: dr[ i ].Assign( r.GetByte( i ) ); break; case DbDataTypes.UInt16: dr[ i ].Assign( r.GetUInt16( i ) ); break; case DbDataTypes.UInt32: dr[ i ].Assign( r.GetUInt32( i ) ); break; case DbDataTypes.UInt64: dr[ i ].Assign( r.GetUInt64( i ) ); break; case DbDataTypes.Float: dr[ i ].Assign( r.GetFloat( i ) ); break; case DbDataTypes.Double: dr[ i ].Assign( r.GetDouble( i ) ); break; case DbDataTypes.DateTime: dr[ i ].Assign( r.GetDateTime( i ) ); break; case DbDataTypes.String: dr[ i ].Assign( r.GetString( i ) ); break; case DbDataTypes.Bytes: var len = (int)r.GetBytes( i, 0, null, 0, 0 ); var buf = new byte[ len ]; r.GetBytes( i, 0, buf, 0, len ); dr[ i ].Assign( buf ); break; default: break; } }
public static uint? getUInt(MySqlDataReader dr, string column) { int ordinal = dr.GetOrdinal(column); if (dr.IsDBNull(ordinal)) { return null; } else { return dr.GetUInt32(ordinal); } }
private static void _mediaReadFields(MySqlDataReader dataReader, PersistentMedia media) { uint flags = dataReader.IsDBNull(dataReader.GetOrdinal("flags")) ? (uint)0 : dataReader.GetUInt32("flags"); byte typVideo = dataReader.IsDBNull(dataReader.GetOrdinal("typVideo")) ? (byte)0 : dataReader.GetByte("typVideo"); media._mediaName = dataReader.IsDBNull(dataReader.GetOrdinal("MediaName")) ? string.Empty : dataReader.GetString("MediaName"); media._duration = dataReader.IsDBNull(dataReader.GetOrdinal("Duration")) ? default(TimeSpan) : dataReader.GetTimeSpan("Duration"); media._durationPlay = dataReader.IsDBNull(dataReader.GetOrdinal("DurationPlay")) ? default(TimeSpan) : dataReader.GetTimeSpan("DurationPlay"); media._folder = dataReader.IsDBNull(dataReader.GetOrdinal("Folder")) ? string.Empty : dataReader.GetString("Folder"); media._fileName = dataReader.IsDBNull(dataReader.GetOrdinal("FileName")) ? string.Empty : dataReader.GetString("FileName"); media._fileSize = dataReader.IsDBNull(dataReader.GetOrdinal("FileSize")) ? 0 : dataReader.GetUInt64("FileSize"); media.idFormat = dataReader.IsDBNull(dataReader.GetOrdinal("idFormat")) ? 0 : dataReader.GetUInt64("idFormat"); media._lastUpdated = _readDateTimeField(dataReader, "LastUpdated"); media._mediaStatus = (TMediaStatus)(dataReader.IsDBNull(dataReader.GetOrdinal("statusMedia")) ? 0 : dataReader.GetInt32("statusMedia")); media._mediaType = (TMediaType)(dataReader.IsDBNull(dataReader.GetOrdinal("typMedia")) ? 0 : dataReader.GetInt32("typMedia")); media._tCStart = dataReader.IsDBNull(dataReader.GetOrdinal("TCStart")) ? default(TimeSpan) : dataReader.GetTimeSpan("TCStart"); media._tCPlay = dataReader.IsDBNull(dataReader.GetOrdinal("TCPlay")) ? default(TimeSpan) : dataReader.GetTimeSpan("TCPlay"); media.idProgramme = dataReader.IsDBNull(dataReader.GetOrdinal("idProgramme")) ? 0 : dataReader.GetUInt64("idProgramme"); media._audioVolume = dataReader.IsDBNull(dataReader.GetOrdinal("AudioVolume")) ? 0 : dataReader.GetDecimal("AudioVolume"); media._audioLevelIntegrated = dataReader.IsDBNull(dataReader.GetOrdinal("AudioLevelIntegrated")) ? 0 : dataReader.GetDecimal("AudioLevelIntegrated"); media._audioLevelPeak = dataReader.IsDBNull(dataReader.GetOrdinal("AudioLevelPeak")) ? 0 : dataReader.GetDecimal("AudioLevelPeak"); media._audioChannelMapping = dataReader.IsDBNull(dataReader.GetOrdinal("typAudio")) ? TAudioChannelMapping.Stereo : (TAudioChannelMapping)dataReader.GetByte("typAudio"); media.HasExtraLines = (typVideo & (byte)0x80) > 0; media._videoFormat = (TVideoFormat)(typVideo & 0x7F); media._idAux = dataReader.IsDBNull(dataReader.GetOrdinal("idAux")) ? string.Empty : dataReader.GetString("idAux"); media._killDate = _readDateTimeField(dataReader, "KillDate"); media._mediaGuid = dataReader.IsDBNull(dataReader.GetOrdinal("MediaGuid")) ? Guid.Empty : dataReader.GetGuid("MediaGuid"); media._mediaEmphasis = (TMediaEmphasis)((flags >> 8) & 0xF); media._parental = (TParental)((flags >> 12) & 0xF); if (media is ServerMedia) ((ServerMedia)media)._doNotArchive = (flags & 0x1) != 0; media._mediaCategory = (TMediaCategory)((flags >> 4) & 0xF); // bits 4-7 of 1st byte }
private static Event _EventRead(Engine engine, MySqlDataReader dataReader) { Event aEvent = new Event(engine); uint flags = dataReader.IsDBNull(dataReader.GetOrdinal("flagsEvent")) ? 0 : dataReader.GetUInt32("flagsEvent"); aEvent._idRundownEvent = dataReader.GetUInt64("idRundownEvent"); aEvent._layer = (VideoLayer)dataReader.GetSByte("Layer"); aEvent._eventType = (TEventType)dataReader.GetByte("typEvent"); aEvent._startType = (TStartType)dataReader.GetByte("typStart"); aEvent._scheduledTime = _readDateTimeField(dataReader, "ScheduledTime"); aEvent._duration = dataReader.IsDBNull(dataReader.GetOrdinal("Duration")) ? default(TimeSpan) : aEvent.Engine.AlignTimeSpan(dataReader.GetTimeSpan("Duration")); aEvent._scheduledDelay = dataReader.IsDBNull(dataReader.GetOrdinal("ScheduledDelay")) ? default(TimeSpan) : aEvent.Engine.AlignTimeSpan(dataReader.GetTimeSpan("ScheduledDelay")); aEvent._scheduledTC = dataReader.IsDBNull(dataReader.GetOrdinal("ScheduledTC")) ? TimeSpan.Zero : dataReader.GetTimeSpan("ScheduledTC"); aEvent._mediaGuid = (dataReader.IsDBNull(dataReader.GetOrdinal("MediaGuid"))) ? Guid.Empty : dataReader.GetGuid("MediaGuid"); aEvent._eventName = dataReader.IsDBNull(dataReader.GetOrdinal("EventName")) ? default(string) : dataReader.GetString("EventName"); var psb = dataReader.GetByte("PlayState"); aEvent._playState = (TPlayState)psb; if (aEvent._playState == TPlayState.Playing || aEvent._playState == TPlayState.Paused) aEvent._playState = TPlayState.Aborted; if (aEvent._playState == TPlayState.Fading) aEvent._playState = TPlayState.Played; aEvent._startTime = _readDateTimeField(dataReader, "StartTime"); aEvent._startTC = dataReader.IsDBNull(dataReader.GetOrdinal("StartTC")) ? TimeSpan.Zero : dataReader.GetTimeSpan("StartTC"); aEvent._requestedStartTime = dataReader.IsDBNull(dataReader.GetOrdinal("RequestedStartTime")) ? null : (TimeSpan?)dataReader.GetTimeSpan("RequestedStartTime"); aEvent._transitionTime = dataReader.IsDBNull(dataReader.GetOrdinal("TransitionTime")) ? default(TimeSpan) : dataReader.GetTimeSpan("TransitionTime"); aEvent._transitionType = (TTransitionType)dataReader.GetByte("typTransition"); aEvent._audioVolume = dataReader.IsDBNull(dataReader.GetOrdinal("AudioVolume")) ? 0 : dataReader.GetDecimal("AudioVolume"); aEvent._idProgramme = dataReader.IsDBNull(dataReader.GetOrdinal("idProgramme")) ? 0 : dataReader.GetUInt64("idProgramme"); aEvent._idAux = dataReader.IsDBNull(dataReader.GetOrdinal("IdAux")) ? default(string) : dataReader.GetString("IdAux"); aEvent._enabled = (flags & (1 << 0)) != 0; aEvent._hold = (flags & (1 << 1)) != 0; EventGPI.FromUInt64(ref aEvent._gPI, (flags >> 4) & EventGPI.Mask); aEvent._nextLoaded = false; return aEvent; }
private void toObject(MySqlDataReader reader) { Id = reader.GetUInt32(0); Email = reader.GetString(1); Password = reader.GetString(2); Verifier = reader.GetString(3); Salt = reader.GetString(4); Points = reader.GetUInt32(5); Admin = reader.GetUInt32(6); Banned = reader.GetByte(7); extrn_login = reader.GetByte(8); token = reader.GetString(9); canhost = reader.GetByte(10); }
/// <summary> /// Read server parameters from the standard database query column /// layout and construct and return a NWGameServer corresponding to the /// data in question. /// </summary> /// <param name="Reader">Supplies a reader containing the results of a /// query that correspond to the standard column set.</param> /// <returns>A NWGameServer object describing the current row.</returns> private NWGameServer LoadGameServerFromQuery(MySqlDataReader Reader) { NWGameServer Server = new NWGameServer(); Server.ExpansionsMask = Reader.GetUInt32(1); Server.BuildNumber = Reader.GetUInt32(2); Server.ModuleName = Reader.GetString(3); Server.ServerName = Reader.GetString(4); Server.ActivePlayerCount = Reader.GetUInt32(5); Server.MaximumPlayerCount = Reader.GetUInt32(6); Server.LocalVault = Reader.GetBoolean(7); Server.LastHeartbeat = Reader.GetDateTime(8); Server.ServerAddress = Reader.GetString(9); Server.Online = Reader.GetBoolean(10); Server.PrivateServer = Reader.GetBoolean(11); Server.ModuleDescription = Reader.GetString(12); Server.ModuleUrl = Reader.GetString(13); Server.GameType = Reader.GetUInt32(14); Server.MinimumLevel = Reader.GetUInt32(15); Server.MaximumLevel = Reader.GetUInt32(16); Server.PVPLevel = Reader.GetUInt32(17); Server.PlayerPause = Reader.GetBoolean(18); Server.OnePartyOnly = Reader.GetBoolean(19); Server.ELCEnforced = Reader.GetBoolean(20); Server.ILREnforced = Reader.GetBoolean(21); Server.PWCUrl = Reader.GetString(22); Server.ServerDescription = Reader.GetString(23); return Server; }
// 取 dr 中某字段的数据并返回 public static object GetValue( DbColumn col, MySqlDataReader r, int idx ) { switch( col.dataType ) { case DbDataTypes.Boolean: return r.GetBoolean( idx ); case DbDataTypes.Int8: return r.GetSByte( idx ); case DbDataTypes.Int16: return r.GetInt16( idx ); case DbDataTypes.Int32: return r.GetInt32( idx ); case DbDataTypes.Int64: return r.GetInt64( idx ); case DbDataTypes.UInt8: return r.GetByte( idx ); case DbDataTypes.UInt16: return r.GetUInt16( idx ); case DbDataTypes.UInt32: return r.GetUInt32( idx ); case DbDataTypes.UInt64: return r.GetUInt64( idx ); case DbDataTypes.Float: return r.GetFloat( idx ); case DbDataTypes.Double: return r.GetDouble( idx ); case DbDataTypes.DateTime: return r.GetDateTime( idx ); case DbDataTypes.String: return r.GetString( idx ); case DbDataTypes.Bytes: var len = (int)r.GetBytes( idx, 0, null, 0, 0 ); var buf = new byte[ len ]; r.GetBytes( idx, 0, buf, 0, len ); return buf; default: throw new Exception( "unsupported DbType" ); } }
private UInt32 getAccID(MySqlDataReader reader) { UInt32 accid = reader.GetUInt32(1); return accid; }
private Byte getGm(MySqlDataReader reader) { UInt32 gm = reader.GetUInt32(6); Byte gm2 = Convert.ToByte(gm); return gm2; }
private UInt32 getCharID(MySqlDataReader reader) { UInt32 charid = reader.GetUInt32(0); return charid; }
private Character toObject(MySqlDataReader reader) { Character character = new Character(); character.Id = reader.GetUInt32(0); character.Slot = reader.GetByte(2); character.Name = reader.GetString(3); character.Faction = reader.GetByte(4); character.Gender = reader.GetByte(5); character.Rank = reader.GetUInt32(6); character.Money = reader.GetUInt32(7); character.Threat = reader.GetByte(8); character.Playtime = reader.GetUInt32(9); character.Clan = reader.GetString(10); character.Version = reader.GetUInt32(11); character.Appearence = reader.GetString(12); character.Custom = reader.GetString(13); character.WorldId = reader.GetUInt32(14); return character; }