aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MSSQL/MSSQLAssetData.cs
diff options
context:
space:
mode:
authorCharles Krinke2008-11-19 18:36:04 +0000
committerCharles Krinke2008-11-19 18:36:04 +0000
commit9babdb109504221903464dfa714a445bdf89fa9e (patch)
tree1fdf1b9bc0853094d7f1ec20a635826e22e6aa20 /OpenSim/Data/MSSQL/MSSQLAssetData.cs
parentMantis#2656. Thank you kindly, Nlin for a patch that: (diff)
downloadopensim-SC_OLD-9babdb109504221903464dfa714a445bdf89fa9e.zip
opensim-SC_OLD-9babdb109504221903464dfa714a445bdf89fa9e.tar.gz
opensim-SC_OLD-9babdb109504221903464dfa714a445bdf89fa9e.tar.bz2
opensim-SC_OLD-9babdb109504221903464dfa714a445bdf89fa9e.tar.xz
Mantis#2657. Thank you kindly, StrawberryFride for a patch that:
Added access_time and create_time, plus the new sun position data to MSSQL code.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLAssetData.cs32
1 files changed, 27 insertions, 5 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
index 5bd2aa2..68f353d 100644
--- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Data.MSSQL
42 private const string _migrationStore = "AssetStore"; 42 private const string _migrationStore = "AssetStore";
43 43
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45 private long TicksToEpoch;
46 /// <summary> 46 /// <summary>
47 /// Database manager 47 /// Database manager
48 /// </summary> 48 /// </summary>
@@ -71,6 +71,8 @@ namespace OpenSim.Data.MSSQL
71 /// <param name="connectionString">connect string</param> 71 /// <param name="connectionString">connect string</param>
72 override public void Initialise(string connectionString) 72 override public void Initialise(string connectionString)
73 { 73 {
74 TicksToEpoch = new System.DateTime(1970, 1, 1).Ticks;
75
74 if (!string.IsNullOrEmpty(connectionString)) 76 if (!string.IsNullOrEmpty(connectionString))
75 { 77 {
76 database = new MSSQLManager(connectionString); 78 database = new MSSQLManager(connectionString);
@@ -156,18 +158,19 @@ namespace OpenSim.Data.MSSQL
156 } 158 }
157 159
158 using (AutoClosingSqlCommand command = database.Query( 160 using (AutoClosingSqlCommand command = database.Query(
159 "INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [data])" + 161 "INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [create_time], [access_time], [data])" +
160 " VALUES " + 162 " VALUES " +
161 "(@id, @name, @description, @assetType, @local, @temporary, @data)")) 163 "(@id, @name, @description, @assetType, @local, @temporary, @create_time, @access_time, @data)"))
162 { 164 {
163 //SqlParameter p = cmd.Parameters.Add("id", SqlDbType.NVarChar); 165 int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000);
164 //p.Value = asset.FullID.ToString();
165 command.Parameters.Add(database.CreateParameter("id", asset.FullID)); 166 command.Parameters.Add(database.CreateParameter("id", asset.FullID));
166 command.Parameters.Add(database.CreateParameter("name", asset.Name)); 167 command.Parameters.Add(database.CreateParameter("name", asset.Name));
167 command.Parameters.Add(database.CreateParameter("description", asset.Description)); 168 command.Parameters.Add(database.CreateParameter("description", asset.Description));
168 command.Parameters.Add(database.CreateParameter("assetType", asset.Type)); 169 command.Parameters.Add(database.CreateParameter("assetType", asset.Type));
169 command.Parameters.Add(database.CreateParameter("local", asset.Local)); 170 command.Parameters.Add(database.CreateParameter("local", asset.Local));
170 command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary)); 171 command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary));
172 command.Parameters.Add(database.CreateParameter("access_time", now));
173 command.Parameters.Add(database.CreateParameter("create_time", now));
171 command.Parameters.Add(database.CreateParameter("data", asset.Data)); 174 command.Parameters.Add(database.CreateParameter("data", asset.Data));
172 175
173 command.ExecuteNonQuery(); 176 command.ExecuteNonQuery();
@@ -209,6 +212,25 @@ namespace OpenSim.Data.MSSQL
209 } 212 }
210 } 213 }
211 214
215
216 private void UpdateAccessTime(AssetBase asset)
217 {
218 using (AutoClosingSqlCommand cmd = database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id"))
219 {
220 int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000);
221 cmd.Parameters.AddWithValue("@id", asset.FullID.ToString());
222 cmd.Parameters.AddWithValue("@access_time", now);
223 try
224 {
225 cmd.ExecuteNonQuery();
226 }
227 catch (Exception e)
228 {
229 m_log.Error(e.ToString());
230 }
231 }
232 }
233
212 /// <summary> 234 /// <summary>
213 /// Check if asset exist in database 235 /// Check if asset exist in database
214 /// </summary> 236 /// </summary>