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
        private bool DeleteAceObjectPropertiesSpellBarPositions(DatabaseTransaction transaction, uint aceObjectId)
        {
            var criteria = new Dictionary <string, object> {
                { "aceObjectId", aceObjectId }
            };

            transaction.AddPreparedDeleteListStatement <ShardPreparedStatement, AceObjectPropertiesSpellBarPositions>(ShardPreparedStatement.DeleteSpellBarPositions, criteria);
            return(true);
        }
Ejemplo n.º 3
0
        private bool DeleteAceContractTrackers(DatabaseTransaction transaction, uint aceObjectId)
        {
            var criteria = new Dictionary <string, object> {
                { "aceObjectId", aceObjectId }
            };

            transaction.AddPreparedDeleteListStatement <ShardPreparedStatement, AceContractTracker>(ShardPreparedStatement.DeleteContractTrackers, criteria);
            return(true);
        }