aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLOfflineIMData.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLOfflineIMData.cs (renamed from OpenSim/ApplicationPlugins/Rest/RestXmlWriter.cs)54
1 files changed, 22 insertions, 32 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/RestXmlWriter.cs b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs
index 283fa2e..252f358 100644
--- a/OpenSim/ApplicationPlugins/Rest/RestXmlWriter.cs
+++ b/OpenSim/Data/MySQL/MySQLOfflineIMData.cs
@@ -25,48 +25,38 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.IO; 28using System;
29using System.Text; 29using System.Collections;
30using System.Xml; 30using System.Collections.Generic;
31using System.Reflection;
31 32
32namespace OpenSim.ApplicationPlugins.Rest 33using OpenSim.Framework;
33{ 34using OpenSim.Data.MySQL;
34 public class RestXmlWriter: XmlTextWriter
35 {
36 private StringWriter m_sw = null;
37
38 public RestXmlWriter(StringWriter sw) : base(sw)
39 {
40 m_sw = sw;
41 Formatting = Formatting.Indented;
42 }
43 35
44 public RestXmlWriter(TextWriter textWriter) : base(textWriter) 36using OpenMetaverse;
45 { 37using MySql.Data.MySqlClient;
46 }
47 38
48 public RestXmlWriter(Stream stream) 39namespace OpenSim.Data.MySQL
49 : this(stream, Encoding.UTF8) 40{
41 public class MySQLOfflineIMData : MySQLGenericTableHandler<OfflineIMData>, IOfflineIMData
42 {
43 public MySQLOfflineIMData(string connectionString, string realm)
44 : base(connectionString, realm, "IM_Store")
50 { 45 {
51 } 46 }
52 47
53 public RestXmlWriter(Stream stream, Encoding enc) : base(stream, enc) 48 public void DeleteOld()
54 { 49 {
55 } 50 uint now = (uint)Util.UnixTimeSinceEpoch();
56 51
57 public override void WriteStartDocument() 52 using (MySqlCommand cmd = new MySqlCommand())
58 { 53 {
59 } 54 cmd.CommandText = String.Format("delete from {0} where TMStamp < ?tstamp", m_Realm);
55 cmd.Parameters.AddWithValue("?tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old
60 56
61 public override void WriteStartDocument(bool standalone) 57 ExecuteNonQuery(cmd);
62 { 58 }
63 }
64 59
65 public override string ToString()
66 {
67 Flush();
68 Close();
69 return m_sw.ToString();
70 } 60 }
71 } 61 }
72} 62}