ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using Grpc.Net.Client;
using HotelPms.Client.Blazor.Models;
using HotelPms.Data.Client;
using HotelPms.Data.Common;
using HotelPms.Data.Master;
using HotelPms.DataAccessGrpc.Client;
using HotelPms.Share.IO;
using HotelPms.Share.Util;
using System.Data;
 
namespace HotelPms.Client.Blazor.Util
{
    public class MasterCore
    {
        /// <summary>
        /// マスタ名称取得
        /// </summary>
        /// <param name="tableName">「M_」なし</param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static async Task<string> GetName(string tableName, int id)
        {
            Data.GrpcTable table = await GrpcClient.GetTableAsync(EnvironmentSetting.GrpcChannel, (int)ETableActionType.MasterName, $"{tableName},{id}");
            return CConvert.ToString(table.GetValue(typeof(string)));
        }
 
        public static async Task<string> GetSaleLoginName(int id)
        {
            Data.GrpcTable table = await GrpcClient.GetTableAsync(EnvironmentSetting.GrpcChannel, (int)ETableActionType.SalesLoginName, $"{id}");
            return CConvert.ToString(table.GetValue(typeof(string)));
        }
 
        /// <summary>
        /// 部屋タイプ名称
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static async Task<string> GetRoomTypeName(int id)
        {
            string name = CacheStorage.Instance.GetMasterName(CacheStorage.Key.RoomTypeName, id);
            if (name.Length > 0) { return name; }
            name = await GetName("RoomType", id);
            if (name.Length > 0) { CacheStorage.Instance.SetMasterName(CacheStorage.Key.RoomTypeName, id, name); }
            return name;
        }
 
        /// <summary>
        /// 部屋タイプ基本情報の取得
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static async Task<RoomTypeBase> GetRoomTypeBase(int id)
        {
            try
            {
                Data.GrpcTable table = await GrpcClient.GetTableAsync(EnvironmentSetting.GrpcChannel, (int)ETableActionType.RoomTypeBase, id.ToString());
                if (table.Rows.Count == 0) { return null; }
                using DataTable data = table.ToDataTable();
                return new RoomTypeBase(data.Rows[0]);
            }
            catch(Exception ex)
            {
                OperationLog.Instance.WriteLog($"GetRoomTypeBase:{ex.Message}");
                return null;
            }
        }
 
        /// <summary>
        /// 選択一覧用部屋タイプマスタを取得する
        /// </summary>
        /// <returns></returns>
        public static async Task<DataTable> GetRoomTypeList()
        {
            try
            {
                Data.GrpcTable table = await GrpcClient.GetTableAsync(EnvironmentSetting.GrpcChannel, (int)ETableActionType.RoomTypeList, string.Empty);                
                return table.ToDataTable();
            }
            catch (Exception ex)
            {
                OperationLog.Instance.WriteLog($"GetRoomTypeList:{ex.Message}");
                return null;
            }
        }
 
        public static async Task<DataTable> GetSalesLoginList()
        {
            try
            {
                Data.GrpcTable table = await GrpcClient.GetTableAsync(EnvironmentSetting.GrpcChannel, (int)ETableActionType.SalesLoginList, string.Empty);
                return table.ToDataTable();
            }
            catch (Exception ex)
            {
                OperationLog.Instance.WriteLog($"GetSalesLoginList:{ex.Message}");
                return null;
            }
        }
 
        /// <summary>
        /// 科目マスタの情報を取得する
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static async Task<Item> GetItem(string id)
        {
            try
            {
                using ItemAccess access = new DataAccessGrpc.Client.ItemAccess(EnvironmentSetting.GrpcChannel);
                return await access.GetItemAsync(id);
            }
            catch (Exception ex)
            {
                OperationLog.Instance.WriteLog($"GetItem:{ex.Message}");
                return null;
            }
        }
 
        /// <summary>
        /// 部屋タイプ、人数の基本料金を取得する
        /// </summary>
        /// <param name="roomTypeID"></param>
        /// <param name="personCount"></param>
        /// <param name="useDate"></param>
        /// <returns></returns>
        public static async Task<Item> GetBaseItem(int roomTypeID, int personCount, string useDate)
        {
            try
            {
                using ItemAccess access = new DataAccessGrpc.Client.ItemAccess(EnvironmentSetting.GrpcChannel);
                return await access.GetBaseItem(roomTypeID, personCount, useDate);
            }
            catch (Exception ex)
            {
                OperationLog.Instance.WriteLog($"GetBaseItem:{ex.Message}");
                return null;
            }
        }
    }
}