Aggiunto export CSV + fix 25 righe visualizzazione
This commit is contained in:
@@ -36,6 +36,21 @@ namespace AppData
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
|
||||
public class FileBatchStats
|
||||
{
|
||||
public string FileCsv { get; set; } = "";
|
||||
public double Yeld { get; set; } = 0;
|
||||
public int NumMaterials { get; set; } = 0;
|
||||
public int NumSheets { get; set; } = 0;
|
||||
public int NumModels { get; set; } = 0;
|
||||
public int NumKit { get; set; } = 0;
|
||||
public int NumParts { get; set; } = 0;
|
||||
public int NumPainted { get; set; } = 0;
|
||||
}
|
||||
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
<div class="col-8 text-right small">
|
||||
<div class="form-row mb-2">
|
||||
<div class="col-5">
|
||||
<asp:LinkButton runat="server" ID="lbtExportCsv" CssClass="btn btn-sm btn-outline-success" OnClick="lbtExportCsv_Click">Create CSV <i class="fa fa-file-excel-o" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:HyperLink runat="server" ID="hlDownload" CssClass="btn btn-sm btn-outline-success" Target="_blank">Download CSV <i class="fa fa-download" aria-hidden="true"></i></asp:HyperLink>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="input-group input-group-sm" runat="server" id="divType">
|
||||
@@ -84,5 +86,6 @@
|
||||
<asp:ControlParameter ControlID="txtNumShow" DefaultValue="20" Name="ShowMax" PropertyName="Text" Type="Int32" />
|
||||
</SelectParameters>
|
||||
</asp:ObjectDataSource>
|
||||
<asp:HiddenField runat="server" ID="hfFileName" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,12 +1,37 @@
|
||||
using System;
|
||||
using AppData;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Linq;
|
||||
|
||||
namespace NKC_WF.WebUserControls
|
||||
{
|
||||
public partial class cmp_BatchStatsList : BaseUserControl
|
||||
{
|
||||
#region Private Properties
|
||||
|
||||
private string fullPath
|
||||
{
|
||||
get
|
||||
{
|
||||
string dirPath = HttpContext.Current.Server.MapPath("~/temp/");
|
||||
return $"{dirPath}\\{FileName}";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected bool fileExist
|
||||
{
|
||||
get
|
||||
{
|
||||
return File.Exists(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
protected int ShowLast
|
||||
{
|
||||
get
|
||||
@@ -23,8 +48,32 @@ namespace NKC_WF.WebUserControls
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public string FileName
|
||||
{
|
||||
get
|
||||
{
|
||||
return hfFileName.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
hfFileName.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void clearFile()
|
||||
{
|
||||
if (fileExist)
|
||||
{
|
||||
File.Delete(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
private void Cmp_numRow_eh_doRefresh(object sender, EventArgs e)
|
||||
{
|
||||
// recupero num righe ed aggiorno...
|
||||
@@ -61,6 +110,29 @@ namespace NKC_WF.WebUserControls
|
||||
{
|
||||
}
|
||||
|
||||
protected void lbtExportCsv_Click(object sender, EventArgs e)
|
||||
{
|
||||
DataLayer DLMan = new DataLayer();
|
||||
DS_App.BatchStatsDataTable currRecords = DLMan.taBStats.getLast(ShowLast);
|
||||
var rowList = currRecords
|
||||
.Select(x => new FileBatchStats()
|
||||
{
|
||||
FileCsv = x.Takt,
|
||||
Yeld = (double)x.AvgYeld,
|
||||
NumMaterials = x.NumMat,
|
||||
NumSheets = x.NumSheets,
|
||||
NumModels = x.NumModel,
|
||||
NumKit = x.NumKit,
|
||||
NumParts = x.NumParts,
|
||||
NumPainted = x.NumPainted
|
||||
})
|
||||
.ToList();
|
||||
utils.SaveToCsv(rowList, fullPath);
|
||||
hlDownload.NavigateUrl = $"~/temp/{FileName}";
|
||||
lbtExportCsv.Visible = !fileExist;
|
||||
hlDownload.Visible = fileExist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Caricamento pagina
|
||||
/// </summary>
|
||||
@@ -70,10 +142,14 @@ namespace NKC_WF.WebUserControls
|
||||
{
|
||||
if (!Page.IsPostBack)
|
||||
{
|
||||
cmp_numRow.numRow = 10;
|
||||
cmp_numRow.numRow = 25;
|
||||
grView.PageSize = cmp_numRow.numRow;
|
||||
divGraph.Visible = false;
|
||||
divType.Visible = false;
|
||||
FileName = "BatchStats.csv";
|
||||
clearFile();
|
||||
lbtExportCsv.Visible = !fileExist;
|
||||
hlDownload.Visible = fileExist;
|
||||
}
|
||||
cmp_numRow.eh_doRefresh += Cmp_numRow_eh_doRefresh;
|
||||
}
|
||||
@@ -96,6 +172,8 @@ namespace NKC_WF.WebUserControls
|
||||
updateGraph();
|
||||
}
|
||||
grView.DataBind();
|
||||
lbtExportCsv.Visible = !fileExist;
|
||||
hlDownload.Visible = fileExist;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
@@ -32,6 +32,24 @@ namespace NKC_WF.WebUserControls
|
||||
/// </remarks>
|
||||
protected global::NKC_WF.WebUserControls.cmp_BatchStatsPlot cmp_BatchStatsPlot;
|
||||
|
||||
/// <summary>
|
||||
/// lbtExportCsv control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.LinkButton lbtExportCsv;
|
||||
|
||||
/// <summary>
|
||||
/// hlDownload control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.HyperLink hlDownload;
|
||||
|
||||
/// <summary>
|
||||
/// divType control.
|
||||
/// </summary>
|
||||
@@ -103,5 +121,14 @@ namespace NKC_WF.WebUserControls
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.ObjectDataSource ods;
|
||||
|
||||
/// <summary>
|
||||
/// hfFileName control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.HiddenField hfFileName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace NKC_WF.WebUserControls
|
||||
{
|
||||
if (!Page.IsPostBack)
|
||||
{
|
||||
cmp_numRow.numRow = 10;
|
||||
cmp_numRow.numRow = 25;
|
||||
grView.PageSize = cmp_numRow.numRow;
|
||||
divGraph.Visible = false;
|
||||
divType.Visible = false;
|
||||
|
||||
Reference in New Issue
Block a user