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
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.IO;
using Microsoft.SqlServer;
using Microsoft.VisualBasic;
using Microsoft.CSharp;
using System.Diagnostics;
namespace IMR
{
class ProgramCSV // Début Programme
{
// Fonction Main
static void Main(string[] args)
{
DirectoryInfo dir = new DirectoryInfo("U:/Données FTP INPI/IMR_Donnees_Saisies/tc/flux/2017/06/01/0101/17");
Console.WriteLine("Recherche de fichier .csv :"); //Fonction de recherche de tout les fichiers .csv
foreach (var fi in dir.EnumerateFiles("*.csv",SearchOption.AllDirectories)) //On précise qu'on veut tout les répértoires
{
Console.WriteLine(fi.Name);
Console.WriteLine(DateTime.Now);
}
// On apelle les deux .exe dans notre main
Process.Start("C:/Utilitaires/UNIX2DOS.EXE");
Process.Start("C:/Utilitaires/Csv2Sql_new.exe");
}
static void LaunchCommandLineApp() //la fonction permettant de rentrer les paramétres d'execution des 2 .exe
{
const string UNIX2DOS = "C:/Utilitaires/UNIX2DOS.EXE";
const string Csv2Sql_new = "C:/Utilitaires/CsvSql_new.exe";
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.FileName = "UNIX2DOS.exe"+"Csv2Sql_new";
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.Arguments = "/K 0101_17_20170601_070828_1_PM.csv";
try
{
// On lance le programme
// On attends la fin du programme
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
// Instruction synchrone : Eviter la confusion lors de la consultations des logs
//faire des if pour push les 13 types d'objets sur les 13 tables différentes
//Possibilité d'argument : "Unix2Dos" + Filename + " Csv2Sql_new" + Filename + "IMR_INPI..ID fin de fichier /force "
//Prototype de fonction de traitement
// if fi = "*.csv"
// Lancer programme " Unix2Dos"
// if fi = "PM.csv"
// if fi = "PM_EVT.csv"
// if fi = "PP.csv"
// if fi = "PP_EVT.csv"
// if fi = "ets.csv"
// if fi = "ets_nouveau_modifie.csv"
// if fi = "ets_supprime_EVT.csv"
// if fi = "rep.csv"
// if fi = "rep_nouveau_modifie.csv"
// if fi = "rep_partant.csv"
// if fi = "obs.csv"
// if fi = "actes.csv"
// if fi = "comptes_annuels.csv"
// Lancer programme " Csv2Sql_new"
// Verifier qu'on est connecter à la BDD et à la bonne table
//Trouver un moyen d'éviter les doublons
//Tester Un premier dossier avant de lancer le tout
//Se Renseigner sur les tests unitaires
Console.ReadKey(); //On attends que l'utilisateur utilise une touche pour arrêter le processus
}
} // Fin Programme
} |
Partager