From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。
---
HotelPms.DataAccessGrpc.Client/RoomViewLayoutAccess.cs | 294 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 294 insertions(+), 0 deletions(-)
diff --git a/HotelPms.DataAccessGrpc.Client/RoomViewLayoutAccess.cs b/HotelPms.DataAccessGrpc.Client/RoomViewLayoutAccess.cs
new file mode 100644
index 0000000..beefcd1
--- /dev/null
+++ b/HotelPms.DataAccessGrpc.Client/RoomViewLayoutAccess.cs
@@ -0,0 +1,294 @@
+using Google.Protobuf;
+using Grpc.Core;
+using Grpc.Net.Client;
+using HotelPms.Data.Client;
+using HotelPms.Data.Common;
+using HotelPms.Data.Master;
+using HotelPms.Share.Util;
+using System;
+using System.Data;
+using System.Threading.Tasks;
+using HotelPms.Data;
+using System.Collections.Generic;
+using HotelPms.Data.Common.Pagination;
+using System.Text.Json;
+using System.Threading;
+
+namespace HotelPms.DataAccessGrpc.Client
+{
+ public class RoomViewLayoutAccess : IDisposable
+ {
+ /// <summary>
+ /// チャネル
+ /// </summary>
+ public GrpcChannel Channel { get; private set; } = null;
+ public RoomViewLayoutCore.RoomViewLayoutCoreClient Client { get; private set; } = null;
+
+
+ public RoomViewLayoutAccess(GrpcChannel channel)
+ {
+ Channel = channel;
+ Client = new RoomViewLayoutCore.RoomViewLayoutCoreClient(Channel);
+ }
+
+ public void Dispose()
+ {
+
+ }
+
+ public bool Exists(int pTabID,int pRow,int pCol)
+ {
+ return GrpcClient.ExecuteScalarSync(Channel, $"IF EXISTS(SELECT 1 FROM M_RoomViewLayout WHERE TabID = {pTabID} AND Row = {pRow} AND Col = {pCol}) SELECT 1 ELSE SELECT 0") == "1";
+
+ }
+
+ public async Task<bool> ExistsAsync(int pTabID,int pRow,int pCol)
+ {
+ return await GrpcClient.ExecuteScalar(Channel, $"IF EXISTS(SELECT 1 FROM M_RoomViewLayout WHERE TabID = {pTabID} AND Row = {pRow} AND Col = {pCol}) SELECT 1 ELSE SELECT 0") == "1";
+
+ }
+
+ public async Task<FileGrpcData> OutputStream(PagingRequest request)
+ {
+ FileGrpcData data = null;
+ request.Table = "M_RoomViewLayout";
+ string json = JsonSerializer.Serialize(request);
+ using (var call = Client.OutputStream(GrpcClient.CreateDataRequest(2, json)))
+ {
+ var reaponseStream = call.ResponseStream;
+ //データの取得
+ while (await reaponseStream.MoveNext(CancellationToken.None))
+ {
+ data = reaponseStream.Current;
+ }
+ }
+ return data;
+ }
+
+ public async Task<RoomViewLayoutTable> GetPageData(PagingRequest request)
+ {
+ request.Table = "M_RoomViewLayout";
+ string json = JsonSerializer.Serialize(request);
+ return await Client.GetDataAsync(GrpcClient.CreateDataRequest(1, json));
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="where"></param>
+ /// <returns></returns>
+ public DataTable GetMasterGridData(string where)
+ {
+ GrpcTable table = GrpcClient.GetTable(Channel, (int)ETableActionType.RoomViewLayoutGrid, where);
+ return table.ToDataTable();
+ }
+
+ public async Task<DataTable> GetRoomState(string where)
+ {
+ GrpcTable table = await GrpcClient.GetTableAsync(Channel, (int)ETableActionType.RoomViewState, where);
+ return table.ToDataTable();
+ }
+
+ /// <summary>
+ /// 客室状況画面の日別表示データ
+ /// </summary>
+ /// <param name="where"></param>
+ /// <returns></returns>
+ public async Task<DataSet> GetRoomViewData(string where)
+ {
+ GrpcSet set = await GrpcClient.GetGrpcSet(Channel, (int)ESetActionType.RoomView, where);
+ return set.ToDataSet();
+ }
+
+ /// <summary>
+ /// 同期データ取得
+ /// </summary>
+ /// <param name="where"></param>
+ /// <returns></returns>
+ public RoomViewLayoutTable GetData(string where)
+ {
+ return Client.GetData(GrpcClient.CreateDataRequest(0, where));
+ }
+
+ public async Task<RoomViewLayoutTable> GetDataAsync(string where)
+ {
+ return await Client.GetDataAsync(GrpcClient.CreateDataRequest(0, where));
+ }
+
+ /// <summary>
+ /// データ取得
+ /// </summary>
+ /// <returns></returns>
+ public RoomViewLayout GetItem(int pTabID,int pRow,int pCol)
+ {
+ RoomViewLayoutTable table = GetData($"TabID = {pTabID} AND Row = {pRow} AND Col = {pCol}");
+ if(table == null || table.ErrNo != 0 || table.Rows.Count == 0) { return null; }
+ return table.Rows[0];
+ }
+
+ public async Task<RoomViewLayoutTable> GetDataStream()
+ {
+ return await GetDataStream(string.Empty);
+ }
+
+ /// <summary>
+ /// データ取得
+ /// </summary>
+ /// <returns></returns>
+ public async Task<RoomViewLayoutTable> GetDataStream(string where)
+ {
+ RoomViewLayoutTable table = null;
+ using (var call = Client.GetDataStream())
+ {
+ await call.RequestStream.WriteAsync(GrpcClient.CreateDataRequest(0, where));
+ await call.RequestStream.CompleteAsync(); // Finish call and report results
+
+ //データの取得
+ await foreach (var message in call.ResponseStream.ReadAllAsync<RoomViewLayoutTable>())
+ {
+ table = message;
+ break;
+ }
+ }
+ return table;
+ }
+
+ public async Task<DataResult> AddAsync(RoomViewLayout data)
+ {
+ return await Client.AddAsync(data);
+ }
+
+ public DataResult Add(RoomViewLayout data)
+ {
+ return Client.Add(data);
+ }
+
+ public async Task<DataResult> UpdateAsync(RoomViewLayout data)
+ {
+ return await Client.UpdateAsync(data);
+ }
+
+ public DataResult Update(RoomViewLayout data)
+ {
+ return Client.Update(data);
+ }
+
+ /// <summary>
+ /// 追加若しくは更新
+ /// </summary>
+ /// <param name="data"></param>
+ /// <param name="add"></param>
+ /// <returns></returns>
+ private async Task<DataResult?> AddOrUpdateStream(RoomViewLayout data, bool add)
+ {
+ DataResult? result = null;
+ using (var call = add ? Client.AddStream() : Client.UpdateStream())
+ {
+ await call.RequestStream.WriteAsync(data);
+ await call.RequestStream.CompleteAsync(); // Finish call and report results
+
+ //データの取得
+ await foreach (var message in call.ResponseStream.ReadAllAsync<DataResult?>())
+ {
+ result = message;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /// <summary>
+ /// 追加
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ public async Task<DataResult> AddStream(RoomViewLayout data)
+ {
+ return await AddOrUpdateStream(data, true);
+ }
+
+ /// <summary>
+ /// 更新
+ /// </summary>
+ /// <param name="data"></param>
+ /// <returns></returns>
+ public async Task<DataResult> UpdateStream(RoomViewLayout data)
+ {
+ return await AddOrUpdateStream(data, true);
+ }
+
+ public DataResult Remove(string where)
+ {
+ SqlWhere data = new SqlWhere()
+ {
+ Data = ByteString.CopyFromUtf8(where)
+ };
+ return Client.Remove(data);
+ }
+
+ public async Task<DataResult> RemoveAsync(string where)
+ {
+ SqlWhere data = new SqlWhere()
+ {
+ Data = ByteString.CopyFromUtf8(where)
+ };
+ return await Client.RemoveAsync(data);
+ }
+
+ /// <summary>
+ /// 削除
+ /// </summary>
+ /// <param name="where"></param>
+ /// <returns></returns>
+ public async Task<DataResult> RemoveStream(string where)
+ {
+ DataResult result = null;
+ SqlWhere data = new SqlWhere()
+ {
+ Data = ByteString.CopyFromUtf8(where)
+ };
+
+ using (var call = Client.RemoveStream())
+ {
+ await call.RequestStream.WriteAsync(data);
+ await call.RequestStream.CompleteAsync(); // Finish call and report results
+
+ //データの取得
+ await foreach (var message in call.ResponseStream.ReadAllAsync<DataResult>())
+ {
+ result = message;
+ break;
+ }
+ }
+ return result;
+ }
+
+ public DataResult SetData(RoomViewLayoutTable table)
+ {
+ return Client.SetData(table);
+ }
+
+ /// <summary>
+ /// バッチ更新
+ /// </summary>
+ /// <param name="table"></param>
+ /// <returns></returns>
+ public async Task<DataResult> SetDataStream(RoomViewLayoutTable table)
+ {
+ DataResult result = null;
+ using (var call = Client.SetDataStream())
+ {
+ await call.RequestStream.WriteAsync(table);
+ await call.RequestStream.CompleteAsync(); // Finish call and report results
+
+ //データの取得
+ await foreach (var message in call.ResponseStream.ReadAllAsync<DataResult>())
+ {
+ result = message;
+ break;
+ }
+ }
+ return result;
+ }
+ }
+}
--
Gitblit v1.10.0