示例#1
0
        /// <summary>
        /// 检查是否有全部权限
        /// </summary>
        /// <returns></returns>
        public bool LookAll(AuthorizeUserTypeEnum authorizeUserType,
                            SystemTypeEnum systemType,
                            string loginKey = null)
        {
            object        _obj      = null;
            StringBuilder sqlString = new StringBuilder();

            if (systemType == SystemTypeEnum.WebSystem && OperatorProvider.Provider.Current().IsSystem)
            {
                _obj = true;
            }
            else
            {
                if (authorizeUserType == AuthorizeUserTypeEnum.UserID && string.IsNullOrEmpty(loginKey))
                {
                    loginKey = SystemInfo.CurrentUserId;
                }
                var parameter = new List <DbParameter>();
                sqlString.AppendLine(@"
                                    SELECT * from view_post_user 
                                    where 1=1");
                sqlString.AppendLine(authorizeUserType == AuthorizeUserTypeEnum.UserID ?
                                     string.Format(" and UserId='{0}' and AuthorizationMethod={1}", loginKey, (int)AuthorizationMethodEnum.AllPorject) :
                                     string.Format(" and Account='{0}' and AuthorizationMethod={1}", loginKey, (int)AuthorizationMethodEnum.AllPorject));
                _obj = this.BaseRepository().FindEntity(sqlString.ToString(), parameter.ToArray());
            }
            return(_obj == null ? false : true);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strSql"></param>
        /// <param name="dbParameter"></param>
        /// <param name="authorizeUserType">授权验证的方式</param>
        /// <param name="systemType">请求系统类型</param>
        /// <param name="loginKey">用户ID 或者 登录名</param>
        /// <returns></returns>
        public IEnumerable <T> FindList(string strSql, DbParameter[] dbParameter,
                                        AuthorizeUserTypeEnum authorizeUserType,
                                        SystemTypeEnum systemType,
                                        string loginKey = null, Pagination pagination = null, string authorizeKeyName = "projectid")
        {
            StringBuilder sqlString = new StringBuilder();

            if (systemType == SystemTypeEnum.WebSystem && OperatorProvider.Provider.Current().IsSystem)
            {
                sqlString.Append(strSql);
            }
            else
            {
                if (!LookAll(authorizeUserType, systemType, loginKey))
                {
                    if (authorizeUserType == AuthorizeUserTypeEnum.UserID && string.IsNullOrEmpty(loginKey))
                    {
                        loginKey = SystemInfo.CurrentUserId;
                    }
                    sqlString.AppendLine(string.Format(@"select *from ({0}) pinfo
                                    inner join 
                                    (
                                    SELECT ItemId,UserId FROM view_post_project 
                                    where 1=1 ", strSql));
                    sqlString.AppendLine(authorizeUserType == AuthorizeUserTypeEnum.UserID ?
                                         string.Format(" and UserId='{0}'", loginKey) : string.Format(" and Account='{0}'", loginKey));
                    sqlString.AppendLine(@" ) as post_project
                                    on pinfo." + authorizeKeyName + "= post_project.ItemId");
                }
                else
                {
                    sqlString.Append(strSql);
                }
            }

            return(pagination == null?this.BaseRepository().FindList(sqlString.ToString(), dbParameter)
                       : this.BaseRepository().FindList(sqlString.ToString(), dbParameter, pagination));
        }
示例#3
0
        /// <summary>
        /// 将消息推送给推送平台
        /// </summary>
        /// <param name="list"></param>
        /// <param name="channel"></param>
        /// <param name="requestTime"></param>
        /// <returns></returns>
        public SenderRet SendPushMsgListToProvider(List <SendProcessDto> processList, SystemTypeEnum systemType, ChannelDto channelDto, out int requestTime)
        {
            string    retMsg    = string.Empty;
            SenderRet senderRet = new SenderRet {
                IsSuccess = true
            };

            requestTime = 0;
            if (processList == null || processList.Count == 0)
            {
                senderRet.IsSuccess = false;
                senderRet.Msg       = "SendProcessDtoList为空";
                return(senderRet);
            }
            int           appId = processList.First().AppId;
            AppChannelDto appChannelDto;

            if (!_channelLogic.CheckAppChannel(appId, (int)systemType, channelDto.Id, out appChannelDto, out retMsg))
            {
                senderRet.IsSuccess = false;
                senderRet.Msg       = retMsg;
                return(senderRet);
            }
            //推送第三方平台  友盟只能单推,小米可以批量推,个推也能批量推送
            ISender sender = PushSenderManager.GetSender(channelDto.Id);

            if (sender == null)
            {
                senderRet.IsSuccess = false;
                senderRet.Msg       = string.Format("ChannelId:{0},推送信息供应商不存在", channelDto.Id);
                return(senderRet);
            }
            PushChannelModel pushChannelModel = new PushChannelModel
            {
                ChannelName    = channelDto.ChannelName,
                Url            = channelDto.MultiUrl,
                AppKey         = appChannelDto.AppKey,
                AppSecret      = appChannelDto.AppSecret,
                ProductionMode = Convert.ToBoolean(_configLogic.GetConfigValue(ConfigKey.ProductionMode)),
                SystemType     = systemType,
                PushNum        = channelDto.PushNum ?? 50,
                TimeOut        = channelDto.PushTimeOut
            };
            List <PushMsgModel> pushMsgModelList = processList.Select(e =>
            {
                return(new PushMsgModel
                {
                    Id = e.Id,
                    Ticker = e.Title,
                    Title = e.Title,
                    Msg = e.Msg,
                    AttachInfo = e.AttachInfo,
                    DeviceToken = e.DeviceToken,
                    SystemType = systemType
                });
            }).ToList();
            var       isRealPushMsg = _configLogic.GetConfigValue(ConfigKey.IsRealPushMsg);
            Stopwatch sw            = new Stopwatch();

            sw.Start();
            if (isRealPushMsg != null && Convert.ToBoolean(isRealPushMsg))
            {
                senderRet = sender.SendList(pushChannelModel, pushMsgModelList);
            }
            else
            {
                Thread.Sleep(2000);
                senderRet = new SenderRet {
                    IsSuccess = true, Sign = Guid.NewGuid().ToString()
                };
            }
            sw.Stop();
            requestTime = (int)sw.ElapsedMilliseconds;
            return(senderRet);
        }