Exemplo n.º 1
0
        public ControleHoraireLocal()
        {
            string path = @"C:\ProgramData\CtrlPc\PLANNING\planning.csv";

            if (File.Exists(path))
            {
                string[]     ligne          = File.ReadAllLines(path);
                int          count          = 0;
                SynchroHeure MySynchroHeure = new SynchroHeure();
                DateTime     heureactuelle  = DateTime.Now;
                try
                {
                    heureactuelle = MySynchroHeure.GetNetworkTime();
                }
                catch (Exception err)
                {
                    MyTrace.WriteLog("Récupération heure serveur KO --> " + err.Message, 1, codeappli);
                    heureactuelle = DateTime.Now;
                }
                foreach (string lignedetail in ligne)
                {
                    if (lignedetail.Contains(";"))
                    {
                        string[] colonne   = lignedetail.Split(new Char[] { ';' });
                        DateTime dateDebut = Convert.ToDateTime(colonne[0]);
                        DateTime dateFin   = Convert.ToDateTime(colonne[1]);

                        if (heureactuelle >= dateDebut && heureactuelle <= dateFin)
                        {
                            count++;
                        }
                    }
                }
                if (count == 0)
                {
                    MyTrace.WriteLog("La date n'est pas comprise parmis les plages locales", 2, codeappli);
                    MyTrace.WriteLog("Appel de l'arrêt de l'ordinateur", 2, codeappli);
                    Shutdown MyShutdown = new Shutdown();
                }
            }
            else
            {
                MyTrace.WriteLog("Le planning n'est pas présent en locale", 2, codeappli);
            }
        }
Exemplo n.º 2
0
        public void ControlePlage(string[] plage)
        {
            MyTrace.WriteLog("Contrôle des plages horaires", 2, codeappli);
            DateTime datetime = DateTime.Now;

            try
            {
                MyTrace.WriteLog("Récupération de l'heure", 2, codeappli);
                SynchroHeure MySynchroHeure = new SynchroHeure();
                datetime = MySynchroHeure.GetNetworkTime();
            }
            catch (Exception err)
            {
                datetime = DateTime.Now;
                MyTrace.WriteLog(err.Message, 1, codeappli);
            }

            string jourSem = datetime.ToString("ddd");

            MyTrace.WriteLog("Jour semaine : " + jourSem, 2, codeappli);
            int heureActuel = Int32.Parse(datetime.ToString("HHmm"));

            MyTrace.WriteLog("Heure : " + heureActuel, 2, codeappli);
            if ((jourSem.Contains("dim") && heureActuel > 1500) || jourSem.Contains("lun") || jourSem.Contains("mar") || jourSem.Contains("mer") || jourSem.Contains("jeu") || (jourSem.Contains("ven") && heureActuel < 1500))
            {
                //lecture ligne S
                foreach (string ligne in plage)
                {
                    if (ligne.Contains("S"))
                    {
                        MyTrace.WriteLog("plage : " + ligne, 2, codeappli);
                        int heuredeb = Int32.Parse(ligne.Substring(2, 4));
                        int heurefin = Int32.Parse(ligne.Substring(7, 4));


                        if (heuredeb < heureActuel || heureActuel < heurefin)
                        {
                            MyTrace.WriteLog("Arrêt demandé : " + ligne, 2, codeappli);
                            Shutdown MyShutDown = new Shutdown();
                        }
                    }
                }
            }
            else
            {
                //lecture ligne W
                foreach (string ligne in plage)
                {
                    if (ligne.Contains("W"))
                    {
                        MyTrace.WriteLog("plage : " + ligne, 2, codeappli);
                        int heuredeb = Int32.Parse(ligne.Substring(2, 4));
                        int heurefin = Int32.Parse(ligne.Substring(7, 4));


                        if (heuredeb < heureActuel || heureActuel < heurefin)
                        {
                            MyTrace.WriteLog("Arrêt demandé : " + ligne, 2, codeappli);
                            Shutdown MyShutDown = new Shutdown();
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Routine3(object sender, System.Timers.ElapsedEventArgs args)
        {
            TMroutine3.Stop();
            if (bcl3 > 1000)
            {
                bcl3 = 0;
            }
            bcl3++;
            int id = bcl3;

            MyTrace.WriteLog("RT3 : " + id.ToString() + " : Début Routine 3", 2, codeappli);
            SynchroHeure MySynchroHeure = new SynchroHeure();

            ReferenceWSCtrlPc.WSCtrlPc ws = new ReferenceWSCtrlPc.WSCtrlPc();
            Object Guid = null;

            Guid = Registry.GetValue(@"HKEY_USERS\.DEFAULT\Software\CtrlPc\Version", "GUID", null);
            DateTime dateTraitement = DateTime.Now;

            try
            {
                dateTraitement = MySynchroHeure.GetNetworkTime();
            }
            catch (Exception err)
            {
                MyTrace.WriteLog("RT3 : " + id.ToString() + " : Récupération heure serveur KO --> " + err.Message, 1, codeappli);
                dateTraitement = DateTime.Now;
            }
            try
            {
                MyTrace.WriteLog("RT3 : " + id.ToString() + " : Appel du WS --> GetExecProgram(" + Guid.ToString() + ", " + dateTraitement + ")", 2, codeappli);
                string ExecProgram = ws.GetExecProgram(Guid.ToString(), dateTraitement);
                if (ExecProgram.Length > 0 && !ExecProgram.Contains("0;0"))
                {
                    string[] ExecProgramLine = ExecProgram.Split(Environment.NewLine.ToCharArray());
                    foreach (string ligne in ExecProgramLine)
                    {
                        if (ligne.Length > 0 && ligne.Contains(";"))
                        {
                            MyTrace.WriteLog("RT3 : " + id.ToString() + " : Parse de la ligne suivante : " + ligne, 2, codeappli);
                            string[] colonne = ligne.Split(';');
                            try
                            {
                                string      path          = @"c:\ProgramData\CtrlPc\SCRIPT\";
                                CtrlProcess MyCtrlProcess = new CtrlProcess();
                                if (File.Exists(path + colonne[1]) && !MyCtrlProcess.CtrlProcessRunning(colonne[1]))
                                {
                                    MyTrace.WriteLog("RT3 : " + id.ToString() + " : Process non trouvé pour l'aplpication : " + colonne[1], 2, codeappli);
                                    dateTraitement = DateTime.Now;
                                    try
                                    {
                                        dateTraitement = MySynchroHeure.GetNetworkTime();
                                    }
                                    catch (Exception err)
                                    {
                                        MyTrace.WriteLog("RT3 : " + id.ToString() + " : Récupération heure serveur KO --> " + err.Message, 1, codeappli);
                                        dateTraitement = DateTime.Now;
                                    }
                                    MyTrace.WriteLog("RT3 : " + id.ToString() + " : Appel du WS --> SetExecProgram(" + Convert.ToInt32(colonne[0]) + "," + dateTraitement + ")", 2, codeappli);
                                    ws.SetExecProgram(Convert.ToInt32(colonne[0]), dateTraitement);
                                    ExecProgram MyExecProgram = new ExecProgram(colonne[1], "0");
                                }
                                else
                                {
                                    MyTrace.WriteLog("RT3 : " + id.ToString() + " : Le program n'est^pas présent : " + ligne, 1, codeappli);
                                }
                            }
                            catch (Exception err)
                            {
                                MyTrace.WriteLog("RT3 : " + id.ToString() + " : " + err.Message, 1, codeappli);
                            }
                        }
                    }
                }
                else
                {
                    MyTrace.WriteLog("RT3 : " + id.ToString() + " : Aucun program à exécuter", 2, codeappli);
                }
            }
            catch (Exception err)
            {
                MyTrace.WriteLog("RT3 : " + id.ToString() + " : ERREUR --> " + err.Message, 1, codeappli);
                MyTrace.WriteLog("RT3 : " + id.ToString() + " : Lecture du fichier d'exécution de program", 2, codeappli);
                try
                {
                    LectureFileExecProgram MyStartRoutine1 = new LectureFileExecProgram();
                }
                catch (Exception err2)
                {
                    MyTrace.WriteLog("RT3 : " + id.ToString() + " : Lecture du fichier csv --> " + err2.Message, 1, codeappli);
                }
            }

            MyTrace.WriteLog("RT3 : " + id.ToString() + " : Fin Routine 3", 2, codeappli);
            TMroutine3.Start();
        }
Exemplo n.º 4
0
        public void Routine2(object sender, System.Timers.ElapsedEventArgs args)
        {
            TMroutine2.Stop();
            if (bcl2 > 1000)
            {
                bcl2 = 0;
            }
            bcl2++;
            int id = bcl2;

            MyTrace.WriteLog("RT2 : " + id.ToString() + " : Début routine 2", 2, codeappli);
            //Maj de la date de dernière connexion
            try
            {
                ReferenceWSCtrlPc.WSCtrlPc ws = new ReferenceWSCtrlPc.WSCtrlPc();
                Object Guid = null;
                Guid = Registry.GetValue(@"HKEY_USERS\.DEFAULT\Software\CtrlPc\Version", "GUID", null);
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : MAJ de la date de dernière connexion", 2, codeappli);
                ws.SetDateDerniereConnexion(Guid.ToString());
            }
            catch (Exception err)
            {
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : Erreur lors de l'ajout de la date de dernière connexion " + err.Message, 1, codeappli);
                throw;
            }

            //Vérification du flag d'arrêt prioritaire sur l'exception
            try
            {
                ReferenceWSCtrlPc.WSCtrlPc ws = new ReferenceWSCtrlPc.WSCtrlPc();
                Object Guid = null;
                Guid = Registry.GetValue(@"HKEY_USERS\.DEFAULT\Software\CtrlPc\Version", "GUID", null);
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : Controle présence demande d'arrêt via WS", 2, codeappli);
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : Appel du WS --> GetArret(" + Guid.ToString() + ")", 2, codeappli);
                string flagArr = ws.GetArret(Guid.ToString());
                if (flagArr.Contains("1") || flagArr.Contains("True"))
                {
                    MyTrace.WriteLog("RT2 : " + id.ToString() + " : Demande d'arrêt de la station =>" + flagArr, 2, codeappli);
                    Shutdown MyShutdown = new Shutdown();
                }
            }
            catch (Exception err)
            {
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : Erreur lors du controle d'arret --> " + err.Message, 1, codeappli);
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : Lecture du fichier arr.flg ", 2, codeappli);
                LectureFlag MyLectureFlag = new LectureFlag();
                try
                {
                    MyLectureFlag.LectureFlagArr(@"C:\ProgramData\CtrlPc\FLAG\");
                }
                catch (Exception err2)
                {
                    MyTrace.WriteLog("RT2 : " + id.ToString() + " : Erreur lors de la lecture du flag arr.flg --> " + err2.Message, 1, codeappli);
                }
            }

            //Controle de l'exception
            int exception = 0;

            try
            {
                ReferenceWSCtrlPc.WSCtrlPc ws = new ReferenceWSCtrlPc.WSCtrlPc();
                Object Guid = null;
                Guid = Registry.GetValue(@"HKEY_USERS\.DEFAULT\Software\CtrlPc\Version", "GUID", null);
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : Controle de demande d'exception", 2, codeappli);

                string result = ws.GetException(Guid.ToString());
                if (result.Contains("True") || result.Contains("1"))
                {
                    exception = 1;
                    MyTrace.WriteLog("RT2 : " + id.ToString() + " : exception => " + result, 2, codeappli);
                    MyTrace.WriteLog("RT2 : " + id.ToString() + " : Pas de contrôle d'arrêt", 2, codeappli);
                }
                else
                {
                    exception = 0;
                    MyTrace.WriteLog("RT2 : " + id.ToString() + " : exception => " + result, 2, codeappli);
                    MyTrace.WriteLog("RT2 : " + id.ToString() + " : Pas d'exception donc contrôle des planning", 2, codeappli);
                }
            }
            catch (Exception err)
            {
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : Erreur lors de la récupération de l'exception => " + err.Message, 1, codeappli);
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : Lecture du fichier nfo.flg ", 2, codeappli);
                LectureFlag MyLectureFlag = new LectureFlag();
                try
                {
                    exception = MyLectureFlag.LectureFlagNfo(@"C:\ProgramData\CtrlPc\FLAG\");
                }
                catch (Exception err2)
                {
                    MyTrace.WriteLog("RT2 : " + id.ToString() + " : Erreur lors de la lecture du flag nfo.flg --> " + err2.Message, 1, codeappli);
                }
            }
            if (exception == 0)
            {
                SynchroHeure MySynchroHeure = new SynchroHeure();
                //controle planning
                MyTrace.WriteLog("RT2 : " + id.ToString() + " : Vérification du planning", 2, codeappli);
                try
                {
                    ReferenceWSCtrlPc.WSCtrlPc ws = new ReferenceWSCtrlPc.WSCtrlPc();
                    Object Guid = null;
                    Guid = Registry.GetValue(@"HKEY_USERS\.DEFAULT\Software\CtrlPc\Version", "GUID", null);
                    DateTime dateTraitement = DateTime.Now;
                    try
                    {
                        dateTraitement = MySynchroHeure.GetNetworkTime();
                    }
                    catch (Exception err)
                    {
                        MyTrace.WriteLog("RT2 : " + id.ToString() + " : Récupération heure serveur KO --> " + err.Message, 1, codeappli);
                        dateTraitement = DateTime.Now;
                    }
                    MyTrace.WriteLog("RT2 : " + id.ToString() + " : Appel du WS --> GetPlageHoraire(" + Guid.ToString() + "," + dateTraitement + ")", 2, codeappli);
                    string stop = ws.GetPlageHoraire(Guid.ToString(), dateTraitement);
                    if (stop.Contains("0") || stop.Contains("False"))
                    {
                        MyTrace.WriteLog("RT2 : " + id.ToString() + " : Demande d'arrêt envoyé par WS --> " + stop, 2, codeappli);
                        Shutdown MyShutdown = new Shutdown();
                    }
                    else
                    {
                        MyTrace.WriteLog("RT2 : " + id.ToString() + " : Pas de demande d'arrêt de la part du WS", 2, codeappli);
                    }
                }
                catch (Exception err)
                {
                    MyTrace.WriteLog("RT2 : " + id.ToString() + " : Erreur lors de la vérification du planning via WS--> " + err.Message, 1, codeappli);
                    //vérification dans fichier
                    try
                    {
                        MyTrace.WriteLog("RT2 : " + id.ToString() + " : Contrôle du planning via fichier planning", 2, codeappli);
                        ControleHoraireLocal MyControleHoraireLocal = new ControleHoraireLocal();
                    }
                    catch (Exception err2)
                    {
                        MyTrace.WriteLog("RT2 : " + id.ToString() + " : Erreur lors du contrôle en local du planning --> " + err2.Message, 1, codeappli);
                    }
                }
            }
            MyTrace.WriteLog("RT2 : " + id.ToString() + " : Fin routine 2", 2, codeappli);
            TMroutine2.Start();
        }
Exemplo n.º 5
0
        public void Routine1(object sender, System.Timers.ElapsedEventArgs args)
        {
            TMroutine1.Stop();
            if (bcl1 > 1000)
            {
                bcl1 = 0;
            }
            bcl1++;
            int id = bcl1;

            //Exécution des program et création des fichiers de param et téléchargement des maj
            //création fichier param
            MyTrace.WriteLog("RT1 : " + id.ToString() + " : Début routine 1", 2, codeappli);
            SynchroHeure MySynchroHeure = new SynchroHeure();

            try
            {
                ReferenceWSCtrlPc.WSCtrlPc ws = new ReferenceWSCtrlPc.WSCtrlPc();
                Object Guid = null;
                Guid = Registry.GetValue(@"HKEY_USERS\.DEFAULT\Software\CtrlPc\Version", "GUID", null);
                MyTrace.WriteLog("RT1 : " + id.ToString() + " : Création de fichiers de paramètrage", 2, codeappli);
                ExecProgram MyExecProgram = new ExecProgram("GeneFileParam.exe", "0");
            }
            catch (Exception err)
            {
                MyTrace.WriteLog("RT1 : " + id.ToString() + " : Erreur lors de la création des fichier de paramètrage --> " + err.Message, 1, codeappli);
            }
            //téléchargement des fichiers :
            try
            {
                ReferenceWSCtrlPc.WSCtrlPc ws = new ReferenceWSCtrlPc.WSCtrlPc();
                Object Guid = null;
                Guid = Registry.GetValue(@"HKEY_USERS\.DEFAULT\Software\CtrlPc\Version", "GUID", null);
                MyTrace.WriteLog("RT1 : " + id.ToString() + " : Controle des fichiers à télécharger", 2, codeappli);
                DateTime dateTraitement = DateTime.Now;
                try
                {
                    dateTraitement = MySynchroHeure.GetNetworkTime();
                }
                catch (Exception err)
                {
                    MyTrace.WriteLog("RT1 : " + id.ToString() + " : Récupération heure serveur KO --> " + err.Message, 1, codeappli);
                    dateTraitement = DateTime.Now;
                }
                string FileDownload = ws.GetDownloadFile(Guid.ToString(), dateTraitement);
                if (FileDownload.Length > 0)
                {
                    string[] LstFileDownload = FileDownload.Split(Environment.NewLine.ToCharArray());
                    foreach (string ligne in LstFileDownload)
                    {
                        string argument = ligne.Replace(";", " ");
                        if (argument.Length > 3)
                        {
                            MyTrace.WriteLog("RT1 : " + id.ToString() + " : Téléchargement de " + ligne, 2, codeappli);
                            ExecProgram MyExecProgram = new ExecProgram("DownloadFile.exe", argument);
                            MyTrace.WriteLog("RT1 : " + id.ToString() + " : Téléchargement terminé de " + ligne, 2, codeappli);
                            //mise a jour de la bdd via ws
                            string[] colonne = ligne.Split(new Char[] { ';' });
                            try
                            {
                                dateTraitement = MySynchroHeure.GetNetworkTime();
                            }
                            catch (Exception err)
                            {
                                MyTrace.WriteLog("RT1 : " + id.ToString() + " : Récupération heure serveur KO --> " + err.Message, 1, codeappli);
                                dateTraitement = DateTime.Now;
                            }
                            //Vérification si le fichier a bien été téléchargé
                            //string pathControle = ligne.Replace(";", @"\");
                            if (File.Exists(@"c:\ProgramData\CtrlPc\" + colonne[0] + @"\" + colonne[1]))
                            {
                                MyTrace.WriteLog("RT1 : " + id.ToString() + " :Téléchargement réussi : " + colonne[0] + @"\" + colonne[1], 2, codeappli);
                                MyTrace.WriteLog("RT1 : " + id.ToString() + " : Appel du WS --> SetDownloadFile(" + Guid.ToString() + "," + dateTraitement + "," + colonne[0] + "," + colonne[1] + ")", 2, codeappli);
                                ws.SetDownloadFile(Guid.ToString(), dateTraitement, colonne[0], colonne[1]);
                            }
                            else
                            {
                                MyTrace.WriteLog("RT1 : " + id.ToString() + " : Téléchargement KO : " + colonne[0] + @"\" + colonne[1], 1, codeappli);
                            }
                        }
                        else
                        {
                            MyTrace.WriteLog("RT1 : " + id.ToString() + " : Aucun fichier à télécharger ", 2, codeappli);
                        }
                    }
                }
                else
                {
                    MyTrace.WriteLog("RT1 : " + id.ToString() + " : Aucun fichier à télécharger ", 2, codeappli);
                }
            }
            catch (Exception err)
            {
                MyTrace.WriteLog("RT1 : " + id.ToString() + " : Erreur lors du téléchargement --> " + err.Message, 1, codeappli);
                MyTrace.WriteLog("RT1 : " + id.ToString() + " : Erreur lors du téléchargement détail--> " + err.StackTrace, 1, codeappli);
            }

            MyTrace.WriteLog("RT1 : " + id.ToString() + " : Fin routine 1", 2, codeappli);
            TMroutine1.Start();
        }
Exemplo n.º 6
0
        private int type        = 3; //tout
        public void WriteLog(string arg0, int arg1, string arg2)
        {
            if (File.Exists(@"c:\ProgramData\CtrlPc\SCRIPT\RemLog.nfo"))
            {
                using (FileStream filestream = new FileStream(@"c:\ProgramData\CtrlPc\SCRIPT\RemLog.nfo", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (StreamReader read = new StreamReader(filestream))
                    {
                        string ligne;
                        while ((ligne = read.ReadLine()) != null)
                        {
                            if (ligne.Length > 2)
                            {
                                string[] colonne = ligne.Split(';');
                                Int32.TryParse(colonne[0], out status);
                                Int32.TryParse(colonne[1], out statusParam);
                                Int32.TryParse(colonne[2], out type);
                            }
                        }
                    }
                }
            }
            SynchroHeure MySynchroHeure = new SynchroHeure();
            DateTime     dateTraitement = DateTime.Now;

            try
            {
                dateTraitement = MySynchroHeure.GetNetworkTime();
            }
            catch (Exception err)
            {
                dateTraitement = DateTime.Now;
            }
            if (status == 3 && statusParam == 3)//mode journal
            {
                try
                {
                    ProcessStartInfo startinfo = new ProcessStartInfo();
                    if (arg1 == 1 && (type == 3 || type == 1))
                    {
                        startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                        startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "JOURNAL" + "\"";
                        Process Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                    }
                    if (arg1 == 2 && (type == 3 || type == 2))
                    {
                        startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                        startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "JOURNAL" + "\"";
                        Process Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                    }
                }
                catch (Exception err)//erreur d'écriture dans le journal
                {
                    string NameDate = dateTraitement.ToString("yyyyMMdd");
                    string Date     = dateTraitement.ToString("dd/MM/yyyy HH:mm:ss");
                    using (StreamWriter writer = File.AppendText(@"C:\ProgramData\CtrlPc\LOG\JOURNAL_ERREUR__" + NameDate + ".log"))
                    {
                        writer.WriteLine(Date + "     " + arg2 + "     " + "ERREUR : " + err.Message);
                    }
                }
            }
            else if (status == 2 && statusParam == 2) //mode WS
            {
                try
                {
                    Object Guid = Registry.GetValue(@"HKEY_USERS\.DEFAULT\Software\CtrlPc\Version", "GUID", null);
                    ReferenceWSCtrlPc.WSCtrlPc ws = new ReferenceWSCtrlPc.WSCtrlPc();
                    string result = "OK";
                    if (arg1 == 1 && (type == 3 || type == 1))
                    {
                        result = ws.TraceLogNew(Guid.ToString(), dateTraitement, arg2, arg1, arg0);
                    }
                    if (arg1 == 2 && (type == 3 || type == 2))
                    {
                        result = ws.TraceLogNew(Guid.ToString(), dateTraitement, arg2, arg1, arg0);
                    }
                    if (result == "RELICA")
                    {
                        try
                        {
                            ProcessStartInfo startinfo = new ProcessStartInfo();
                            if (arg1 == 1 && (type == 3 || type == 1))
                            {
                                startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                                startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "RELICA" + "\"";
                                Process Trace = Process.Start(startinfo);
                                Trace.WaitForExit();
                            }
                            if (arg1 == 2 && (type == 3 || type == 2))
                            {
                                startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                                startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "RELICA" + "\"";
                                Process Trace = Process.Start(startinfo);
                                Trace.WaitForExit();
                            }
                        }
                        catch (Exception err)//erreur d'écriture
                        {
                            ProcessStartInfo startinfo = new ProcessStartInfo();
                            if (arg1 == 1 && (type == 3 || type == 1))
                            {
                                startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                                startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "RELICA_ERREUR" + "\"";
                                Process Trace = Process.Start(startinfo);
                                Trace.WaitForExit();
                                startinfo.Arguments = "\"" + err.Message + "\" " + arg1 + " " + "\"" + "RELICA_ERREUR" + "\"";
                                Trace = Process.Start(startinfo);
                                Trace.WaitForExit();
                            }
                            if (arg1 == 2 && (type == 3 || type == 2))
                            {
                                startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                                startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "RELICA_ERREUR" + "\"";
                                Process Trace = Process.Start(startinfo);
                                Trace.WaitForExit();
                            }
                        }
                    }
                }
                catch (Exception err)//erreur d'écriture via WS problème de connexion
                {
                    ProcessStartInfo startinfo = new ProcessStartInfo();
                    if (arg1 == 1 && (type == 3 || type == 1))
                    {
                        startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                        startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "JOURNAL_ERREUR" + "\"";
                        Process Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                        startinfo.Arguments = "\"" + err.Message + "\" " + arg1 + " " + "\"" + "JOURNAL_ERREUR" + "\"";
                        Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                    }
                    if (arg1 == 2 && (type == 3 || type == 2))
                    {
                        startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                        startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "JOURNAL_ERREUR" + "\"";
                        Process Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                    }
                }
            }

            if (status == 3 && statusParam == 2) //mode relica
            {
                try
                {
                    ReferenceWSCtrlPc.WSCtrlPc ws = new ReferenceWSCtrlPc.WSCtrlPc();
                    Object Guid = Registry.GetValue(@"HKEY_USERS\.DEFAULT\Software\CtrlPc\Version", "GUID", null);

                    ProcessStartInfo startinfo = new ProcessStartInfo();
                    if (arg1 == 1 && (type == 3 || type == 1))
                    {
                        startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                        startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "RELICA" + "\"";
                        Process Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                        try
                        {
                            ws.SetIncrementeRelica(Guid.ToString());
                        }
                        catch (Exception err)//erreur connexion WS
                        {
                            startinfo.Arguments = "\"" + err.Message + "\" " + arg1 + " " + "\"" + "RELICA" + "\"";
                            Trace = Process.Start(startinfo);
                            Trace.WaitForExit();
                        }
                    }
                    if (arg1 == 2 && (type == 3 || type == 2))
                    {
                        startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                        startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "RELICA" + "\"";
                        Process Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                        try
                        {
                            ws.SetIncrementeRelica(Guid.ToString());
                        }
                        catch (Exception err)//erreur connexion WS
                        {
                            startinfo.Arguments = "\"" + err.Message + "\" " + arg1 + " " + "\"" + "RELICA" + "\"";
                            Trace = Process.Start(startinfo);
                            Trace.WaitForExit();
                        }
                    }
                }
                catch (Exception err)//erreur d'écriture
                {
                    ProcessStartInfo startinfo = new ProcessStartInfo();
                    if (arg1 == 1 && (type == 3 || type == 1))
                    {
                        startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                        startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "RELICA_ERREUR" + "\"";
                        Process Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                        startinfo.Arguments = "\"" + err.Message + "\" " + arg1 + " " + "\"" + "RELICA_ERREUR" + "\"";
                        Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                    }
                    if (arg1 == 2 && (type == 3 || type == 2))
                    {
                        startinfo.FileName  = @"c:\ProgramData\CtrlPc\SCRIPT\TraceLog.exe";
                        startinfo.Arguments = "\"" + arg0 + "\" " + arg1 + " " + "\"" + "RELICA_ERREUR" + "\"";
                        Process Trace = Process.Start(startinfo);
                        Trace.WaitForExit();
                    }
                }
            }
        }