コード例 #1
0
        private static Dictionary <string, bool> CheckService(PartnerServiceParams param)
        {
            Dictionary <string, bool> serviceDict = null;

            if (DataCache.Partners != null && DataCache.Partners.Count > 0)
            {
                serviceDict = new Dictionary <string, bool>(DataCache.Partners.Count);
                //并行检查活动
                Parallel.ForEach(DataCache.Partners, p => {
                    param.Obj       = p;
                    param.PartnerId = p.Id;
                    var service     = PartnerServiceFactory.CreatePayService(p.ServiceName);

                    if (service != null)
                    {
                        var result = service.IsCanJoin(param);
                        serviceDict.Add(p.Name, result);
                        //
                        if (result)
                        {
                            service.Join(param);
                        }
                    }
                    else
                    {
                        serviceDict.Add(p.Name, false);
                    }
                });
            }

            return(serviceDict);
        }
コード例 #2
0
        // PUT: api/PlayerReturn
        public async Task <bool> Put([FromBody] PartnerServiceParams req)
        {
            if (req == null || req.AreaId == 0 || string.IsNullOrEmpty(req.PlayerId) || string.IsNullOrEmpty(req.UserId))
            {
                return(false);
            }

            var result  = false;
            var service = PartnerServiceFactory.CreatePayService(serverName);

            if (service != null)
            {
                result = service.Join(req);
            }
            return(result);
        }