예제 #1
0
        public bool DeleteContract(AceContractTracker contract)
        {
            DatabaseTransaction transaction = BeginTransaction();

            DeleteAceContractTracker(transaction, contract);
            return(transaction.Commit().Result);
        }
예제 #2
0
        public void UpdateContent(Content content)
        {
            if (content?.ContentGuid == null)
            {
                throw new ArgumentNullException("content", "Cannot update null content or content with a null ContentGuid.");
            }

            DatabaseTransaction transaction = BeginTransaction();

            transaction.AddPreparedUpdateStatement(WorldPreparedStatement.UpdateContent, content);

            // forcibly propagate the content id
            content.Weenies.ForEach(w => w.ContentGuid              = content.ContentGuid.Value);
            content.ExternalResources.ForEach(r => r.ContentGuid    = content.ContentGuid.Value);
            content.AssociatedLandblocks.ForEach(l => l.ContentGuid = content.ContentGuid.Value);
            content.AssociatedContent.ForEach(c => c.ContentGuid    = content.ContentGuid.Value);

            content.Weenies.Where(o => o.IsDirty).ToList().ForEach(w => transaction.AddPreparedUpdateStatement(WorldPreparedStatement.UpdateContentWeenie, w));
            content.ExternalResources.Where(o => o.IsDirty).ToList().ForEach(r => transaction.AddPreparedUpdateStatement(WorldPreparedStatement.UpdateContentResource, r));
            content.AssociatedLandblocks.Where(o => o.IsDirty).ToList().ForEach(l => transaction.AddPreparedUpdateStatement(WorldPreparedStatement.UpdateContentLandblock, l));

            // content resources are weak entities that cannot be updated.  always delete and reinsert the list
            var criteria = new Dictionary <string, object>();

            criteria.Add("contentGuid1", content.ContentGuid.Value.ToByteArray());
            transaction.AddPreparedDeleteListStatement <WorldPreparedStatement, ContentLink>(WorldPreparedStatement.DeleteAssociatedContent, criteria);
            transaction.AddPreparedInsertListStatement(WorldPreparedStatement.DeleteAssociatedContent, content.AssociatedContent);

            transaction.Commit().Wait();

            content.ClearDirtyFlags();
        }
예제 #3
0
 public void Update(IEnumerable <ISlipLease> leases, long forCustomerId)
 {
     using (IDatabaseTransaction transaction = new DatabaseTransaction( )) {
         _gateway.Execute(DatabaseDelete.Where(LeaseTable.CustomerID, forCustomerId));
         Insert(leases, forCustomerId);
         transaction.Commit( );
     }
 }
예제 #4
0
 public void Update(IRegistration registration, long forCustomerId)
 {
     using (IDatabaseTransaction unitOfWork = new DatabaseTransaction( )) {
         _gateway.Execute(Queries.UpdateCustomer(registration, forCustomerId),
                          Queries.UpdateAuthorization(registration, forCustomerId));
         unitOfWork.Commit( );
     }
 }
예제 #5
0
 public void Update(ICustomer customer)
 {
     using (IDatabaseTransaction workUnit = new DatabaseTransaction( )) {
         _registrationMapper.Update(customer.Registration( ), customer.ID( ));
         _boatMapper.Update(customer.RegisteredBoats( ), customer.ID( ));
         _leaseMapper.Update(customer.Leases( ), customer.ID( ));
         workUnit.Commit( );
     }
 }
예제 #6
0
 public void Insert(ICustomer customer)
 {
     using (IDatabaseTransaction workUnit = new DatabaseTransaction( )) {
         customer.ChangeIdTo(_gateway.ExecuteScalar(Queries.Insert( )));
         _registrationMapper.Insert(customer.Registration( ), customer.ID( ));
         _boatMapper.Insert(customer.RegisteredBoats( ), customer.ID( ));
         _leaseMapper.Insert(customer.Leases( ), customer.ID( ));
         workUnit.Commit( );
     }
 }
예제 #7
0
 public void Insert(IEnumerable <ISlipLease> leases, long forCustomerId)
 {
     using (IDatabaseTransaction transaction = new DatabaseTransaction( )) {
         IList <IQuery> queries = new List <IQuery>( );
         foreach (ISlipLease lease in leases)
         {
             queries.Add(
                 DatabaseInsert.Into(LeaseTable.TableName)
                 .AddValue(LeaseTable.StartDate, lease.StartDate( ))
                 .AddValue(LeaseTable.EndDate, lease.ExpiryDate( ))
                 .AddValue(LeaseTable.SlipID, lease.Slip( ).ID( ))
                 .AddValue(LeaseTable.CustomerID, forCustomerId)
                 .AddValue(LeaseTable.LeaseTypeID, lease.Duration( ).ID( )).Build( )
                 );
         }
         _gateway.Execute(queries);
         transaction.Commit( );
     }
 }
예제 #8
0
        public async Task UpdateCharacter(Character character)
        {
            // Save all of the player positions
            // TODO: Remove this after allowing positions to be saved on demand
            foreach (KeyValuePair <PositionType, Position> pos in character.Positions)
            {
                ExecuteConstructedUpdateStatement(CharacterPreparedStatement.CharacterPositionUpdate, typeof(Position), pos.Value);
            }

            DatabaseTransaction transaction = BeginTransaction();

            UpdateCharacterProperties(character, transaction);

            UpdateCharacterStats(character, transaction);

            UpdateCharacterSkills(character, transaction);

            await transaction.Commit();
        }
예제 #9
0
        public void CreateContent(Content content)
        {
            DatabaseTransaction transaction = BeginTransaction();

            transaction.AddPreparedInsertStatement <WorldPreparedStatement, Content>(WorldPreparedStatement.CreateContent, content);

            // forcibly propagate the content id
            content.Weenies.ForEach(w => w.ContentGuid              = content.ContentGuid);
            content.ExternalResources.ForEach(r => r.ContentGuid    = content.ContentGuid);
            content.AssociatedLandblocks.ForEach(l => l.ContentGuid = content.ContentGuid);
            content.AssociatedContent.ForEach(c => c.ContentGuid    = content.ContentGuid);

            content.Weenies.ForEach(w => transaction.AddPreparedInsertStatement(WorldPreparedStatement.CreateContentWeenie, w));
            content.ExternalResources.ForEach(r => transaction.AddPreparedInsertStatement(WorldPreparedStatement.CreateContentResource, r));
            content.AssociatedLandblocks.ForEach(l => transaction.AddPreparedInsertStatement(WorldPreparedStatement.CreateContentLandblock, l));
            transaction.AddPreparedInsertListStatement(WorldPreparedStatement.CreateAssociatedContent, content.AssociatedContent);

            transaction.Commit().Wait();

            content.ClearDirtyFlags();
        }
예제 #10
0
        public void Commit()
        {
            DatabaseTransaction.Commit();

            DatabaseProvider.State.ApplyChanges(Changes.ToArray());
        }
예제 #11
0
        public async Task <bool> CreateCharacter(Character character)
        {
            DatabaseTransaction transaction = BeginTransaction();

            transaction.AddPreparedStatement(CharacterPreparedStatement.CharacterInsert,
                                             character.Id,
                                             character.AccountId,
                                             character.Name,
                                             character.TemplateOption,
                                             character.StartArea);

            transaction.AddPreparedStatement(CharacterPreparedStatement.CharacterAppearanceInsert,
                                             character.Id,
                                             character.Appearance.Eyes,
                                             character.Appearance.Nose,
                                             character.Appearance.Mouth,
                                             character.Appearance.EyeColor,
                                             character.Appearance.HairColor,
                                             character.Appearance.HairStyle,
                                             character.Appearance.HairHue,
                                             character.Appearance.SkinHue);

            transaction.AddPreparedStatement(CharacterPreparedStatement.CharacterStatsInsert,
                                             character.Id,
                                             character.StrengthAbility.Base,
                                             character.EnduranceAbility.Base,
                                             character.CoordinationAbility.Base,
                                             character.QuicknessAbility.Base,
                                             character.FocusAbility.Base,
                                             character.SelfAbility.Base,
                                             character.Health.Current,
                                             character.Stamina.Current,
                                             character.Mana.Current);

            foreach (CharacterSkill skill in character.Skills.Values)
            {
                transaction.AddPreparedStatement(CharacterPreparedStatement.CharacterSkillsInsert,
                                                 character.Id,
                                                 (uint)skill.Skill,
                                                 (uint)skill.Status,
                                                 skill.Ranks);
            }

            transaction.AddPreparedStatement(CharacterPreparedStatement.CharacterStartupGearInsert,
                                             character.Id,
                                             character.Appearance.HeadgearStyle,
                                             character.Appearance.HeadgearColor,
                                             character.Appearance.HeadgearHue,
                                             character.Appearance.ShirtStyle,
                                             character.Appearance.ShirtColor,
                                             character.Appearance.ShirtHue,
                                             character.Appearance.PantsStyle,
                                             character.Appearance.PantsColor,
                                             character.Appearance.PantsHue,
                                             character.Appearance.FootwearStyle,
                                             character.Appearance.FootwearColor,
                                             character.Appearance.FootwearHue);

            SaveCharacterProperties(character, transaction);

            return(await transaction.Commit());
        }