public AvatarArchive GetAvatarArchive(string Name)
        {
            List<string> RetVal = GD.Query("Name", Name, "avatararchives", "*");
            if (RetVal.Count == 0)
                return null;

            AvatarArchive Archive = new AvatarArchive {Name = RetVal[0], ArchiveXML = RetVal[1]};
            return Archive;
        }
		public AvatarArchive GetAvatarArchive(string Name, string Password)
		{
			if (!CheckPassword(Password))
				return null;
            List<string> RetVal = GD.Query("Name", Name, "avatararchives", "*");
			if (RetVal.Count == 0)
				return null;

			AvatarArchive Archive = new AvatarArchive();
            Archive.Name = RetVal[0];
            Archive.ArchiveXML = RetVal[1];
			return Archive;
		}
 /// <summary>
 /// Returns a list object of AvatarArchives. This is being used for wiredux
 /// </summary>
 /// <param name="Public"></param>
 /// <returns></returns>
 public List<AvatarArchive> GetAvatarArchives(bool isPublic)
 {
     List<AvatarArchive> returnValue = new List<AvatarArchive>();
    IDataReader RetVal = GD.QueryDataFull("where IsPublic = 1", "avatararchives", "Name, Snapshot, IsPublic");
     while (RetVal.Read())
     {
         AvatarArchive Archive = new AvatarArchive();
         Archive.Name = RetVal["Name"].ToString();
         Archive.Snapshot = RetVal["Snapshot"].ToString();
         Archive.IsPublic = int.Parse(RetVal["IsPublic"].ToString());
         returnValue.Add(Archive);
     }
     return returnValue;
 }
		public void SaveAvatarArchive(AvatarArchive archive)
		{
			List<string> Check = GD.Query("Name", archive.Name, "avatararchives", "Name");
			if (Check.Count == 0)
            {
                GD.Insert("avatararchives", new object[] {
					archive.Name,
					archive.ArchiveXML
				});
			}
            else
            {
				GD.Update("avatararchives", new object[] { archive.ArchiveXML }, new string[] { "Archive" }, new string[] { "Name" }, new object[] { archive.Name });
			}
		}
 /// <summary>
 /// Returns a list object of AvatarArchives. This is being used for wiredux
 /// </summary>
 /// <param name="Public"></param>
 /// <returns></returns>
 public List<AvatarArchive> GetAvatarArchives(bool isPublic)
 {
     List<AvatarArchive> returnValue = new List<AvatarArchive>();
     try
     {
         System.Data.IDataReader RetVal = GD.QueryData ("where IsPublic = 1", "avatararchives", "Name, Snapshot, IsPublic");
         while (RetVal.Read ())
         {
             AvatarArchive Archive = new AvatarArchive ();
             Archive.Name = RetVal["Name"].ToString ();
             Archive.Snapshot = RetVal["Snapshot"].ToString ();
             Archive.IsPublic = int.Parse (RetVal["IsPublic"].ToString ());
             returnValue.Add (Archive);
         }
         RetVal.Close ();
         RetVal.Dispose ();
     }
     catch
     {
     }
     GD.CloseDatabase ();
     return returnValue;
 }
Beispiel #6
0
        protected void HandleSaveAvatarArchive(string[] cmdparams)
        {
            if (cmdparams.Length < 7)
            {
                m_log.Info("[AvatarArchive] Not enough parameters!");
                return;
            }
            UserAccount account = UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]);
            if (account == null)
            {
                m_log.Error("[AvatarArchive] User not found!");
                return;
            }

            AvatarAppearance appearance = AvatarService.GetAppearance(account.PrincipalID);
            OSDMap map = new OSDMap();
            OSDMap body = new OSDMap();
            OSDMap assets = new OSDMap();
            OSDMap items = new OSDMap();
            body = appearance.Pack();
            body.Add("FolderName", OSD.FromString(cmdparams[6]));

            try
            {
                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, items, assets);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                m_log.Warn("Excpetion: " + ex.ToString());
            }
            try
            {
                List<AvatarAttachment> attachments = appearance.GetAttachments();
                foreach (AvatarAttachment a in attachments)
                {
                    if (a.AssetID != UUID.Zero)
                    {
                        SaveItem(a.ItemID, items, assets); 
                    }
                }
            }
            catch(Exception ex)
            {
                m_log.Warn("Excpetion: " + ex.ToString());
            }

            map.Add("Body", body);
            map.Add("Assets", assets);
            map.Add("Items", items);
            //Write the map

            if (cmdparams[5].EndsWith(".database"))
            {
                //Remove the .database
                string ArchiveName = cmdparams[5].Substring(0, cmdparams[5].Length - 9);
                string ArchiveXML = OSDParser.SerializeLLSDXmlString(map);

                AvatarArchive archive = new AvatarArchive();
                archive.ArchiveXML = ArchiveXML;
                archive.Name = ArchiveName;

                if ((cmdparams.Length >= 8) && (cmdparams[7].Length == 36)) archive.Snapshot = cmdparams[7];
                if ((cmdparams.Length >= 9) && (cmdparams[8].Length == 1)) archive.IsPublic = int.Parse(cmdparams[8]);
				
                DataManager.RequestPlugin<IAvatarArchiverConnector>().SaveAvatarArchive(archive);

                m_log.Info("[AvatarArchive] Saved archive to database " + cmdparams[5]);
            }
            else
            {
                m_log.Info("[AvatarArchive] Saving archive to " + cmdparams[5]);
                StreamWriter writer = new StreamWriter(cmdparams[5], false);
                writer.Write(OSDParser.SerializeLLSDXmlString(map));
                writer.Close();
                writer.Dispose();
                m_log.Info("[AvatarArchive] Saved archive to " + cmdparams[5]);
            }
        }
        public void SaveAvatarArchive(AvatarArchive archive)
        {
            QueryFilter filter = new QueryFilter();
            filter.andFilters["Name"] = archive.Name.MySqlEscape();
            List<string> Check = GD.Query(new string[] { "Name" }, "avatararchives", filter, null, null, null);
            if (Check.Count == 0)
            {
                GD.Insert("avatararchives", new object[]{
                    archive.Name.MySqlEscape(),
                    archive.ArchiveXML,
                    archive.Snapshot.MySqlEscape(),
                    archive.IsPublic
                });
            }
            else
            {
                Dictionary<string, object> values = new Dictionary<string, object>(1);
                values["Archive"] = archive.ArchiveXML;

                GD.Update("avatararchives", values, null, filter, null, null);
            }
        }
 /// <summary>
 ///   Returns a list object of AvatarArchives. This is being used for WebUI
 /// </summary>
 /// <param name = "Public"></param>
 /// <returns></returns>
 public List<AvatarArchive> GetAvatarArchives(bool isPublic)
 {
     List<AvatarArchive> returnValue = new List<AvatarArchive>();
     DataReaderConnection RetVal = null;
     try
     {
         RetVal = GD.QueryData("where IsPublic = 1", "avatararchives", "Name, Snapshot, IsPublic");
         while (RetVal.DataReader.Read())
         {
             AvatarArchive Archive = new AvatarArchive
                                         {
                                             Name = RetVal.DataReader["Name"].ToString(),
                                             Snapshot = RetVal.DataReader["Snapshot"].ToString(),
                                             IsPublic = int.Parse(RetVal.DataReader["IsPublic"].ToString())
                                         };
             returnValue.Add(Archive);
         }
     }
     catch
     {
         GD.CloseDatabase(RetVal);
     }
     return returnValue;
 }
Beispiel #9
0
        protected void HandleSaveAvatarArchive(string module, string[] cmdparams)
        {
            if (cmdparams.Length != 7)
            {
                m_log.Debug("[AvatarArchive] Not enough parameters!");
                return;
            }
            UserAccount account = UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]);
            if (account == null)
            {
                m_log.Error("[AvatarArchive] User not found!");
                return;
            }
            AvatarData avatarData = AvatarService.GetAvatar(account.PrincipalID);
            AvatarAppearance appearance = avatarData.ToAvatarAppearance(account.PrincipalID);
            if (cmdparams[5].EndsWith(".database"))
            {
                string Password = Util.Md5Hash(MainConsole.Instance.CmdPrompt("Password: "));
                string ArchiveName = cmdparams[5].Substring(0, cmdparams[5].Length - 9);
                string ArchiveXML = MakeXMLFormat(appearance, cmdparams[6]);
                
                AvatarArchive archive = new AvatarArchive();
                archive.ArchiveXML = ArchiveXML;
                archive.Name = ArchiveName;

                DataManager.RequestPlugin<IAvatarArchiverConnector>().SaveAvatarArchive(archive, Password);

                m_log.Debug("[AvatarArchive] Saved archive to database " + cmdparams[5]);
            }
            else
            {
                StreamWriter writer = new StreamWriter(cmdparams[5]);
                writer.Write(MakeXMLFormat(appearance, cmdparams[6]));
                writer.Close();
                writer.Dispose();
                m_log.Debug("[AvatarArchive] Saved archive to " + cmdparams[5]);
            }
        }
Beispiel #10
0
        protected void HandleSaveAvatarArchive(string[] cmdparams)
        {
            if (cmdparams.Length < 7)
            {
                MainConsole.Instance.Info("[AvatarArchive] Not enough parameters!");
            }
            UserAccount account = UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3] + " " + cmdparams[4]);
            if (account == null)
            {
                MainConsole.Instance.Error("[AvatarArchive] User not found!");
                return;
            }

            IScenePresence SP = null;
            ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager>();
            if (manager != null)
            {
                foreach (IScene scene in manager.GetAllScenes())
                    if (scene.TryGetScenePresence(account.PrincipalID, out SP))
                        break;
                if (SP == null)
                    return; //Bad people!
            }

            if (SP != null)
                SP.ControllingClient.SendAlertMessage("Appearance saving in progress...");

            AvatarAppearance appearance = AvatarService.GetAppearance(account.PrincipalID);
            if (appearance == null)
            {
                IAvatarAppearanceModule appearancemod = m_registry.RequestModuleInterface<IAvatarAppearanceModule>();
                appearance = appearancemod.Appearance;
            }
            OSDMap map = new OSDMap();
            OSDMap body = new OSDMap();
            OSDMap assets = new OSDMap();
            OSDMap items = new OSDMap();
            body = appearance.Pack();
            body.Add("FolderName", OSD.FromString(cmdparams[6]));

            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, items, assets);
                        SaveAsset(w.AssetID, assets);
                    }
                }
            }
            List<AvatarAttachment> attachments = appearance.GetAttachments();
            #if (!ISWIN)
            foreach (AvatarAttachment a in attachments)
            {
                if (a.AssetID != UUID.Zero)
                {
                    SaveItem(a.ItemID, items, assets);
                    SaveAsset(a.AssetID, assets);
                }
            }
            #else
            foreach (AvatarAttachment a in attachments.Where(a => a.AssetID != UUID.Zero))
            {
                SaveItem(a.ItemID, items, assets);
                SaveAsset(a.AssetID, assets);
            }
            #endif
            map.Add("Body", body);
            map.Add("Assets", assets);
            map.Add("Items", items);

            //Write the map
            if (cmdparams[5].EndsWith(".database"))
            {
                IAvatarArchiverConnector archiver = DataManager.DataManager.RequestPlugin<IAvatarArchiverConnector>();
                if (archiver != null)
                {
                    AvatarArchive archive = new AvatarArchive();
                    archive.ArchiveXML = OSDParser.SerializeLLSDXmlString(map);

                    // Add the extra details for archives
                    archive.Name = cmdparams[5].Substring(0, cmdparams[5].LastIndexOf(".database"));
                    if (cmdparams.Length > 7)
                    {
                        if (cmdparams.Contains("--Snapshot"))
                        {
                            UUID snapshot;
                            int index = 0;
                            for(; index < cmdparams.Length; index++)
                            {
                                if(cmdparams[index] == "--Snapshot")
                                {
                                    index++;
                                    break;
                                }
                            }
                            if(index < cmdparams.Length && UUID.TryParse(cmdparams[index], out snapshot))
                            {
                                archive.Snapshot = snapshot.ToString();
                            }
                        }
                        else
                        {
                            archive.Snapshot = UUID.Zero.ToString();
                        }
                        if (cmdparams.Contains("--public"))
                        {
                            archive.IsPublic = 1;
                        }
                    }
                    else
                    {
                        archive.Snapshot = UUID.Zero.ToString();
                        archive.IsPublic = 0;
                    }

                    // Save the archive
                    archiver.SaveAvatarArchive(archive);
                    MainConsole.Instance.Info("[AvatarArchive] Saved archive to database as: " + archive.Name);
                }
                else
                {
                    MainConsole.Instance.Error("[AvatarArchive] Unable to save to database!");
                    return;
                }
            }
            else
            {
                StreamWriter writer = new StreamWriter(cmdparams[5], false);
                writer.Write(OSDParser.SerializeLLSDXmlString(map));
                writer.Close();
                writer.Dispose();
                MainConsole.Instance.Info("[AvatarArchive] Saved archive to " + cmdparams[5]);
            }
        }
		public void SaveAvatarArchive(AvatarArchive archive)
		{
			List<string> Check = GD.Query("Name", archive.Name, "avatararchives", "Name");
			if (Check.Count == 0)
            {
                GD.Insert("avatararchives", new object[] {
					archive.Name.MySqlEscape(),
					archive.ArchiveXML,
                    archive.Snapshot.MySqlEscape(),
                    archive.IsPublic
				});
			}
            else
            {
                GD.Update("avatararchives", new object[] { archive.ArchiveXML }, new string[] { "Archive" }, new string[] { "Name" }, new object[] { archive.Name.MySqlEscape() });
			}
		}
Beispiel #12
0
        protected void HandleSaveAvatarArchive(string module, string[] cmdparams)
        {
            if (cmdparams.Length != 7)
            {
                m_log.Debug("[AvatarArchive] Not enough parameters!");
            }
            UserAccount account = UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]);
            if (account == null)
            {
                m_log.Error("[AvatarArchive] User not found!");
                return;
            }

            AvatarData avatarData = AvatarService.GetAvatar(account.PrincipalID);
            AvatarAppearance appearance = avatarData.ToAvatarAppearance(account.PrincipalID);
            OSDMap map = new OSDMap();
            OSDMap body = new OSDMap();
            OSDMap assets = new OSDMap();
            OSDMap items = new OSDMap();
            body = appearance.Pack();

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

            map.Add("Body", body);
            map.Add("Assets", assets);
            map.Add("Items", items);
            //Write the map

            if (cmdparams[5].EndsWith(".database"))
            {
                //Remove the .database
                string ArchiveName = cmdparams[5].Substring(0, cmdparams[5].Length - 9);
                string ArchiveXML = OSDParser.SerializeLLSDXmlString(map);

                AvatarArchive archive = new AvatarArchive();
                archive.ArchiveXML = ArchiveXML;
                archive.Name = ArchiveName;

                DataManager.RequestPlugin<IAvatarArchiverConnector>().SaveAvatarArchive(archive);

                m_log.Debug("[AvatarArchive] Saved archive to database " + cmdparams[5]);
            }
            else
            {
                StreamWriter writer = new StreamWriter(cmdparams[5]);
                writer.Write(OSDParser.SerializeLLSDXmlString(map));
                writer.Close();
                writer.Dispose();
                m_log.Debug("[AvatarArchive] Saved archive to " + cmdparams[5]);
            }
        }
        protected void HandleSaveAvatarArchive(string module, string[] cmdparams)
        {
            if (cmdparams.Length != 7)
            {
                m_log.Debug("[AvatarArchive] Not enough parameters!");
            }
            UserAccount account = UserAccountService.GetUserAccount(UUID.Zero, cmdparams[3], cmdparams[4]);
            if (account == null)
            {
                m_log.Error("[AvatarArchive] User not found!");
                return;
            }

            AvatarData avatarData = AvatarService.GetAvatar(account.PrincipalID);
            AvatarAppearance appearance = avatarData.ToAvatarAppearance(account.PrincipalID);
            OSDMap map = new OSDMap();
            OSDMap body = new OSDMap();
            OSDMap assets = new OSDMap();
            OSDMap items = new OSDMap();
            body.Add("AvatarHeight", OSD.FromReal(appearance.AvatarHeight));
            body.Add("BodyAsset", OSD.FromUUID(appearance.BodyAsset));
            body.Add("BodyItem", OSD.FromUUID(appearance.BodyItem));
            body.Add("EyesAsset", OSD.FromUUID(appearance.EyesAsset));
            body.Add("EyesItem", OSD.FromUUID(appearance.EyesItem));
            body.Add("GlovesAsset", OSD.FromUUID(appearance.GlovesAsset));
            body.Add("GlovesItem", OSD.FromUUID(appearance.GlovesItem));
            body.Add("HairAsset", OSD.FromUUID(appearance.HairAsset));
            body.Add("HairItem", OSD.FromUUID(appearance.HairItem));
            body.Add("HipOffset", OSD.FromReal(appearance.HipOffset));
            body.Add("JacketAsset", OSD.FromUUID(appearance.JacketAsset));
            body.Add("JacketItem", OSD.FromUUID(appearance.JacketItem));
            body.Add("Owner", OSD.FromUUID(appearance.Owner));
            body.Add("PantsAsset", OSD.FromUUID(appearance.PantsAsset));
            body.Add("Serial", OSD.FromInteger(appearance.Serial));
            body.Add("ShirtAsset", OSD.FromUUID(appearance.ShirtAsset));
            body.Add("ShirtItem", OSD.FromUUID(appearance.ShirtItem));
            body.Add("ShoesAsset", OSD.FromUUID(appearance.ShoesAsset));
            body.Add("ShoesItem", OSD.FromUUID(appearance.ShoesItem));
            body.Add("SkinAsset", OSD.FromUUID(appearance.SkinAsset));
            body.Add("SkirtAsset", OSD.FromUUID(appearance.SkirtAsset));
            body.Add("SkirtItem", OSD.FromUUID(appearance.SkirtItem));
            body.Add("SocksAsset", OSD.FromUUID(appearance.SocksAsset));
            body.Add("SocksItem", OSD.FromUUID(appearance.SocksItem));
            body.Add("UnderPantsAsset", OSD.FromUUID(appearance.UnderPantsAsset));
            body.Add("UnderPantsItem", OSD.FromUUID(appearance.UnderPantsItem));
            body.Add("UnderShirtAsset", OSD.FromUUID(appearance.UnderShirtAsset));
            body.Add("UnderShirtItem", OSD.FromUUID(appearance.UnderShirtItem));
            body.Add("TattooAsset", OSD.FromUUID(appearance.TattooAsset));
            body.Add("TattooItem", OSD.FromUUID(appearance.TattooItem));
            body.Add("AlphaAsset", OSD.FromUUID(appearance.AlphaAsset));
            body.Add("AlphaItem", OSD.FromUUID(appearance.AlphaItem));
            body.Add("FolderName", OSD.FromString(cmdparams[6]));
            body.Add("VisualParams", OSD.FromBinary(appearance.VisualParams));

            OSDArray wearables = new OSDArray();
            foreach (AvatarWearable wear in appearance.Wearables)
            {
                OSDMap wearable = new OSDMap();
                if (wear.AssetID != UUID.Zero)
                {
                    SaveAsset(wear.AssetID, assets);
                    SaveItem(wear.ItemID, items);
                }
                wearable.Add("Asset", wear.AssetID);
                wearable.Add("Item", wear.ItemID);
                wearables.Add(wearable);
            }
            body.Add("AvatarWearables", wearables);

            body.Add("Texture", appearance.Texture.GetOSD());

            OSDArray attachmentsArray = new OSDArray();

            Hashtable attachments = appearance.GetAttachments();
            if (attachments != null)
            {
                foreach (DictionaryEntry element in attachments)
                {
                    Hashtable attachInfo = (Hashtable)element.Value;
                    InventoryItemBase IB = new InventoryItemBase(UUID.Parse(attachInfo["item"].ToString()));
                    OSDMap attachment = new OSDMap();
                    SaveAsset(IB.AssetID, assets);
                    SaveItem(UUID.Parse(attachInfo["item"].ToString()), items);
                    attachment.Add("Asset", OSD.FromUUID(IB.AssetID));
                    attachment.Add("Item", OSD.FromUUID(UUID.Parse(attachInfo["item"].ToString())));
                    attachment.Add("Point", OSD.FromInteger((int)element.Key));
                    attachmentsArray.Add(attachment);
                }
            }

            body.Add("Attachments", attachmentsArray);

            map.Add("Body", body);
            map.Add("Assets", assets);
            map.Add("Items", items);
            //Write the map

            if (cmdparams[5].EndsWith(".database"))
            {
                //Remove the .database
                string ArchiveName = cmdparams[5].Substring(0, cmdparams[5].Length - 9);
                string ArchiveXML = OSDParser.SerializeLLSDXmlString(map);

                AvatarArchive archive = new AvatarArchive();
                archive.ArchiveXML = ArchiveXML;
                archive.Name = ArchiveName;

                DataManager.RequestPlugin<IAvatarArchiverConnector>().SaveAvatarArchive(archive);

                m_log.Debug("[AvatarArchive] Saved archive to database " + cmdparams[5]);
            }
            else
            {
                StreamWriter writer = new StreamWriter(cmdparams[5]);
                writer.Write(OSDParser.SerializeLLSDXmlString(map));
                writer.Close();
                writer.Dispose();
                m_log.Debug("[AvatarArchive] Saved archive to " + cmdparams[5]);
            }
        }