aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLUserData.cs
diff options
context:
space:
mode:
authorCharles Krinke2008-06-11 13:57:32 +0000
committerCharles Krinke2008-06-11 13:57:32 +0000
commitaba396cb329a359a0ff9d5e6596912079bfb3584 (patch)
tree8e8c98a60a73a896b5d43fbe2c9fd132ed32369b /OpenSim/Data/MSSQL/MSSQLUserData.cs
parent* Drop periodic stats logging back down to 60 minutes to reduce console spam. (diff)
downloadopensim-SC-aba396cb329a359a0ff9d5e6596912079bfb3584.zip
opensim-SC-aba396cb329a359a0ff9d5e6596912079bfb3584.tar.gz
opensim-SC-aba396cb329a359a0ff9d5e6596912079bfb3584.tar.bz2
opensim-SC-aba396cb329a359a0ff9d5e6596912079bfb3584.tar.xz
Mantis#1528. Thank you kindly, Boscata for:
MSSQL Avatar appearance solved. Appearance functions and modified table.
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLUserData.cs')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLUserData.cs138
1 files changed, 137 insertions, 1 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs
index aa8c2ed..8714e2b 100644
--- a/OpenSim/Data/MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs
@@ -749,11 +749,147 @@ namespace OpenSim.Data.MSSQL
749 /// TODO: stubs for now to get us to a compiling state gently 749 /// TODO: stubs for now to get us to a compiling state gently
750 override public AvatarAppearance GetUserAppearance(LLUUID user) 750 override public AvatarAppearance GetUserAppearance(LLUUID user)
751 { 751 {
752 return new AvatarAppearance(); 752// return new AvatarAppearance();
753 try
754 {
755 lock (database)
756 {
757 Dictionary<string, string> param = new Dictionary<string, string>();
758 param["@UUID"] = user.ToString();
759
760 IDbCommand result =
761 database.Query("SELECT * FROM avatarappearance WHERE owner = @UUID", param);
762 IDataReader reader = result.ExecuteReader();
763
764 AvatarAppearance item = null;
765 if (reader.Read())
766 item = readUserAppearance(reader);
767
768 reader.Close();
769 result.Dispose();
770
771 return item;
772 }
773 }
774 catch (Exception e)
775 {
776 database.Reconnect();
777 m_log.Error(e.ToString());
778 }
779 return null;
780 }
781
782 /// <summary>
783 /// Reads a one item from an SQL result
784 /// </summary>
785 /// <param name="reader">The SQL Result</param>
786 /// <returns>the item read</returns>
787 private static AvatarAppearance readUserAppearance(IDataReader reader)
788 {
789 try
790 {
791 AvatarAppearance appearance = new AvatarAppearance();
792
793 appearance.Owner = new LLUUID((string)reader["owner"]);
794 appearance.Serial = Convert.ToInt32(reader["serial"]);
795 appearance.VisualParams = (byte[])reader["visual_params"];
796 appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length);
797 appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]);
798 appearance.BodyItem = new LLUUID((string)reader["body_item"]);
799 appearance.BodyAsset = new LLUUID((string)reader["body_asset"]);
800 appearance.SkinItem = new LLUUID((string)reader["skin_item"]);
801 appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]);
802 appearance.HairItem = new LLUUID((string)reader["hair_item"]);
803 appearance.HairAsset = new LLUUID((string)reader["hair_asset"]);
804 appearance.EyesItem = new LLUUID((string)reader["eyes_item"]);
805 appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]);
806 appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]);
807 appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]);
808 appearance.PantsItem = new LLUUID((string)reader["pants_item"]);
809 appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]);
810 appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]);
811 appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]);
812 appearance.SocksItem = new LLUUID((string)reader["socks_item"]);
813 appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]);
814 appearance.JacketItem = new LLUUID((string)reader["jacket_item"]);
815 appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]);
816 appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]);
817 appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]);
818 appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]);
819 appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]);
820 appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]);
821 appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]);
822 appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]);
823 appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]);
824
825 return appearance;
826 }
827 catch (SqlException e)
828 {
829 m_log.Error(e.ToString());
830 }
831
832 return null;
753 } 833 }
754 834
755 override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) 835 override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
756 { 836 {
837 string sql = String.Empty;
838 sql += "DELETE FROM avatarappearance WHERE owner=@owner ";
839 sql += "INSERT INTO avatarappearance ";
840 sql += "(owner, serial, visual_params, texture, avatar_height, ";
841 sql += "body_item, body_asset, skin_item, skin_asset, hair_item, hair_asset, eyes_item, eyes_asset, ";
842 sql += "shirt_item, shirt_asset, pants_item, pants_asset, shoes_item, shoes_asset, socks_item, socks_asset, ";
843 sql += "jacket_item, jacket_asset, gloves_item, gloves_asset, undershirt_item, undershirt_asset, underpants_item, underpants_asset, ";
844 sql += "skirt_item, skirt_asset) values (";
845 sql += "@owner, @serial, @visual_params, @texture, @avatar_height, ";
846 sql += "@body_item, @body_asset, @skin_item, @skin_asset, @hair_item, @hair_asset, @eyes_item, @eyes_asset, ";
847 sql += "@shirt_item, @shirt_asset, @pants_item, @pants_asset, @shoes_item, @shoes_asset, @socks_item, @socks_asset, ";
848 sql += "@jacket_item, @jacket_asset, @gloves_item, @gloves_asset, @undershirt_item, @undershirt_asset, @underpants_item, @underpants_asset, ";
849 sql += "@skirt_item, @skirt_asset)";
850
851 SqlCommand cmd = new SqlCommand(sql, database.getConnection());
852 cmd.Parameters.AddWithValue("@owner", appearance.Owner.ToString());
853 cmd.Parameters.AddWithValue("@serial", appearance.Serial);
854 cmd.Parameters.AddWithValue("@visual_params", appearance.VisualParams);
855 cmd.Parameters.AddWithValue("@texture", appearance.Texture.ToBytes());
856 cmd.Parameters.AddWithValue("@avatar_height", appearance.AvatarHeight);
857 cmd.Parameters.AddWithValue("@body_item", appearance.BodyItem.ToString());
858 cmd.Parameters.AddWithValue("@body_asset", appearance.BodyAsset.ToString());
859 cmd.Parameters.AddWithValue("@skin_item", appearance.SkinItem.ToString());
860 cmd.Parameters.AddWithValue("@skin_asset", appearance.SkinAsset.ToString());
861 cmd.Parameters.AddWithValue("@hair_item", appearance.HairItem.ToString());
862 cmd.Parameters.AddWithValue("@hair_asset", appearance.HairAsset.ToString());
863 cmd.Parameters.AddWithValue("@eyes_item", appearance.EyesItem.ToString());
864 cmd.Parameters.AddWithValue("@eyes_asset", appearance.EyesAsset.ToString());
865 cmd.Parameters.AddWithValue("@shirt_item", appearance.ShirtItem.ToString());
866 cmd.Parameters.AddWithValue("@shirt_asset", appearance.ShirtAsset.ToString());
867 cmd.Parameters.AddWithValue("@pants_item", appearance.PantsItem.ToString());
868 cmd.Parameters.AddWithValue("@pants_asset", appearance.PantsAsset.ToString());
869 cmd.Parameters.AddWithValue("@shoes_item", appearance.ShoesItem.ToString());
870 cmd.Parameters.AddWithValue("@shoes_asset", appearance.ShoesAsset.ToString());
871 cmd.Parameters.AddWithValue("@socks_item", appearance.SocksItem.ToString());
872 cmd.Parameters.AddWithValue("@socks_asset", appearance.SocksAsset.ToString());
873 cmd.Parameters.AddWithValue("@jacket_item", appearance.JacketItem.ToString());
874 cmd.Parameters.AddWithValue("@jacket_asset", appearance.JacketAsset.ToString());
875 cmd.Parameters.AddWithValue("@gloves_item", appearance.GlovesItem.ToString());
876 cmd.Parameters.AddWithValue("@gloves_asset", appearance.GlovesAsset.ToString());
877 cmd.Parameters.AddWithValue("@undershirt_item", appearance.UnderShirtItem.ToString());
878 cmd.Parameters.AddWithValue("@undershirt_asset", appearance.UnderShirtAsset.ToString());
879 cmd.Parameters.AddWithValue("@underpants_item", appearance.UnderPantsItem.ToString());
880 cmd.Parameters.AddWithValue("@underpants_asset", appearance.UnderPantsAsset.ToString());
881 cmd.Parameters.AddWithValue("@skirt_item", appearance.SkirtItem.ToString());
882 cmd.Parameters.AddWithValue("@skirt_asset", appearance.SkirtAsset.ToString());
883
884 try
885 {
886 cmd.ExecuteNonQuery();
887 cmd.Dispose();
888 }
889 catch (Exception e)
890 {
891 m_log.Error(e.ToString());
892 }
757 return; 893 return;
758 } 894 }
759 895