-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathProjectFileCompressor.cs
More file actions
39 lines (35 loc) · 1007 Bytes
/
ProjectFileCompressor.cs
File metadata and controls
39 lines (35 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Microsoft.Data.Sqlite;
using OSPSuite.Core.Extensions;
using OSPSuite.Infrastructure.Serialization.Extensions;
using System.Data.Common;
namespace MoBi.Core.Services
{
public interface IProjectFileCompressor
{
void Compress(string projectFile);
}
public class ProjectFileCompressor : IProjectFileCompressor
{
public void Compress(string projectFile)
{
var path = projectFile.ToUNCPath();
using (var sqlLite = new SqliteConnection(ConnectionStringHelper.ConnectionStringFor(path)))
{
sqlLite.Open();
vacuum(sqlLite);
}
}
private void vacuum(SqliteConnection sqlLite)
{
ExecuteNonQuery(sqlLite, "vacuum;");
}
public int ExecuteNonQuery(DbConnection connection, string query)
{
using (var command = connection.CreateCommand())
{
command.CommandText = query;
return command.ExecuteNonQuery();
}
}
}
}