频道规则

         string channelT = $"owner-{pf.OwnerId}-{beforeKey}-{pf.ModuleKey}";

PFGlobalParameter


 var pf = new PFGlobalParameter
            {
                TenantId = RequestPFUtil.GetFromTenantIdByHeader(this.HttpContext),
                ChannelRule = RequestPFUtil.GetFromChannelRuleByHeader(this.HttpContext),
                ChannelReceiver = RequestPFUtil.GetFromChannelReceiverByHeader(this.HttpContext),
                UserId = _authProvider.GetCurrentUserId()?.ToString(),
                AppId = RequestPFUtil.GetFromAppIdByHeader(this.HttpContext),
                OwnerId = RequestPFUtil.GetOwnerId(this.HttpContext),
                SysId = RequestPFUtil.GetSysId(this.HttpContext),
                ModuleKey = mkey,
                ReponseField = resField,
                FromTraceId="FromTraceId",
                FromTraceId =pf.FromTraceId
            };

 string beforeKey = pf.SubBeforeKey ?? "mkey";
            SubResult result = new SubResult
            {
                TenantId = pf.TenantId,
                ChannelRule = pf.ChannelRule,
                ChannelReceiver = pf.ChannelReceiver,
                SysId = pf.SysId,
                AppId = pf.AppId,
                OwnerId = pf.OwnerId,
                UserId = pf.UserId,
                SubBeforeKey = beforeKey,
                FromTraceId = pf.FromTraceId,
                LastDate = DateTimeUtil.Now(),
                ModuleKey = pf.ModuleKey,
                ReponseField = pf.ReponseField
            };

  SubResult result = new SubResult
            {
                LastDate = DateTimeUtil.Now(),
                OwnerId = pf.OwnerId,
                SysId = pf.SysId,
                ModuleKey = pf.ModuleKey,
                ReponseField = pf.ReponseField,
                TenantId = pf.TenantId,
                ChannelRule = pf.ChannelRule,
                ChannelReceiver = pf.ChannelReceiver,
                AppId = pf.AppId,
                UserId = pf.UserId,
                SubBeforeKey = pf.SubBeforeKey ?? "bridge",
                FromTraceId = pf.FromTraceId,
            };

  var pf = new PFGlobalParameter
            {
                TenantId = RequestPFUtil.GetFromTenantIdByHeader(this.HttpContext),
                ChannelRule = RequestPFUtil.GetFromChannelRuleByHeader(this.HttpContext),
                ChannelReceiver = RequestPFUtil.GetFromChannelReceiverByHeader(this.HttpContext),
                UserId = _authProvider.GetCurrentUserId()?.ToString(),
                AppId = RequestPFUtil.GetFromAppIdByHeader(this.HttpContext),
                OwnerId = RequestPFUtil.GetOwnerId(this.HttpContext),
                SysId = RequestPFUtil.GetSysId(this.HttpContext),
                ModuleKey = mkey,
                ReponseField = resField,
                MenuId = _menuId,
                FromTraceId= "BridgeController$Pro.cs",
            };
            Dictionary<string, object> dictionaryUrl = RequestPFUtil.ConvertHTByReqFormOrParamsD(this.HttpContext);
            await _isubPush.SubInit<SubResult>(new SubResult { }, new PFGlobalParameter
            {
                TenantId = pf.TenantId,
                ChannelRule = pf.ChannelRule,
                ChannelReceiver = pf.ChannelReceiver,
                SysId = pf.SysId,
                AppId = pf.AppId,
                OwnerId = pf.OwnerId,
                ModuleKey = mkey,
                UserId = pf.UserId,
                SubBeforeKey = "bridge",
                FromTraceId=pf.FromTraceId
            }); ;
            await _isubPush.SubInit<SubResult>(new SubResult { }, new PFGlobalParameter
            {
                TenantId = pf.TenantId,
                ChannelRule = pf.ChannelRule,
                ChannelReceiver = pf.ChannelReceiver,
                SysId = pf.SysId,
                AppId = pf.AppId,
                OwnerId = pf.OwnerId,
                ModuleKey = mkey,
                UserId = pf.UserId,
                SubBeforeKey = "mapper",
                FromTraceId = pf.FromTraceId
            });

Nginx头参数看 _有 X 替换


location /ws/api/v3/ {
                proxy_pass {{_owner_nginx_ws_api}};
                proxy_set_header Host $host;
                proxy_set_header XfromAppId $http_XfromAppId;
                proxy_set_header XownerId $http_XownerId;
                proxy_set_header XsysId $http_XsysId;
                proxy_set_header XuserId $http_XuserId;
                proxy_set_header XverifyApi $http_XverifyApi;
                proxy_set_header Authorization $http_Authorization;
                proxy_set_header XfilterAreaCode $http_XfilterAreaCode;
                proxy_set_header XuserFromFirstShareId $http_XuserFromFirstShareId;
                proxy_set_header XuserFromSecondShareId $http_XuserFromSecondShareId;
                # websoket频道和规则
                proxy_set_header XchannelRule $http_XchannelRule;
                proxy_set_header XchannelReceiver $http_XchannelReceiver;
                proxy_set_header XfromTenantId $http_XfromTenantId;
                proxy_set_header XfromAppId $http_XfromAppId;
                #proxy_set_header XuserLat $http_XuserLat;
                #proxy_set_header XuserLng $http_XuserLng;
                #proxy_set_header XuserAreaCode $http_XuserAreaCode;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                # 转发websocket需要的设置
                 proxy_connect_timeout 4s;                #配置点1
                proxy_read_timeout 60s;                  #配置点2,如果没效,可以考虑这个时间配置长一点
                proxy_send_timeout 12s;                  #配置点3
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
        }

SystemParamConst.cs

C:\0_RG\Code\RG6.PF\rg3-pf\RG3.PF.Abstractions\Consts\SystemParamConst.cs

  /// <summary>
        ///  //当前经度  GC102  _userLng
        /// </summary>
        public const string USER_LNG = "_userLng";

        /// <summary>
        ///  当前纬度  GC102  _userLat
        /// </summary>
        public const string USER_LAT = "_userLat";

        /// <summary>
        ///  当前 行政编码
        /// </summary>
        public const string USER_AREA_CODE = "_userAreaCode";

        /// <summary>
        ///  来源应用 
        /// </summary>
        public const string FROM_APP_ID = "_fromAppId";

        /// <summary>
        ///  多租户ID 
        /// </summary>
        public const string FROM_TENANT_ID = "_fromTenantId";

        /// <summary>
        /// websoket频道接收者
        /// </summary>
        public const string WS_CHANNEL_RECEIVER = "_channelReceiver";

        /// <summary>
        /// websoket频道规则
        /// </summary>
        public const string WS_CHANNEL_RULE = "_channelRule";


        /// <summary>
        ///  项目
        /// </summary>
        public const string OWNER_ID = "_ownerId";

        /// <summary>
        ///  项目 URL 传递
        /// </summary>
        public const string PARAM_OWNER_ID = "ownerId";

        /// <summary>
        ///  头前缀
        /// </summary>
        public const string HEADER_BEFORE_SUFFIX = "X";

        /// <summary>
        /// 来至用户分享的id
        /// </summary>
        public const string USER_FROM_FIRST_SHARE_ID = "_userFromFirstShareId";
        /// <summary>
        /// 来至用户分享的二级ID
        /// </summary>
        public const string USER_FROM_SECOND_SHARE_ID = "_userFromSecondShareId";

        /// <summary>
        /// 特定api验证
        /// </summary>
        public const string API_VERIFY_SOURCE = "_verifySource";

RequestPFUtil.cs

E:\0_RG\Code\RG6.PF\rg3-pf\RG3.PF.Utilities\RequestPFUtil.cs


        /// <summary>
        /// 获取所有着信息
        /// </summary>
        /// <param name="httpContext">query:_ownerId, header:_ownerId或者 XownerId</param>
        /// <returns></returns>
        public static string GetOwnerId(HttpContext httpContext)



        /// <summary>
        /// 来源应用ID  如果等于0 表示没有传递或返回
        /// </summary>
        /// <param name="httpContext"> header:_fromAppId或者 XfromAppId</param>
        /// <returns></returns>
        public static string GetFromAppIdByHeader(HttpContext httpContext)

        /// <summary>
        /// 来源租户ID  如果等于0 表示没有传递或返回
        /// </summary>
        /// <param name="httpContext"> header:_fromTenantId或者 XfromTenantId</param>
        /// <returns></returns>
        public static string GetFromTenantIdByHeader(HttpContext httpContext)

        /// <summary>
        /// 一级分享ID  如果等于0 表示没有传递或返回
        /// </summary>
        /// <param name="httpContext"> header:_fromTenantId或者 XfromTenantId</param>
        /// <returns></returns>
        public static string GetFromFirstShareIdByHeader(HttpContext httpContext)

        /// <summary>
        /// 二级分享ID  如果等于0 表示没有传递或返回
        /// </summary>
        /// <param name="httpContext"> header:_fromTenantId或者 XfromTenantId</param>
        /// <returns></returns>
        public static string GetFromSecondShareIdByHeader(HttpContext httpContext)


        /// <summary>
        /// 频道接收者  如果等于0 表示没有传递或返回
        /// </summary>
        /// <param name="httpContext"> header:_channelReceiver 或者 XchannelReceiver</param>
        /// <returns></returns>
        public static string GetFromChannelReceiverByHeader(HttpContext httpContext)
        /// <summary>
        /// 频道接收者 规则控制  如果等于0 表示没有传递或返回
        /// </summary>
        /// <param name="httpContext"> header:_channelReceiver 或者 XchannelReceiver</param>
        /// <returns></returns>
        public static string GetFromChannelRuleByHeader(HttpContext httpContext)
文档更新时间: 2023-05-28 19:07   作者:admin