Merge branch 'release/UpdateDeleteMode'
This commit is contained in:
+13
-2
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -12,6 +13,8 @@
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
@@ -32,10 +35,10 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
@@ -63,4 +66,12 @@
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
|
||||
</Project>
|
||||
@@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.2.0" targetFramework="net462" />
|
||||
<package id="EntityFramework.it" version="6.2.0" targetFramework="net462" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net462" />
|
||||
</packages>
|
||||
+1
-1
@@ -19,6 +19,6 @@
|
||||
</entityFramework>
|
||||
<connectionStrings>
|
||||
<!--<add name="ElmahModelEF" connectionString="data source=sql2016dev;initial catalog=Elmah;persist security info=True;user id=sa;password=keyhammer16;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />-->
|
||||
<add name="ElmahDbModel" connectionString="data source=SQL2016DEV;initial catalog=Elmah;persist security info=True;user id=sa;password=keyhammer16;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
|
||||
<add name="ElmahDbModel" connectionString="data source=SQL2016DEV;initial catalog=Elmah;persist security info=True;user id=sa;password=keyhammer16;MultipleActiveResultSets=True;App=EntityFramework" providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
</configuration>
|
||||
+15
-4
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -12,6 +13,8 @@
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -34,13 +37,13 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
<HintPath>..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
@@ -131,4 +134,12 @@
|
||||
<Content Include="Resources\SteamWare.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.props'))" />
|
||||
<Error Condition="!Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.4\build\EntityFramework.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />
|
||||
</Project>
|
||||
Generated
+20
-19
@@ -45,6 +45,8 @@
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.tsslNumRec = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.gboxFiltri = new System.Windows.Forms.GroupBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.txtMaxRow = new System.Windows.Forms.TextBox();
|
||||
this.btnDeleteSel = new System.Windows.Forms.Button();
|
||||
this.chkUsers = new System.Windows.Forms.CheckBox();
|
||||
this.chkStatus = new System.Windows.Forms.CheckBox();
|
||||
@@ -62,8 +64,6 @@
|
||||
this.currentConfigToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.txtMaxRow = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ErrorsDGV)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.bsErrors)).BeginInit();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
@@ -239,6 +239,24 @@
|
||||
this.gboxFiltri.TabStop = false;
|
||||
this.gboxFiltri.Text = "Filtri";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(813, 15);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(65, 13);
|
||||
this.label1.TabIndex = 19;
|
||||
this.label1.Text = "Max Record";
|
||||
//
|
||||
// txtMaxRow
|
||||
//
|
||||
this.txtMaxRow.Location = new System.Drawing.Point(816, 31);
|
||||
this.txtMaxRow.Name = "txtMaxRow";
|
||||
this.txtMaxRow.Size = new System.Drawing.Size(80, 20);
|
||||
this.txtMaxRow.TabIndex = 18;
|
||||
this.txtMaxRow.Text = "1000";
|
||||
this.txtMaxRow.TextChanged += new System.EventHandler(this.txtMaxRow_TextChanged);
|
||||
//
|
||||
// btnDeleteSel
|
||||
//
|
||||
this.btnDeleteSel.Location = new System.Drawing.Point(690, 31);
|
||||
@@ -411,23 +429,6 @@
|
||||
this.saveToolStripMenuItem.Text = "&Save";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||
//
|
||||
// txtMaxRow
|
||||
//
|
||||
this.txtMaxRow.Location = new System.Drawing.Point(816, 31);
|
||||
this.txtMaxRow.Name = "txtMaxRow";
|
||||
this.txtMaxRow.Size = new System.Drawing.Size(80, 20);
|
||||
this.txtMaxRow.TabIndex = 18;
|
||||
this.txtMaxRow.Text = "1000";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(813, 15);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(65, 13);
|
||||
this.label1.TabIndex = 19;
|
||||
this.label1.Text = "Max Record";
|
||||
//
|
||||
// LogAnalyzer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
||||
+401
-358
@@ -1,32 +1,406 @@
|
||||
using System;
|
||||
using AppData;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.Entity;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AppData;
|
||||
using Newtonsoft;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace ELMA
|
||||
{
|
||||
public partial class LogAnalyzer : Form
|
||||
{
|
||||
|
||||
#region setup
|
||||
|
||||
ElmahModel model = new ElmahModel();
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto conf setup
|
||||
/// Oggetto conf setup
|
||||
/// </summary>
|
||||
public eSetup activeSetup = new eSetup();
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public LogAnalyzer()
|
||||
{
|
||||
InitializeComponent();
|
||||
myInit();
|
||||
startTimers();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected string selApp
|
||||
{ get { return listApp.SelectedItem.ToString(); } }
|
||||
protected string selHost
|
||||
{ get { return listHost.SelectedItem.ToString(); } }
|
||||
|
||||
protected string selStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (chkStatus.Checked)
|
||||
{
|
||||
if (listStatus.SelectedItem != null)
|
||||
{
|
||||
answ = listStatus.SelectedItem.ToString();
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
protected string selType
|
||||
{ get { return listType.SelectedItem.ToString(); } }
|
||||
protected string selUser
|
||||
{ get { return listUsers.SelectedItem.ToString(); } }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Calcola path applicazione partendo da bassePath
|
||||
/// </summary>
|
||||
/// <param name="application"></param>
|
||||
/// <returns></returns>
|
||||
protected string getAppPath(string application)
|
||||
{
|
||||
return application.Replace(activeSetup.appBasePath, "");
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private ElmahModel model = new ElmahModel();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elimino record selezionati
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnDeleteSel_Click(object sender, EventArgs e)
|
||||
{
|
||||
deleteSelRows().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private void checkFilterVisibility()
|
||||
{
|
||||
// Verifico TUTTI i filtri
|
||||
listApp.Enabled = chkApp.Checked && listApp.Items.Count > 0;
|
||||
listHost.Enabled = chkHost.Checked && listHost.Items.Count > 0;
|
||||
listStatus.Enabled = chkStatus.Checked && listStatus.Items.Count > 0;
|
||||
listType.Enabled = chkType.Checked && listType.Items.Count > 0;
|
||||
listUsers.Enabled = chkUsers.Checked && listUsers.Items.Count > 0;
|
||||
}
|
||||
|
||||
private void chkApp_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void chkHost_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void chkStatus_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void chkType_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void chkUsers_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void currentConfigToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ConfigMan currConfig = new ConfigMan();
|
||||
currConfig.currSetup = activeSetup;
|
||||
currConfig.Owner = this;
|
||||
currConfig.doUpdate();
|
||||
currConfig.Show();
|
||||
}
|
||||
|
||||
private void deleteRecordFiltered()
|
||||
{
|
||||
// elimino 1:1 da selezione
|
||||
foreach (var item in getFiltData())
|
||||
{
|
||||
model.ELMAH_Error.Remove(item);
|
||||
}
|
||||
|
||||
// salvo
|
||||
model.SaveChangesAsync();
|
||||
// aggiorno!!
|
||||
setupFilterData();
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private async Task deleteSelRows()
|
||||
{
|
||||
List<string> selIdx = new List<string>();
|
||||
Guid ErrorId;
|
||||
// num max x ogni step...
|
||||
int maxBatch = 500;
|
||||
// SOLO SE selezionato in dgv...
|
||||
int totRow = ErrorsDGV.SelectedRows.Count;
|
||||
if (totRow > 0)
|
||||
{
|
||||
foreach (DataGridViewRow riga in ErrorsDGV.SelectedRows)
|
||||
{
|
||||
selIdx.Add($"'{((ELMAH_Error)riga.DataBoundItem).ErrorId}'");
|
||||
#if false
|
||||
// chiudo!
|
||||
ErrorId = ((ELMAH_Error)riga.DataBoundItem).ErrorId;
|
||||
try
|
||||
{
|
||||
model.ELMAH_Error.Remove((ELMAH_Error)riga.DataBoundItem);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
#endif
|
||||
// verifico se cancellare
|
||||
if (selIdx.Count >= maxBatch)
|
||||
{
|
||||
await deleteList(selIdx);
|
||||
// resetto
|
||||
selIdx = new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selIdx.Count > 0)
|
||||
{
|
||||
await deleteList(selIdx);
|
||||
}
|
||||
// aggiorno!!
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private async Task deleteList(List<string> selIdx)
|
||||
{
|
||||
// scrivo query x cancellare tutti...
|
||||
string stringOfIds = string.Join(",", selIdx);
|
||||
await model.Database.ExecuteSqlCommandAsync($"DELETE FROM ELMAH_Error WHERE ErrorId IN ({stringOfIds})");
|
||||
// salvo/eseguo
|
||||
await model.SaveChangesAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiornamento visualizzazioni
|
||||
/// </summary>
|
||||
private void doUpdate()
|
||||
{
|
||||
checkFilterVisibility();
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
private void ErrorsDGV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
// seleziono riga
|
||||
}
|
||||
|
||||
private void ErrorsDGV_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
// recupero valore...
|
||||
Guid ErrorId;
|
||||
string appPath = "";
|
||||
string pageUrl = "";
|
||||
// SOLO SE selezionato in dgv...
|
||||
if (ErrorsDGV.SelectedRows.Count > 0)
|
||||
{
|
||||
foreach (DataGridViewRow riga in ErrorsDGV.SelectedRows)
|
||||
{
|
||||
// recupero dati
|
||||
ErrorId = ((ELMAH_Error)riga.DataBoundItem).ErrorId;
|
||||
appPath = getAppPath(((ELMAH_Error)riga.DataBoundItem).Application);
|
||||
// SE appPAth !="" accodo...
|
||||
if (!string.IsNullOrEmpty(appPath))
|
||||
{
|
||||
pageUrl = $"{activeSetup.baseUrl}/{appPath}/elmah.axd/detail?id={ErrorId}";
|
||||
}
|
||||
else
|
||||
{
|
||||
pageUrl = $"{activeSetup.baseUrl}/elmah.axd/detail?id={ErrorId}";
|
||||
}
|
||||
// mostro form
|
||||
var newBrowser = new WBrowser();
|
||||
newBrowser.pageUrl = pageUrl;
|
||||
newBrowser.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int allRecord = 0;
|
||||
|
||||
private List<ELMAH_Error> getFiltData()
|
||||
{
|
||||
var dbSet = model.ELMAH_Error;
|
||||
int statusCode = 0;
|
||||
int.TryParse(selStatus, out statusCode);
|
||||
string selApp = listApp.SelectedItem.ToString();
|
||||
// inizio azione filtraggio..
|
||||
IQueryable<ELMAH_Error> subset = dbSet.Where(x => x.Sequence > 0);
|
||||
if (chkApp.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.Application == selApp);
|
||||
}
|
||||
if (chkHost.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.Host == selHost);
|
||||
}
|
||||
if (chkStatus.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.StatusCode == statusCode);
|
||||
}
|
||||
if (chkType.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.Type == selType);
|
||||
}
|
||||
if (chkUsers.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.User == selUser);
|
||||
}
|
||||
int maxRec = 100;
|
||||
int.TryParse(txtMaxRow.Text, out maxRec);
|
||||
// calcolo tutti ir ecord filtrati...
|
||||
allRecord = subset.Count();
|
||||
// se + di maxRec --> filtro
|
||||
if (allRecord > maxRec)
|
||||
{
|
||||
subset = subset.Take(maxRec);
|
||||
}
|
||||
return subset.OrderByDescending(x => x.TimeUtc).ToList();
|
||||
}
|
||||
|
||||
private void listApp_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkApp.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void listHost_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkHost.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void listStatus_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkStatus.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void listType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkType.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void listUsers_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkUsers.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Carica la conf corrente
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
private void loadConf(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
activeSetup = JsonConvert.DeserializeObject<eSetup>(File.ReadAllText(filePath));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// salvo la conf corrente...
|
||||
OpenFileDialog oFileDialog = new OpenFileDialog();
|
||||
oFileDialog.DefaultExt = "jset";
|
||||
oFileDialog.Filter = "Conf files (*.jset)|*.jset|All files (*.*)|*.*";
|
||||
oFileDialog.InitialDirectory = Utils.confDir;
|
||||
oFileDialog.RestoreDirectory = true;
|
||||
if (oFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// carico
|
||||
loadConf(oFileDialog.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
timerMain.Stop();
|
||||
}
|
||||
|
||||
private void myInit()
|
||||
{
|
||||
setupConfig();
|
||||
setupFilterData();
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void resetFilter()
|
||||
{
|
||||
chkApp.Checked = false;
|
||||
chkHost.Checked = false;
|
||||
chkStatus.Checked = false;
|
||||
chkType.Checked = false;
|
||||
chkUsers.Checked = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva conf corrente sul file indicato
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
private void saveConf(string filePath)
|
||||
{
|
||||
// .. e lo salvo...
|
||||
string rawData = JsonConvert.SerializeObject(activeSetup, Formatting.Indented);
|
||||
File.WriteAllText(filePath, rawData);
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// salvo la conf corrente...
|
||||
SaveFileDialog sFileDialog = new SaveFileDialog();
|
||||
sFileDialog.DefaultExt = "jset";
|
||||
sFileDialog.Filter = "Conf files (*.jset)|*.jset|All files (*.*)|*.*";
|
||||
sFileDialog.InitialDirectory = Utils.confDir;
|
||||
sFileDialog.RestoreDirectory = true;
|
||||
if (sFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// salvo!
|
||||
string rawData = JsonConvert.SerializeObject(activeSetup, Formatting.Indented);
|
||||
saveConf(sFileDialog.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup configurazione da std file
|
||||
/// </summary>
|
||||
@@ -51,114 +425,6 @@ namespace ELMA
|
||||
saveConf(filePath);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Carica la conf corrente
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
private void loadConf(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
activeSetup = JsonConvert.DeserializeObject<eSetup>(File.ReadAllText(filePath));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva conf corrente sul file indicato
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
private void saveConf(string filePath)
|
||||
{
|
||||
// .. e lo salvo...
|
||||
string rawData = JsonConvert.SerializeObject(activeSetup, Formatting.Indented);
|
||||
File.WriteAllText(filePath, rawData);
|
||||
}
|
||||
|
||||
private void currentConfigToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ConfigMan currConfig = new ConfigMan();
|
||||
currConfig.currSetup = activeSetup;
|
||||
currConfig.Owner = this;
|
||||
currConfig.doUpdate();
|
||||
currConfig.Show();
|
||||
}
|
||||
|
||||
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// salvo la conf corrente...
|
||||
OpenFileDialog oFileDialog = new OpenFileDialog();
|
||||
oFileDialog.DefaultExt = "jset";
|
||||
oFileDialog.Filter = "Conf files (*.jset)|*.jset|All files (*.*)|*.*";
|
||||
oFileDialog.InitialDirectory = Utils.confDir;
|
||||
oFileDialog.RestoreDirectory = true;
|
||||
if (oFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// carico
|
||||
loadConf(oFileDialog.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
// salvo la conf corrente...
|
||||
SaveFileDialog sFileDialog = new SaveFileDialog();
|
||||
sFileDialog.DefaultExt = "jset";
|
||||
sFileDialog.Filter = "Conf files (*.jset)|*.jset|All files (*.*)|*.*";
|
||||
sFileDialog.InitialDirectory = Utils.confDir;
|
||||
sFileDialog.RestoreDirectory = true;
|
||||
if (sFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// salvo!
|
||||
string rawData = JsonConvert.SerializeObject(activeSetup, Formatting.Indented);
|
||||
saveConf(sFileDialog.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region area init & close
|
||||
|
||||
public LogAnalyzer()
|
||||
{
|
||||
InitializeComponent();
|
||||
myInit();
|
||||
startTimers();
|
||||
}
|
||||
|
||||
private void startTimers()
|
||||
{
|
||||
timerMain.Start();
|
||||
}
|
||||
|
||||
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
timerMain.Stop();
|
||||
}
|
||||
|
||||
private void myInit()
|
||||
{
|
||||
setupConfig();
|
||||
setupFilterData();
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void timerMain_Tick(object sender, EventArgs e)
|
||||
{
|
||||
#if false
|
||||
setupFilterData();
|
||||
doUpdate();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Utils e metodi dati
|
||||
|
||||
private void setupFilterData()
|
||||
{
|
||||
@@ -217,35 +483,24 @@ namespace ELMA
|
||||
listType.SelectedIndex = 0;
|
||||
listUsers.SelectedIndex = 0;
|
||||
}
|
||||
private void checkFilterVisibility()
|
||||
|
||||
private void startTimers()
|
||||
{
|
||||
// Verifico TUTTI i filtri
|
||||
listApp.Enabled = chkApp.Checked && listApp.Items.Count > 0;
|
||||
listHost.Enabled = chkHost.Checked && listHost.Items.Count > 0;
|
||||
listStatus.Enabled = chkStatus.Checked && listStatus.Items.Count > 0;
|
||||
listType.Enabled = chkType.Checked && listType.Items.Count > 0;
|
||||
listUsers.Enabled = chkUsers.Checked && listUsers.Items.Count > 0;
|
||||
timerMain.Start();
|
||||
}
|
||||
|
||||
protected string selApp { get { return listApp.SelectedItem.ToString(); } }
|
||||
protected string selStatus
|
||||
private void timerMain_Tick(object sender, EventArgs e)
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
if (chkStatus.Checked)
|
||||
{
|
||||
if (listStatus.SelectedItem != null)
|
||||
{
|
||||
answ = listStatus.SelectedItem.ToString();
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#if false
|
||||
setupFilterData();
|
||||
doUpdate();
|
||||
#endif
|
||||
}
|
||||
|
||||
private void txtMaxRow_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
protected string selHost { get { return listHost.SelectedItem.ToString(); } }
|
||||
protected string selType { get { return listType.SelectedItem.ToString(); } }
|
||||
protected string selUser { get { return listUsers.SelectedItem.ToString(); } }
|
||||
|
||||
private void updateSelection()
|
||||
{
|
||||
@@ -255,221 +510,9 @@ namespace ELMA
|
||||
{
|
||||
ErrorsDGV.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||
}
|
||||
tsslNumRec.Text = $"{subset.Count} rec";
|
||||
tsslNumRec.Text = $"{subset.Count}/{allRecord} rec";
|
||||
}
|
||||
|
||||
private List<ELMAH_Error> getFiltData()
|
||||
{
|
||||
var dbSet = model.ELMAH_Error;
|
||||
int statusCode = 0;
|
||||
int.TryParse(selStatus, out statusCode);
|
||||
string selApp = listApp.SelectedItem.ToString();
|
||||
// inizio azione filtraggio..
|
||||
IQueryable<ELMAH_Error> subset = dbSet.Where(x => x.Sequence > 0);
|
||||
if (chkApp.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.Application == selApp);
|
||||
}
|
||||
if (chkHost.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.Host == selHost);
|
||||
}
|
||||
if (chkStatus.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.StatusCode == statusCode);
|
||||
}
|
||||
if (chkType.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.Type == selType);
|
||||
}
|
||||
if (chkUsers.Checked)
|
||||
{
|
||||
subset = subset.Where(x => x.User == selUser);
|
||||
}
|
||||
int maxRec = 100;
|
||||
int.TryParse(txtMaxRow.Text, out maxRec);
|
||||
// se + di maxRec --> filtro
|
||||
if (subset.Count() > maxRec)
|
||||
{
|
||||
subset = subset.Take(maxRec);
|
||||
}
|
||||
return subset.OrderByDescending(x => x.TimeUtc).ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// Aggiornamento visualizzazioni
|
||||
/// </summary>
|
||||
private void doUpdate()
|
||||
{
|
||||
checkFilterVisibility();
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
private void deleteRecordFiltered()
|
||||
{
|
||||
// elimino 1:1 da selezione
|
||||
foreach (var item in getFiltData())
|
||||
{
|
||||
model.ELMAH_Error.Remove(item);
|
||||
}
|
||||
|
||||
// salvo
|
||||
model.SaveChangesAsync();
|
||||
// aggiorno!!
|
||||
setupFilterData();
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void deleteSelRows()
|
||||
{
|
||||
Guid ErrorId;
|
||||
// SOLO SE selezionato in dgv...
|
||||
if (ErrorsDGV.SelectedRows.Count > 0)
|
||||
{
|
||||
|
||||
foreach (DataGridViewRow riga in ErrorsDGV.SelectedRows)
|
||||
{
|
||||
// chiudo!
|
||||
ErrorId = ((ELMAH_Error)riga.DataBoundItem).ErrorId;
|
||||
try
|
||||
{
|
||||
model.ELMAH_Error.Remove((ELMAH_Error)riga.DataBoundItem);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
|
||||
// salvo
|
||||
model.SaveChanges();
|
||||
// aggiorno!!
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void resetFilter()
|
||||
{
|
||||
chkApp.Checked = false;
|
||||
chkHost.Checked = false;
|
||||
chkStatus.Checked = false;
|
||||
chkType.Checked = false;
|
||||
chkUsers.Checked = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region area interazione
|
||||
|
||||
private void listApp_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkApp.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void listHost_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkHost.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void listStatus_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkStatus.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void listType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkType.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void listUsers_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (chkUsers.Checked)
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void chkApp_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
|
||||
private void chkType_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void chkStatus_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void chkHost_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void chkUsers_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
private void ErrorsDGV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
// seleziono riga
|
||||
}
|
||||
/// <summary>
|
||||
/// Elimino record selezionati
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnDeleteSel_Click(object sender, EventArgs e)
|
||||
{
|
||||
deleteSelRows();
|
||||
}
|
||||
/// <summary>
|
||||
/// Calcola path applicazione partendo da bassePath
|
||||
/// </summary>
|
||||
/// <param name="application"></param>
|
||||
/// <returns></returns>
|
||||
protected string getAppPath(string application)
|
||||
{
|
||||
return application.Replace(activeSetup.appBasePath, "");
|
||||
}
|
||||
|
||||
private void ErrorsDGV_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
// recupero valore...
|
||||
Guid ErrorId;
|
||||
string appPath = "";
|
||||
string pageUrl = "";
|
||||
// SOLO SE selezionato in dgv...
|
||||
if (ErrorsDGV.SelectedRows.Count > 0)
|
||||
{
|
||||
|
||||
foreach (DataGridViewRow riga in ErrorsDGV.SelectedRows)
|
||||
{
|
||||
// recupero dati
|
||||
ErrorId = ((ELMAH_Error)riga.DataBoundItem).ErrorId;
|
||||
appPath = getAppPath(((ELMAH_Error)riga.DataBoundItem).Application);
|
||||
// SE appPAth !="" accodo...
|
||||
if (!string.IsNullOrEmpty(appPath))
|
||||
{
|
||||
pageUrl = $"{activeSetup.baseUrl}/{appPath}/elmah.axd/detail?id={ErrorId}";
|
||||
}
|
||||
else
|
||||
{
|
||||
pageUrl = $"{activeSetup.baseUrl}/elmah.axd/detail?id={ErrorId}";
|
||||
}
|
||||
// mostro form
|
||||
var newBrowser = new WBrowser();
|
||||
newBrowser.pageUrl = pageUrl;
|
||||
newBrowser.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EntityFramework" version="6.2.0" targetFramework="net462" />
|
||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net462" />
|
||||
<package id="EntityFramework" version="6.4.4" targetFramework="net462" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net462" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user