需求1. 将A服务器的sqlserver数据库item_mst表的数据同步到MySQL数据库Part表2. 监控Item_mst表中item,description,overview 的更改并同步到MySQL数据库 针对需求一,基本就是执行一次,单独写了个winform用来做这事针对需求二,写了个Windows service app
帮别人整得,挺简单的代码,用来学习Windows Service app 不错。
求点热心值,谢谢了!!!如有违规,删除即可。
Nuget安装
2.png (89.95 KB, 下载次数: 1)
2019-7-26 15:05 上传
Dapper就是个ormSerilog用来记logSQLTableDependency用来检测表的改动,文档地址:https://github.com/christiandelbianco/monitor-table-change-with-sqltabledependency使用这个别忘了执行 alter database [] set enable_broker with rollbackimmediate;1.创建service2.添加安装程序3.如何安装serviceCreate a Windows service apphttps://docs.microsoft.com/en-us/dotnet/framework/windows-services/walkthrough-creating-a-windows-service-application-in-the-component-designer How to: Add Installers to Your Service ApplicationHow to: Install and uninstallWindows services源码目录结构
1.png (41.25 KB, 下载次数: 0)
2019-7-26 15:06 上传
Models文件夹里的ItemMst.cs文件
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;
namespaceSyncItemMstAllService.Models
{//tablename: item_mst///note:We do not need to specify all table columns but just the ones we areinterested:///publicclassItemMst{// internalNumberpublicstringItem {get;set; }// namepublicstringDescription {get;set; }// descriptionpublicstringOverview {get;set; }}
}App.config
AllowUser