public void Execute(Arguments CommandLine) { string[] inutile = CommandLine.Intercept(new string[] { "dateStart", "dateEnd", "step1", "step2", "step3", "step4", "step5", "calculate", "factsetPath", "modelClassificationPath", "notationISR", "actPtfAlimSQSLrequest", "env" }); // afficher les parametres passés et inutiles // prendre ceux qui commencent par @xxx ou #xxx qui représentent les variables if (inutile.Length > 0) { if (InfoLogger.IsInfoEnabled) { string liste = "("; foreach (string s in inutile) { if (!s.StartsWith("@") && !s.StartsWith("#")) { liste += s + " "; } } liste += ")"; if (liste.Length > 2) { InfoLogger.Info("Les parametres suivants ne sont pas exploitees: " + liste); } } } //------------------------------------------------------------------------------------------ if (CommandLine["env"] != null) { ENV = CommandLine["env"]; } //------------------------------------------------------------------------------------------ // 2 configurations: dateStart et dateEnd au format JJ/MM/AAAA , donc toutes les dates comprises entre Start et End, sauf les WE // dateStart et dateEnd au format MM/AAAA , donc toutes les fins de mois comprises entre Start et End //------------------------------------------------------------------------------------------ DateTime dStart, dEnd, dEom; bool eom_config = false; DateTime.TryParse(CommandLine["dateStart"], out dStart); if (!DateTime.TryParse(CommandLine["dateEnd"], out dEnd)) { dEnd = dStart; } if (CommandLine["dateStart"].Length <= 7) { eom_config = true; if (CommandLine["dateEnd"].Length <= 7) { // take the next 1rst day of month dEnd = dEnd.AddMonths(1); if (dEnd.DayOfWeek == DayOfWeek.Saturday) { dEnd = dEnd.AddDays(2); } else if (dEnd.DayOfWeek == DayOfWeek.Sunday) { dEnd = dEnd.AddDays(1); } } } dEom = dStart; for (DateTime dateOfData = dStart; dateOfData <= dEnd; dateOfData = dateOfData.AddDays(1)) { InfoLogger.Info("Donnees du " + dateOfData + " en cours: " + DateTime.Now.ToString()); if (dateOfData.DayOfWeek == DayOfWeek.Saturday || dateOfData.DayOfWeek == DayOfWeek.Sunday) { InfoLogger.Info("La date est un WE. Pas d integration " + dateOfData); continue; } if (eom_config) { // if the date end of month is the previous month, if ((dateOfData.Month == 1 && dEom.Month == 12) || dateOfData.Month > dEom.Month) { try { ACTION_PROCESS(dEom, CommandLine); } catch (DirectoryNotFoundException e) { InfoLogger.Error("File not found ... continue", e); } } } else { ACTION_PROCESS(dateOfData, CommandLine); } dEom = dateOfData; } }
public static void ACTION_PROCESS(DateTime d, Arguments CommandLine) { string date = d.ToString("dd/MM/yyyy"); InfoLogger.Error("PROCESSING DATE" + date); //------------------------------------------------------------------------------------------ if (CommandLine["histo"] != null) { string root = CommandLine["factsetPath"] ?? @"\\vill1\Partage\TQA\Datas Factset pour Guillaume"; string filepath = root + @"\" + CommandLine["histo"]; ACTION_PROCESS_BulkCopy_DATA_FACTSET_DATA_1(filepath); } //------------------------------------------------------------------------------------------ if (CommandLine["step1"] != null) { string root = CommandLine["factsetPath"] ?? @"\\vill1\Partage\,FGA MarketData\FACTSET"; string filepath = root + @"\" + d.ToString("yyyyMM") + @"\base_" + d.ToString("yyyyMMdd") + @".csv"; ACTION_PROCESS_BulkCopy_DATA_FACTSET_DATA_1(filepath); } //------------------------------------------------------------------------------------------ if (CommandLine["step2"] != null) { string filepath = CommandLine["modelClassificationPath"] ?? @"\\vill1\Partage\,FGA Front Office\02_Gestion_Actions\00_BASE\Base 2.0\Modele_Classification.xlsx"; ACTION_PROCESS_BulkCopy_FACTSET_MODELE_CLASSIFICATION_2(date, filepath); } //------------------------------------------------------------------------------------------ if (CommandLine["step3"] != null) { string filepath = CommandLine["notationISR"] ?? @"\\vill1\Partage\,FGA ISR\Notation Fédéris\NotationISRbase.xlsx"; try { ACTION_PROCESS_BulkCopy_IMPORT_ISR_3(filepath); } catch (System.Data.SqlClient.SqlException sqle) { if (sqle.ErrorCode == 2627) // violation Primary Key { InfoLogger.Info("Data already inserted"); } InfoLogger.Error("Problem on " + filepath, sqle); } catch (Exception e) { InfoLogger.Error("Problem on " + filepath, e); } } //------------------------------------------------------------------------------------------ if (CommandLine["step4"] != null) { string filePath = CommandLine["actPtfAlimSQSLrequest"] ?? @"\\vill1\Partage\,FGA Soft\SQL_SCRIPTS\AUTOMATE\GESTION_ACTION\FCP_Action_BaseTitresDirects.sql"; ACTION_PROCESS_BulkCopy_Import_ACT_PTF_BaseTitreDirects_4(filePath, date); } if (CommandLine["step5"] != null) { ACTION_PROCESS_BulkCopy_Enrich_5(date); } if (CommandLine["calculate"] != null) { int to; if (!Int32.TryParse(CommandLine["timeout"], out to)) { to = 60 * 60 * 3; // 3 heures par defaut } ACTION_PROCESS_BulkCopy_Calculate_6(date, to); } }