Ejemplo n.º 1
0
        private void DoCreateItem(uint callbackID)
        {
            m_createItem = false;   // don't create or bill for the same item more than once

            try
            {
                m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(m_asset, AssetRequestInfo.GenericNetRequest());
            }
            catch (AssetServerException e)
            {
                ourClient.SendAgentAlertMessage("Unable to upload asset. Please try again later.", false);
                m_log.ErrorFormat("[ASSET TRANSACTIONS] Asset storage failed: {0}", e);
                return;
            }

            CachedUserInfo userInfo =
                m_userTransactions.Manager.MyScene.CommsManager.UserService.GetUserDetails(
                    ourClient.AgentId);

            if (userInfo != null)
            {
                InventoryItemBase item = new InventoryItemBase();
                item.Owner               = ourClient.AgentId;
                item.CreatorId           = ourClient.AgentId.ToString();
                item.ID                  = UUID.Random();
                item.AssetID             = m_asset.FullID;
                item.Description         = m_description;
                item.Name                = m_name;
                item.AssetType           = type;
                item.InvType             = invType;
                item.Folder              = InventFolder;
                item.BasePermissions     = (uint)(PermissionMask.All | PermissionMask.Export);
                item.CurrentPermissions  = (uint)(PermissionMask.All | PermissionMask.Export);
                item.GroupPermissions    = (uint)PermissionMask.None;
                item.EveryOnePermissions = (uint)PermissionMask.None;
                item.NextPermissions     = nextPerm;
                item.Flags               = (uint)wearableType;

                item.CreationDate = Util.UnixTimeSinceEpoch();

                userInfo.AddItem(item);
                ourClient.SendInventoryItemCreateUpdate(item, callbackID);

                // Charge for the upload if appropriate.
                IMoneyModule mm = ourClient.Scene.RequestModuleInterface <IMoneyModule>();
                if (mm != null)
                {
                    if (mm.UploadChargeApplies((AssetType)m_asset.Type) && !m_asset.Temporary)
                    {
                        mm.ApplyUploadCharge(ourClient.AgentId);
                    }
                }
            }
            else
            {
                m_log.ErrorFormat("[ASSET TRANSACTIONS]: Could not find user {0} for inventory item creation", ourClient.AgentId);
            }
        }