ホテル管理システム
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
141
142
143
using Grpc.Net.Client;
using HotelPms.Data.Client;
using HotelPms.Data.Common;
using HotelPms.DataAccessGrpc.Client;
using HotelPms.Share.Util;
 
namespace HotelPms.Client.Blazor.Util
{
    public class EnvironmentSetting
    {
        /// <summary>
        /// どこでも取得できるように
        /// </summary>
        public static IServiceCollection ServiceCollection { get; set; }
 
        public static IServiceProvider ServiceProvider { get; set; }
 
        /// <summary>
        /// どこでも取得できるように
        /// </summary>
        public static GrpcChannel GrpcChannel { get; set; }
 
        /// <summary>
        /// 端末ID
        /// </summary>
        public static string ClientID = string.Empty;
 
        /// <summary>
        /// マスタ設定一覧の頁毎表示行設定
        /// </summary>
        public static int[] CountOfPage = new int[] { 5, 10, 50, 100, 999999 };
 
        /// <summary>
        /// マスタ設定一覧画面の操作列幅
        /// </summary>
        public const int MasterOpeColWidth = 250;
 
        /// <summary>
        /// マスタ設定一覧画面の操作列幅のCSS
        /// </summary>
        /// <returns></returns>
        public static string GetOpeColWidthCss()
        {
            return GetWidthCss(MasterOpeColWidth);
        }
 
        /// <summary>
        /// 幅CSSの取得
        /// </summary>
        /// <param name="width"></param>
        /// <returns></returns>
        public static string GetWidthCss(int width)
        {
            return $"width: {width}px;";
        }
 
        /// <summary>
        /// データ設定関係のUserName
        /// </summary>
        public static string UserName { get; set; } = "Web";
 
        /// <summary>
        /// バックグラウンドのイメージ
        /// </summary>
        public static string BackgroundImage { get; set; } = "/bg1.jpg";
 
        /// <summary>
        /// gRPCのroot URL
        /// </summary>
        public static string BackendUrl { get; set; } = string.Empty;
 
        /// <summary>
        /// gRPCのサブDir
        /// </summary>
        public static string SubDir { get; set; } = string.Empty;
 
        /// <summary>
        /// サイトのサブPath
        /// 例:「/pms/」後ろに「/」が必要
        /// index.htmlの<base Href>と一致するもの
        /// </summary>
        public static string SiteSubDir { get; set; } = string.Empty;
 
        public static bool IsDevelopment { get; set; } = false;
 
        /// <summary>
        /// appsettings.jsonを読む
        /// </summary>
        /// <param name="config"></param>
        public static void Init(IConfiguration config)
        {
            ClientID = Guid.NewGuid().ToString();
            BackendUrl = CConvert.ToString(config["BackendUrl"]);
            SubDir = CConvert.ToString(config["SubDir"]);
            SiteSubDir = CConvert.ToString(config["SiteSubDir"]);
            EnvironmentSetting.Debug($"ClientID={ClientID},BackendUrl={BackendUrl},SubDir={SubDir},SiteSubDir={SiteSubDir}");
        }
 
        /// <summary>
        /// ホテル日取得
        /// </summary>
        /// <param name="channel"></param>
        /// <returns></returns>
        public static async Task<DateTime> GetHotelDate()
        {
            using HotelAccess access = new DataAccessGrpc.Client.HotelAccess(GrpcChannel);
            return await access.GetHotelDate();
        }
 
        /// <summary>
        /// 採番
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static async Task<int> GetSeq(ESeqType type)
        {
            Data.GrpcTable table = await GrpcClient.GetTableAsync(GrpcChannel, (int)ETableActionType.Sequence, ((int)type).ToString());
            return CConvert.ToInt(table.GetValue(typeof(System.Int32)));
        }
 
        /// <summary>
        /// 消費税率の取得
        /// </summary>
        /// <param name="date">利用日</param>
        /// <param name="type">0.消費税 1.軽減税</param>
        /// <returns></returns>
        public static async Task<int> GetTaxRate(string date, int type)
        {
            Data.GrpcTable table = await GrpcClient.GetTableAsync(GrpcChannel, (int)ETableActionType.TaxRate, $"{date},{type}");
            return CConvert.ToInt(table.GetValue(typeof(System.Int32)));
        }
 
        /// <summary>
        /// システム全体ログON/OFF制御
        /// </summary>
        /// <param name="text"></param>
        public static void Debug(string text)
        {          
            if(!IsDevelopment) { return; }
            Console.WriteLine($"【{DateTime.Now.ToString("HH:mm:ss fff")}】{text}");
        }
    }
}