-
Notifications
You must be signed in to change notification settings - Fork 0
/
Database.cs
47 lines (43 loc) · 2.24 KB
/
Database.cs
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
40
41
42
43
44
45
46
47
using System.Data.OleDb;
using System.Runtime.Versioning;
namespace MKVToMP4Converter
{
[SupportedOSPlatform("windows")]
public static class Database
{
private static string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\gkim\\Documents\\MKVToMP4Converter.accdb";
public static void AddVideoInfo(VideoInfo videoInfo, string conversionVersionCode, DateTime startedDateTime, DateTime finishedDateTime)
{
// Add tblVideoInfo record.
using (var connection = new OleDbConnection(connectionString))
{
string insertSQL =
$@"INSERT INTO tblVideoInfo
(Title, MKVFile, CoverFile, OutputFile, [Year], RatingCode, Duration, QualityCode, ConversionVersionCode, StartedDateTime, FinishedDateTime)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
try
{
var command = new OleDbCommand(insertSQL, connection);
command.Parameters.AddWithValue("@title", videoInfo.Title);
command.Parameters.AddWithValue("@mkvFile", videoInfo.MKVFile);
command.Parameters.AddWithValue("@coverFile", videoInfo.CoverFile);
command.Parameters.AddWithValue("@outputFile", videoInfo.OutputFile);
command.Parameters.AddWithValue("@year", videoInfo.Year);
command.Parameters.AddWithValue("@rating", videoInfo.Rating);
command.Parameters.AddWithValue("@duration", videoInfo.Duration);
command.Parameters.AddWithValue("@quality", videoInfo.Quality);
command.Parameters.AddWithValue("@conversionVersionCode", conversionVersionCode);
command.Parameters.AddWithValue("@startedDateTime", startedDateTime.ToString("yyyy-MM-dd HH:mm:ss"));
command.Parameters.AddWithValue("@finishedDateTime", finishedDateTime.ToString("yyyy-MM-dd HH:mm:ss"));
connection.Open();
command.ExecuteNonQuery();
}
catch (Exception ex)
{
Program.LogError(ex.Message);
throw;
}
}
}
}
}