Revision 540b8cf8 trunk/Pithos.Core/Agents/StatusAgent.cs
b/trunk/Pithos.Core/Agents/StatusAgent.cs | ||
---|---|---|
6 | 6 |
using System.Diagnostics.Contracts; |
7 | 7 |
using System.IO; |
8 | 8 |
using System.Linq; |
9 |
using System.Text; |
|
9 | 10 |
using System.Threading; |
10 | 11 |
using System.Threading.Tasks; |
11 | 12 |
using Castle.ActiveRecord; |
... | ... | |
40 | 41 |
|
41 | 42 |
if (!File.Exists(Path.Combine(_pithosDataPath ,"pithos.db"))) |
42 | 43 |
ActiveRecordStarter.CreateSchema(); |
43 |
} |
|
44 | 44 |
|
45 |
CreateTrigger(); |
|
46 |
} |
|
47 |
|
|
48 |
private void CreateTrigger() |
|
49 |
{ |
|
50 |
using (var connection = GetConnection()) |
|
51 |
using (var triggerCommand = connection.CreateCommand()) |
|
52 |
{ |
|
53 |
var cmdText = new StringBuilder() |
|
54 |
.AppendLine("CREATE TRIGGER IF NOT EXISTS update_last_modified UPDATE ON FileState FOR EACH ROW") |
|
55 |
.AppendLine("BEGIN") |
|
56 |
.AppendLine("UPDATE FileState SET Modified=datetime('now') WHERE Id=old.Id;") |
|
57 |
.AppendLine("END;") |
|
58 |
.AppendLine("CREATE TRIGGER IF NOT EXISTS insert_last_modified INSERT ON FileState FOR EACH ROW") |
|
59 |
.AppendLine("BEGIN") |
|
60 |
.AppendLine("UPDATE FileState SET Modified=datetime('now') WHERE Id=new.Id;") |
|
61 |
.AppendLine("END;") |
|
62 |
.ToString(); |
|
63 |
triggerCommand.CommandText = cmdText; |
|
64 |
triggerCommand.ExecuteNonQuery(); |
|
65 |
} |
|
66 |
} |
|
45 | 67 |
|
46 | 68 |
|
47 | 69 |
private static InPlaceConfigurationSource GetConfiguration(string pithosDbPath) |
Also available in: Unified diff