示例#1
0
        private Task MakeAppointment4User(UserModel userInfo)
        {
            var shopInfo = maskDataBase.GetShop(userInfo.ShopID).ConfigureAwait(false).GetAwaiter().GetResult();
            var parm     = new RequestParm()
            {
                pharmacyName    = shopInfo.serviceName,
                pharmcayId      = shopInfo.id,
                pharmacyAddress = shopInfo.serviceAddress,
                realName        = userInfo.Name.RSAEncrypt(),
                idcard          = userInfo.IDCard.RSAEncrypt(),
                mobile          = userInfo.Tel.RSAEncrypt()
            };
            var cts = new CancellationTokenSource();

            return(Task.Run(() =>
            {
                while (DatetimeUtils.GetChinaDatetimeNow().TimeOfDay < endTime)
                {
                    Enumerable.Range(1, threadNum).Select(p => new Task(() =>
                    {
                        if (serviceProvider.GetService <MaskWebClient>().MakeAppointment(parm, out var result))
                        {
                            cts.Cancel();
                        }
                        else
                        {
                        }
                    }, cts.Token));
                    Thread.Sleep(sleepTime);
                }
            }, cts.Token));
        }
示例#2
0
        public async Task <ResultModel> GetAppointmentResult(string id)
        {
            var user = await maskDataBase.GetUser(id);

            if (user == null)
            {
                return(null);
            }
            var shop = await maskDataBase.GetShop(user.ShopID);

            return(new ResultModel()
            {
                AppointmentCode = user.AppointmentCode,
                AppointmentDate = user.LastAppointmentDate,
                ShopAddress = shop.serviceAddress,
                ShopName = shop.serviceName
            });
        }