本文不再对宏观结构进行赘述,只从代码细节方面介绍几个关键的地方,帮助你快速了解代码的具体实现。
从Github上获取代码后,源代码目录结构如图所示:
解决方案说明:
Sheng.WeixinConstruction.Admin.sln
超级管理员、系统运维人员使用的超级管理后台。
此部分功能开发并未完成,目前只有基本框架和微主页模版的简单管理功能。
Sheng.WeixinConstruction.Container.sln
鉴权中控服务服务。
负责管理和维护第三方平台自己的AccessToken和对接过来的所有公众号的AccessToken。
Sheng.WeixinConstruction.FileService.sln
文件服务器。
可以部署多个不同的文件服务器实例,可以部署CDN内容分发。
Sheng.WeixinConstruction.sln
Sheng.WeixinConstruction.WindowsService.sln
Windows服务
主要用来执行一些定时服务。
下面主要对解决方案Sheng.WeixinConstruction.sln和Sheng.WeixinConstruction.Container.sln进行说明,其它几个解决方案都比较简单,不作赘述。
打开Sheng.WeixinConstruction.sln之后,结构如图:
Sheng.WeixinConstruction.Management.Shell
后台站点
Sheng.WeixinConstruction.Client.Shell
1)Sheng.WeixinConstruction.Management.Shell
打开Controllers目录下的SettingsController.cs,并展开“对接”region。
这里留意一个细节:
_createAuthorizerUrl是鉴权中控服务器的地址:
管理后台的其它功能同其它管理系统后台并无太大差别,可自行查阅代码。
2)Sheng.WeixinConstruction.Client.Shell
Handler接口用于接收公众号消息与事件推送。
推送消息过来时,URL如下格式:
signature=84001ea92e2f369642e861d557b9f4c6781db1ca
×tamp=1446393828
&nonce=1291578710
&encrypt_type=aes
&msg_signature=3ed4a96dbc50d491664ec3f425eb7fc1f088ac9b
在这个工厂类中,_receiverList保存了处理不同消息所需要的具体实现,这些消息接收器的实现,定义在Sheng.WeixinConstruction.Client.Core:
白名单IP地址列表填写你的服务器IP地址。
2)安装Redis
可以准备一台Linux服务器安装:
也可以下载Windows版本安装在Windows服务器:
3)站点部署说明
解决方案:Sheng.WeixinConstruction.sln
所对接过来的公众号所使用的站点。
IIS绑定参考:
类型
主机名
端口
IP地址
wxc.shengxunwei.com
80
*
注意,要添加一个不指定主机名的绑定,并使用80端口,与泛解析对应。
WebConfig的配置:
connectionStrings节点下:
DefaultConnection配置主数据库WxConstruction的连接串,LoggingConnection配置日志库WxLogging的连接串。
appSettings节点下:
Sheng.WeixinConstruction.Container
鉴权中控服务
解决方案:Sheng.WeixinConstruction.Container.sln
8013
wxauth.你的域名
Redis:Redis服务的地址和端口号。
AllowedIPList:IP地址白名单,逗号分隔,只有从这些IP地址发起的请求,才被允许访问中控服务器的全部接口。
Management.Shell
管理端
wxcm.shengxunwei.com
debug:false,正常运行发布模式,如果设置为true,则开始调试模式。
emailPassword:发邮件功能中邮件服务器的密码。
FileService
文件服务器
解决方案:Sheng.WeixinConstruction.FileService.sln
wxcfile1.shengxunwei.com
DefaultConnection配置主数据库WxConstruction的连接串,LoggingConnection配置日志库WxLogging的连接串,FileConnection配置文件数据库WxConstruction_File的连接串。
ServerPath:部署的实际物理路径地址,如:D:\wwwroot\WeixinConstruction\FileService\
文件服务的MIME类型需要添加:
.mp4-video/mpeg4
至此,代码结构和安装部署说明结束,如有其它疑问,可以与我联系留言。