CodeMaid:
- Cleanup codice area MapoDb
This commit is contained in:
+89
-71
@@ -6,78 +6,96 @@ using System.Collections.Generic;
|
||||
|
||||
namespace MapoDb
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe gestione ALLARMI come eventi speciali (documenti registrati su MongoDb)
|
||||
/// </summary>
|
||||
public class AlarmsArchive
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Database corrente MongoDB
|
||||
/// Classe gestione ALLARMI come eventi speciali (documenti registrati su MongoDb)
|
||||
/// </summary>
|
||||
IMongoDatabase database;
|
||||
/// <summary>
|
||||
/// Oggetto privato datalayer
|
||||
/// </summary>
|
||||
DataLayer DataLayerObj;
|
||||
|
||||
/// <summary>
|
||||
/// Classe gestione archivio allarmi
|
||||
/// </summary>
|
||||
public AlarmsArchive()
|
||||
public class AlarmsArchive
|
||||
{
|
||||
database = memLayer.ML.getMongoDatabase("MAPO");
|
||||
DataLayerObj = new DataLayer();
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Singleton gestione istanza AlarmsManager
|
||||
/// </summary>
|
||||
public static AlarmsArchive man = new AlarmsArchive();
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Classe gestione archivio allarmi
|
||||
/// </summary>
|
||||
public AlarmsArchive()
|
||||
{
|
||||
database = memLayer.ML.getMongoDatabase("MAPO");
|
||||
DataLayerObj = new DataLayer();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Crea una registrazione incidente su MongoDB
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="elencoAllarmi"></param>
|
||||
/// <param name="lastMinutes">numero di minuti precedenti di dati FluxLog da includere</param>
|
||||
/// <returns></returns>
|
||||
public int createAlarmEvent(string idxMacchina, List<alarmData> elencoAllarmi, int lastMinutes)
|
||||
{
|
||||
int answ = 0;
|
||||
string currDateStr = "";
|
||||
int startYMD = 0;
|
||||
DateTime adesso = DateTime.Now;
|
||||
int anno = adesso.Year;
|
||||
currDateStr = adesso.ToString("yyyyMMdd");
|
||||
int.TryParse(currDateStr, out startYMD);
|
||||
// in primis recupero contatore allarmi correnti, lo incremento salvandolo e genero
|
||||
// nuovo documento...
|
||||
var collAlarmStats = database.GetCollection<alarmStats>("AlarmStats");
|
||||
var builderAlarmStat = Builders<alarmStats>.Filter;
|
||||
var filtThisYear = builderAlarmStat.Eq(u => u.year, anno);
|
||||
|
||||
var datiCorrenti = collAlarmStats.Find(filtThisYear);
|
||||
var collAlarmEvents = database.GetCollection<alarmEvent>("AlarmEvents");
|
||||
|
||||
List<rawData> lastFluxLog = new List<rawData>();
|
||||
DS_applicazione.FluxLogDataTable tabDati = DataLayerObj.taFL.getFiltOrd(idxMacchina, adesso.AddMinutes(-lastMinutes), adesso, true, "");
|
||||
if (tabDati.Count > 0)
|
||||
{
|
||||
// chiamo procedura x conversione
|
||||
lastFluxLog = FluxArchive.man.convertTable(tabDati, adesso, timeWindow.free);
|
||||
}
|
||||
alarmEvent nuovoAllarme = new alarmEvent()
|
||||
{
|
||||
yCurr = anno,
|
||||
yCounter = answ,
|
||||
dateYMD = startYMD,
|
||||
started = DateTime.Now,
|
||||
blackBoxData = lastFluxLog,
|
||||
activeConditions = elencoAllarmi
|
||||
};
|
||||
|
||||
collAlarmEvents.InsertOne(nuovoAllarme);
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Database corrente MongoDB
|
||||
/// </summary>
|
||||
private IMongoDatabase database;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto privato datalayer
|
||||
/// </summary>
|
||||
private DataLayer DataLayerObj;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
/// <summary>
|
||||
/// Singleton gestione istanza AlarmsManager
|
||||
/// </summary>
|
||||
public static AlarmsArchive man = new AlarmsArchive();
|
||||
/// <summary>
|
||||
/// Crea una registrazione incidente su MongoDB
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="elencoAllarmi"></param>
|
||||
/// <param name="lastMinutes">numero di minuti precedenti di dati FluxLog da includere</param>
|
||||
/// <returns></returns>
|
||||
public int createAlarmEvent(string idxMacchina, List<alarmData> elencoAllarmi, int lastMinutes)
|
||||
{
|
||||
int answ = 0;
|
||||
string currDateStr = "";
|
||||
int startYMD = 0;
|
||||
DateTime adesso = DateTime.Now;
|
||||
int anno = adesso.Year;
|
||||
currDateStr = adesso.ToString("yyyyMMdd");
|
||||
int.TryParse(currDateStr, out startYMD);
|
||||
// in primis recupero contatore allarmi correnti, lo incremento salvandolo e genero nuovo documento...
|
||||
var collAlarmStats = database.GetCollection<alarmStats>("AlarmStats");
|
||||
var builderAlarmStat = Builders<alarmStats>.Filter;
|
||||
var filtThisYear = builderAlarmStat.Eq(u => u.year, anno);
|
||||
|
||||
var datiCorrenti = collAlarmStats.Find(filtThisYear);
|
||||
var collAlarmEvents = database.GetCollection<alarmEvent>("AlarmEvents");
|
||||
|
||||
List<rawData> lastFluxLog = new List<rawData>();
|
||||
DS_applicazione.FluxLogDataTable tabDati = DataLayerObj.taFL.getFiltOrd(idxMacchina, adesso.AddMinutes(-lastMinutes), adesso, true, "");
|
||||
if (tabDati.Count > 0)
|
||||
{
|
||||
// chiamo procedura x conversione
|
||||
lastFluxLog = FluxArchive.man.convertTable(tabDati, adesso, timeWindow.free);
|
||||
}
|
||||
alarmEvent nuovoAllarme = new alarmEvent()
|
||||
{
|
||||
yCurr = anno,
|
||||
yCounter = answ,
|
||||
dateYMD = startYMD,
|
||||
started = DateTime.Now,
|
||||
blackBoxData = lastFluxLog,
|
||||
activeConditions = elencoAllarmi
|
||||
};
|
||||
|
||||
collAlarmEvents.InsertOne(nuovoAllarme);
|
||||
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
-14
@@ -1,26 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MapoDb
|
||||
namespace MapoDb
|
||||
{
|
||||
public class Constants
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
|
||||
public static readonly string BROADCAST_M_PIPE = $"BroadCastMsg";
|
||||
public static readonly string BROADCAST_CURR_KEY = $"{BASE_HASH}:Current:BroadCast";
|
||||
|
||||
// dati conf REDIS Cache
|
||||
public static readonly string BASE_HASH = "MAPO";
|
||||
|
||||
|
||||
private const string redisBaseAddr = "MP:";
|
||||
public static readonly string BROADCAST_CURR_KEY = $"{BASE_HASH}:Current:BroadCast";
|
||||
public static readonly string BROADCAST_M_PIPE = $"BroadCastMsg";
|
||||
public static readonly string redisActionReq = redisBaseAddr + "IO:Action:Req";
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private const string redisBaseAddr = "MP:";
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MapoDb
|
||||
{
|
||||
@@ -15,12 +11,12 @@ namespace MapoDb
|
||||
public DateTime DtReq { get; set; } = DateTime.Now;
|
||||
public bool IsActive { get; set; } = false;
|
||||
public string Message { get; set; } = "New Message";
|
||||
public string Parameter { get; set; } = "";
|
||||
public bool ShowCancel { get; set; } = true;
|
||||
public bool ShowClose { get; set; } = true;
|
||||
public bool ShowConfirm { get; set; } = true;
|
||||
public string Topic { get; set; } = "New Topic";
|
||||
public string Parameter { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
}
|
||||
+96
-94
@@ -44,20 +44,6 @@ namespace MapoDb
|
||||
/// </summary>
|
||||
public class FluxArchive
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Database corrente MongoDB
|
||||
/// </summary>
|
||||
private IMongoDatabase database;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto datalayer
|
||||
/// </summary>
|
||||
private DataLayer DataLayerObj = new DataLayer();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
public static FluxArchive man = new FluxArchive();
|
||||
@@ -84,85 +70,6 @@ namespace MapoDb
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Calcola statistiche per i dati giornalieri processati
|
||||
/// </summary>
|
||||
/// <param name="datiGiornalieri"></param>
|
||||
/// <returns></returns>
|
||||
protected histData getStats(List<rawData> datiGiornalieri)
|
||||
{
|
||||
// init oggetti
|
||||
histData currHist;
|
||||
varStats currStat;
|
||||
List<varStats> statistiche = new List<varStats>();
|
||||
int sampleNumRec = 1;
|
||||
float sampleTotal = 0;
|
||||
float sampleMinVal = 0;
|
||||
float sampleMaxVal = 0;
|
||||
float sampleAvg = 0;
|
||||
float currVal = 0;
|
||||
bool fatto = false;
|
||||
string macName = "";
|
||||
int dateYMD = 0;
|
||||
// ciclo x ogni variabile
|
||||
foreach (var item in datiGiornalieri)
|
||||
{
|
||||
if (item.samples != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(macName))
|
||||
{
|
||||
macName = item.macName;
|
||||
dateYMD = item.dateYMD;
|
||||
}
|
||||
// reset vabiabili
|
||||
sampleTotal = 0;
|
||||
sampleMinVal = 0;
|
||||
sampleMaxVal = 0;
|
||||
sampleAvg = 0;
|
||||
// calcolo statistiche
|
||||
sampleNumRec = item.samples.Count;
|
||||
foreach (var sample in item.samples)
|
||||
{
|
||||
fatto = float.TryParse(sample.value, out currVal);
|
||||
if (fatto)
|
||||
{
|
||||
sampleTotal += currVal;
|
||||
sampleMaxVal = sampleMaxVal < currVal ? currVal : sampleMaxVal;
|
||||
sampleMinVal = sampleMinVal > currVal ? currVal : sampleMinVal;
|
||||
}
|
||||
}
|
||||
if (sampleNumRec > 0)
|
||||
{
|
||||
sampleAvg = sampleTotal / sampleNumRec;
|
||||
}
|
||||
// salvo statistica
|
||||
currStat = new varStats()
|
||||
{
|
||||
varName = item.varName,
|
||||
numRec = sampleNumRec,
|
||||
avg = sampleAvg,
|
||||
min = sampleMinVal,
|
||||
max = sampleMaxVal
|
||||
};
|
||||
statistiche.Add(currStat);
|
||||
}
|
||||
}
|
||||
currHist = new histData()
|
||||
{
|
||||
macName = macName,
|
||||
varType = plcDataType.Real,
|
||||
dateYMD = dateYMD,
|
||||
period = timeWindow.day,
|
||||
stats = statistiche
|
||||
};
|
||||
// restituisco...
|
||||
return currHist;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -170,7 +77,9 @@ namespace MapoDb
|
||||
/// </summary>
|
||||
/// <param name="tabDati">Tabelal dei dati RAW registrati</param>
|
||||
/// <param name="tStamp">Data di riferimento</param>
|
||||
/// <param name="periodo">Periodo del campionamento desiderato (e passato coi dati che sono relativi a tale periodo...)</param>
|
||||
/// <param name="periodo">
|
||||
/// Periodo del campionamento desiderato (e passato coi dati che sono relativi a tale periodo...)
|
||||
/// </param>
|
||||
public List<rawData> convertTable(DS_applicazione.FluxLogDataTable tabDati, DateTime tStamp, timeWindow periodo)
|
||||
{
|
||||
// init oggetti
|
||||
@@ -309,5 +218,98 @@ namespace MapoDb
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Calcola statistiche per i dati giornalieri processati
|
||||
/// </summary>
|
||||
/// <param name="datiGiornalieri"></param>
|
||||
/// <returns></returns>
|
||||
protected histData getStats(List<rawData> datiGiornalieri)
|
||||
{
|
||||
// init oggetti
|
||||
histData currHist;
|
||||
varStats currStat;
|
||||
List<varStats> statistiche = new List<varStats>();
|
||||
int sampleNumRec = 1;
|
||||
float sampleTotal = 0;
|
||||
float sampleMinVal = 0;
|
||||
float sampleMaxVal = 0;
|
||||
float sampleAvg = 0;
|
||||
float currVal = 0;
|
||||
bool fatto = false;
|
||||
string macName = "";
|
||||
int dateYMD = 0;
|
||||
// ciclo x ogni variabile
|
||||
foreach (var item in datiGiornalieri)
|
||||
{
|
||||
if (item.samples != null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(macName))
|
||||
{
|
||||
macName = item.macName;
|
||||
dateYMD = item.dateYMD;
|
||||
}
|
||||
// reset vabiabili
|
||||
sampleTotal = 0;
|
||||
sampleMinVal = 0;
|
||||
sampleMaxVal = 0;
|
||||
sampleAvg = 0;
|
||||
// calcolo statistiche
|
||||
sampleNumRec = item.samples.Count;
|
||||
foreach (var sample in item.samples)
|
||||
{
|
||||
fatto = float.TryParse(sample.value, out currVal);
|
||||
if (fatto)
|
||||
{
|
||||
sampleTotal += currVal;
|
||||
sampleMaxVal = sampleMaxVal < currVal ? currVal : sampleMaxVal;
|
||||
sampleMinVal = sampleMinVal > currVal ? currVal : sampleMinVal;
|
||||
}
|
||||
}
|
||||
if (sampleNumRec > 0)
|
||||
{
|
||||
sampleAvg = sampleTotal / sampleNumRec;
|
||||
}
|
||||
// salvo statistica
|
||||
currStat = new varStats()
|
||||
{
|
||||
varName = item.varName,
|
||||
numRec = sampleNumRec,
|
||||
avg = sampleAvg,
|
||||
min = sampleMinVal,
|
||||
max = sampleMaxVal
|
||||
};
|
||||
statistiche.Add(currStat);
|
||||
}
|
||||
}
|
||||
currHist = new histData()
|
||||
{
|
||||
macName = macName,
|
||||
varType = plcDataType.Real,
|
||||
dateYMD = dateYMD,
|
||||
period = timeWindow.day,
|
||||
stats = statistiche
|
||||
};
|
||||
// restituisco...
|
||||
return currHist;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Database corrente MongoDB
|
||||
/// </summary>
|
||||
private IMongoDatabase database;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto datalayer
|
||||
/// </summary>
|
||||
private DataLayer DataLayerObj = new DataLayer();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
+17
-13
@@ -2,16 +2,20 @@
|
||||
|
||||
namespace MapoDb
|
||||
{
|
||||
/// <summary>
|
||||
/// Struttura
|
||||
/// </summary>
|
||||
public class ISTD_OrderColcom
|
||||
{
|
||||
public string CodOrdine;
|
||||
public string CodArticolo;
|
||||
public string DescrArticolo;
|
||||
public DateTime DataConsegna;
|
||||
public Decimal Qta;
|
||||
public string KitCode;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Struttura
|
||||
/// </summary>
|
||||
public class ISTD_OrderColcom
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
public string CodArticolo;
|
||||
public string CodOrdine;
|
||||
public DateTime DataConsegna;
|
||||
public string DescrArticolo;
|
||||
public string KitCode;
|
||||
public Decimal Qta;
|
||||
|
||||
#endregion Public Fields
|
||||
}
|
||||
}
|
||||
+125
-133
@@ -2,28 +2,17 @@ using MapoDb.DS_ProdTempiTableAdapters;
|
||||
using MapoSDK;
|
||||
using SteamWare;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace MapoDb
|
||||
{
|
||||
public class MapoDb
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected string _connectionString = "";
|
||||
protected string _separatore = ",";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
public DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter taAnagEv;
|
||||
|
||||
public DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter taAnagSt;
|
||||
|
||||
public DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter taAnOpr;
|
||||
|
||||
public DS_applicazioneTableAdapters.DatiMacchineTableAdapter taDatiMacch;
|
||||
|
||||
// area tempi ciclo
|
||||
@@ -35,27 +24,16 @@ namespace MapoDb
|
||||
public DS_applicazioneTableAdapters.EventListTableAdapter taEvList;
|
||||
|
||||
public DS_applicazioneTableAdapters.KeepAliveTableAdapter taKeepAlive;
|
||||
|
||||
public DS_ProdTempiTableAdapters.Macchine2SlaveTableAdapter taM2S;
|
||||
|
||||
public DS_applicazioneTableAdapters.MacchineTableAdapter taMacchine;
|
||||
|
||||
public DS_applicazioneTableAdapters.MSFDTableAdapter taMSFD;
|
||||
|
||||
public DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter taMSM;
|
||||
|
||||
public DS_ProdTempiTableAdapters.ODLTableAdapter taODL;
|
||||
|
||||
public DS_applicazioneTableAdapters.RemoteRebootLogTableAdapter taRRL;
|
||||
|
||||
public DS_applicazioneTableAdapters.StatoMacchineTableAdapter taStatoMacchine;
|
||||
|
||||
public DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter taTCRilevati;
|
||||
|
||||
public DS_applicazioneTableAdapters.TransizioneEventiTableAdapter taTranEv;
|
||||
|
||||
public DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter taTransIngr;
|
||||
|
||||
public DS_applicazioneTableAdapters.TransizioneStatiTableAdapter taTranSt;
|
||||
|
||||
#endregion Public Fields
|
||||
@@ -72,102 +50,6 @@ namespace MapoDb
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// avvio i table adapter della classe
|
||||
/// </summary>
|
||||
private void AvviaTabAdapt()
|
||||
{
|
||||
taEvList = new DS_applicazioneTableAdapters.EventListTableAdapter();
|
||||
taDiario = new DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter();
|
||||
taAnagSt = new DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter();
|
||||
taAnagEv = new DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter();
|
||||
taMacchine = new DS_applicazioneTableAdapters.MacchineTableAdapter();
|
||||
taTranEv = new DS_applicazioneTableAdapters.TransizioneEventiTableAdapter();
|
||||
taTranSt = new DS_applicazioneTableAdapters.TransizioneStatiTableAdapter();
|
||||
taStatoMacchine = new DS_applicazioneTableAdapters.StatoMacchineTableAdapter();
|
||||
taKeepAlive = new DS_applicazioneTableAdapters.KeepAliveTableAdapter();
|
||||
taRRL = new DS_applicazioneTableAdapters.RemoteRebootLogTableAdapter();
|
||||
taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter();
|
||||
taAnOpr = new DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter();
|
||||
taDatiMacch = new DS_applicazioneTableAdapters.DatiMacchineTableAdapter();
|
||||
taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter();
|
||||
taMSFD = new DS_applicazioneTableAdapters.MSFDTableAdapter();
|
||||
taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter();
|
||||
taODL = new DS_ProdTempiTableAdapters.ODLTableAdapter();
|
||||
taTCRilevati = new DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter();
|
||||
taM2S = new DS_ProdTempiTableAdapters.Macchine2SlaveTableAdapter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// metodo privato x fornire cognome-nome dalla matricola
|
||||
/// </summary>
|
||||
/// <param name="matrOpr"></param>
|
||||
/// <returns></returns>
|
||||
private string getGeneralitDaMatr(int matrOpr)
|
||||
{
|
||||
string cognNome = "";
|
||||
// cerco operatore...
|
||||
DS_applicazione.AnagraficaOperatoriRow rigaOpr;
|
||||
try
|
||||
{
|
||||
rigaOpr = taAnOpr.getByMatrOpr(matrOpr)[0];
|
||||
cognNome = string.Format("{0} {1}", rigaOpr.Cognome, rigaOpr.Nome);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return cognNome;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// metodo privato x fornire matricola che è correntemente sulla macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
private int getMatrOpMacc(string idxMacchina)
|
||||
{
|
||||
int matr = -1;
|
||||
try
|
||||
{
|
||||
matr = (taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]).MatrOpr;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return matr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// forza la connString x i vari table adapters
|
||||
/// </summary>
|
||||
private void setConnString()
|
||||
{
|
||||
_connectionString = SteamWare.memLayer.ML.confReadString("MoonProConnectionString");
|
||||
taEvList.Connection.ConnectionString = _connectionString;
|
||||
taDiario.Connection.ConnectionString = _connectionString;
|
||||
taAnagEv.Connection.ConnectionString = _connectionString;
|
||||
taAnagSt.Connection.ConnectionString = _connectionString;
|
||||
taMacchine.Connection.ConnectionString = _connectionString;
|
||||
taTranEv.Connection.ConnectionString = _connectionString;
|
||||
taTranSt.Connection.ConnectionString = _connectionString;
|
||||
taStatoMacchine.Connection.ConnectionString = _connectionString;
|
||||
taKeepAlive.Connection.ConnectionString = _connectionString;
|
||||
taRRL.Connection.ConnectionString = _connectionString;
|
||||
taTransIngr.Connection.ConnectionString = _connectionString;
|
||||
taAnOpr.Connection.ConnectionString = _connectionString;
|
||||
taDatiMacch.Connection.ConnectionString = _connectionString;
|
||||
taMSM.Connection.ConnectionString = _connectionString;
|
||||
taMSFD.Connection.ConnectionString = _connectionString;
|
||||
taDatiMacchine.Connection.ConnectionString = _connectionString;
|
||||
taODL.Connection.ConnectionString = _connectionString;
|
||||
taTCRilevati.Connection.ConnectionString = _connectionString;
|
||||
taM2S.Connection.ConnectionString = _connectionString;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -235,7 +117,8 @@ namespace MapoDb
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dichiara esplicitamente produzione e tempo ciclo rilevato per il numero di pezzi indicati (real time, NON confermati)
|
||||
/// Dichiara esplicitamente produzione e tempo ciclo rilevato per il numero di pezzi
|
||||
/// indicati (real time, NON confermati)
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <param name="CodArticolo"></param>
|
||||
@@ -299,7 +182,8 @@ namespace MapoDb
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore
|
||||
/// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto
|
||||
/// cercato tutti delimitati da separatore
|
||||
/// </summary>
|
||||
/// <param name="chiave"></param>
|
||||
/// <returns></returns>
|
||||
@@ -318,7 +202,8 @@ namespace MapoDb
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore
|
||||
/// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto
|
||||
/// cercato tutti delimitati da separatore
|
||||
/// </summary>
|
||||
/// <param name="chiave"></param>
|
||||
/// <returns></returns>
|
||||
@@ -336,7 +221,8 @@ namespace MapoDb
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto cercato tutti delimitati da separatore
|
||||
/// Restituisce una stringa su 2 righe con intestazione colonne e valore dell'oggetto
|
||||
/// cercato tutti delimitati da separatore
|
||||
/// </summary>
|
||||
/// <param name="chiave"></param>
|
||||
/// <returns></returns>
|
||||
@@ -618,22 +504,24 @@ namespace MapoDb
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary> verifica che il bar code sia un barcode nomeMacchina
|
||||
/// <summary>
|
||||
/// verifica che il bar code sia un barcode nomeMacchina
|
||||
/// </summary>
|
||||
/// <param name="codice"> Bar code da verificare</param>
|
||||
/// <returns> true se bar code per operatore </returns>
|
||||
/// <param name="codice">Bar code da verificare</param>
|
||||
/// <returns>true se bar code per operatore</returns>
|
||||
public bool isNomeMacchina(string codice)
|
||||
{
|
||||
// FARE!!! controllare quale codice ci vuole
|
||||
// controlli validità bar code nomeMacchina : deve cominciare con O maiuscola
|
||||
// FARE!!! controllare quale codice ci vuole controlli validità bar code nomeMacchina :
|
||||
// deve cominciare con O maiuscola
|
||||
bool check = codice.StartsWith("C#");
|
||||
return check;
|
||||
}
|
||||
|
||||
/// <summary> verifica che il bar code sia un barcode Operatore
|
||||
/// <summary>
|
||||
/// verifica che il bar code sia un barcode Operatore
|
||||
/// </summary>
|
||||
/// <param name="codice"> Bar code da verificare</param>
|
||||
/// <returns> true se bar code per operatore </returns>
|
||||
/// <param name="codice">Bar code da verificare</param>
|
||||
/// <returns>true se bar code per operatore</returns>
|
||||
public bool isOperatore(string codice)
|
||||
{
|
||||
// controlli validità bar code operatore : deve cominciare con O maiuscola
|
||||
@@ -669,7 +557,6 @@ namespace MapoDb
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="IPv4"></param>
|
||||
@@ -735,7 +622,8 @@ namespace MapoDb
|
||||
{
|
||||
logger.lg.scriviLog($"Scrittura keep alive! IdxMacchina: {IdxMacchina}");
|
||||
}
|
||||
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione NUOVO oggetto
|
||||
// 2017.07.11 se richiesto di NON usare singleton... riporto FUORI la gestione
|
||||
// NUOVO oggetto
|
||||
if (memLayer.ML.CRB("disable_singleton"))
|
||||
{
|
||||
// 2017.06.09 forzo init x errori "sovrapposizioni"
|
||||
@@ -825,7 +713,8 @@ namespace MapoDb
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua verifica del codice barcode e restituisce un oggetto inputComandoMapo che indica come proseguire
|
||||
/// effettua verifica del codice barcode e restituisce un oggetto inputComandoMapo che
|
||||
/// indica come proseguire
|
||||
/// </summary>
|
||||
/// <param name="barcodeValue"></param>
|
||||
/// <returns></returns>
|
||||
@@ -838,5 +727,108 @@ namespace MapoDb
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected string _connectionString = "";
|
||||
protected string _separatore = ",";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// avvio i table adapter della classe
|
||||
/// </summary>
|
||||
private void AvviaTabAdapt()
|
||||
{
|
||||
taEvList = new DS_applicazioneTableAdapters.EventListTableAdapter();
|
||||
taDiario = new DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter();
|
||||
taAnagSt = new DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter();
|
||||
taAnagEv = new DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter();
|
||||
taMacchine = new DS_applicazioneTableAdapters.MacchineTableAdapter();
|
||||
taTranEv = new DS_applicazioneTableAdapters.TransizioneEventiTableAdapter();
|
||||
taTranSt = new DS_applicazioneTableAdapters.TransizioneStatiTableAdapter();
|
||||
taStatoMacchine = new DS_applicazioneTableAdapters.StatoMacchineTableAdapter();
|
||||
taKeepAlive = new DS_applicazioneTableAdapters.KeepAliveTableAdapter();
|
||||
taRRL = new DS_applicazioneTableAdapters.RemoteRebootLogTableAdapter();
|
||||
taTransIngr = new DS_applicazioneTableAdapters.TransizioneIngressiTableAdapter();
|
||||
taAnOpr = new DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter();
|
||||
taDatiMacch = new DS_applicazioneTableAdapters.DatiMacchineTableAdapter();
|
||||
taMSM = new DS_applicazioneTableAdapters.MicroStatoMacchinaTableAdapter();
|
||||
taMSFD = new DS_applicazioneTableAdapters.MSFDTableAdapter();
|
||||
taDatiMacchine = new DS_ProdTempiTableAdapters.DatiMacchineTableAdapter();
|
||||
taODL = new DS_ProdTempiTableAdapters.ODLTableAdapter();
|
||||
taTCRilevati = new DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter();
|
||||
taM2S = new DS_ProdTempiTableAdapters.Macchine2SlaveTableAdapter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// metodo privato x fornire cognome-nome dalla matricola
|
||||
/// </summary>
|
||||
/// <param name="matrOpr"></param>
|
||||
/// <returns></returns>
|
||||
private string getGeneralitDaMatr(int matrOpr)
|
||||
{
|
||||
string cognNome = "";
|
||||
// cerco operatore...
|
||||
DS_applicazione.AnagraficaOperatoriRow rigaOpr;
|
||||
try
|
||||
{
|
||||
rigaOpr = taAnOpr.getByMatrOpr(matrOpr)[0];
|
||||
cognNome = string.Format("{0} {1}", rigaOpr.Cognome, rigaOpr.Nome);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return cognNome;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// metodo privato x fornire matricola che è correntemente sulla macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
private int getMatrOpMacc(string idxMacchina)
|
||||
{
|
||||
int matr = -1;
|
||||
try
|
||||
{
|
||||
matr = (taStatoMacchine.GetDataByIdxMacchina(idxMacchina)[0]).MatrOpr;
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
return matr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// forza la connString x i vari table adapters
|
||||
/// </summary>
|
||||
private void setConnString()
|
||||
{
|
||||
_connectionString = SteamWare.memLayer.ML.confReadString("MoonProConnectionString");
|
||||
taEvList.Connection.ConnectionString = _connectionString;
|
||||
taDiario.Connection.ConnectionString = _connectionString;
|
||||
taAnagEv.Connection.ConnectionString = _connectionString;
|
||||
taAnagSt.Connection.ConnectionString = _connectionString;
|
||||
taMacchine.Connection.ConnectionString = _connectionString;
|
||||
taTranEv.Connection.ConnectionString = _connectionString;
|
||||
taTranSt.Connection.ConnectionString = _connectionString;
|
||||
taStatoMacchine.Connection.ConnectionString = _connectionString;
|
||||
taKeepAlive.Connection.ConnectionString = _connectionString;
|
||||
taRRL.Connection.ConnectionString = _connectionString;
|
||||
taTransIngr.Connection.ConnectionString = _connectionString;
|
||||
taAnOpr.Connection.ConnectionString = _connectionString;
|
||||
taDatiMacch.Connection.ConnectionString = _connectionString;
|
||||
taMSM.Connection.ConnectionString = _connectionString;
|
||||
taMSFD.Connection.ConnectionString = _connectionString;
|
||||
taDatiMacchine.Connection.ConnectionString = _connectionString;
|
||||
taODL.Connection.ConnectionString = _connectionString;
|
||||
taTCRilevati.Connection.ConnectionString = _connectionString;
|
||||
taM2S.Connection.ConnectionString = _connectionString;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,6 @@ using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MapoDb
|
||||
{
|
||||
@@ -130,6 +127,7 @@ namespace MapoDb
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
|
||||
public class PubSubEventArgs : EventArgs
|
||||
{
|
||||
#region Public Constructors
|
||||
@@ -147,4 +145,4 @@ namespace MapoDb
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,15 +10,22 @@ namespace MapoDb
|
||||
/// </summary>
|
||||
public class MtcDataModelArchive
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Database corrente MongoDB
|
||||
/// Singleton gestione istanza AlarmsManager
|
||||
/// </summary>
|
||||
IMongoDatabase database;
|
||||
public static MtcDataModelArchive man = new MtcDataModelArchive();
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario conf macchine
|
||||
/// </summary>
|
||||
public Dictionary<string, List<machDataItem>> machineDataItems = new Dictionary<string, List<machDataItem>>();
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Classe gestione archivio allarmi
|
||||
/// </summary>
|
||||
@@ -26,10 +33,11 @@ namespace MapoDb
|
||||
{
|
||||
database = memLayer.ML.getMongoDatabase("MAPO");
|
||||
}
|
||||
/// <summary>
|
||||
/// Singleton gestione istanza AlarmsManager
|
||||
/// </summary>
|
||||
public static MtcDataModelArchive man = new MtcDataModelArchive();
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Salva i dataItems della macchina indicata
|
||||
/// </summary>
|
||||
@@ -60,5 +68,16 @@ namespace MapoDb
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
/// <summary>
|
||||
/// Database corrente MongoDB
|
||||
/// </summary>
|
||||
private IMongoDatabase database;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
+119
-96
@@ -8,100 +8,123 @@ using System.Data;
|
||||
/// </summary>
|
||||
public class reportExporter
|
||||
{
|
||||
/// <summary>
|
||||
/// mimeType del report
|
||||
/// </summary>
|
||||
public string mimeType;
|
||||
/// <summary>
|
||||
/// encoding dei dati
|
||||
/// </summary>
|
||||
public string encoding;
|
||||
/// <summary>
|
||||
/// nome estensione
|
||||
/// </summary>
|
||||
public string fileNameExtension;
|
||||
/// <summary>
|
||||
/// steam di bytes del report
|
||||
/// </summary>
|
||||
public byte[] renderedBytes;
|
||||
/// <summary>
|
||||
/// metodo protected
|
||||
/// </summary>
|
||||
public reportExporter()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// carica i dati richiesti dal report dalla StoredProcedure (filtrando quindi...)
|
||||
/// </summary>
|
||||
/// <param name="tipoReport">report ammessi: RichiestaIntervento</param>
|
||||
/// <param name="idxObj">num int mtz</param>
|
||||
/// <returns>tabella dati</returns>
|
||||
private DataTable caricaDati(reportRichiesto tipoReport, string idxObj)
|
||||
{
|
||||
// calcolo idxODL
|
||||
int idxOdl = 0;
|
||||
try
|
||||
{
|
||||
idxOdl = Convert.ToInt32(idxObj);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
DataTable tab = new DataTable();
|
||||
MapoDb.DataLayer DataLayerObj = new MapoDb.DataLayer();
|
||||
switch (tipoReport)
|
||||
{
|
||||
case reportRichiesto.SchedaODL:
|
||||
tab = (DataTable)DataLayerObj.taODL.getByIdx(idxOdl, false);
|
||||
break;
|
||||
//case reportRichiesto.RichiestaIntervento:
|
||||
// tab = (DataTable)TA_app.obj.taInterventiMtz.getByIdx(Convert.ToInt32(idxObj));
|
||||
// break;
|
||||
//default:
|
||||
// break;
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
/// <summary>
|
||||
/// renderizza il report in pdf
|
||||
/// </summary>
|
||||
/// <param name="tipoReport">report ammessi: RichiestaIntervento</param>
|
||||
/// <param name="parametro">idx della richiesta (numIntMtz)</param>
|
||||
/// <returns></returns>
|
||||
public void popolaPdfStream(reportRichiesto tipoReport, string parametro)
|
||||
{
|
||||
LocalReport report = new LocalReport();
|
||||
devInfoParam deviceInfo = new devInfoParam("PDF", "21cm", "29.7cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
switch (tipoReport)
|
||||
{
|
||||
case reportRichiesto.SchedaODL:
|
||||
report.ReportPath = @".\Reports\Donati_ODL.rdlc";
|
||||
report.DataSources.Add(new ReportDataSource("MoonPro", caricaDati(tipoReport, parametro))); // OCCHIO!!! va messa sorgente dati CORRETTA
|
||||
deviceInfo = new devInfoParam("PDF", "29.7cm", "21cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
createPdfStream(report, deviceInfo.xmlParam);
|
||||
}
|
||||
/// <summary>
|
||||
/// crea il vero e proprio stream pdf
|
||||
/// </summary>
|
||||
/// <param name="report"></param>
|
||||
/// <param name="deviceInfo"></param>
|
||||
private void createPdfStream(LocalReport report, string deviceInfo)
|
||||
{
|
||||
// export in PDF
|
||||
string reportType = "PDF";
|
||||
Warning[] warnings;
|
||||
string[] streams;
|
||||
renderedBytes = report.Render(
|
||||
reportType,
|
||||
deviceInfo,
|
||||
out mimeType,
|
||||
out encoding,
|
||||
out fileNameExtension,
|
||||
out streams,
|
||||
out warnings);
|
||||
}
|
||||
#region Public Fields
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// encoding dei dati
|
||||
/// </summary>
|
||||
public string encoding;
|
||||
|
||||
/// <summary>
|
||||
/// nome estensione
|
||||
/// </summary>
|
||||
public string fileNameExtension;
|
||||
|
||||
/// <summary>
|
||||
/// mimeType del report
|
||||
/// </summary>
|
||||
public string mimeType;
|
||||
|
||||
/// <summary>
|
||||
/// steam di bytes del report
|
||||
/// </summary>
|
||||
public byte[] renderedBytes;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// metodo protected
|
||||
/// </summary>
|
||||
public reportExporter()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// renderizza il report in pdf
|
||||
/// </summary>
|
||||
/// <param name="tipoReport">report ammessi: RichiestaIntervento</param>
|
||||
/// <param name="parametro">idx della richiesta (numIntMtz)</param>
|
||||
/// <returns></returns>
|
||||
public void popolaPdfStream(reportRichiesto tipoReport, string parametro)
|
||||
{
|
||||
LocalReport report = new LocalReport();
|
||||
devInfoParam deviceInfo = new devInfoParam("PDF", "21cm", "29.7cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
switch (tipoReport)
|
||||
{
|
||||
case reportRichiesto.SchedaODL:
|
||||
report.ReportPath = @".\Reports\Donati_ODL.rdlc";
|
||||
report.DataSources.Add(new ReportDataSource("MoonPro", caricaDati(tipoReport, parametro))); // OCCHIO!!! va messa sorgente dati CORRETTA
|
||||
deviceInfo = new devInfoParam("PDF", "29.7cm", "21cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
createPdfStream(report, deviceInfo.xmlParam);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// carica i dati richiesti dal report dalla StoredProcedure (filtrando quindi...)
|
||||
/// </summary>
|
||||
/// <param name="tipoReport">report ammessi: RichiestaIntervento</param>
|
||||
/// <param name="idxObj">num int mtz</param>
|
||||
/// <returns>tabella dati</returns>
|
||||
private DataTable caricaDati(reportRichiesto tipoReport, string idxObj)
|
||||
{
|
||||
// calcolo idxODL
|
||||
int idxOdl = 0;
|
||||
try
|
||||
{
|
||||
idxOdl = Convert.ToInt32(idxObj);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
DataTable tab = new DataTable();
|
||||
MapoDb.DataLayer DataLayerObj = new MapoDb.DataLayer();
|
||||
switch (tipoReport)
|
||||
{
|
||||
case reportRichiesto.SchedaODL:
|
||||
tab = (DataTable)DataLayerObj.taODL.getByIdx(idxOdl, false);
|
||||
break;
|
||||
//case reportRichiesto.RichiestaIntervento:
|
||||
// tab = (DataTable)TA_app.obj.taInterventiMtz.getByIdx(Convert.ToInt32(idxObj));
|
||||
// break;
|
||||
//default:
|
||||
// break;
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// crea il vero e proprio stream pdf
|
||||
/// </summary>
|
||||
/// <param name="report"></param>
|
||||
/// <param name="deviceInfo"></param>
|
||||
private void createPdfStream(LocalReport report, string deviceInfo)
|
||||
{
|
||||
// export in PDF
|
||||
string reportType = "PDF";
|
||||
Warning[] warnings;
|
||||
string[] streams;
|
||||
renderedBytes = report.Render(
|
||||
reportType,
|
||||
deviceInfo,
|
||||
out mimeType,
|
||||
out encoding,
|
||||
out fileNameExtension,
|
||||
out streams,
|
||||
out warnings);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
+113
-98
@@ -22,10 +22,16 @@ public enum reportRichiesto
|
||||
/// </summary>
|
||||
public class reportPrinter
|
||||
{
|
||||
#region area codice da non modificare
|
||||
#region Public Fields
|
||||
|
||||
private int m_currentPageIndex;
|
||||
private IList<Stream> m_streams;
|
||||
/// <summary>
|
||||
/// singleton pubblico
|
||||
/// </summary>
|
||||
public static reportPrinter obj = new reportPrinter();
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// dispone l'applicazione e rilascia le risorse
|
||||
@@ -40,6 +46,92 @@ public class reportPrinter
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Crea un report locale da file rdlc, carica i dati, esporta report come EMF file e quindi lo
|
||||
/// invia alla stampante
|
||||
/// </summary>
|
||||
/// <param name="tipoReport">report ammessi: ElencoMacchine / RichiestaIntervento</param>
|
||||
/// <param name="printerName">nome completo stampante (rispetto al server)</param>
|
||||
/// <param name="parametro">numIntMtz (codice numero richiesta)</param>
|
||||
public void printReport(reportRichiesto tipoReport, string printerName, string parametro)
|
||||
{
|
||||
LocalReport report = new LocalReport();
|
||||
devInfoParam deviceInfo = new devInfoParam("EMF", "21cm", "29.7cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
switch (tipoReport)
|
||||
{
|
||||
case reportRichiesto.SchedaODL:
|
||||
report.ReportPath = @".\Reports\Donati_ODL.rdlc";
|
||||
report.DataSources.Add(new ReportDataSource("MoonPro", caricaDati(tipoReport, parametro)));
|
||||
deviceInfo = new devInfoParam("EMF", "21cm", "29.7cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
break;
|
||||
//case reportRichiesto.RichiestaIntervento:
|
||||
// report.ReportPath = @".\Reports\RichiestaIntervento.rdlc";
|
||||
// report.DataSources.Add(new ReportDataSource("WebGim", caricaDati(tipoReport, parametro)));
|
||||
// deviceInfo = new devInfoParam("EMF", "29.7cm", "21cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
// break;
|
||||
//default:
|
||||
// break;
|
||||
}
|
||||
doEmfPrint(printerName, report, deviceInfo.xmlParam);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Constructors
|
||||
|
||||
/// <summary>
|
||||
/// oggetto protected
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
protected reportPrinter()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Protected Constructors
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private int m_currentPageIndex;
|
||||
private IList<Stream> m_streams;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// carica i dati richiesti dal report dalla StoredProcedure (filtrando quindi...)
|
||||
/// </summary>
|
||||
/// <param name="tipoReport">report ammessi: ElencoMacchine / RichiestaIntervento</param>
|
||||
/// <param name="periodoAnalizzato">
|
||||
/// oggetto che contiene data inizio e data fine dell'analisi richiesta per il report
|
||||
/// </param>
|
||||
/// <returns>tabella dati</returns>
|
||||
private DataTable caricaDati(reportRichiesto tipoReport, string idxObj)
|
||||
{
|
||||
DataLayer DataLayerObj = new DataLayer();
|
||||
// calcolo idxODL
|
||||
int idxOdl = 0;
|
||||
try
|
||||
{
|
||||
idxOdl = Convert.ToInt32(idxObj);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
DataTable tab = new DataTable();
|
||||
switch (tipoReport)
|
||||
{
|
||||
case reportRichiesto.SchedaODL:
|
||||
tab = (DataTable)DataLayerObj.taODL.getByIdx(idxOdl, false);
|
||||
break;
|
||||
//case reportRichiesto.RichiestaIntervento:
|
||||
// tab = (DataTable)TA_app.obj.taInterventiMtz.getByIdx(Convert.ToInt32(idxObj));
|
||||
// break;
|
||||
//default:
|
||||
// break;
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ciclo da fornire al renderizzatore dei report, per salvare 1 immagine da ogni pagina del report
|
||||
/// </summary>
|
||||
@@ -56,6 +148,23 @@ public class reportPrinter
|
||||
return stream;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// esegue print vero e proprio
|
||||
/// </summary>
|
||||
/// <param name="printerName"></param>
|
||||
/// <param name="report"></param>
|
||||
/// <param name="deviceInfo"></param>
|
||||
private void doEmfPrint(string printerName, LocalReport report, string deviceInfo)
|
||||
{
|
||||
// export in EMF
|
||||
Export(report, deviceInfo);
|
||||
m_currentPageIndex = 0;
|
||||
// stampo
|
||||
Print(printerName);
|
||||
// do dispose?
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Export del report come EMF (Enhanced Metafile) file.
|
||||
/// </summary>
|
||||
@@ -101,99 +210,5 @@ public class reportPrinter
|
||||
ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
|
||||
}
|
||||
|
||||
#endregion area codice da non modificare
|
||||
|
||||
#region area codice da modificare
|
||||
|
||||
/// <summary>
|
||||
/// singleton pubblico
|
||||
/// </summary>
|
||||
public static reportPrinter obj = new reportPrinter();
|
||||
|
||||
/// <summary>
|
||||
/// oggetto protected
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
protected reportPrinter()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Crea un report locale da file rdlc, carica i dati, esporta report come EMF file e quindi lo invia alla stampante
|
||||
/// </summary>
|
||||
/// <param name="tipoReport">report ammessi: ElencoMacchine / RichiestaIntervento</param>
|
||||
/// <param name="printerName">nome completo stampante (rispetto al server)</param>
|
||||
/// <param name="parametro">numIntMtz (codice numero richiesta)</param>
|
||||
public void printReport(reportRichiesto tipoReport, string printerName, string parametro)
|
||||
{
|
||||
LocalReport report = new LocalReport();
|
||||
devInfoParam deviceInfo = new devInfoParam("EMF", "21cm", "29.7cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
switch (tipoReport)
|
||||
{
|
||||
case reportRichiesto.SchedaODL:
|
||||
report.ReportPath = @".\Reports\Donati_ODL.rdlc";
|
||||
report.DataSources.Add(new ReportDataSource("MoonPro", caricaDati(tipoReport, parametro)));
|
||||
deviceInfo = new devInfoParam("EMF", "21cm", "29.7cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
break;
|
||||
//case reportRichiesto.RichiestaIntervento:
|
||||
// report.ReportPath = @".\Reports\RichiestaIntervento.rdlc";
|
||||
// report.DataSources.Add(new ReportDataSource("WebGim", caricaDati(tipoReport, parametro)));
|
||||
// deviceInfo = new devInfoParam("EMF", "29.7cm", "21cm", "0.2cm", "0.2cm", "0.2cm", "0.2cm");
|
||||
// break;
|
||||
//default:
|
||||
// break;
|
||||
}
|
||||
doEmfPrint(printerName, report, deviceInfo.xmlParam);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// carica i dati richiesti dal report dalla StoredProcedure (filtrando quindi...)
|
||||
/// </summary>
|
||||
/// <param name="tipoReport">report ammessi: ElencoMacchine / RichiestaIntervento</param>
|
||||
/// <param name="periodoAnalizzato">oggetto che contiene data inizio e data fine dell'analisi richiesta per il report</param>
|
||||
/// <returns>tabella dati</returns>
|
||||
private DataTable caricaDati(reportRichiesto tipoReport, string idxObj)
|
||||
{
|
||||
DataLayer DataLayerObj = new DataLayer();
|
||||
// calcolo idxODL
|
||||
int idxOdl = 0;
|
||||
try
|
||||
{
|
||||
idxOdl = Convert.ToInt32(idxObj);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
DataTable tab = new DataTable();
|
||||
switch (tipoReport)
|
||||
{
|
||||
case reportRichiesto.SchedaODL:
|
||||
tab = (DataTable)DataLayerObj.taODL.getByIdx(idxOdl, false);
|
||||
break;
|
||||
//case reportRichiesto.RichiestaIntervento:
|
||||
// tab = (DataTable)TA_app.obj.taInterventiMtz.getByIdx(Convert.ToInt32(idxObj));
|
||||
// break;
|
||||
//default:
|
||||
// break;
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// esegue print vero e proprio
|
||||
/// </summary>
|
||||
/// <param name="printerName"></param>
|
||||
/// <param name="report"></param>
|
||||
/// <param name="deviceInfo"></param>
|
||||
private void doEmfPrint(string printerName, LocalReport report, string deviceInfo)
|
||||
{
|
||||
// export in EMF
|
||||
Export(report, deviceInfo);
|
||||
m_currentPageIndex = 0;
|
||||
// stampo
|
||||
Print(printerName);
|
||||
// do dispose?
|
||||
Dispose();
|
||||
}
|
||||
|
||||
#endregion area codice da modificare
|
||||
#endregion Private Methods
|
||||
}
|
||||
+436
-439
@@ -98,27 +98,6 @@ public struct objTempiCiclo
|
||||
//}
|
||||
public class resoconti
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected DS_applicazione.AnagArticoliDataTable _AnagArt;
|
||||
protected DS_applicazione.AnagraficaOperatoriDataTable _AnagOpr;
|
||||
protected DS_applicazione.AnagraficaEventiDataTable _AnagraficaEventi;
|
||||
protected DS_applicazione.DiarioDiBordoDataTable _DiarioDiBordo;
|
||||
protected DS_applicazione.MacchineDataTable _Macchine;
|
||||
protected DS_applicazione.AnagraficaStatiDataTable _Stati;
|
||||
protected DS_applicazione.StatoMacchineDataTable _StatoMacchine;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.AnagArticoliTableAdapter taAnagArt;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter taAnagOpr;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter taAnagraficaEventi;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter taDiarioDiBordo;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.MacchineTableAdapter taMacchine;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.ParetoDurateTableAdapter taParetoDurate;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter taStati;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.StatoMacchineTableAdapter taStatoMacchine;
|
||||
protected MapoDb.DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter taTempiCiclo;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
@@ -138,423 +117,6 @@ public class resoconti
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected DS_applicazione.AnagraficaOperatoriDataTable AnagOpr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("AnagOpr"))
|
||||
{
|
||||
_AnagOpr = taAnagOpr.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_AnagOpr);
|
||||
memLayer.ML.setCacheVal("AnagOpr", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("AnagOpr");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_AnagOpr = JsonConvert.DeserializeObject<DS_applicazione.AnagraficaOperatoriDataTable>(serVal);
|
||||
}
|
||||
return _AnagOpr;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario codici colore (chiave = idxStato), valore = codice colore
|
||||
/// </summary>
|
||||
protected Dictionary<int, string> codColore
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<int, string> answ = new Dictionary<int, string>();
|
||||
if (memLayer.ML.isInCacheObject("codColore"))
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("codColore");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
answ = JsonConvert.DeserializeObject<Dictionary<int, string>>(serVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
string _colore = "";
|
||||
foreach (DS_applicazione.AnagraficaStatiRow item in Stati)
|
||||
{
|
||||
switch (item.Semaforo)
|
||||
{
|
||||
case "sGi": // giallo
|
||||
_colore = "#ffec00";
|
||||
break;
|
||||
|
||||
case "sRo": // rosso
|
||||
_colore = "#e2001a";
|
||||
break;
|
||||
|
||||
case "sGr": // grigio - spenta
|
||||
_colore = "#bcbcbc";
|
||||
break;
|
||||
|
||||
case "sVe": // verde
|
||||
_colore = "#009036";
|
||||
break;
|
||||
|
||||
case "sBl": // blu
|
||||
_colore = "#3690FF";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
answ.Add(item.IdxStato, _colore);
|
||||
}
|
||||
string serVal = JsonConvert.SerializeObject(answ);
|
||||
memLayer.ML.setCacheVal("codColore", serVal, true);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario codici semaforo (chiave = idxStato), valore = codice semaforo
|
||||
/// </summary>
|
||||
protected Dictionary<int, string> codSemaforo
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<int, string> answ = new Dictionary<int, string>();
|
||||
if (memLayer.ML.isInCacheObject("codSemaforo"))
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("codSemaforo");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
answ = JsonConvert.DeserializeObject<Dictionary<int, string>>(serVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DS_applicazione.AnagraficaStatiRow item in Stati)
|
||||
{
|
||||
answ.Add(item.IdxStato, item.Semaforo);
|
||||
}
|
||||
string serVal = JsonConvert.SerializeObject(answ);
|
||||
memLayer.ML.setCacheVal("codSemaforo", serVal, true);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.AnagraficaStatiDataTable Stati
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("Stati"))
|
||||
{
|
||||
_Stati = taStati.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_Stati);
|
||||
memLayer.ML.setCacheVal("Stati", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("Stati");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_Stati = JsonConvert.DeserializeObject<DS_applicazione.AnagraficaStatiDataTable>(serVal);
|
||||
}
|
||||
return _Stati;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
protected DS_applicazione.AnagArticoliDataTable AnagArt
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("AnagArt"))
|
||||
{
|
||||
_AnagArt = taAnagArt.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_AnagArt);
|
||||
memLayer.ML.setCacheVal("AnagArt", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("AnagArt");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_AnagArt = JsonConvert.DeserializeObject<DS_applicazione.AnagArticoliDataTable>(serVal);
|
||||
}
|
||||
return _AnagArt;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.AnagraficaEventiDataTable AnagraficaEventi
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("AnagraficaEventi"))
|
||||
{
|
||||
_AnagraficaEventi = taAnagraficaEventi.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_AnagraficaEventi);
|
||||
memLayer.ML.setCacheVal("AnagraficaEventi", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("AnagraficaEventi");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_AnagraficaEventi = JsonConvert.DeserializeObject<DS_applicazione.AnagraficaEventiDataTable>(serVal);
|
||||
}
|
||||
return _AnagraficaEventi;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.DiarioDiBordoDataTable DiarioDiBordo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DiarioDiBordo == null)
|
||||
{
|
||||
_DiarioDiBordo = taDiarioDiBordo.GetData();
|
||||
}
|
||||
return _DiarioDiBordo;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.MacchineDataTable Macchine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("Macchine"))
|
||||
{
|
||||
_Macchine = taMacchine.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_Macchine);
|
||||
memLayer.ML.setCacheVal("Macchine", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("Macchine");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_Macchine = JsonConvert.DeserializeObject<DS_applicazione.MacchineDataTable>(serVal);
|
||||
}
|
||||
return _Macchine;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.StatoMacchineDataTable StatoMacchine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("StatoMacchine"))
|
||||
{
|
||||
_StatoMacchine = taStatoMacchine.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_StatoMacchine);
|
||||
memLayer.ML.setCacheVal("StatoMacchine", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("StatoMacchine");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_StatoMacchine = JsonConvert.DeserializeObject<DS_applicazione.StatoMacchineDataTable>(serVal);
|
||||
}
|
||||
return _StatoMacchine;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// avvio i table adapter della classe
|
||||
/// </summary>
|
||||
private void AvviaTabAdapt()
|
||||
{
|
||||
taMacchine = new MapoDb.DS_applicazioneTableAdapters.MacchineTableAdapter();
|
||||
taStatoMacchine = new MapoDb.DS_applicazioneTableAdapters.StatoMacchineTableAdapter();
|
||||
taStati = new MapoDb.DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter();
|
||||
taDiarioDiBordo = new MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter();
|
||||
taParetoDurate = new MapoDb.DS_applicazioneTableAdapters.ParetoDurateTableAdapter();
|
||||
taAnagraficaEventi = new MapoDb.DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter();
|
||||
taAnagArt = new MapoDb.DS_applicazioneTableAdapters.AnagArticoliTableAdapter();
|
||||
taAnagOpr = new MapoDb.DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter();
|
||||
taTempiCiclo = new MapoDb.DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// recupera sequenza x una SINGOLA macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="_intervallo"></param>
|
||||
/// <param name="numSplit"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
private List<visjsDsItem> seqSingleMachine(string idxMacchina, intervalloDate _intervallo, int numSplit, int index)
|
||||
{
|
||||
List<visjsDsItem> sequenza = new List<visjsDsItem>();
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
DateTime start = DateTime.Now;
|
||||
// leggo i dati e costituisco una collezione...
|
||||
int i = index;
|
||||
if (idxMacchina != null && idxMacchina != "")
|
||||
{
|
||||
logger.lg.scriviLog("inizio WS");
|
||||
stopwatch.Restart();
|
||||
// seleziono i dati...
|
||||
DS_applicazione.DiarioDiBordoDataTable tabSeq = taDiarioDiBordo.GetSequenza(idxMacchina, _intervallo.inizio, _intervallo.fine);
|
||||
logger.lg.scriviLog(string.Format("Letta tabella: {0} rec, {1} msec", tabSeq.Rows.Count, stopwatch.ElapsedMilliseconds));
|
||||
|
||||
// se ho troppi dati faccio la riduzione dei dati, MAX numSplit...
|
||||
if (tabSeq.Rows.Count > numSplit)
|
||||
{
|
||||
double sogliaMin = _intervallo.fine.Subtract(_intervallo.inizio).TotalMinutes / numSplit;
|
||||
tabSeq = riduciSeq(tabSeq, sogliaMin);
|
||||
}
|
||||
logger.lg.scriviLog(string.Format("Riduzione seq fatta: {0} rec, {1} msec", tabSeq.Count, stopwatch.ElapsedMilliseconds));
|
||||
// ora converto in oggetto definitivo x vis.js
|
||||
sequenza = tabSeq.AsEnumerable().Select(riga => new visjsDsItem
|
||||
{
|
||||
//id = i,
|
||||
content = "",//riga.CodArticolo,
|
||||
start = riga.InizioStato.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
end = riga.FineStato.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
group = riga.IdxMacchina,// "1", // per mostrare multi macchine
|
||||
type = "background", // importante x non vedere bordi...
|
||||
className = semaforoDaIdxStato(riga.IdxStato)
|
||||
}).ToList();
|
||||
|
||||
foreach (var item in sequenza)
|
||||
{
|
||||
//item.content = i.ToString();
|
||||
item.id = i;
|
||||
i++;
|
||||
}
|
||||
logger.lg.scriviLog(string.Format("Conversione oggetto eseguita: {0} rec, {1} msec", sequenza.Count, stopwatch.ElapsedMilliseconds));
|
||||
}
|
||||
|
||||
return sequenza;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// forza la connString x i vari table adapters
|
||||
/// </summary>
|
||||
private void setConnString()
|
||||
{
|
||||
string _connectionString = memLayer.ML.confReadString("MoonProConnectionString");
|
||||
taMacchine.Connection.ConnectionString = _connectionString;
|
||||
taStatoMacchine.Connection.ConnectionString = _connectionString;
|
||||
taStati.Connection.ConnectionString = _connectionString;
|
||||
taDiarioDiBordo.Connection.ConnectionString = _connectionString;
|
||||
taParetoDurate.Connection.ConnectionString = _connectionString;
|
||||
taAnagraficaEventi.Connection.ConnectionString = _connectionString;
|
||||
taAnagArt.Connection.ConnectionString = _connectionString;
|
||||
taAnagOpr.Connection.ConnectionString = _connectionString;
|
||||
taTempiCiclo.Connection.ConnectionString = _connectionString;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua riduzione per accorpamento valori
|
||||
/// </summary>
|
||||
/// <param name="original"></param>
|
||||
/// <returns></returns>
|
||||
protected DS_applicazione.DiarioDiBordoDataTable riduciSeq(DS_applicazione.DiarioDiBordoDataTable original, double sogliaMin)
|
||||
{
|
||||
DS_applicazione.DiarioDiBordoDataTable copia = new DS_applicazione.DiarioDiBordoDataTable();
|
||||
//DS_applicazione.DiarioDiBordoRow currRow;
|
||||
// valori x setup
|
||||
double minVerde = 0.5;
|
||||
double minRosso = 0.5;
|
||||
double minSpento = 0.5;
|
||||
|
||||
double valRigaCum = 0.0;
|
||||
double valR = 0.0;
|
||||
double valG = 0.0;
|
||||
double valV = 0.0;
|
||||
double valB = 0.0;
|
||||
double valS = 0.0;
|
||||
DateTime _t_0 = new DateTime(9999, 1, 1);
|
||||
string _mostCodArticolo = "";
|
||||
int _maxVal = 0;
|
||||
foreach (var riga in original)
|
||||
{
|
||||
// salvo prima data...
|
||||
if (riga.InizioStato < _t_0)
|
||||
{
|
||||
_t_0 = riga.InizioStato;
|
||||
}
|
||||
if (riga.DurataMinuti > _maxVal)
|
||||
{
|
||||
_maxVal = Convert.ToInt32(riga.DurataMinuti);
|
||||
_mostCodArticolo = riga.CodArticolo;
|
||||
}
|
||||
valRigaCum = valRigaCum + riga.DurataMinuti;
|
||||
// accumulo valori...
|
||||
switch (semaforoDaIdxStato(riga.IdxStato))
|
||||
{
|
||||
case "sVe":
|
||||
valV = valV + riga.DurataMinuti;
|
||||
break;
|
||||
|
||||
case "sGi":
|
||||
valG = valG + riga.DurataMinuti;
|
||||
break;
|
||||
|
||||
case "sRo":
|
||||
valR = valR + riga.DurataMinuti;
|
||||
break;
|
||||
|
||||
case "sBl":
|
||||
valB = valB + riga.DurataMinuti;
|
||||
break;
|
||||
|
||||
case "sGr":
|
||||
valS = valS + riga.DurataMinuti;
|
||||
break;
|
||||
}
|
||||
// se è maggiore plotto...
|
||||
if (valRigaCum >= sogliaMin)
|
||||
{
|
||||
// determino il colore...
|
||||
if (valV / valRigaCum >= minVerde)
|
||||
{
|
||||
valV = 0.0;
|
||||
}
|
||||
else if (valR / valRigaCum >= minRosso)
|
||||
{
|
||||
valR = 0.0;
|
||||
}
|
||||
else if (valS / valRigaCum >= minSpento)
|
||||
{
|
||||
valS = 0.0;
|
||||
}
|
||||
else if (valB / valRigaCum >= minSpento)
|
||||
{
|
||||
valB = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
valG = 0.0;
|
||||
}
|
||||
// modifico riga corrente...
|
||||
riga.DurataMinuti = valRigaCum;
|
||||
riga.CodArticolo = _mostCodArticolo;
|
||||
//riga.InizioStato = _t_0;
|
||||
copia.ImportRow(riga);
|
||||
// modifico inizio stato...
|
||||
((DS_applicazione.DiarioDiBordoRow)copia.Rows[copia.Rows.Count - 1]).InizioStato = _t_0;
|
||||
// reset dei contatori...
|
||||
valRigaCum = 0.0;
|
||||
|
||||
_t_0 = new DateTime(9999, 1, 1);
|
||||
_mostCodArticolo = "";
|
||||
_maxVal = 0;
|
||||
}
|
||||
}
|
||||
// restituisco valori "ridotti"
|
||||
return copia;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -795,7 +357,8 @@ public class resoconti
|
||||
logger.lg.scriviLog(string.Format("FINE calcolo dati per {0} {1}", idxMacchina, rKey));
|
||||
// salvo sequenza in REDIS...
|
||||
string rData = JsonConvert.SerializeObject(_sequenza);
|
||||
// salvo in sessione l'oggetto... secondo durata impostata in web.config.. moltiplicata x numero gg...
|
||||
// salvo in sessione l'oggetto... secondo durata impostata in web.config..
|
||||
// moltiplicata x numero gg...
|
||||
memLayer.ML.setRSV(rKey, rData, 60 * memLayer.ML.CRI("seqCacheDurMin") * (int)numGG);
|
||||
logger.lg.scriviLog(string.Format("Salvato legacySeq in REDIS {0} {1}", idxMacchina, rKey));
|
||||
}
|
||||
@@ -1002,6 +565,440 @@ public class resoconti
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected DS_applicazione.AnagArticoliDataTable _AnagArt;
|
||||
protected DS_applicazione.AnagraficaOperatoriDataTable _AnagOpr;
|
||||
protected DS_applicazione.AnagraficaEventiDataTable _AnagraficaEventi;
|
||||
protected DS_applicazione.DiarioDiBordoDataTable _DiarioDiBordo;
|
||||
protected DS_applicazione.MacchineDataTable _Macchine;
|
||||
protected DS_applicazione.AnagraficaStatiDataTable _Stati;
|
||||
protected DS_applicazione.StatoMacchineDataTable _StatoMacchine;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.AnagArticoliTableAdapter taAnagArt;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter taAnagOpr;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter taAnagraficaEventi;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter taDiarioDiBordo;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.MacchineTableAdapter taMacchine;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.ParetoDurateTableAdapter taParetoDurate;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter taStati;
|
||||
protected MapoDb.DS_applicazioneTableAdapters.StatoMacchineTableAdapter taStatoMacchine;
|
||||
protected MapoDb.DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter taTempiCiclo;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected DS_applicazione.AnagArticoliDataTable AnagArt
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("AnagArt"))
|
||||
{
|
||||
_AnagArt = taAnagArt.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_AnagArt);
|
||||
memLayer.ML.setCacheVal("AnagArt", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("AnagArt");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_AnagArt = JsonConvert.DeserializeObject<DS_applicazione.AnagArticoliDataTable>(serVal);
|
||||
}
|
||||
return _AnagArt;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.AnagraficaOperatoriDataTable AnagOpr
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("AnagOpr"))
|
||||
{
|
||||
_AnagOpr = taAnagOpr.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_AnagOpr);
|
||||
memLayer.ML.setCacheVal("AnagOpr", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("AnagOpr");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_AnagOpr = JsonConvert.DeserializeObject<DS_applicazione.AnagraficaOperatoriDataTable>(serVal);
|
||||
}
|
||||
return _AnagOpr;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.AnagraficaEventiDataTable AnagraficaEventi
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("AnagraficaEventi"))
|
||||
{
|
||||
_AnagraficaEventi = taAnagraficaEventi.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_AnagraficaEventi);
|
||||
memLayer.ML.setCacheVal("AnagraficaEventi", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("AnagraficaEventi");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_AnagraficaEventi = JsonConvert.DeserializeObject<DS_applicazione.AnagraficaEventiDataTable>(serVal);
|
||||
}
|
||||
return _AnagraficaEventi;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario codici colore (chiave = idxStato), valore = codice colore
|
||||
/// </summary>
|
||||
protected Dictionary<int, string> codColore
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<int, string> answ = new Dictionary<int, string>();
|
||||
if (memLayer.ML.isInCacheObject("codColore"))
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("codColore");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
answ = JsonConvert.DeserializeObject<Dictionary<int, string>>(serVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
string _colore = "";
|
||||
foreach (DS_applicazione.AnagraficaStatiRow item in Stati)
|
||||
{
|
||||
switch (item.Semaforo)
|
||||
{
|
||||
case "sGi": // giallo
|
||||
_colore = "#ffec00";
|
||||
break;
|
||||
|
||||
case "sRo": // rosso
|
||||
_colore = "#e2001a";
|
||||
break;
|
||||
|
||||
case "sGr": // grigio - spenta
|
||||
_colore = "#bcbcbc";
|
||||
break;
|
||||
|
||||
case "sVe": // verde
|
||||
_colore = "#009036";
|
||||
break;
|
||||
|
||||
case "sBl": // blu
|
||||
_colore = "#3690FF";
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
answ.Add(item.IdxStato, _colore);
|
||||
}
|
||||
string serVal = JsonConvert.SerializeObject(answ);
|
||||
memLayer.ML.setCacheVal("codColore", serVal, true);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario codici semaforo (chiave = idxStato), valore = codice semaforo
|
||||
/// </summary>
|
||||
protected Dictionary<int, string> codSemaforo
|
||||
{
|
||||
get
|
||||
{
|
||||
Dictionary<int, string> answ = new Dictionary<int, string>();
|
||||
if (memLayer.ML.isInCacheObject("codSemaforo"))
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("codSemaforo");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
answ = JsonConvert.DeserializeObject<Dictionary<int, string>>(serVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DS_applicazione.AnagraficaStatiRow item in Stati)
|
||||
{
|
||||
answ.Add(item.IdxStato, item.Semaforo);
|
||||
}
|
||||
string serVal = JsonConvert.SerializeObject(answ);
|
||||
memLayer.ML.setCacheVal("codSemaforo", serVal, true);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.DiarioDiBordoDataTable DiarioDiBordo
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_DiarioDiBordo == null)
|
||||
{
|
||||
_DiarioDiBordo = taDiarioDiBordo.GetData();
|
||||
}
|
||||
return _DiarioDiBordo;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.MacchineDataTable Macchine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("Macchine"))
|
||||
{
|
||||
_Macchine = taMacchine.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_Macchine);
|
||||
memLayer.ML.setCacheVal("Macchine", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("Macchine");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_Macchine = JsonConvert.DeserializeObject<DS_applicazione.MacchineDataTable>(serVal);
|
||||
}
|
||||
return _Macchine;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.AnagraficaStatiDataTable Stati
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("Stati"))
|
||||
{
|
||||
_Stati = taStati.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_Stati);
|
||||
memLayer.ML.setCacheVal("Stati", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("Stati");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_Stati = JsonConvert.DeserializeObject<DS_applicazione.AnagraficaStatiDataTable>(serVal);
|
||||
}
|
||||
return _Stati;
|
||||
}
|
||||
}
|
||||
|
||||
protected DS_applicazione.StatoMacchineDataTable StatoMacchine
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!memLayer.ML.isInCacheObject("StatoMacchine"))
|
||||
{
|
||||
_StatoMacchine = taStatoMacchine.GetData();
|
||||
string serVal = JsonConvert.SerializeObject(_StatoMacchine);
|
||||
memLayer.ML.setCacheVal("StatoMacchine", serVal, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("StatoMacchine");
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
_StatoMacchine = JsonConvert.DeserializeObject<DS_applicazione.StatoMacchineDataTable>(serVal);
|
||||
}
|
||||
return _StatoMacchine;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua riduzione per accorpamento valori
|
||||
/// </summary>
|
||||
/// <param name="original"></param>
|
||||
/// <returns></returns>
|
||||
protected DS_applicazione.DiarioDiBordoDataTable riduciSeq(DS_applicazione.DiarioDiBordoDataTable original, double sogliaMin)
|
||||
{
|
||||
DS_applicazione.DiarioDiBordoDataTable copia = new DS_applicazione.DiarioDiBordoDataTable();
|
||||
//DS_applicazione.DiarioDiBordoRow currRow;
|
||||
// valori x setup
|
||||
double minVerde = 0.5;
|
||||
double minRosso = 0.5;
|
||||
double minSpento = 0.5;
|
||||
|
||||
double valRigaCum = 0.0;
|
||||
double valR = 0.0;
|
||||
double valG = 0.0;
|
||||
double valV = 0.0;
|
||||
double valB = 0.0;
|
||||
double valS = 0.0;
|
||||
DateTime _t_0 = new DateTime(9999, 1, 1);
|
||||
string _mostCodArticolo = "";
|
||||
int _maxVal = 0;
|
||||
foreach (var riga in original)
|
||||
{
|
||||
// salvo prima data...
|
||||
if (riga.InizioStato < _t_0)
|
||||
{
|
||||
_t_0 = riga.InizioStato;
|
||||
}
|
||||
if (riga.DurataMinuti > _maxVal)
|
||||
{
|
||||
_maxVal = Convert.ToInt32(riga.DurataMinuti);
|
||||
_mostCodArticolo = riga.CodArticolo;
|
||||
}
|
||||
valRigaCum = valRigaCum + riga.DurataMinuti;
|
||||
// accumulo valori...
|
||||
switch (semaforoDaIdxStato(riga.IdxStato))
|
||||
{
|
||||
case "sVe":
|
||||
valV = valV + riga.DurataMinuti;
|
||||
break;
|
||||
|
||||
case "sGi":
|
||||
valG = valG + riga.DurataMinuti;
|
||||
break;
|
||||
|
||||
case "sRo":
|
||||
valR = valR + riga.DurataMinuti;
|
||||
break;
|
||||
|
||||
case "sBl":
|
||||
valB = valB + riga.DurataMinuti;
|
||||
break;
|
||||
|
||||
case "sGr":
|
||||
valS = valS + riga.DurataMinuti;
|
||||
break;
|
||||
}
|
||||
// se è maggiore plotto...
|
||||
if (valRigaCum >= sogliaMin)
|
||||
{
|
||||
// determino il colore...
|
||||
if (valV / valRigaCum >= minVerde)
|
||||
{
|
||||
valV = 0.0;
|
||||
}
|
||||
else if (valR / valRigaCum >= minRosso)
|
||||
{
|
||||
valR = 0.0;
|
||||
}
|
||||
else if (valS / valRigaCum >= minSpento)
|
||||
{
|
||||
valS = 0.0;
|
||||
}
|
||||
else if (valB / valRigaCum >= minSpento)
|
||||
{
|
||||
valB = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
valG = 0.0;
|
||||
}
|
||||
// modifico riga corrente...
|
||||
riga.DurataMinuti = valRigaCum;
|
||||
riga.CodArticolo = _mostCodArticolo;
|
||||
//riga.InizioStato = _t_0;
|
||||
copia.ImportRow(riga);
|
||||
// modifico inizio stato...
|
||||
((DS_applicazione.DiarioDiBordoRow)copia.Rows[copia.Rows.Count - 1]).InizioStato = _t_0;
|
||||
// reset dei contatori...
|
||||
valRigaCum = 0.0;
|
||||
|
||||
_t_0 = new DateTime(9999, 1, 1);
|
||||
_mostCodArticolo = "";
|
||||
_maxVal = 0;
|
||||
}
|
||||
}
|
||||
// restituisco valori "ridotti"
|
||||
return copia;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// avvio i table adapter della classe
|
||||
/// </summary>
|
||||
private void AvviaTabAdapt()
|
||||
{
|
||||
taMacchine = new MapoDb.DS_applicazioneTableAdapters.MacchineTableAdapter();
|
||||
taStatoMacchine = new MapoDb.DS_applicazioneTableAdapters.StatoMacchineTableAdapter();
|
||||
taStati = new MapoDb.DS_applicazioneTableAdapters.AnagraficaStatiTableAdapter();
|
||||
taDiarioDiBordo = new MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter();
|
||||
taParetoDurate = new MapoDb.DS_applicazioneTableAdapters.ParetoDurateTableAdapter();
|
||||
taAnagraficaEventi = new MapoDb.DS_applicazioneTableAdapters.AnagraficaEventiTableAdapter();
|
||||
taAnagArt = new MapoDb.DS_applicazioneTableAdapters.AnagArticoliTableAdapter();
|
||||
taAnagOpr = new MapoDb.DS_applicazioneTableAdapters.AnagraficaOperatoriTableAdapter();
|
||||
taTempiCiclo = new MapoDb.DS_ProdTempiTableAdapters.TempiCicloRilevatiTableAdapter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// recupera sequenza x una SINGOLA macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="_intervallo"></param>
|
||||
/// <param name="numSplit"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
private List<visjsDsItem> seqSingleMachine(string idxMacchina, intervalloDate _intervallo, int numSplit, int index)
|
||||
{
|
||||
List<visjsDsItem> sequenza = new List<visjsDsItem>();
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
DateTime start = DateTime.Now;
|
||||
// leggo i dati e costituisco una collezione...
|
||||
int i = index;
|
||||
if (idxMacchina != null && idxMacchina != "")
|
||||
{
|
||||
logger.lg.scriviLog("inizio WS");
|
||||
stopwatch.Restart();
|
||||
// seleziono i dati...
|
||||
DS_applicazione.DiarioDiBordoDataTable tabSeq = taDiarioDiBordo.GetSequenza(idxMacchina, _intervallo.inizio, _intervallo.fine);
|
||||
logger.lg.scriviLog(string.Format("Letta tabella: {0} rec, {1} msec", tabSeq.Rows.Count, stopwatch.ElapsedMilliseconds));
|
||||
|
||||
// se ho troppi dati faccio la riduzione dei dati, MAX numSplit...
|
||||
if (tabSeq.Rows.Count > numSplit)
|
||||
{
|
||||
double sogliaMin = _intervallo.fine.Subtract(_intervallo.inizio).TotalMinutes / numSplit;
|
||||
tabSeq = riduciSeq(tabSeq, sogliaMin);
|
||||
}
|
||||
logger.lg.scriviLog(string.Format("Riduzione seq fatta: {0} rec, {1} msec", tabSeq.Count, stopwatch.ElapsedMilliseconds));
|
||||
// ora converto in oggetto definitivo x vis.js
|
||||
sequenza = tabSeq.AsEnumerable().Select(riga => new visjsDsItem
|
||||
{
|
||||
//id = i,
|
||||
content = "",//riga.CodArticolo,
|
||||
start = riga.InizioStato.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
end = riga.FineStato.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
group = riga.IdxMacchina,// "1", // per mostrare multi macchine
|
||||
type = "background", // importante x non vedere bordi...
|
||||
className = semaforoDaIdxStato(riga.IdxStato)
|
||||
}).ToList();
|
||||
|
||||
foreach (var item in sequenza)
|
||||
{
|
||||
//item.content = i.ToString();
|
||||
item.id = i;
|
||||
i++;
|
||||
}
|
||||
logger.lg.scriviLog(string.Format("Conversione oggetto eseguita: {0} rec, {1} msec", sequenza.Count, stopwatch.ElapsedMilliseconds));
|
||||
}
|
||||
|
||||
return sequenza;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// forza la connString x i vari table adapters
|
||||
/// </summary>
|
||||
private void setConnString()
|
||||
{
|
||||
string _connectionString = memLayer.ML.confReadString("MoonProConnectionString");
|
||||
taMacchine.Connection.ConnectionString = _connectionString;
|
||||
taStatoMacchine.Connection.ConnectionString = _connectionString;
|
||||
taStati.Connection.ConnectionString = _connectionString;
|
||||
taDiarioDiBordo.Connection.ConnectionString = _connectionString;
|
||||
taParetoDurate.Connection.ConnectionString = _connectionString;
|
||||
taAnagraficaEventi.Connection.ConnectionString = _connectionString;
|
||||
taAnagArt.Connection.ConnectionString = _connectionString;
|
||||
taAnagOpr.Connection.ConnectionString = _connectionString;
|
||||
taTempiCiclo.Connection.ConnectionString = _connectionString;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+139
-122
@@ -5,142 +5,159 @@ using System;
|
||||
|
||||
public class selData
|
||||
{
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Durata standard cache info
|
||||
/// </summary>
|
||||
protected int cacheDuration = 5;
|
||||
protected DataLayer DataLayerObj;
|
||||
/// <summary>
|
||||
/// classe accesso tabelle selettori
|
||||
/// </summary>
|
||||
public selData()
|
||||
{
|
||||
DataLayerObj = new DataLayer();
|
||||
}
|
||||
public static selData mng = new selData();
|
||||
|
||||
public static selData mng = new selData();
|
||||
#endregion Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// Tabella elenco Articoli
|
||||
/// NB: mantenuta in cache redis x evitare continue letture...
|
||||
/// </summary>
|
||||
/// <param name="conditio"></param>
|
||||
/// <returns></returns>
|
||||
public DS_ProdTempi.AnagArticoliDataTable getSelAllArticoli()
|
||||
{
|
||||
return DataLayerObj.taAnagArt.GetData();
|
||||
}
|
||||
/// <summary>
|
||||
/// Riga dettaglio singolo articolo
|
||||
/// NB: mantenuta in cache redis x evitare continue letture...
|
||||
/// </summary>
|
||||
/// <param name="conditio"></param>
|
||||
/// <returns></returns>
|
||||
public DS_ProdTempi.AnagArticoliRow rigaArt(string codArt)
|
||||
{
|
||||
DS_ProdTempi.AnagArticoliRow answ = null;
|
||||
// cerco in REDIS...
|
||||
string redKey = memLayer.ML.redHash("Cache:Art:" + codArt);
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
if (serVal != null && serVal != "")
|
||||
#region Public Constructors
|
||||
|
||||
/// <summary>
|
||||
/// classe accesso tabelle selettori
|
||||
/// </summary>
|
||||
public selData()
|
||||
{
|
||||
try
|
||||
{
|
||||
DS_ProdTempi.AnagArticoliDataTable tab = JsonConvert.DeserializeObject<DS_ProdTempi.AnagArticoliDataTable>(serVal);
|
||||
if (tab.Rows.Count > 0)
|
||||
DataLayerObj = new DataLayer();
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Tabella elenco Articoli
|
||||
/// NB: mantenuta in cache redis x evitare continue letture...
|
||||
/// </summary>
|
||||
/// <param name="conditio"></param>
|
||||
/// <returns></returns>
|
||||
public DS_ProdTempi.AnagArticoliDataTable getSelAllArticoli()
|
||||
{
|
||||
return DataLayerObj.taAnagArt.GetData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invalida e svuota la cache di selezione post update vari...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool invalidateCache()
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
answ = tab[0];
|
||||
string redKey = memLayer.ML.redHash("Cache:Art:");
|
||||
memLayer.ML.redFlushKey(redKey);
|
||||
redKey = memLayer.ML.redHash("Cache:StatoMacc:");
|
||||
memLayer.ML.redFlushKey(redKey);
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
logger.lg.scriviLog(string.Format("rigaArt|Errore in deserializzazione chiave {0}{1}{2}", codArt, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
}
|
||||
else
|
||||
/// <summary>
|
||||
/// Riga dettaglio singolo articolo
|
||||
/// NB: mantenuta in cache redis x evitare continue letture...
|
||||
/// </summary>
|
||||
/// <param name="conditio"></param>
|
||||
/// <returns></returns>
|
||||
public DS_ProdTempi.AnagArticoliRow rigaArt(string codArt)
|
||||
{
|
||||
// se non trovo --> DB!
|
||||
try
|
||||
{
|
||||
DS_ProdTempi.AnagArticoliDataTable tab = DataLayerObj.taAnagArt.getByCod(codArt);
|
||||
if (tab.Rows.Count > 0)
|
||||
DS_ProdTempi.AnagArticoliRow answ = null;
|
||||
// cerco in REDIS...
|
||||
string redKey = memLayer.ML.redHash("Cache:Art:" + codArt);
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
if (serVal != null && serVal != "")
|
||||
{
|
||||
answ = tab[0];
|
||||
try
|
||||
{
|
||||
DS_ProdTempi.AnagArticoliDataTable tab = JsonConvert.DeserializeObject<DS_ProdTempi.AnagArticoliDataTable>(serVal);
|
||||
if (tab.Rows.Count > 0)
|
||||
{
|
||||
answ = tab[0];
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("rigaArt|Errore in deserializzazione chiave {0}{1}{2}", codArt, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
}
|
||||
serVal = JsonConvert.SerializeObject(tab);
|
||||
memLayer.ML.setRSV(redKey, serVal, cacheDuration);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
else
|
||||
{
|
||||
// se non trovo --> DB!
|
||||
try
|
||||
{
|
||||
DS_ProdTempi.AnagArticoliDataTable tab = DataLayerObj.taAnagArt.getByCod(codArt);
|
||||
if (tab.Rows.Count > 0)
|
||||
{
|
||||
answ = tab[0];
|
||||
}
|
||||
serVal = JsonConvert.SerializeObject(tab);
|
||||
memLayer.ML.setRSV(redKey, serVal, cacheDuration);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Riga STATO macchina
|
||||
/// NB: mantenuta in cache redis x evitare continue letture...
|
||||
/// </summary>
|
||||
/// <param name="conditio"></param>
|
||||
/// <returns></returns>
|
||||
public DS_applicazione.StatoMacchineRow rigaStato(string idxMacc)
|
||||
{
|
||||
DS_applicazione.StatoMacchineRow answ = null;
|
||||
// cerco in REDIS...
|
||||
string redKey = memLayer.ML.redHash("Cache:StatoMacc:" + idxMacc);
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
if (serVal != null && serVal != "")
|
||||
{
|
||||
try
|
||||
{
|
||||
DS_applicazione.StatoMacchineDataTable tab = JsonConvert.DeserializeObject<DS_applicazione.StatoMacchineDataTable>(serVal);
|
||||
if (tab.Rows.Count > 0)
|
||||
{
|
||||
answ = tab[0];
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
||||
logger.lg.scriviLog(string.Format("rigaStato|Errore in deserializzazione chiave {0}{1}{2}", idxMacc, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
}
|
||||
else
|
||||
/// <summary>
|
||||
/// Riga STATO macchina
|
||||
/// NB: mantenuta in cache redis x evitare continue letture...
|
||||
/// </summary>
|
||||
/// <param name="conditio"></param>
|
||||
/// <returns></returns>
|
||||
public DS_applicazione.StatoMacchineRow rigaStato(string idxMacc)
|
||||
{
|
||||
// se non trovo --> DB!
|
||||
try
|
||||
{
|
||||
DS_applicazione.StatoMacchineDataTable tab = DataLayerObj.taStatoMacchine.GetDataByIdxMacchina(idxMacc);
|
||||
if (tab.Rows.Count > 0)
|
||||
DS_applicazione.StatoMacchineRow answ = null;
|
||||
// cerco in REDIS...
|
||||
string redKey = memLayer.ML.redHash("Cache:StatoMacc:" + idxMacc);
|
||||
string serVal = memLayer.ML.getRSV(redKey);
|
||||
if (serVal != null && serVal != "")
|
||||
{
|
||||
answ = tab[0];
|
||||
try
|
||||
{
|
||||
DS_applicazione.StatoMacchineDataTable tab = JsonConvert.DeserializeObject<DS_applicazione.StatoMacchineDataTable>(serVal);
|
||||
if (tab.Rows.Count > 0)
|
||||
{
|
||||
answ = tab[0];
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("rigaStato|Errore in deserializzazione chiave {0}{1}{2}", idxMacc, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
}
|
||||
serVal = JsonConvert.SerializeObject(tab);
|
||||
memLayer.ML.setRSV(redKey, serVal, cacheDuration);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
else
|
||||
{
|
||||
// se non trovo --> DB!
|
||||
try
|
||||
{
|
||||
DS_applicazione.StatoMacchineDataTable tab = DataLayerObj.taStatoMacchine.GetDataByIdxMacchina(idxMacc);
|
||||
if (tab.Rows.Count > 0)
|
||||
{
|
||||
answ = tab[0];
|
||||
}
|
||||
serVal = JsonConvert.SerializeObject(tab);
|
||||
memLayer.ML.setRSV(redKey, serVal, cacheDuration);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Invalida e svuota la cache di selezione post update vari...
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool invalidateCache()
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
string redKey = memLayer.ML.redHash("Cache:Art:");
|
||||
memLayer.ML.redFlushKey(redKey);
|
||||
redKey = memLayer.ML.redHash("Cache:StatoMacc:");
|
||||
memLayer.ML.redFlushKey(redKey);
|
||||
answ = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Durata standard cache info
|
||||
/// </summary>
|
||||
protected int cacheDuration = 5;
|
||||
|
||||
protected DataLayer DataLayerObj;
|
||||
|
||||
#endregion Protected Fields
|
||||
}
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MapoDb
|
||||
namespace MapoDb
|
||||
{
|
||||
public class selDataVoc
|
||||
{
|
||||
|
||||
+202
-188
@@ -7,226 +7,240 @@ using System;
|
||||
/// </summary>
|
||||
public class utility
|
||||
{
|
||||
MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter taStati;
|
||||
MapoDb.DS_applicazioneTableAdapters.EventListTableAdapter taEventi;
|
||||
MapoDb.DS_UtilityTableAdapters.StatoMacchineTableAdapter taSM;
|
||||
#region Public Fields
|
||||
|
||||
/// <summary>
|
||||
/// oggetto static per fare chiamate sul magazzino
|
||||
/// </summary>
|
||||
public static utility obj = new utility();
|
||||
|
||||
/// <summary>
|
||||
/// effettua primo step
|
||||
/// * se 13,4,17 --> (da lavora a cambioPallet) pulizia righe tab elenco stati x caber 1 e 2 (cambio pallet "instabile" su lavorazione)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxStatoFrom"></param>
|
||||
/// <param name="idxStatoTo"></param>
|
||||
/// <param name="idxEventoTo"></param>
|
||||
public void ripulisciStepOne(string idxMacchina, int idxStatoFrom, int idxStatoTo, int idxEventoTo)
|
||||
{
|
||||
// recupero SOLO le righe delle caber,1 alla volta...
|
||||
DS_applicazione.DiarioDiBordoDataTable tabella = taStati.GetShortChanging(idxMacchina, 1, idxStatoFrom); // prendo solo le lavorazioni...
|
||||
foreach (DS_applicazione.DiarioDiBordoRow riga in tabella)
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Effettua la masking di un valore (INT) rispetto ad una BitMask (INT)
|
||||
/// </summary>
|
||||
/// <param name="valore">Valore da filtrare</param>
|
||||
/// <param name="bitMask">BitMask (espresso in valore INT: es 1001 --> 9)</param>
|
||||
/// <returns></returns>
|
||||
public static int bMaskInt(int valore, int bitMask)
|
||||
{
|
||||
// modifico lavorazione in cambiopallet...
|
||||
taStati.UpdateStato(idxStatoTo, riga.IdxMacchina, riga.InizioStato);
|
||||
taEventi.UpdateTipo(idxEventoTo, riga.IdxMacchina, riga.InizioStato);
|
||||
return valore & bitMask;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua secondo step (eliminazione e ricalcolo durate) pulizia righe tab elenco stati
|
||||
/// * 14 --> x caber 1 e 2 (cambio pallet "instabile" su lavorazione)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxStato2reduce"></param>
|
||||
public void ripulisciStepTwo(string idxMacchina, int idxStato2reduce)
|
||||
{
|
||||
DS_applicazione.DiarioDiBordoDataTable tabella = taStati.GetData();
|
||||
// inizializzo riga...
|
||||
DS_applicazione.DiarioDiBordoRow rigaCumulo = (DS_applicazione.DiarioDiBordoRow)tabella.Rows[0];
|
||||
// controllo ogni riga, salvo i valori cumsum e start dalla prima, cancello corrente ed infine inserisco riga di sunto delle contigue...
|
||||
double durata;
|
||||
foreach (DS_applicazione.DiarioDiBordoRow riga in tabella)
|
||||
/// <summary>
|
||||
/// restituisce stringa formattata in HH:mm:ss
|
||||
/// </summary>
|
||||
/// <param name="durataMinuti"></param>
|
||||
/// <returns></returns>
|
||||
public static string durataEventoHMS(double durataMinuti)
|
||||
{
|
||||
// verifico se sia identica alla precedente...
|
||||
if (rigaCumulo.IdxStato == idxStato2reduce && riga.IdxStato == idxStato2reduce && rigaCumulo.CodArticolo == riga.CodArticolo)
|
||||
{
|
||||
if (riga.InizioStato != rigaCumulo.InizioStato)
|
||||
string durataFormattata = "";
|
||||
try
|
||||
{
|
||||
|
||||
durata = riga.FineStato.Subtract(rigaCumulo.InizioStato).TotalMinutes;
|
||||
taStati.UpdateFineDurata(riga.FineStato, (float)durata, rigaCumulo.IdxMacchina, rigaCumulo.InizioStato);
|
||||
// cancello riga duplicata
|
||||
taStati.DeleteQuery(riga.IdxMacchina, riga.InizioStato);
|
||||
DateTime tempo = new DateTime();
|
||||
tempo = tempo.AddMinutes(durataMinuti);
|
||||
durataFormattata = string.Format("{0:00}:{1:00}:{2:00}", tempo.Hour, tempo.Minute, tempo.Second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rigaCumulo = riga;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua terzo step (eliminazione e ricalcolo durate) pulizia righe tab elenco eventi
|
||||
/// * 17 --> x caber 1 e 2 (cambio pallet "instabile" su lavorazione)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxEvento2del"></param>
|
||||
public void ripulisciStepThree(string idxMacchina, int idxEvento2del)
|
||||
{
|
||||
// adesso svuoto i duplicati dalla tab eventi...
|
||||
DS_applicazione.EventListRow[] righe = (DS_applicazione.EventListRow[])taEventi.GetDataFiltered(idxMacchina, new DateTime(1999, 1, 1), new DateTime(9999, 1, 1)).Select("", "InizioStato ASC");
|
||||
DS_applicazione.EventListRow rigaEvPrev = righe[0];
|
||||
foreach (DS_applicazione.EventListRow riga in righe)
|
||||
{
|
||||
if (riga.IdxTipo == idxEvento2del && rigaEvPrev.IdxTipo == idxEvento2del && riga.CodArticolo == rigaEvPrev.CodArticolo)
|
||||
{
|
||||
if (riga.InizioStato != rigaEvPrev.InizioStato)
|
||||
catch
|
||||
{
|
||||
taEventi.DeleteQuery(riga.IdxMacchina, riga.InizioStato);
|
||||
logger.lg.scriviLog(string.Format("errore calcolo durata: durataMinuti {0}", durataMinuti), tipoLog.EXCEPTION);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rigaEvPrev = riga;
|
||||
}
|
||||
return durataFormattata;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua terzo step (eliminazione e ricalcolo durate) pulizia righe tab elenco eventi
|
||||
/// * 16/17 --> x caber 1 e 2 (cambio pallet "instabile" su lavorazione)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxEvento2del"></param>
|
||||
public void ripulisciStepFour(string idxMacchina, int idxEventoPre, int idxEvento2del)
|
||||
{
|
||||
// adesso svuoto i duplicati dalla tab eventi...
|
||||
DS_applicazione.EventListRow[] righe = (DS_applicazione.EventListRow[])taEventi.GetDataFiltered(idxMacchina, new DateTime(1999, 1, 1), new DateTime(9999, 1, 1)).Select("", "InizioStato ASC");
|
||||
DS_applicazione.EventListRow rigaEvPrev = righe[0];
|
||||
foreach (DS_applicazione.EventListRow riga in righe)
|
||||
/// <summary>
|
||||
/// effettua reset del db
|
||||
/// </summary>
|
||||
public void resetDb()
|
||||
{
|
||||
if (riga.IdxTipo == idxEvento2del && rigaEvPrev.IdxTipo == idxEventoPre && riga.CodArticolo == rigaEvPrev.CodArticolo)
|
||||
{
|
||||
if (riga.InizioStato != rigaEvPrev.InizioStato)
|
||||
taSM.stp_ZZZ_riallineaDateDb();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua ultimo step (eliminazione eventi) * 16/15 --> x Syntesy L11 (HW - machining / HW
|
||||
/// - power on) elimino se è (15/16) ed i 2 prec sono 15+16...
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxEvento1"></param>
|
||||
/// <param name="idxEvento2"></param>
|
||||
public void ripulisciStepFive(string idxMacchina, int idxEvento1, int idxEvento2)
|
||||
{
|
||||
// adesso svuoto i duplicati dalla tab eventi...
|
||||
DS_applicazione.EventListRow[] righe = (DS_applicazione.EventListRow[])taEventi.GetDataFiltered(idxMacchina, new DateTime(1999, 1, 1), new DateTime(9999, 1, 1)).Select("", "InizioStato ASC");
|
||||
DS_applicazione.EventListRow rigaMenoUno = righe[0];
|
||||
DS_applicazione.EventListRow rigaMenoDue = righe[1];
|
||||
foreach (DS_applicazione.EventListRow riga in righe)
|
||||
{
|
||||
taEventi.DeleteQuery(riga.IdxMacchina, riga.InizioStato);
|
||||
if (riga.InizioStato > rigaMenoDue.InizioStato)
|
||||
{
|
||||
if (riga.IdxTipo == idxEvento1 || riga.IdxTipo == idxEvento2)
|
||||
{
|
||||
if ((rigaMenoUno.IdxTipo == idxEvento1 && rigaMenoDue.IdxTipo == idxEvento2) || (rigaMenoUno.IdxTipo == idxEvento2 && rigaMenoDue.IdxTipo == idxEvento1))
|
||||
{
|
||||
taEventi.DeleteQuery(riga.IdxMacchina, riga.InizioStato);
|
||||
}
|
||||
}
|
||||
rigaMenoDue = rigaMenoUno;
|
||||
rigaMenoUno = riga;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rigaEvPrev = riga;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua ultimo step (eliminazione eventi) * 16/15 --> x Syntesy L11
|
||||
/// (HW - machining / HW - power on)
|
||||
/// elimino se è (15/16) ed i 2 prec sono 15+16...
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxEvento1"></param>
|
||||
/// <param name="idxEvento2"></param>
|
||||
public void ripulisciStepFive(string idxMacchina, int idxEvento1, int idxEvento2)
|
||||
{
|
||||
// adesso svuoto i duplicati dalla tab eventi...
|
||||
DS_applicazione.EventListRow[] righe = (DS_applicazione.EventListRow[])taEventi.GetDataFiltered(idxMacchina, new DateTime(1999, 1, 1), new DateTime(9999, 1, 1)).Select("", "InizioStato ASC");
|
||||
DS_applicazione.EventListRow rigaMenoUno = righe[0];
|
||||
DS_applicazione.EventListRow rigaMenoDue = righe[1];
|
||||
foreach (DS_applicazione.EventListRow riga in righe)
|
||||
/// <summary>
|
||||
/// effettua terzo step (eliminazione e ricalcolo durate) pulizia righe tab elenco eventi
|
||||
/// * 16/17 --> x caber 1 e 2 (cambio pallet "instabile" su lavorazione)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxEvento2del"></param>
|
||||
public void ripulisciStepFour(string idxMacchina, int idxEventoPre, int idxEvento2del)
|
||||
{
|
||||
if (riga.InizioStato > rigaMenoDue.InizioStato)
|
||||
{
|
||||
if (riga.IdxTipo == idxEvento1 || riga.IdxTipo == idxEvento2)
|
||||
// adesso svuoto i duplicati dalla tab eventi...
|
||||
DS_applicazione.EventListRow[] righe = (DS_applicazione.EventListRow[])taEventi.GetDataFiltered(idxMacchina, new DateTime(1999, 1, 1), new DateTime(9999, 1, 1)).Select("", "InizioStato ASC");
|
||||
DS_applicazione.EventListRow rigaEvPrev = righe[0];
|
||||
foreach (DS_applicazione.EventListRow riga in righe)
|
||||
{
|
||||
if ((rigaMenoUno.IdxTipo == idxEvento1 && rigaMenoDue.IdxTipo == idxEvento2) || (rigaMenoUno.IdxTipo == idxEvento2 && rigaMenoDue.IdxTipo == idxEvento1))
|
||||
{
|
||||
taEventi.DeleteQuery(riga.IdxMacchina, riga.InizioStato);
|
||||
}
|
||||
if (riga.IdxTipo == idxEvento2del && rigaEvPrev.IdxTipo == idxEventoPre && riga.CodArticolo == rigaEvPrev.CodArticolo)
|
||||
{
|
||||
if (riga.InizioStato != rigaEvPrev.InizioStato)
|
||||
{
|
||||
taEventi.DeleteQuery(riga.IdxMacchina, riga.InizioStato);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rigaEvPrev = riga;
|
||||
}
|
||||
}
|
||||
rigaMenoDue = rigaMenoUno;
|
||||
rigaMenoUno = riga;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// effettua reset del db
|
||||
/// </summary>
|
||||
public void resetDb()
|
||||
{
|
||||
taSM.stp_ZZZ_riallineaDateDb();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// restituisce stringa formattata in HH:mm:ss
|
||||
/// </summary>
|
||||
/// <param name="durataMinuti"></param>
|
||||
/// <returns></returns>
|
||||
public static string durataEventoHMS(double durataMinuti)
|
||||
{
|
||||
string durataFormattata = "";
|
||||
try
|
||||
/// <summary>
|
||||
/// effettua primo step
|
||||
/// * se 13,4,17 --> (da lavora a cambioPallet) pulizia righe tab elenco stati x caber 1 e 2
|
||||
/// (cambio pallet "instabile" su lavorazione)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxStatoFrom"></param>
|
||||
/// <param name="idxStatoTo"></param>
|
||||
/// <param name="idxEventoTo"></param>
|
||||
public void ripulisciStepOne(string idxMacchina, int idxStatoFrom, int idxStatoTo, int idxEventoTo)
|
||||
{
|
||||
DateTime tempo = new DateTime();
|
||||
tempo = tempo.AddMinutes(durataMinuti);
|
||||
durataFormattata = string.Format("{0:00}:{1:00}:{2:00}", tempo.Hour, tempo.Minute, tempo.Second);
|
||||
// recupero SOLO le righe delle caber,1 alla volta...
|
||||
DS_applicazione.DiarioDiBordoDataTable tabella = taStati.GetShortChanging(idxMacchina, 1, idxStatoFrom); // prendo solo le lavorazioni...
|
||||
foreach (DS_applicazione.DiarioDiBordoRow riga in tabella)
|
||||
{
|
||||
// modifico lavorazione in cambiopallet...
|
||||
taStati.UpdateStato(idxStatoTo, riga.IdxMacchina, riga.InizioStato);
|
||||
taEventi.UpdateTipo(idxEventoTo, riga.IdxMacchina, riga.InizioStato);
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
/// <summary>
|
||||
/// effettua terzo step (eliminazione e ricalcolo durate) pulizia righe tab elenco eventi
|
||||
/// * 17 --> x caber 1 e 2 (cambio pallet "instabile" su lavorazione)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxEvento2del"></param>
|
||||
public void ripulisciStepThree(string idxMacchina, int idxEvento2del)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("errore calcolo durata: durataMinuti {0}", durataMinuti), tipoLog.EXCEPTION);
|
||||
// adesso svuoto i duplicati dalla tab eventi...
|
||||
DS_applicazione.EventListRow[] righe = (DS_applicazione.EventListRow[])taEventi.GetDataFiltered(idxMacchina, new DateTime(1999, 1, 1), new DateTime(9999, 1, 1)).Select("", "InizioStato ASC");
|
||||
DS_applicazione.EventListRow rigaEvPrev = righe[0];
|
||||
foreach (DS_applicazione.EventListRow riga in righe)
|
||||
{
|
||||
if (riga.IdxTipo == idxEvento2del && rigaEvPrev.IdxTipo == idxEvento2del && riga.CodArticolo == rigaEvPrev.CodArticolo)
|
||||
{
|
||||
if (riga.InizioStato != rigaEvPrev.InizioStato)
|
||||
{
|
||||
taEventi.DeleteQuery(riga.IdxMacchina, riga.InizioStato);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rigaEvPrev = riga;
|
||||
}
|
||||
}
|
||||
}
|
||||
return durataFormattata;
|
||||
}
|
||||
/// <summary>
|
||||
/// Effettua la masking di un valore (INT) rispetto ad una BitMask (INT)
|
||||
/// </summary>
|
||||
/// <param name="valore">Valore da filtrare</param>
|
||||
/// <param name="bitMask">BitMask (espresso in valore INT: es 1001 --> 9)</param>
|
||||
/// <returns></returns>
|
||||
public static int bMaskInt(int valore, int bitMask)
|
||||
{
|
||||
return valore & bitMask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua secondo step (eliminazione e ricalcolo durate) pulizia righe tab elenco stati
|
||||
/// * 14 --> x caber 1 e 2 (cambio pallet "instabile" su lavorazione)
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="idxStato2reduce"></param>
|
||||
public void ripulisciStepTwo(string idxMacchina, int idxStato2reduce)
|
||||
{
|
||||
DS_applicazione.DiarioDiBordoDataTable tabella = taStati.GetData();
|
||||
// inizializzo riga...
|
||||
DS_applicazione.DiarioDiBordoRow rigaCumulo = (DS_applicazione.DiarioDiBordoRow)tabella.Rows[0];
|
||||
// controllo ogni riga, salvo i valori cumsum e start dalla prima, cancello corrente ed
|
||||
// infine inserisco riga di sunto delle contigue...
|
||||
double durata;
|
||||
foreach (DS_applicazione.DiarioDiBordoRow riga in tabella)
|
||||
{
|
||||
// verifico se sia identica alla precedente...
|
||||
if (rigaCumulo.IdxStato == idxStato2reduce && riga.IdxStato == idxStato2reduce && rigaCumulo.CodArticolo == riga.CodArticolo)
|
||||
{
|
||||
if (riga.InizioStato != rigaCumulo.InizioStato)
|
||||
{
|
||||
durata = riga.FineStato.Subtract(rigaCumulo.InizioStato).TotalMinutes;
|
||||
taStati.UpdateFineDurata(riga.FineStato, (float)durata, rigaCumulo.IdxMacchina, rigaCumulo.InizioStato);
|
||||
// cancello riga duplicata
|
||||
taStati.DeleteQuery(riga.IdxMacchina, riga.InizioStato);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rigaCumulo = riga;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Inizializzazione
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Constructors
|
||||
|
||||
/// <summary>
|
||||
/// init dei table adapters
|
||||
/// </summary>
|
||||
protected void initTA()
|
||||
{
|
||||
// istanzio oggetto
|
||||
taStati = new MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter();
|
||||
taEventi = new MapoDb.DS_applicazioneTableAdapters.EventListTableAdapter();
|
||||
taSM = new MapoDb.DS_UtilityTableAdapters.StatoMacchineTableAdapter();
|
||||
}
|
||||
/// <summary>
|
||||
/// effettua setup dei connection strings da web.config delal singola applicazione
|
||||
/// </summary>
|
||||
protected virtual void setupConnectionStringBase()
|
||||
{
|
||||
// connections del db
|
||||
string _connectionString = memLayer.ML.confReadString("MoonProConnectionString");
|
||||
taStati.Connection.ConnectionString = _connectionString;
|
||||
taEventi.Connection.ConnectionString = _connectionString;
|
||||
taSM.Connection.ConnectionString = _connectionString;
|
||||
}
|
||||
protected utility()
|
||||
{
|
||||
initTA();
|
||||
setupConnectionStringBase();
|
||||
}
|
||||
|
||||
#endregion Protected Constructors
|
||||
|
||||
protected utility()
|
||||
{
|
||||
initTA();
|
||||
setupConnectionStringBase();
|
||||
}
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// oggetto static per fare chiamate sul magazzino
|
||||
/// </summary>
|
||||
public static utility obj = new utility();
|
||||
/// <summary>
|
||||
/// init dei table adapters
|
||||
/// </summary>
|
||||
protected void initTA()
|
||||
{
|
||||
// istanzio oggetto
|
||||
taStati = new MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter();
|
||||
taEventi = new MapoDb.DS_applicazioneTableAdapters.EventListTableAdapter();
|
||||
taSM = new MapoDb.DS_UtilityTableAdapters.StatoMacchineTableAdapter();
|
||||
}
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// effettua setup dei connection strings da web.config delal singola applicazione
|
||||
/// </summary>
|
||||
protected virtual void setupConnectionStringBase()
|
||||
{
|
||||
// connections del db
|
||||
string _connectionString = memLayer.ML.confReadString("MoonProConnectionString");
|
||||
taStati.Connection.ConnectionString = _connectionString;
|
||||
taEventi.Connection.ConnectionString = _connectionString;
|
||||
taSM.Connection.ConnectionString = _connectionString;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private MapoDb.DS_applicazioneTableAdapters.EventListTableAdapter taEventi;
|
||||
private MapoDb.DS_UtilityTableAdapters.StatoMacchineTableAdapter taSM;
|
||||
private MapoDb.DS_applicazioneTableAdapters.DiarioDiBordoTableAdapter taStati;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
Reference in New Issue
Block a user