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 { /// /// マスタ名称取得 /// /// 「M_」なし /// /// public static async Task 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 GetSaleLoginName(int id) { Data.GrpcTable table = await GrpcClient.GetTableAsync(EnvironmentSetting.GrpcChannel, (int)ETableActionType.SalesLoginName, $"{id}"); return CConvert.ToString(table.GetValue(typeof(string))); } /// /// 部屋タイプ名称 /// /// /// public static async Task 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; } /// /// 部屋タイプ基本情報の取得 /// /// /// public static async Task 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; } } /// /// 選択一覧用部屋タイプマスタを取得する /// /// public static async Task 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 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; } } /// /// 科目マスタの情報を取得する /// /// /// public static async Task 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; } } /// /// 部屋タイプ、人数の基本料金を取得する /// /// /// /// /// public static async Task 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; } } } }