Update x permettere split parziali
This commit is contained in:
@@ -42,11 +42,11 @@
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<asp:LinkButton runat="server" ID="lbtOrdRemAll01" CssClass="btn btn-danger" OnClick="lbtOrdRemAll_Click" CommandArgument="NE01" ToolTip="Remove All"><i class="fa fa-angle-double-left" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdRem01" CssClass="btn btn-dark" OnClick="lbtOrdRem_Click" CommandArgument="NE01" ToolTip="Remove 1"><i class="fa fa-minus" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdRem01" CssClass="btn btn-dark" OnClick="lbtOrdRem_Click" CommandArgument="NE01" ToolTip="Remove 1"><i class="fa fa-angle-left" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div>
|
||||
<asp:Label runat="server" ID="lblRat01" CssClass="form-control text-right"></asp:Label>
|
||||
<div class="input-group-append">
|
||||
<asp:LinkButton runat="server" ID="lbtOrdAdd01" CssClass="btn btn-dark" OnClick="lbtOrdAdd_Click" CommandArgument="NE01" ToolTip="Add 1"><i class="fa fa-plus" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdAdd01" CssClass="btn btn-dark" OnClick="lbtOrdAdd_Click" CommandArgument="NE01" ToolTip="Add 1"><i class="fa fa-angle-right" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdAddAll01" CssClass="btn btn-success" OnClick="lbtOrdAddAll_Click" CommandArgument="NE01" ToolTip="Add All"><i class="fa fa-angle-double-right" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div>
|
||||
</div>
|
||||
@@ -75,11 +75,11 @@
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<asp:LinkButton runat="server" ID="lbtOrdRemAll02" CssClass="btn btn-danger" OnClick="lbtOrdRemAll_Click" CommandArgument="NE02" ToolTip="Remove All"><i class="fa fa-angle-double-left" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdRem02" CssClass="btn btn-dark" OnClick="lbtOrdRem_Click" CommandArgument="NE02"><i class="fa fa-minus" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdRem02" CssClass="btn btn-dark" OnClick="lbtOrdRem_Click" CommandArgument="NE02"><i class="fa fa-angle-left" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div>
|
||||
<asp:Label runat="server" ID="lblRat02" TextMode="Number" CssClass="form-control text-right"></asp:Label>
|
||||
<div class="input-group-append">
|
||||
<asp:LinkButton runat="server" ID="lbtOrdAdd02" CssClass="btn btn-dark" OnClick="lbtOrdAdd_Click" CommandArgument="NE02"><i class="fa fa-plus" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdAdd02" CssClass="btn btn-dark" OnClick="lbtOrdAdd_Click" CommandArgument="NE02"><i class="fa fa-angle-right" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdAddAll02" CssClass="btn btn-success" OnClick="lbtOrdAddAll_Click" CommandArgument="NE02" ToolTip="Add All"><i class="fa fa-angle-double-right" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div>
|
||||
</div>
|
||||
@@ -108,11 +108,11 @@
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<asp:LinkButton runat="server" ID="lbtOrdRemAll03" CssClass="btn btn-danger" OnClick="lbtOrdRemAll_Click" CommandArgument="NE03" ToolTip="Remove All"><i class="fa fa-angle-double-left" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdRem03" CssClass="btn btn-dark" OnClick="lbtOrdRem_Click" CommandArgument="NE03"><i class="fa fa-minus" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdRem03" CssClass="btn btn-dark" OnClick="lbtOrdRem_Click" CommandArgument="NE03"><i class="fa fa-angle-left" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div>
|
||||
<asp:Label runat="server" ID="lblRat03" TextMode="Number" CssClass="form-control text-right"></asp:Label>
|
||||
<div class="input-group-append">
|
||||
<asp:LinkButton runat="server" ID="lbtOrdAdd03" CssClass="btn btn-dark" OnClick="lbtOrdAdd_Click" CommandArgument="NE03"><i class="fa fa-plus" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdAdd03" CssClass="btn btn-dark" OnClick="lbtOrdAdd_Click" CommandArgument="NE03"><i class="fa fa-angle-right" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton runat="server" ID="lbtOrdAddAll03" CssClass="btn btn-success" OnClick="lbtOrdAddAll_Click" CommandArgument="NE03" ToolTip="Add All"><i class="fa fa-angle-double-right" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -393,9 +393,12 @@ namespace NKC_WF.WebUserControls
|
||||
|
||||
protected void lbtBalance_Click(object sender, EventArgs e)
|
||||
{
|
||||
Ratio01 = 0.33;
|
||||
Ratio02 = 0.34;
|
||||
Ratio03 = 0.33;
|
||||
// imposto la % secondo numero di abilitati...
|
||||
Ratio01 = enable01 ? (double)1 / numEnabled : 0;
|
||||
Ratio02 = enable02 ? (double)1 / numEnabled : 0;
|
||||
Ratio03 = enable03 ? (double)1 / numEnabled : 0;
|
||||
//Ratio02 = 0.34;
|
||||
//Ratio03 = 0.33;
|
||||
lastRatio01 = 0;
|
||||
lastRatio02 = 0;
|
||||
lastRatio03 = 0;
|
||||
@@ -461,6 +464,7 @@ namespace NKC_WF.WebUserControls
|
||||
if (!Page.IsPostBack)
|
||||
{
|
||||
// verifica visualizzazione
|
||||
enableAll();
|
||||
fixChildBatch();
|
||||
fixRatio();
|
||||
checkDisplayMode();
|
||||
@@ -471,6 +475,13 @@ namespace NKC_WF.WebUserControls
|
||||
cmp_orderExtListNE03.eh_doRefresh += Cmp_orderExtListNE03_eh_doRefresh;
|
||||
}
|
||||
|
||||
private void enableAll()
|
||||
{
|
||||
enable01 = true;
|
||||
enable02 = true;
|
||||
enable03 = true;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Properties
|
||||
@@ -479,7 +490,7 @@ namespace NKC_WF.WebUserControls
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
bool answ = true;
|
||||
bool.TryParse(hfEnabled01.Value, out answ);
|
||||
return answ;
|
||||
}
|
||||
@@ -521,11 +532,18 @@ namespace NKC_WF.WebUserControls
|
||||
{
|
||||
get
|
||||
{
|
||||
int numEnab = 0;
|
||||
numEnab += enable01 ? 1 : 0;
|
||||
numEnab += enable02 ? 1 : 0;
|
||||
numEnab += enable03 ? 1 : 0;
|
||||
return numEnab == 2;
|
||||
return numEnabled == 2;
|
||||
}
|
||||
}
|
||||
private int numEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 0;
|
||||
answ += enable01 ? 1 : 0;
|
||||
answ += enable02 ? 1 : 0;
|
||||
answ += enable03 ? 1 : 0;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,12 +643,12 @@ namespace NKC_WF.WebUserControls
|
||||
lbtToggle01.CssClass = enable01 ? "btn btn-sm btn-dark" : "btn btn-sm btn-secondary";
|
||||
lbtToggle02.CssClass = enable02 ? "btn btn-sm btn-dark" : "btn btn-sm btn-secondary";
|
||||
lbtToggle03.CssClass = enable03 ? "btn btn-sm btn-dark" : "btn btn-sm btn-secondary";
|
||||
lbtOrdAdd01.CssClass = movEnabled && enable01 ? "btn btn-primary px-3" : "btn btn-secondary disabled";
|
||||
lbtOrdRem01.CssClass = movEnabled && enable01 ? "btn btn-primary px-3" : "btn btn-secondary disabled";
|
||||
lbtOrdAdd02.CssClass = movEnabled && enable02 ? "btn btn-primary px-3" : "btn btn-secondary disabled";
|
||||
lbtOrdRem02.CssClass = movEnabled && enable02 ? "btn btn-primary px-3" : "btn btn-secondary disabled";
|
||||
lbtOrdAdd03.CssClass = movEnabled && enable03 ? "btn btn-primary px-3" : "btn btn-secondary disabled";
|
||||
lbtOrdRem03.CssClass = movEnabled && enable03 ? "btn btn-primary px-3" : "btn btn-secondary disabled";
|
||||
lbtOrdAdd01.CssClass = movEnabled && enable01 ? "btn btn-primary px-3" : "btn btn-secondary px-3 disabled";
|
||||
lbtOrdRem01.CssClass = movEnabled && enable01 ? "btn btn-primary px-3" : "btn btn-secondary px-3 disabled";
|
||||
lbtOrdAdd02.CssClass = movEnabled && enable02 ? "btn btn-primary px-3" : "btn btn-secondary px-3 disabled";
|
||||
lbtOrdRem02.CssClass = movEnabled && enable02 ? "btn btn-primary px-3" : "btn btn-secondary px-3 disabled";
|
||||
lbtOrdAdd03.CssClass = movEnabled && enable03 ? "btn btn-primary px-3" : "btn btn-secondary px-3 disabled";
|
||||
lbtOrdRem03.CssClass = movEnabled && enable03 ? "btn btn-primary px-3" : "btn btn-secondary px-3 disabled";
|
||||
lbtOrdRemAll01.CssClass = movEnabled && enable01 ? "btn btn-danger" : "btn btn-secondary disabled";
|
||||
lbtOrdAddAll01.CssClass = movEnabled && enable01 ? "btn btn-success" : "btn btn-secondary disabled";
|
||||
lbtOrdRemAll02.CssClass = movEnabled && enable02 ? "btn btn-danger" : "btn btn-secondary disabled";
|
||||
@@ -847,20 +865,22 @@ namespace NKC_WF.WebUserControls
|
||||
// inizio immaginando di usare TUTTI gli ordini
|
||||
FullSet.OrderSet = OrderedList;
|
||||
// calcolo i valori target iniziali
|
||||
SetNe01.TargetValue = FullSet.ActualValue * Ratio01;
|
||||
SetNe02.TargetValue = FullSet.ActualValue * Ratio02;
|
||||
SetNe03.TargetValue = FullSet.ActualValue * Ratio03;
|
||||
SetNe01.TargetValue = enable01 ? FullSet.ActualValue * Ratio01 : 0;
|
||||
SetNe02.TargetValue = enable02 ? FullSet.ActualValue * Ratio02 : 0;
|
||||
SetNe03.TargetValue = enable03 ? FullSet.ActualValue * Ratio03 : 0;
|
||||
// salvo i set su cui lavorare, SE ho 4+ ordini, prendo i 3 task + lunghi x assegnarli in modo deterministico
|
||||
if (OrderedList.Count > 3)
|
||||
int num2proc = numEnabled;
|
||||
if (OrderedList.Count > num2proc)
|
||||
{
|
||||
directAssign = true;
|
||||
StartSet.OrderSet = OrderedList.OrderByDescending(x => x.Value).Take(3).ToDictionary(t => t.Key, t => t.Value);
|
||||
StartSet.OrderSet = OrderedList.OrderByDescending(x => x.Value).Take(num2proc).ToDictionary(t => t.Key, t => t.Value);
|
||||
// tolgo ordini lunghi tra quelli da processare
|
||||
OrderedList = OrderedList.Take(OrderedList.Count - 3).ToDictionary(t => t.Key, t => t.Value);
|
||||
// imposto nuovi target
|
||||
SetNe01.TargetValue -= StartSet.OrderSet.FirstOrDefault().Value;
|
||||
SetNe02.TargetValue -= StartSet.OrderSet.Skip(1).FirstOrDefault().Value;
|
||||
SetNe03.TargetValue -= StartSet.OrderSet.Skip(2).FirstOrDefault().Value; ;
|
||||
OrderedList = OrderedList.Take(OrderedList.Count - num2proc).ToDictionary(t => t.Key, t => t.Value);
|
||||
// imposto nuovi target secondo sia abilitato
|
||||
int idx = 0;
|
||||
SetNe01.TargetValue -= enable01 ? StartSet.OrderSet.Skip(idx++).FirstOrDefault().Value : 0;
|
||||
SetNe02.TargetValue -= enable02 ? StartSet.OrderSet.Skip(idx++).FirstOrDefault().Value : 0;
|
||||
SetNe03.TargetValue -= enable03 ? StartSet.OrderSet.Skip(idx++).FirstOrDefault().Value : 0;
|
||||
}
|
||||
|
||||
// ciclo x riempire il + primo...SE manca ...
|
||||
@@ -879,17 +899,54 @@ namespace NKC_WF.WebUserControls
|
||||
SetNe02.OrderSet = findLocalMin(ordRemain, SetNe02.TargetValue, maxDepth);
|
||||
}
|
||||
// l'ultimo è la differenza
|
||||
SetNe03.OrderSet = ordRemain;
|
||||
foreach (var item in SetNe02.OrderSet)
|
||||
if (SetNe03.TargetValue > 0)
|
||||
{
|
||||
SetNe03.OrderSet.Remove(item.Key);
|
||||
SetNe03.OrderSet = ordRemain;
|
||||
foreach (var item in SetNe02.OrderSet)
|
||||
{
|
||||
SetNe03.OrderSet.Remove(item.Key);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// riporto ai precedenti
|
||||
if(enable02)
|
||||
{
|
||||
foreach (var item in ordRemain)
|
||||
{
|
||||
if(!SetNe02.OrderSet.ContainsKey(item.Key))
|
||||
{
|
||||
SetNe02.OrderSet.Add(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(enable01)
|
||||
{
|
||||
foreach (var item in ordRemain)
|
||||
{
|
||||
if (!SetNe01.OrderSet.ContainsKey(item.Key))
|
||||
{
|
||||
SetNe01.OrderSet.Add(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// se directAssign --> reinserisco i 3 ordini grandi
|
||||
if (directAssign)
|
||||
{
|
||||
SetNe01.OrderSet.Add(StartSet.OrderSet.FirstOrDefault().Key, StartSet.OrderSet.FirstOrDefault().Value);
|
||||
SetNe02.OrderSet.Add(StartSet.OrderSet.Skip(1).FirstOrDefault().Key, StartSet.OrderSet.Skip(1).FirstOrDefault().Value);
|
||||
SetNe03.OrderSet.Add(StartSet.OrderSet.Skip(2).FirstOrDefault().Key, StartSet.OrderSet.Skip(2).FirstOrDefault().Value);
|
||||
int idx = 0;
|
||||
if (enable01)
|
||||
{
|
||||
SetNe01.OrderSet.Add(StartSet.OrderSet.Skip(idx).FirstOrDefault().Key, StartSet.OrderSet.Skip(idx++).FirstOrDefault().Value);
|
||||
}
|
||||
if (enable02)
|
||||
{
|
||||
SetNe02.OrderSet.Add(StartSet.OrderSet.Skip(idx).FirstOrDefault().Key, StartSet.OrderSet.Skip(idx++).FirstOrDefault().Value);
|
||||
}
|
||||
if (enable03)
|
||||
{
|
||||
SetNe03.OrderSet.Add(StartSet.OrderSet.Skip(idx).FirstOrDefault().Key, StartSet.OrderSet.Skip(idx++).FirstOrDefault().Value);
|
||||
}
|
||||
}
|
||||
// riorganizzo tabOrders...
|
||||
foreach (var orderItem in TabOrders)
|
||||
@@ -922,6 +979,7 @@ namespace NKC_WF.WebUserControls
|
||||
stopWatch.Stop();
|
||||
Log.Instance.Info($"Rebalance executed | R01: {Ratio01} | R02: {Ratio02} | R03: {Ratio03} | maxDepth: {maxDepth} | elapsed ms: {stopWatch.ElapsedMilliseconds}");
|
||||
}
|
||||
#if false
|
||||
// calcolo min/max..
|
||||
var actMax = totTime01 > totTime02 ? totTime01 : totTime02;
|
||||
var actMin = totTime01 < totTime02 ? totTime01 : totTime02;
|
||||
@@ -929,7 +987,8 @@ namespace NKC_WF.WebUserControls
|
||||
actMin = totTime03 < actMin ? totTime03 : actMin;
|
||||
enable01 = (totTime01 == actMin || totTime01 == actMax);
|
||||
enable02 = (totTime02 == actMin || totTime02 == actMax);
|
||||
enable03 = (totTime03 == actMin || totTime03 == actMax);
|
||||
enable03 = (totTime03 == actMin || totTime03 == actMax);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace NKC_WF.WebUserControls
|
||||
|
||||
protected string moveCss
|
||||
{
|
||||
get => enableMove ? "btn btn-dark btn-sm py-0" : "btn btn-secondary disabled btn-sm py-0";
|
||||
get => enableMove ? "btn btn-primary btn-sm py-0" : "btn btn-secondary disabled btn-sm py-0";
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
Reference in New Issue
Block a user