using AnfiniL.SqlServerTools.Data;
using SqlServerTools;
using SqlServerTools.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Text;namespace windowsApiAcitonSimulation.Help
{
public class DBProfiler
{
public static void StartSqlServerProfiler()
{
IProfiler profiler = ToolsFactory.Instance.CreateProfiler("192.168.0.83,9920", "sa", "zdsoft123", null);
profiler.Initialize(TraceOptions.FileRollover, DateTime.Now.ToString(".yyyy.MM.dd.HH.mm.ss"));
var TraceFieldArr = new TraceField[] {
TraceField.TextData,
TraceField.StartTime,
TraceField.Writes,
TraceField.Reads,
TraceField.ApplicationName
};
TraceEventProperties eventPropSql = new TraceEventProperties()
{
Event = TraceEvent.SQLBatchCompleted,
Fields = TraceFieldArr
};
TraceEventProperties eventPropSP = new TraceEventProperties()
{
Event = TraceEvent.RPCCompleted,
Fields = TraceFieldArr
};
profiler.AddTraceEvent(eventPropSql.Event, eventPropSql.Fields);
profiler.AddTraceEvent(eventPropSP.Event, eventPropSP.Fields);
var filter = new FilterProperties(
TraceField.ApplicationName,
(ComparisonOperator)Enum.Parse(typeof(ComparisonOperator), "Equal"),
"cszhidacysoft");
if (filter.CheckFilter())
{
profiler.AddTraceFilter(filter.Field, LogicalOperator.AND, filter.Operator, filter.TypedValue);
}
profiler.TraceEvent += profiler_TraceEvent;
profiler.Start();
}
private static void profiler_TraceEvent(object sender, TraceEventArgs e)
{
if (e.EventsTable.Rows.Count > 0)
{
foreach (DataRow row in e.EventsTable.Rows)
{
if (row["TextData"].ToString().IndexOf("insert into ba_consume(vcvipno,vcNo,vcCust_c,vcCust_n,iPeople,vcTable_c,vcTable_n,vcTimes,vcServer,dtTime,vcMemo,vcOper,dtOper,vcSaler,cType,bPrint,vcID)") > -1
||
row["TextData"].ToString().IndexOf("delete from ba_consume where") > -1
)
{
//此时通知用户开台列表有变动
string url = "http://localhost:62123/api/server/GetKTChange";
WebClient client = new WebClient();
//上传并接收数据
string result = client.DownloadString(url);
break;
}
//insert into ba_consume_d(zsr,jb,costprice,jstcmny,jsmc,isdz,szsj,jsbm,tcbm,tcsl,tcdj,tcpkid,ddlx,vcNo,vcCode,vcName,fNumber,fNumber_s,vcUnit,mPrice,mMoney,iAgio,vcMemo,vcChoose,vcClass,vcPrint,dtChoose,vcEnter,bPrint,addmoney)
if (row["TextData"].ToString().IndexOf("insert into ba_consume_d(zsr,jb,costprice,jstcmny,jsmc,isdz,szsj,jsbm,tcbm,tcsl,tcdj,tcpkid,ddlx,vcNo,vcCode,vcName,fNumber,fNumber_s,vcUnit,mPrice,mMoney,iAgio,vcMemo,vcChoose,vcClass,vcPrint,dtChoose,vcEnter,bPrint,addmoney)") > -1
||
row["TextData"].ToString().IndexOf("delete from ba_consume_d") > -1
)
{
//点菜操作
//此时通知用户点菜列表有变动
string url = "http://localhost:62123/api/server/GetDCChange";
WebClient client = new WebClient();
//上传并接收数据
string result = client.DownloadString(url);
break;
}
}
}
}
}
}
Sql Server数据库监听 c#代码
原创
©著作权归作者所有:来自51CTO博客作者心冰之海的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
sql server 数据库日志还原
角色是一个权限的集合,只要将用户加入到角色成员(给用户分配一个角色),就可以给这个用户分配这个角色所具有的全部权限。角色的出现极大的简化了权限的管理。
服务器角色 数据库角色 用户定义数据库角色 架构