-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathDdonSqlDbEquipPresetTemplate.cs
More file actions
89 lines (81 loc) · 4.28 KB
/
Copy pathDdonSqlDbEquipPresetTemplate.cs
File metadata and controls
89 lines (81 loc) · 4.28 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Data.Common;
using System.Reflection.Metadata.Ecma335;
using System.Xml;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Ddon.Shared.Model;
namespace Arrowgene.Ddon.Database.Sql.Core
{
public abstract partial class DdonSqlDb<TCon, TCom, TReader> : SqlDb<TCon, TCom, TReader>
where TCon : DbConnection
where TCom : DbCommand
where TReader : DbDataReader
{
protected static readonly string[] EquipmentTmeplateFields = new string[]
{
"character_common_id", "job_id", "preset_no", "slot_no", "item_uid"
};
private readonly string SqlInsertEquipmentPresetTemplate = $"INSERT INTO \"ddon_equip_preset_template\" ({BuildQueryField(EquipmentTmeplateFields)}) VALUES ({BuildQueryInsert(EquipmentTmeplateFields)});";
private static readonly string SqlSelectEquipmentPresetTemplate = $"SELECT {BuildQueryField(EquipmentTmeplateFields)} FROM \"ddon_equip_preset_template\" WHERE \"character_common_id\" = @character_common_id AND \"job_id\" = @job_id AND \"preset_no\" = @preset_no;";
private static readonly string SqlDeleteEquipmentPresetTemplate = $"DELETE FROM \"ddon_equip_preset_template\" WHERE \"character_common_id\"=@character_common_id AND \"job_id\"=@job_id AND \"preset_no\"=@preset_no;";
public bool InsertEquipmentPresetTemplate(uint characterCommonId, JobId jobId, uint presetNo, uint slotNo, string itemUId)
{
using TCon connection = OpenNewConnection();
return InsertEquipmentPresetTemplate(connection, characterCommonId, jobId, presetNo, slotNo, itemUId);
}
public bool InsertEquipmentPresetTemplate(TCon conn, uint characterCommonId, JobId jobId, uint presetNo, uint slotNo, string itemUId)
{
return ExecuteNonQuery(conn, SqlInsertEquipmentPresetTemplate, command =>
{
AddParameter(command, "character_common_id", characterCommonId);
AddParameter(command, "job_id", (byte)jobId);
AddParameter(command, "preset_no", presetNo);
AddParameter(command, "slot_no", slotNo);
AddParameter(command, "item_uid", itemUId);
}) == 1;
}
public List<CDataPresetEquipInfo> SelectEquipmentPresetTemplate(uint characterCommonId, JobId jobId, uint presetNo)
{
using TCon connection = OpenNewConnection();
return SelectEquipmentPresetTemplate(connection, characterCommonId, jobId, presetNo);
}
public List<CDataPresetEquipInfo> SelectEquipmentPresetTemplate(TCon conn, uint characterCommonId, JobId jobId, uint presetNo)
{
var results = new List<CDataPresetEquipInfo>();
ExecuteInTransaction(conn =>
{
ExecuteReader(conn, SqlSelectEquipmentPresetTemplate,
command => {
AddParameter(command, "character_common_id", characterCommonId);
AddParameter(command, "job_id", (byte)jobId);
AddParameter(command, "preset_no", presetNo);
}, reader => {
while (reader.Read())
{
results.Add(new CDataPresetEquipInfo()
{
ItemUId = GetString(reader, "item_uid"),
EquipSlotNo = GetByte(reader, "slot_no")
});
}
});
});
return results;
}
public bool DeleteEquipmentPresetTemplate(uint characterCommonId, JobId jobId, uint presetNo)
{
using TCon connection = OpenNewConnection();
return DeleteEquipmentPresetTemplate(connection, characterCommonId, jobId, presetNo);
}
public bool DeleteEquipmentPresetTemplate(TCon conn, uint characterCommonId, JobId jobId, uint presetNo)
{
return ExecuteNonQuery(conn, SqlDeleteEquipmentPresetTemplate, command =>
{
AddParameter(command, "character_common_id", characterCommonId);
AddParameter(command, "job_id", (byte)jobId);
AddParameter(command, "preset_no", presetNo);
}) == 1;
}
}
}