예제 #1
0
        public bool SaveAvatarArchive(string fileName, UUID principalID, string folderName, UUID snapshotUUID, bool isPublic)
        {
            UserAccount account = UserAccountService.GetUserAccount(null, principalID);

            if (account == null)
            {
                MainConsole.Instance.Error("[AvatarArchive]: User not found!");
                return(false);
            }

            AvatarAppearance appearance = AvatarService.GetAppearance(account.PrincipalID);

            if (appearance == null)
            {
                MainConsole.Instance.Error("[AvatarArchive] Appearance not found!");
                return(false);
            }
            AvatarArchive archive = new AvatarArchive();

            archive.AssetsMap  = new OSDMap();
            archive.BodyMap    = appearance.Pack();
            archive.Appearance = appearance;
            archive.ItemsMap   = new OSDMap();

            foreach (AvatarWearable wear in appearance.Wearables)
            {
                for (int i = 0; i < wear.Count; i++)
                {
                    WearableItem w = wear[i];
                    if (w.AssetID != UUID.Zero)
                    {
                        SaveItem(w.ItemID, ref archive);
                        SaveAsset(w.AssetID, ref archive);
                    }
                }
            }
            List <AvatarAttachment> attachments = appearance.GetAttachments();

            foreach (AvatarAttachment a in attachments.Where(a => a.AssetID != UUID.Zero))
            {
                SaveItem(a.ItemID, ref archive);
                SaveAsset(a.AssetID, ref archive);
            }

            archive.FolderName = folderName;
            archive.Snapshot   = snapshotUUID;
            archive.IsPublic   = isPublic;

            File.WriteAllText(fileName, OSDParser.SerializeLLSDXmlString(archive.ToOSD()));
            MainConsole.Instance.Info("[AvatarArchive] Saved archive to " + fileName);

            return(true);
        }
예제 #2
0
        public bool SaveAvatarArchive(string fileName, UUID principalID, string folderName, UUID snapshotUUID, bool isPublic)
        {
            UserAccount account = UserAccountService.GetUserAccount(null, principalID);
            if (account == null)
            {
                MainConsole.Instance.Error("[AvatarArchive]: User not found!");
                return false;
            }

            AvatarAppearance appearance = AvatarService.GetAppearance(account.PrincipalID);
            if (appearance == null)
            {
                MainConsole.Instance.Error("[AvatarArchive] Appearance not found!");
                return false;
            }
            AvatarArchive archive = new AvatarArchive();
            archive.AssetsMap = new OSDMap();
            archive.BodyMap = appearance.Pack();
            archive.Appearance = appearance;
            archive.ItemsMap = new OSDMap();

            foreach (AvatarWearable wear in appearance.Wearables)
            {
                for (int i = 0; i < wear.Count; i++)
                {
                    WearableItem w = wear[i];
                    if (w.AssetID != UUID.Zero)
                    {
                        SaveItem(w.ItemID, ref archive);
                        SaveAsset(w.AssetID, ref archive);
                    }
                }
            }
            List<AvatarAttachment> attachments = appearance.GetAttachments();

            foreach (AvatarAttachment a in attachments.Where(a => a.AssetID != UUID.Zero))
            {
                SaveItem(a.ItemID, ref archive);
                SaveAsset(a.AssetID, ref archive);
            }

            archive.FolderName = folderName;
            archive.Snapshot = snapshotUUID;
            archive.IsPublic = isPublic;

            File.WriteAllText(fileName, OSDParser.SerializeLLSDXmlString(archive.ToOSD()));
            MainConsole.Instance.Info("[AvatarArchive] Saved archive to " + fileName);

            return true;
        }
예제 #3
0
        /// <summary>
        /// Saves the avatar archive.
        /// </summary>
        /// <returns><c>true</c>, if avatar archive was saved, <c>false</c> otherwise.</returns>
        /// <param name="fileName">File name.</param>
        /// <param name="principalID">Principal I.</param>
        /// <param name="folderName">Folder name.</param>
        /// <param name="snapshotUUID">Snapshot UUI.</param>
        /// <param name="isPublic">If set to <c>true</c> is public.</param>
        public bool SaveAvatarArchive(string fileName, UUID principalID, string folderName, UUID snapshotUUID, bool isPublic)
        {
            UserAccount account = userAccountService.GetUserAccount(null, principalID);

            if (account == null)
            {
                MainConsole.Instance.Error("[AvatarArchive]: User not found!");
                return(false);
            }

            AvatarAppearance appearance = avatarService.GetAppearance(account.PrincipalID);

            if (appearance == null)
            {
                MainConsole.Instance.Error("[AvatarArchive] Appearance not found!");
                return(false);
            }

            string archiveName = Path.GetFileNameWithoutExtension(fileName);
            string filePath    = Path.GetDirectoryName(fileName);

            AvatarArchive archive = new AvatarArchive();

            archive.AssetsMap = new OSDMap();
            archive.ItemsMap  = new OSDMap();

            int wearCount = 0;

            foreach (AvatarWearable wear in appearance.Wearables)
            {
                for (int i = 0; i < wear.Count; i++)
                {
                    WearableItem w = wear[i];
                    if (w.AssetID != UUID.Zero)
                    {
                        SaveItem(w.ItemID, ref archive);
                        SaveAsset(w.AssetID, ref archive);
                        wearCount++;
                    }
                }
            }
            MainConsole.Instance.InfoFormat("[AvatarArchive] Adding {0} wearables to {1}", wearCount, archiveName);

            int attachCount = 0;
            List <AvatarAttachment> attachments = appearance.GetAttachments();

            foreach (AvatarAttachment a in attachments.Where(a => a.AssetID != UUID.Zero))
            {
                SaveItem(a.ItemID, ref archive);
                SaveAsset(a.AssetID, ref archive);
                attachCount++;
            }
            MainConsole.Instance.InfoFormat("[AvatarArchive] Adding {0} attachments to {1}", attachCount, archiveName);

            // set details
            archive.Appearance = appearance;
            archive.BodyMap    = appearance.Pack();
            archive.FolderName = folderName;
            archive.Snapshot   = snapshotUUID;
            archive.IsPublic   = isPublic;

            File.WriteAllText(fileName, OSDParser.SerializeLLSDXmlString(archive.ToOSD()));

            if (snapshotUUID != UUID.Zero)
            {
                ExportArchiveImage(snapshotUUID, archiveName, filePath);
                MainConsole.Instance.Info("[AvatarArchive] Saved archive snapshot");
            }

            MainConsole.Instance.Info("[AvatarArchive] Saved archive to " + fileName);

            return(true);
        }