ホテル管理システム
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
using Grpc.Net.Client;
using Grpc.Net.Client.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
 
namespace HotelPms.Data.Client
{
    public class GrpcFactory : IDisposable
    {
        public static string Url = "https://localhost:7240";      //托管
        //public static string Url = "https://localhost:5001";       //
        //public static string Url = "https://133.125.63.43:46492";  //Web ⇒OK
 
        private static GrpcFactory m_Default = null;
 
        public static GrpcFactory Instance
        {
            get
            {
                if (m_Default == null) { m_Default = new GrpcFactory(); }
                return m_Default;
            }
        }
 
 
 
        /// <summary>
        /// チャネル
        /// </summary>
        public GrpcChannel Channel { get; private set; } = null;
 
        /// <summary>
        /// GrpcTableの取得、更新用クライアント
        /// </summary>
        public GrpcTableCore.GrpcTableCoreClient TableCore { get; private set; } = null;
 
        /// <summary>
        /// GrpcSetの取得、更新用クライアント
        /// </summary>
        public GrpcSetCore.GrpcSetCoreClient SetCore { get; private set; } = null;
 
        #region 各テーブルのクラウド
 
        //public MenuCore.MenuCoreClient Menu { get; private set; } = null;
 
        #endregion
 
        public GrpcFactory()
        {
            var httpClientHandler = new HttpClientHandler();
            httpClientHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
            var httpClient = new HttpClient(new GrpcWebHandler(GrpcWebMode.GrpcWeb, httpClientHandler));
            //var httpClient = new HttpClient(httpClientHandler);
            GrpcChannelOptions options = new GrpcChannelOptions()
            {
                MaxReceiveMessageSize = int.MaxValue,
                HttpClient = httpClient
            };
            Channel = GrpcChannel.ForAddress(Url, options);
            TableCore = new GrpcTableCore.GrpcTableCoreClient(Channel);
            SetCore = new GrpcSetCore.GrpcSetCoreClient(Channel);
 
            #region 各テーブルのクラウド
 
            //Menu = new MenuCore.MenuCoreClient(Channel);
 
            #endregion
        }
 
        public void Dispose()
        {
            if (Channel != null) { Channel.Dispose(); }
        }
    }
}