From 9babdb109504221903464dfa714a445bdf89fa9e Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 19 Nov 2008 18:36:04 +0000 Subject: 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. --- OpenSim/Data/MSSQL/MSSQLAssetData.cs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'OpenSim/Data/MSSQL/MSSQLAssetData.cs') 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 private const string _migrationStore = "AssetStore"; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - + private long TicksToEpoch; /// /// Database manager /// @@ -71,6 +71,8 @@ namespace OpenSim.Data.MSSQL /// connect string override public void Initialise(string connectionString) { + TicksToEpoch = new System.DateTime(1970, 1, 1).Ticks; + if (!string.IsNullOrEmpty(connectionString)) { database = new MSSQLManager(connectionString); @@ -156,18 +158,19 @@ namespace OpenSim.Data.MSSQL } using (AutoClosingSqlCommand command = database.Query( - "INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [data])" + + "INSERT INTO assets ([id], [name], [description], [assetType], [local], [temporary], [create_time], [access_time], [data])" + " VALUES " + - "(@id, @name, @description, @assetType, @local, @temporary, @data)")) + "(@id, @name, @description, @assetType, @local, @temporary, @create_time, @access_time, @data)")) { - //SqlParameter p = cmd.Parameters.Add("id", SqlDbType.NVarChar); - //p.Value = asset.FullID.ToString(); + int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); command.Parameters.Add(database.CreateParameter("id", asset.FullID)); command.Parameters.Add(database.CreateParameter("name", asset.Name)); command.Parameters.Add(database.CreateParameter("description", asset.Description)); command.Parameters.Add(database.CreateParameter("assetType", asset.Type)); command.Parameters.Add(database.CreateParameter("local", asset.Local)); command.Parameters.Add(database.CreateParameter("temporary", asset.Temporary)); + command.Parameters.Add(database.CreateParameter("access_time", now)); + command.Parameters.Add(database.CreateParameter("create_time", now)); command.Parameters.Add(database.CreateParameter("data", asset.Data)); command.ExecuteNonQuery(); @@ -209,6 +212,25 @@ namespace OpenSim.Data.MSSQL } } + + private void UpdateAccessTime(AssetBase asset) + { + using (AutoClosingSqlCommand cmd = database.Query("UPDATE assets SET access_time = @access_time WHERE id=@id")) + { + int now = (int)((System.DateTime.Now.Ticks - TicksToEpoch) / 10000000); + cmd.Parameters.AddWithValue("@id", asset.FullID.ToString()); + cmd.Parameters.AddWithValue("@access_time", now); + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception e) + { + m_log.Error(e.ToString()); + } + } + } + /// /// Check if asset exist in database /// -- cgit v1.1