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}");
|
}
|
}
|
}
|