Esempio n. 1
0
        public void OnPass(bool hasImageInvalid = false)
        {
            var task = new TaskFactory();
            var fid  = _FootPrintService.Fid;
            //推送到图数据库
            int scopeType = 20;
            //5.找到关键人,12.已签单,30.可推荐
            var bonusTagId = new long[] { 5, 12, 30 };

            if (_FootPrintTagRepository.Entities.Any(p => p.fid == fid && bonusTagId.Contains(p.tid)))
            {
                scopeType = 100;
            }
            var areaNo     = _FootPrintService.AreaNo;
            var areaLength = !string.IsNullOrWhiteSpace(areaNo) ? areaNo.Length : 0;
            var request    = new FCRMAPI.Request.PushFootPrintRequest()
            {
                Fid        = _FootPrintService.Fid,
                Pid        = _FootPrintService.Pid,
                ScopeType  = scopeType,
                Uid        = _FootPrintService.Uid,
                CountryNo  = areaLength >= 4 ? areaNo.Left(4) : "",
                ProvinceNo = areaLength >= 8 ? areaNo.Left(8) : "",
                CityNo     = areaLength >= 12 ? areaNo.Left(12) : "",
                AreaNo     = areaLength >= 16 ? areaNo.Left(16) : "",
                Created    = _FootPrintService.OrderUpdated
            };

            task.StartNew(() =>
            {
                _FCRMAPIPushManager.PublisSingleFootPrint(request, false);
            });

            //try
            //{
            //    var passNotifySevice = new PassFootPrintNotifyService(_FootPrintService, _FootPrintRepository, _FootPrintManager, _ProjSourceManager, _AddressBookMobileRepository, _UserServiceFactory, _NotifyServiceProxy, _MessageService, _PushManager, _UserManager);
            //    passNotifySevice.NotifyPublishUser();
            //    passNotifySevice.NotifyFollowSameProjUser();
            //    passNotifySevice.NotifyFriendsOnecAWeek();
            //    passNotifySevice.NotifyFriendsOnecInDay(_FootPrintService.Pid);
            //    if (hasImageInvalid)
            //        passNotifySevice.NotifyUserIfHasImgInvalid();
            //}
            //catch (System.Exception ex)
            //{
            //    Tgnet.Log.LoggerResolver.Current.Error("push Error ", ex);
            //    Tgnet.Log.LoggerResolver.Current.Debug("push Error ", ex.Message);
            //}
        }
        public bool PushFootPrintToNoqlDataBase(int start, int limit)
        {
            bool end    = false;
            var  source = _FootPrintRepository.Entities.Where(p => p.isEnable && p.state == FootPrintState.Pass);
            var  count  = source.Count();

            if (start + limit >= count)
            {
                end = true;
            }
            var footPrints = source.OrderBy(p => p.created).Select(p => new
            {
                Pid          = p.pid,
                Uid          = p.uid,
                Fid          = p.fid,
                AreaNo       = p.areaNo,
                OrderUpdated = p.orderUpdated
            }).Take(start, limit).ToArray();
            var fids       = footPrints.Select(p => p.Fid).ToArray();
            var bonusTagId = new long[] { 5, 12, 30 };
            var tagids     = _FootPrintTagRepository.Entities.Where(p => fids.Contains(p.fid) && bonusTagId.Contains(p.tid))
                             .GroupBy(p => p.fid).ToDictionary(p => p.Key, p => p.Any());

            foreach (var footPrint in footPrints.ToArray())
            {
                var request = new FCRMAPI.Request.PushFootPrintRequest()
                {
                    Pid = footPrint.Pid,
                    Fid = footPrint.Fid,
                    Uid = footPrint.Uid,
                };
                var areaNo     = footPrint.AreaNo;
                var areaLength = !string.IsNullOrWhiteSpace(areaNo) ? areaNo.Length : 0;
                request.CountryNo  = areaLength >= 4 ? areaNo.Left(4) : "";
                request.ProvinceNo = areaLength >= 8 ? areaNo.Left(8) : "";
                request.CityNo     = areaLength >= 12 ? areaNo.Left(12) : "";
                request.AreaNo     = areaLength >= 16 ? areaNo.Left(16) : "";
                request.ScopeType  = (tagids.ContainsKey(footPrint.Fid) ? tagids[footPrint.Fid] : false) ? 20 : 0;
                request.Created    = footPrint.OrderUpdated;
                _PushManager.PublisSingleFootPrint(request);
            }
            return(end);
        }