Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
0
 private bool SaveAceObjectPropertiesSpellBarPositions(DatabaseTransaction transaction, List <AceObjectPropertiesSpellBarPositions> properties)
 {
     transaction.AddPreparedInsertListStatement(ShardPreparedStatement.InsertSpellBarPositions, properties);
     return(true);
 }
Ejemplo n.º 4
0
 private bool SaveAceContractTracker(DatabaseTransaction transaction, uint aceObjectId, List <AceContractTracker> properties)
 {
     properties.ForEach(a => a.AceObjectId = aceObjectId);
     transaction.AddPreparedInsertListStatement <ShardPreparedStatement, AceContractTracker>(ShardPreparedStatement.InsertContractTracker, properties);
     return(true);
 }