Esempio n. 1
0
        public static void Setup(string weixinfile, string p12file, bool deploy)
        {
            // load weixin parameters
            var wx = DataInputUtility.FileTo <JObj>(weixinfile);

            appid          = wx[nameof(appid)];
            appsecret      = wx[nameof(appsecret)];
            mchid          = wx[nameof(mchid)];
            noncestr       = wx[nameof(noncestr)];
            spbillcreateip = wx[nameof(spbillcreateip)];
            key            = wx[nameof(key)];

            // load and init client certificate
            var handler = new HttpClientHandler
            {
                ClientCertificateOptions = ClientCertificateOption.Manual
            };
            X509Certificate2 cert = new X509Certificate2(p12file, mchid, X509KeyStorageFlags.MachineKeySet);

            handler.ClientCertificates.Add(cert);
            WCPay = new Client(handler)
            {
                BaseAddress = new Uri("https://api.mch.weixin.qq.com")
            };

            // start the access token renewer thread
            if (deploy)
            {
                Renewer.Start();
            }
        }
Esempio n. 2
0
        public ShopService(ServiceContext sc) : base(sc)
        {
            Create <PubShopWork>("pub"); // public

            Create <MyUserWork>("my");   // personal

            Create <OprShopWork>("opr"); // shop operator

            Create <SprCityWork>("spr"); // local supervisor

            Create <AdmWork>("adm");     // administrator

            cities = DataInputUtility.FileToArray <City>(sc.GetFilePath("$cities.json"));

            int len = cities.Length;

            cityopt = new string[len];
            for (int i = 0; i < len; i++)
            {
                cityopt[i] = cities[i].name;
            }
        }