Commit c946e129 authored by 朱天博's avatar 朱天博

1.app模块访问监控

parent 65c60631
No preview for this file type
No preview for this file type
......@@ -30,4 +30,10 @@
<UserId>sa</UserId>
<Pwd>sa</Pwd>
</links>
<links>
<Link>59.58.142.170,1800</Link>
<DbName>FTT</DbName>
<UserId>sa</UserId>
<Pwd>a*1</Pwd>
</links>
</DocumentElement>
\ No newline at end of file
......@@ -107,6 +107,12 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UI\wMonitorVisit.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UI\wMonitorVisit.Designer.cs">
<DependentUpon>wMonitorVisit.cs</DependentUpon>
</Compile>
<Compile Include="UI\wSysChecker.cs">
<SubType>Form</SubType>
</Compile>
......@@ -148,6 +154,9 @@
<EmbeddedResource Include="UI\wDBTools.resx">
<DependentUpon>wDBTools.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\wMonitorVisit.resx">
<DependentUpon>wMonitorVisit.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UI\wSysChecker.resx">
<DependentUpon>wSysChecker.cs</DependentUpon>
</EmbeddedResource>
......
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
//
using Tools.MyCommon;
using Tools.MyData;
using Tools.MyUtils;
namespace Tools.UI
{
public partial class wMonitorVisit : wBasic
{
SmpDB _db = new SmpDB();
string _link = "";
public wMonitorVisit()
{
InitializeComponent();
}
private void wMonitorVisit_Load(object sender, EventArgs e)
{
dtpBeginDate.Value = DateTime.Now.AddMonths(-1);
rdbSelectedByNull.Checked = true;
}
private void tsbDB_Click(object sender, EventArgs e)
{
//数据库
var frm = new wDbSetting();
if (frm.ShowDialog() == DialogResult.OK)
{
this.SetDbLink(frm.LinkModel);
cmbModelList.ValueMember = "ID";
cmbModelList.DisplayMember = "Name";
DataTable dataTable = this._db.GetDataTable(this._link, "SELECT ID,CAST(ID AS NVARCHAR(10)) +'-'+ Name AS name FROM [FTT].[dbo].App_SysBusinessModel ORDER BY ID", "模块列表");
DataRow dataRow = dataTable.NewRow();
dataRow["ID"] = 0;
dataRow["Name"] = "全部";
dataTable.Rows.Add(dataRow);
cmbModelList.DataSource = dataTable.AsEnumerable().OrderBy(G => G["ID"].ToString()).CopyToDataTable();
cmbModelList.SelectedIndex = 0;
}
}
/// <summary>
/// 设置数据库链接
/// </summary>
/// <param name="m"></param>
private void SetDbLink(DbItemModel m)
{
this._link = m.LinkString;
this.tstbLinkString.Text = m.ToString();
}
private void RefrashData()
{
if (cmbModelList.DataSource == null)
return;
string strDataSelected = "";
if (rdbSelectedByNull.Checked)
strDataSelected = "";
else if (rdbSelectedByDay.Checked)
strDataSelected = "CONVERT(NVARCHAR(10),a.CreateDate,120)";
else if (rdbSelectedByMonth.Checked)
strDataSelected = "CONVERT(NVARCHAR(7),a.CreateDate,120)";
else if (rdbSelectedByYear.Checked)
strDataSelected = "CONVERT(NVARCHAR(4),a.CreateDate,120)";
StringBuilder sb = new StringBuilder();
sb.AppendLine($@"
SELECT ModelCode,b.Name as ModelName,{(string.IsNullOrEmpty(strDataSelected) ? "''" : strDataSelected)} AS CreateDate,COUNT(*) AS Count FROM [App_Sys_ModelVisitLog] a
INNER JOIN dbo.App_SysBusinessModel b ON a.ModelCode=CAST(b.ID AS NVARCHAR(50)) ");
sb.AppendLine($@"WHERE a.CreateDate BETWEEN '{dtpBeginDate.Value.ToString("yyyy-MM-dd")}' AND '{dtpEndDate.Value.ToString("yyyy-MM-dd")}'");
sb.AppendLine($@" AND (b.ID={cmbModelList.SelectedValue} OR 0={cmbModelList.SelectedValue})");
sb.AppendLine($@" GROUP BY a.ModelCode{(string.IsNullOrEmpty(strDataSelected) ? "" : $",{strDataSelected}")},b.Name");
sb.AppendLine($@" ORDER BY a.ModelCode{(string.IsNullOrEmpty(strDataSelected) ? "" : $",{strDataSelected}")}");
dgvMessage.DataSource = this._db.GetDataTable(this._link, sb.ToString(), "结果列表");
}
private void cmbModelList_SelectedIndexChanged(object sender, EventArgs e)
{
RefrashData();
}
private void rdbSelected_CheckedChanged(object sender, EventArgs e)
{
RefrashData();
}
private void btnSelected_Click(object sender, EventArgs e)
{
RefrashData();
}
}
}
This diff is collapsed.
......@@ -22,6 +22,7 @@ namespace Tools
case "DbDevelopTool": result = new UI.wDBTools(); break;
case "DbAnlysis": result = new UI.wDbAnlysis(); break;
case "CheckConfig": result = new UI.wSysChecker(); break;
case "AppModelVisit": result = new UI.wMonitorVisit(); break;
default: break;
}
......
......@@ -35,6 +35,7 @@
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.btnDbAnlysis = new System.Windows.Forms.Button();
this.btnCheckConfig = new System.Windows.Forms.Button();
this.btnAppModelVisit = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnUpdateExecuter
......@@ -92,12 +93,24 @@
this.btnCheckConfig.Text = "系统检查配置工具";
this.btnCheckConfig.UseVisualStyleBackColor = false;
//
// btnAppModelVisit
//
this.btnAppModelVisit.BackColor = System.Drawing.SystemColors.Control;
this.btnAppModelVisit.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnAppModelVisit.Location = new System.Drawing.Point(58, 205);
this.btnAppModelVisit.Name = "btnAppModelVisit";
this.btnAppModelVisit.Size = new System.Drawing.Size(135, 25);
this.btnAppModelVisit.TabIndex = 4;
this.btnAppModelVisit.Text = "APP模块访问次数监控";
this.btnAppModelVisit.UseVisualStyleBackColor = false;
//
// wMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
this.ClientSize = new System.Drawing.Size(251, 272);
this.Controls.Add(this.btnAppModelVisit);
this.Controls.Add(this.btnCheckConfig);
this.Controls.Add(this.btnDbAnlysis);
this.Controls.Add(this.btnDbDevelopTool);
......@@ -118,5 +131,6 @@
private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.Button btnDbAnlysis;
private System.Windows.Forms.Button btnCheckConfig;
private System.Windows.Forms.Button btnAppModelVisit;
}
}
\ No newline at end of file
......@@ -30,6 +30,7 @@ namespace Tools
this.btnDbDevelopTool.Click += Button_Click;
this.btnDbAnlysis.Click += Button_Click;
this.btnCheckConfig.Click += Button_Click;
this.btnAppModelVisit.Click += Button_Click;
}
private void Button_Click(object sender, EventArgs e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment