示例#1
0
 public void PushJsonMessage(PushService.PushJsonMessageRequest request, PushService.Targets targets, PushService.PushSetting setting)
 {
     ExceptionHelper.ThrowIfNull(request, "request");
     using (var provider = _PushServiceChannelProvider.NewChannelProvider())
     {
         provider.Channel.PushJsonMessage(new OAuth2ClientIdentity(), request, targets, setting);
     }
 }
示例#2
0
 public void SendVerifyCode(string mobile, ValidateType verifyType, long?uid, string signName, string ip, string from)
 {
     ExceptionHelper.ThrowIfNullOrWhiteSpace(mobile, "mobile", "手机号码不能为空");
     ExceptionHelper.ThrowIfTrue(!StringRule.VerifyMobile(mobile), "mobile", "手机号码格式错误");
     using (var service = _UserManagerService.NewChannelProvider())
     {
         service.Channel.SendCode(new OAuth2ClientIdentity(), mobile, verifyType, uid, signName, ip, from);
     }
 }
示例#3
0
        public ProjectSurvey GetProjectSurvey(long tgPid)
        {
            ExceptionHelper.ThrowIfNotId(tgPid, nameof(tgPid));
            var encryptPid = Tgnet.Security.NumberConfuse.Confuse(tgPid);

            using (var provider = _ProjectServiceProvider.NewChannelProvider())
            {
                return(provider.Channel.GetProjectSurvey(new Api.OAuth2ClientIdentity(), encryptPid));
            }
        }
示例#4
0
        public AccessTokenResult Register(string mobile, string code, string password, string ip, string from)
        {
            ExceptionHelper.ThrowIfNullOrWhiteSpace(from, "from", "注册来源不能为空");
            ExceptionHelper.ThrowIfTrue(!StringRule.VerifyPassword(password), "password", "密码格式错误");
            _MobileManager.Verify(code, mobile, ValidateType.登陆);
            var areaNo = "0001";
            var area   = _StaticResourceManager.GetIPArea(ip);

            if (area != null)
            {
                areaNo = area.area_no;
            }
            long uid;

            using (var service = _UserManagerServiceChannelProvider.NewChannelProvider())
            {
                uid = service.Channel.GetUidIfNonexistentRegister(new OAuth2ClientIdentity(), mobile, true, password, ip, from);
            }
            ExceptionHelper.ThrowIfTrue(uid <= 0, "uid", "创建用户失败");
            var securityPsw = string.Empty;

            using (var provider = _UserManagerServiceChannelProvider.NewChannelProvider())
            {
                var id = Tgnet.Security.NumberConfuse.Confuse(uid);
                securityPsw = provider.Channel.GetPassword(new OAuth2ClientIdentity(), id);
            }
            if (!_UserRepository.Entities.Any(p => p.uid == uid))
            {
                _UserRepository.Add(new FootUser()
                {
                    mobile     = mobile,
                    uid        = uid,
                    password   = securityPsw,
                    areaNo     = areaNo,
                    isInner    = false,
                    isLocked   = false,
                    loginCount = 1,
                    lastLogin  = DateTime.Now,


                    created      = DateTime.Now,
                    verifyImage  = String.Empty,
                    verifyStatus = VerifyStatus.None,
                    cover        = "",
                });
                _UserRepository.SaveChanges();
                //推送到图数据库
                var taskFactory = new TaskFactory();
                taskFactory.StartNew(() =>
                {
                    _PushManager.AddUser(uid, mobile, false);
                });
            }
            return(VerificationCodeLogin(mobile, code, ip));
        }
示例#5
0
 public Dictionary <long, ProjectService.SimpleProjectInfo> GetSimpleProjectInfoByPids(long[] pids)
 {
     if (pids.Length <= 0)
     {
         return(new Dictionary <long, ProjectService.SimpleProjectInfo>());
     }
     using (var provider = _ProjectService.NewChannelProvider())
     {
         var source = provider.Channel.GetSimpleProjectInfo(new Api.OAuth2ClientIdentity(), pids);
         return(source.GroupBy(p => p.pid).ToDictionary(p => p.Key, p => p.FirstOrDefault()));
     }
 }
示例#6
0
        public ProductResult GetProducts(long uid, Dictionary <string, string> extension)
        {
            var products = new string[]
            {
                PRODUCT_FOOTCHAT_SERVICE_6MONTH,
                PRODUCT_FOOTCHAT_SERVICE_12MONTH
            };
            var result = new ProductResult();

            using (var provider = _PayServiceChannelProvider.NewChannelProvider())
            {
                result.Products = provider.Channel.GetProducts(new OAuth2ClientIdentity(), products, null, extension);
            }
            return(result);
        }
示例#7
0
 public ProjectSource AddProject(string name, string areaNo, double?longitude, double?latitude, string address)
 {
     using (var provider = _YwqManagerService.NewChannelProvider())
     {
         return(provider.Channel.AddProject(new Api.OAuth2ClientIdentity(),
                                            name, areaNo, longitude, latitude, address));
     }
 }
示例#8
0
 public FootPrintModel[] GetFootPrints(DateTime start, DateTime end, int limit)
 {
     using (var provider = _ProjectMangerServiceProvider.NewChannelProvider())
     {
         return(provider.Channel.GetFootPrints(new Api.OAuth2ClientIdentity(), start, end, limit));
     }
 }
示例#9
0
 public UserSimpleInfo[] GetTgUserInfoByMobiles(IEnumerable <string> mobiles)
 {
     if (mobiles == null)
     {
         return(new Tgnet.FootChat.UserService.UserSimpleInfo[0]);
     }
     mobiles = mobiles.Where(m => StringRule.VerifyMobile(m)).ToArray();
     if (mobiles.Count() == 0)
     {
         return(new Tgnet.FootChat.UserService.UserSimpleInfo[0]);
     }
     using (var provider = _UserInfoServiceChannelProvider.NewChannelProvider())
     {
         return(provider.Channel.GetUsersSimpleInfoByMobiles(new OAuth2ClientIdentity(), mobiles.ToArray()));
     }
 }
示例#10
0
 public void Bind(string app, string openId, long tgUid)
 {
     using (var provider = _WeixinServiceProvider.NewChannelProvider())
     {
         var result = provider.Channel.AccountBindingAsync(new Api.OAuth2ClientIdentity(), app, openId, tgUid, null).Result;
     }
 }
示例#11
0
        public RoleDetail[] GetProjectRoleDetail(long tgPid, bool isPreview)
        {
            ExceptionHelper.ThrowIfNotId(tgPid, nameof(tgPid));
            var encryptPid = Tgnet.Security.NumberConfuse.Confuse(tgPid);

            using (var provider = _ProjectServiceProvider.NewChannelProvider())
            {
                return(provider.Channel.GetProjectRoleDetail(new Api.OAuth2ClientIdentity(), encryptPid, isPreview));
            }
        }
示例#12
0
        /// <summary>
        /// 管道提供者扩展方法
        /// </summary>
        /// <typeparam name="TChannel"></typeparam>
        /// <param name="provider"></param>
        /// <param name="executeAction">要执行的调用</param>
        public static void Execute <TChannel>(this IChannelProviderService <TChannel> provider, Action <TChannel> executeAction)
            where TChannel : class
        {
            ExceptionHelper.ThrowIfNull(provider, "provider");
            ExceptionHelper.ThrowIfNull(executeAction, "executeAction");

            using (var channelService = provider.NewChannelProvider())
            {
                executeAction(channelService.Channel);
            }
        }
示例#13
0
        /// <summary>
        /// 管道提供者扩展方法
        /// </summary>
        /// <typeparam name="TChannel"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <param name="provider"></param>
        /// <param name="executeFunc">要执行的调用</param>
        /// <returns></returns>
        public static T Execute <TChannel, T>(this IChannelProviderService <TChannel> provider, Func <TChannel, T> executeFunc)
            where TChannel : class
        {
            ExceptionHelper.ThrowIfNull(provider, "provider");
            ExceptionHelper.ThrowIfNull(executeFunc, "executeFunc");

            using (var channelService = provider.NewChannelProvider())
            {
                return(executeFunc(channelService.Channel));
            }
        }
示例#14
0
        public Dictionary <long, long> GetTpmPIdByTgPId(long[] tgpids)
        {
            tgpids = (tgpids ?? Enumerable.Empty <long>()).Where(id => id > 0).Distinct().ToArray();
            var result = new Dictionary <long, long>();

            if (tgpids.Length <= 0)
            {
                return(result);
            }
            using (var provider = _TpmService.NewChannelProvider())
            {
                result = provider.Channel.GetTpmPIdByTgPId(new Api.OAuth2ClientIdentity(), tgpids);
                return(result);
            }
        }
示例#15
0
 private void ClearToken(long uid)
 {
     try
     {
         ExceptionHelper.ThrowIfNotId(uid, "uid");
         using (var service = _VerifyServiceProvider.NewChannelProvider())
         {
             service.Channel.ClearToken(new Api.OAuth2ClientIdentity(), Api.IdentityType.FootChat, uid);
             Tgnet.Log.LoggerResolver.Current.Debug("clear Token");
         }
     }
     catch (System.Exception ex)
     {
         Tgnet.Log.LoggerResolver.Current.Error("清除token出错:", ex);
         Tgnet.Log.LoggerResolver.Current.Debug("清除token出错:", ex);
     }
 }
示例#16
0
        public ProjectSearchItem[] SearchSimilarProject(ProjectSearchArgs args, int pageIndex, int limit, out int recordCount, out int pageCount)
        {
            pageIndex = Math.Max(pageIndex, 1);
            if (limit <= 0)
            {
                limit = 30;
            }
            if (limit > 100)
            {
                limit = 100;
            }

            using (var provider = _SearchService.NewChannelProvider())
            {
                //var HIGHLIGHT_TAG = "span";
                var setting = new SearchService.SearchSetting();
                //setting.Summary = new SearchService.SearchSetting.SearchSummary { Length = 500, Element = HIGHLIGHT_TAG };
                setting.Summary = new SearchService.SearchSetting.SearchSummary {
                    Length = 500, Element = ""
                };

                var request = new SearchService.ProjectSearchRequest();
                request.Limit = limit;
                request.Start = (pageIndex - 1) * limit;
                if (!String.IsNullOrWhiteSpace(args.Name))
                {
                    request.Keyword = args.Name;
                }

                var result = provider.Channel.SearchProject(new Api.OAuth2ClientIdentity(), request, setting);
                recordCount = result.Count;
                pageCount   = (int)Math.Ceiling((float)recordCount / limit);
                return(result.Models.Select(d => new ProjectSearchItem
                {
                    //Name = (d.Name ?? String.Empty).Replace(HIGHLIGHT_TAG, HIGHLIGHT_TAG + " style='color:red'"),
                    Name = (d.Name ?? String.Empty).Replace("<em>", "").Replace("</em>", ""),
                    TgPid = d.Pid,
                    AreaNo = d.AreaNo,
                    Longitude = d.Longitude,
                    Latitude = d.Latitude,
                    Address = (d.Address ?? string.Empty).Replace("<em>", "").Replace("</em>", ""),
                }).ToArray());
            }
        }
示例#17
0
 public Dictionary <string, string> GetBaseClassNames(string[] classNos)
 {
     classNos = (classNos ?? Enumerable.Empty <string>()).Where(no => !String.IsNullOrWhiteSpace(no)).Distinct().ToArray();
     if (classNos.Count() == 0)
     {
         return(new Dictionary <string, string>());
     }
     using (var provider = _StaticResourceServiceProvider.NewChannelProvider())
     {
         var result = provider.Channel.GetBaseClassNamesAsync(new Tgnet.Api.OAuth2ClientIdentity(), classNos).Result;
         return(result ?? new Dictionary <string, string>());
     }
 }