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.Client.Blazor/Models/RoomStatusSetting.cs | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 150 insertions(+), 0 deletions(-)
diff --git a/HotelPms.Client.Blazor/Models/RoomStatusSetting.cs b/HotelPms.Client.Blazor/Models/RoomStatusSetting.cs
new file mode 100644
index 0000000..678361b
--- /dev/null
+++ b/HotelPms.Client.Blazor/Models/RoomStatusSetting.cs
@@ -0,0 +1,150 @@
+using Grpc.Net.Client;
+using HotelPms.Client.Blazor.Util;
+using HotelPms.Data.Common;
+using HotelPms.Data.Master;
+using HotelPms.DataAccessGrpc.Client;
+using HotelPms.Share.Data;
+using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
+using System.Data;
+
+namespace HotelPms.Client.Blazor.Models;
+
+/// <summary>
+/// M_RoomStatusを管理する
+/// SignalRより更新通知を届く予定
+/// Redis订阅
+/// </summary>
+public class RoomStatusSetting : IDisposable
+{
+ private static object syncObj = new object();
+ private static RoomStatusSetting m_Instance;
+ public static async Task<RoomStatusSetting> Instance()
+ {
+ bool isNew = false;
+ lock (syncObj)
+ {
+ if (m_Instance == null)
+ {
+ m_Instance = new RoomStatusSetting();
+ isNew = true;
+ }
+ }
+ if(isNew) { await m_Instance.GetData(); }
+ return m_Instance;
+
+ }
+
+ public void Dispose()
+ {
+
+ }
+
+ public RoomStatusSetting()
+ {
+ }
+
+ /// <summary>
+ /// SignalRより更新通知を届く予定
+ /// SortID順
+ /// </summary>
+ public List<RoomStatus> BufferStorage { get; set; } = new List<RoomStatus>();
+
+ /// <summary>
+ /// ID⇒BufferStorage.Index
+ /// </summary>
+ private Dictionary<int, int> m_IDMap = new Dictionary<int, int>();
+
+ /// <summary>
+ /// 空室のID
+ /// </summary>
+ public int Vacancy { get; set; } = 0;
+
+ /// <summary>
+ /// 清掃指示のID
+ /// </summary>
+ public int InstructClean { get; set; } = 0;
+
+ /// <summary>
+ /// 点検中のID
+ /// </summary>
+ public int MaidCheck { get; set; } = 0;
+
+ public void ClearBuffer()
+ {
+ BufferStorage.Clear();
+ m_IDMap.Clear();
+ }
+
+ public async Task GetData()
+ {
+ ClearBuffer();
+ using RoomStatusAccess access = new RoomStatusAccess(EnvironmentSetting.GrpcChannel);
+ var data = await access.GetDataAsync(string.Empty);
+ int i = 0;
+ foreach(RoomStatus item in data.Rows)
+ {
+ m_IDMap.Add(item.ID, i++);
+ BufferStorage.Add(item);
+ if (item.MaidType == (int)EMaidType.Vacancy) { Vacancy = item.ID; }
+ else if (item.MaidType == (int)EMaidType.Instruct) { InstructClean = item.ID; }
+ else if (item.MaidType == (int)EMaidType.Check) { MaidCheck = item.ID; }
+ EnvironmentSetting.Debug(item.ToText());
+ }
+ }
+
+ /// <summary>
+ /// 現在のIDより次のIDを取得する
+ /// </summary>
+ /// <param name="id"></param>
+ /// <returns></returns>
+ public RoomStatus Next(int id)
+ {
+ try
+ {
+ if (BufferStorage.Count == 0) { return null; }
+
+ int idx = m_IDMap[id];
+ if (idx == (BufferStorage.Count - 1))
+ {
+ return BufferStorage[0];
+ }
+ else
+ {
+ return BufferStorage[idx + 1];
+ }
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ /// <summary>
+ /// 現在IDより前のIDを取得する
+ /// </summary>
+ /// <param name=""></param>
+ /// <param name=""></param>
+ /// <returns></returns>
+ public RoomStatus Prev(int id)
+ {
+ try
+ {
+ if (BufferStorage.Count == 0) { return null; }
+
+ int idx = m_IDMap[id];
+ if (idx == 0)
+ {
+ return BufferStorage[BufferStorage.Count - 1];
+ }
+ else
+ {
+ return BufferStorage[idx - 1];
+ }
+ }
+ catch
+ {
+ return null;
+ }
+ }
+}
+
--
Gitblit v1.10.0