1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| private void RunThread()
{
DateTime lastTime = System.DateTime.Now;
try
{
myTimerTotal = new System.Timers.Timer(1000);
myTimerTotal.Elapsed += new ElapsedEventHandler(OnTotalTimedEvent);
myTimerTotal.Enabled = true;
myTimerTotal.Start();
myTimer = new System.Timers.Timer(100);
myTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
myTimer.Enabled = true;
myTimer.Start();
Trace.WriteLine(" Start: " + lastTime.TimeOfDay);
step = 1;
triggerShowProgress(0, 5, "Etape 1 sur 5");
triggerShowDetailProgress(0, 0, "Checking Rules...");
// Get calc infos
//Presta3.Calculation.Data._2_PrepareData.DataPrepare.GetCalculationInfos(ref param);
//param.CalcErrors = Presta3.Calculation.Data._2_PrepareData.DataPrepare.GetErrorMessages(param);
// 1 Check Rules
if (!CheckRules())
{
this.hasErrors = true;
this.param.CalcStatus = CalcStatus.OnError;
throw new ArgumentException("Checking Rules Failed!");
}
triggerShowProgress(1, 5, "Etape 1 sur 5 terminée.");
this.triggerStepEnd(step, this.hasErrors, this.param);
// 2 PrepareObjects on DB
step = 2;
myTimer.Stop();
this.timeCount=0;
triggerShowProgress(1, 5, "Etape 2 sur 5");
triggerShowDetailProgress(0, 0, "Préparation des données...");
myTimer.Start();
DataPrepare dp = new DataPrepare(param);
triggerShowProgress(2, 5, "Etape 2 sur 5 terminée");
this.triggerStepEnd(step, this.hasErrors, this.param);
// 3 Get Structure
step = 3;
myTimer.Stop();
this.timeCount=0;
triggerShowProgress(2, 5, "Etape 3 sur 5");
triggerShowDetailProgress(0, 0, "Préparation de la structure...");
myTimer.Start();
DataStructure ds = new DataStructure(param);
tot = ds.GetStructure();
counter = (tot.CountChildrens * 2);
param.StudentValues = ds.GetStudentValues();
triggerShowProgress(3, 5, "Etape 3 sur 5 terminée");
this.triggerStepEnd(step, this.hasErrors, this.param);
// 4 Get Prices and Calculate
step = 4;
myTimer.Stop();
triggerShowProgress(3, 5, "Etape 4 sur 5");
triggerShowDetailProgress(0, 0, "Calculation...");
myTimer.Start();
results = DoCalculation(tot);
triggerShowProgress(4, 5, "Etape 4 of 5 terminée");
this.triggerStepEnd(step, this.hasErrors, this.param);
// 5 Save Result on DB
step = 5;
myTimer.Stop();
this.timeCount=0;
triggerShowProgress(4, 5, "Etape 5 sur 5");
triggerShowDetailProgress(0, 0, "Ecriture des résultats...");
myTimer.Start();
WriteResults(results);
DataResultReplication.WriteCalcStatus(param, param.CalcStatus , param.ToleranceLimitViolation );
myTimer.Stop();
}
catch (Exception ex)
{
// Write error in log file with default error number
myTimer.Stop();
this.hasErrors = true;
this.triggerStepEnd(step, this.hasErrors, this.param);
param.LogFiles.WriteExceptionToErrorLogFile(ex);
DataResultReplication.WriteCalcStatus(param, CalcStatus.OnError,param.ToleranceLimitViolation );
}
finally
{
DataResultReplication drr = new DataResultReplication(param);
param.LogFiles.CloseFiles();
drr.WriteLogFileOnOracle();
drr.WriteErrorLogFileOnOracle();
if (this.hasErrors)
{
triggerShowProgress(step, 5, "Erreur - Calculation annulée !");
triggerShowDetailProgress(0, 5, "Erreur - Calculation annulée !");
}
else
{
triggerShowDetailProgress(5, 5, "Ecriture des résultats terminée !");
triggerShowProgress(5, 5, "Etape 5 sur 5 terminée - Calculation terminée !");
}
this.triggerStepEnd(step, this.hasErrors, this.param);
this.triggerStepEnd(6, this.hasErrors, this.param);
myTimerTotal.Stop();
}
} |
Partager