Пример #1
0
        private static void GetCharacterStandings(Character character)
        {
            SQLiteCommand cmd = sqlConnection.CreateCommand();
            cmd.CommandText = string.Format("SELECT * FROM ecmCharacterStandings WHERE CharacterID = {0}", character.ID);

            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    StandingInfo newStanding = new StandingInfo();

                    newStanding.Type = (CharacterStandingType)reader["StandingType"];
                    newStanding.FromID = Convert.ToInt64(reader["FromID"].ToString());
                    newStanding.FromName = reader["FromName"].ToString();
                    newStanding.Standing = Convert.ToSingle(reader["Standing"].ToString());

                    if (newStanding.Type == CharacterStandingType.Agent)
                        character.Standings.Agents.Add(newStanding);
                    else if (newStanding.Type == CharacterStandingType.Corporation)
                        character.Standings.NPCCorporations.Add(newStanding);
                    else if (newStanding.Type == CharacterStandingType.Faction)
                        character.Standings.Factions.Add(newStanding);
                }
            }
        }
Пример #2
0
        private static void AddCharacter(Character charToAdd)
        {
            if (m_FirstCharID == -1)
                m_FirstCharID = charToAdd.ID;

            m_Characters.Add(charToAdd.ID, charToAdd);

            charToAdd.CharacterUpdated += delegate
            {
                if(charToAdd == CurrentCharacter)
                    UpdateGui();
            };
        }
Пример #3
0
        private static void GetCharacterSkills(Character character)
        {
            SQLiteCommand cmd = sqlConnection.CreateCommand();
            cmd.CommandText = string.Format("SELECT * FROM ecmCharacterSkills WHERE CharacterID = {0}", character.ID);

            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                character.Skills.Clear();

                while (reader.Read())
                {
                    CharacterSkills newSkill = new CharacterSkills();

                    newSkill.ID = Convert.ToInt64(reader["SkillTypeID"].ToString());
                    newSkill.Level = Convert.ToInt32(reader["SkillLevel"].ToString());
                    newSkill.Skillpoints = Convert.ToInt32(reader["Skillpoints"].ToString());

                    character.Skills.Add(newSkill.ID, newSkill);
                }
            }
        }
Пример #4
0
        private static void GetCharacterImplants(Character character)
        {
            SQLiteCommand cmd = sqlConnection.CreateCommand();
            cmd.CommandText = string.Format("SELECT * FROM ecmCharacterImplants WHERE CharacterID = {0}", character.ID);

            SQLiteDataReader reader = cmd.ExecuteReader();

            if(reader.HasRows)
            {
                while(reader.Read())
                {
                    character.Implants.Intelligence.Name = reader["IntImplantName"].ToString();
                    character.Implants.Intelligence.Amount = Convert.ToInt32(reader["IntImplantValue"].ToString());

                    character.Implants.Charisma.Name = reader["ChaImplantName"].ToString();
                    character.Implants.Charisma.Amount = Convert.ToInt32(reader["ChaImplantValue"].ToString());

                    character.Implants.Memory.Name = reader["MemImplantName"].ToString();
                    character.Implants.Memory.Amount = Convert.ToInt32(reader["MemImplantValue"].ToString());

                    character.Implants.Willpower.Name = reader["WilImplantName"].ToString();
                    character.Implants.Willpower.Amount = Convert.ToInt32(reader["WilImplantValue"].ToString());

                    character.Implants.Perception.Name = reader["PerImplantName"].ToString();
                    character.Implants.Perception.Amount = Convert.ToInt32(reader["PerImplantValue"].ToString());
                }
            }
        }
Пример #5
0
        private static void GetCharacterCertificates(Character character)
        {
            SQLiteCommand cmd = sqlConnection.CreateCommand();
            cmd.CommandText = string.Format("SELECT * FROM ecmCharacterCertificates WHERE CharacterID = {0}", character.ID);

            SQLiteDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                character.Certificates.Clear();

                while (reader.Read())
                {
                    CharacterCertificates newCert = new CharacterCertificates();

                    newCert.ID = Convert.ToInt64(reader["CertificateID"].ToString());

                    character.Certificates.Add(newCert);
                }
            }
        }
Пример #6
0
 internal static void RemoveCharacter(Character charToRemove)
 {
     throw new NotImplementedException();
 }
Пример #7
0
        internal static void AddCharacter(Character charToAdd)
        {
            // Insert/Update the character
            string createCmd = @"INSERT OR REPLACE INTO ecmCharacters(ID,
                                    AccountID,
                                    AutoUpdate,
                                    Name,
                                    Race,
                                    Bloodline,
                                    Ancestry,
                                    AccountBalance,
                                    Skillpoints,
                                    ShipName,
                                    ShipTypeID,
                                    ShipTypeName,
                                    CorporationID,
                                    Corporation,
                                    CorporationDate,
                                    AllianceID,
                                    Alliance,
                                    AllianceDate,
                                    LastKnownLocation,
                                    SecurityStatus,
                                    Birthday,
                                    Gender,
                                    CloneName,
                                    CloneSkillpoints,
                                    Intelligence,
                                    Memory,
                                    Perception,
                                    Willpower,
                                    Charisma,
                                    Portrait,
                                    Assets)
                                VALUES(@ID,
                                    @AccountID,
                                    @AutoUpdate,
                                    @Name,
                                    @Race,
                                    @Bloodline,
                                    @Ancestry,
                                    @AccountBalance,
                                    @Skillpoints,
                                    @ShipName,
                                    @ShipTypeID,
                                    @ShipTypeName,
                                    @CorporationID,
                                    @Corporation,
                                    @CorporationDate,
                                    @AllianceID,
                                    @Alliance,
                                    @AllianceDate,
                                    @LastKnownLocation,
                                    @SecurityStatus,
                                    @Birthday,
                                    @Gender,
                                    @CloneName,
                                    @CloneSkillpoints,
                                    @Intelligence,
                                    @Memory,
                                    @Perception,
                                    @Willpower,
                                    @Charisma,
                                    @Portrait,
                                    @Assets)";
            bool mustClose = false;

            if(sqlConnection == null || sqlConnection.State != System.Data.ConnectionState.Open)
            {
                OpenDatabase();
                mustClose = true;
            }

            SQLiteCommand cmd = sqlConnection.CreateCommand();
            cmd.CommandText = createCmd;

            cmd.Parameters.AddWithValue("@ID", charToAdd.ID);
            cmd.Parameters.AddWithValue("@AccountID", charToAdd.Account.KeyID);
            cmd.Parameters.AddWithValue("@AutoUpdate", charToAdd.AutoUpdate);
            cmd.Parameters.AddWithValue("@Name", charToAdd.Name);
            cmd.Parameters.AddWithValue("@Race", charToAdd.Race);
            cmd.Parameters.AddWithValue("@Bloodline", charToAdd.Bloodline);
            cmd.Parameters.AddWithValue("@Ancestry", charToAdd.Ancestry);
            cmd.Parameters.AddWithValue("@AccountBalance", charToAdd.AccountBalance);
            cmd.Parameters.AddWithValue("@Skillpoints", charToAdd.SkillPoints);
            cmd.Parameters.AddWithValue("@ShipName", charToAdd.ShipName);
            cmd.Parameters.AddWithValue("@ShipTypeID", charToAdd.ShipTypeID);
            cmd.Parameters.AddWithValue("@ShipTypeName", charToAdd.ShipTypeName);
            cmd.Parameters.AddWithValue("@CorporationID", charToAdd.CorporationID);
            cmd.Parameters.AddWithValue("@Corporation", charToAdd.Corporation);
            cmd.Parameters.AddWithValue("@CorporationDate", charToAdd.CorporationDate);
            cmd.Parameters.AddWithValue("@AllianceID", charToAdd.AllianceID);
            cmd.Parameters.AddWithValue("@Alliance", charToAdd.Alliance);
            cmd.Parameters.AddWithValue("@AllianceDate", charToAdd.AllianceDate);
            cmd.Parameters.AddWithValue("@LastKnownLocation", charToAdd.LastKnownLocation);
            cmd.Parameters.AddWithValue("@SecurityStatus", charToAdd.SecurityStatus);
            cmd.Parameters.AddWithValue("@Birthday", charToAdd.Birthday);
            cmd.Parameters.AddWithValue("@Gender", charToAdd.Gender);
            cmd.Parameters.AddWithValue("@CloneName", charToAdd.CloneName);
            cmd.Parameters.AddWithValue("@CloneSkillpoints", charToAdd.CloneSkillPoints);
            cmd.Parameters.AddWithValue("@Intelligence", charToAdd.Attributes.Intelligence);
            cmd.Parameters.AddWithValue("@Memory", charToAdd.Attributes.Memory);
            cmd.Parameters.AddWithValue("@Perception", charToAdd.Attributes.Perception);
            cmd.Parameters.AddWithValue("@Willpower", charToAdd.Attributes.Willpower);
            cmd.Parameters.AddWithValue("@Charisma", charToAdd.Attributes.Charisma);
            cmd.Parameters.AddWithValue("@Portrait", charToAdd.Portrait.ToArray());

            using (MemoryStream stream = new MemoryStream())
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(stream, charToAdd.Assets);

                cmd.Parameters.AddWithValue("@Assets", stream.ToArray());

                Console.WriteLine("Saving {0} assets for {1}", charToAdd.Assets.Count, charToAdd.Name);
            }

            cmd.ExecuteNonQuery();

            // Add Implants
            cmd = sqlConnection.CreateCommand();
            cmd.CommandText = @"INSERT OR REPLACE INTO ecmCharacterImplants(CharacterID, IntImplantName, IntImplantValue, ChaImplantName, ChaImplantValue, MemImplantName, MemImplantValue, WilImplantName,
                                WilImplantValue, PerImplantName, PerImplantValue) VALUES (@CharacterID, @IntImplantName, @IntImplantValue, @ChaImplantName, @ChaImplantValue, @MemImplantName, @MemImplantValue,
                                @WilImplantName, @WilImplantValue, @PerImplantName, @PerImplantValue)";

            cmd.Parameters.AddWithValue("@CharacterID", charToAdd.ID);

            cmd.Parameters.AddWithValue("@IntImplantName", charToAdd.Implants.Intelligence.Name);
            cmd.Parameters.AddWithValue("@IntImplantValue", charToAdd.Implants.Intelligence.Amount);

            cmd.Parameters.AddWithValue("@ChaImplantName", charToAdd.Implants.Charisma.Name);
            cmd.Parameters.AddWithValue("@ChaImplantValue", charToAdd.Implants.Charisma.Amount);

            cmd.Parameters.AddWithValue("@MemImplantName", charToAdd.Implants.Memory.Name);
            cmd.Parameters.AddWithValue("@MemImplantValue", charToAdd.Implants.Memory.Amount);

            cmd.Parameters.AddWithValue("@WilImplantName", charToAdd.Implants.Willpower.Name);
            cmd.Parameters.AddWithValue("@WilImplantValue", charToAdd.Implants.Willpower.Amount);

            cmd.Parameters.AddWithValue("@PerImplantName", charToAdd.Implants.Perception.Name);
            cmd.Parameters.AddWithValue("@PerImplantValue", charToAdd.Implants.Perception.Amount);

            cmd.ExecuteNonQuery();

            // Add Skills
            foreach(CharacterSkills skill in charToAdd.Skills.Values)
            {
                cmd = sqlConnection.CreateCommand();
                cmd.CommandText = @"INSERT OR REPLACE INTO ecmCharacterSkills(CharacterID, SkillTypeID, SkillLevel, Skillpoints) VALUES (@CharacterID, @SkillTypeID, @SkillLevel, @Skillpoints)";

                cmd.Parameters.AddWithValue("@CharacterID", charToAdd.ID);
                cmd.Parameters.AddWithValue("@SkillTypeID", skill.ID);
                cmd.Parameters.AddWithValue("@SkillLevel", skill.Level);
                cmd.Parameters.AddWithValue("@Skillpoints", skill.Skillpoints);

                cmd.ExecuteNonQuery();
            }

            // Add Certificates
            foreach(CharacterCertificates cert in charToAdd.Certificates)
            {
                cmd = sqlConnection.CreateCommand();
                cmd.CommandText = @"INSERT OR REPLACE INTO ecmCharacterCertificates(CharacterID, CertificateID) VALUES (@CharacterID, @CertificateID)";

                cmd.Parameters.AddWithValue("@CharacterID", charToAdd.ID);
                cmd.Parameters.AddWithValue("@CertificateID", cert.ID);

                cmd.ExecuteNonQuery();
            }

            // Add Standings
            foreach (StandingInfo standing in charToAdd.Standings.All)
            {
                cmd = sqlConnection.CreateCommand();
                cmd.CommandText = @"INSERT OR REPLACE INTO ecmCharacterStandings(CharacterID, StandingType, FromID, FromName, Standing) VALUES (@CharacterID, @StandingType, @FromID, @FromName, @Standing)";

                cmd.Parameters.AddWithValue("@CharacterID", charToAdd.ID);
                cmd.Parameters.AddWithValue("@StandingType", (int)standing.Type);
                cmd.Parameters.AddWithValue("@FromID", standing.FromID);
                cmd.Parameters.AddWithValue("@FromName", standing.FromName);
                cmd.Parameters.AddWithValue("@Standing", standing.Standing);

                cmd.ExecuteNonQuery();
            }

            if(mustClose)
            {
                CloseDatabase();
            }
        }