public void LogData()
        {
            InventoryDescription description = new InventoryDescription();

            foreach (InventoryItem item in ItemDeltas)
            {
                if (item.Added > 0)
                {
                    description.Add(EntityId, BlockId, item.Index, item.InventoryType, InvAction.Add, item.Added, item.TypeId.ToString(), item.SubtypeId.ToString());
                }

                if (item.Removed > 0)
                {
                    description.Add(EntityId, BlockId, item.Index, item.InventoryType, InvAction.Remove, item.Removed, item.TypeId.ToString(), item.SubtypeId.ToString());
                }
            }

            SQLQueryData.WriteToDatabase(description);
            ItemDeltas.Clear();
        }
        public InventoryComponent(MyEntity entity)
        {
            Entity = entity;

            if (entity.HasInventory)
            {
                Entity.OnClose += OnClose;

                InventoryDescription description = new InventoryDescription();

                if (Output != null)
                {
                    Output.BeforeContentsChanged += OnBeforeOutputChange;
                    Output.ContentsChanged       += OnOutputChange;

                    if (!(entity is MyCharacter))
                    {
                        foreach (var item in Output.GetItems())
                        {
                            description.Add(EntityId, BlockId, item.ItemId, InvType.Output, InvAction.Current, item.Amount, item.Content.TypeId.ToString(), item.Content.SubtypeId.ToString());
                        }
                    }
                }

                if (Input != null)
                {
                    Input.BeforeContentsChanged += OnBeforeInputChange;
                    Input.ContentsChanged       += OnInputChange;

                    foreach (var item in Input.GetItems())
                    {
                        description.Add(EntityId, BlockId, item.ItemId, InvType.Input, InvAction.Current, item.Amount, item.Content.TypeId.ToString(), item.Content.SubtypeId.ToString());
                    }
                }

                SQLQueryData.WriteToDatabase(description);
            }
        }