Exemple #1
0
        /// <summary>
        /// Méthode effectuant le contrôle.
        /// <returns>Retourne un booléen, vrai si le contrôle est concluant et sinon faux.</returns>
        /// </summary>
        public string  MakeControl()
        {
            string          bResultat          = ParamAppli.StatutOk;
            string          sRequete           = string.Empty;
            List <string>   lListeCCTManquants = new List <string>();
            List <TacheCCT> lTacheCCT          = new List <TacheCCT>();

            DataManagerSQLServer dataManagerSQLServer;

            try
            {
                // Chargement de la liste des tâche CCT de niveau 3 depuis la base de référence
                dataManagerSQLServer = new DataManagerSQLServer();
                sRequete             = "SELECT DEP_CCT_TASK_ID, DEP_CCT_OBJECT_TYPE, DEP_CCT_OBJECT_ID, DEP_CCT_PARENT_OBJ_ID from PNPU_DEP_REF where NIV_DEP = '3' AND ID_H_WORKFLOW = " + Process.WORKFLOW_ID;
                DataSet dsDataSet = dataManagerSQLServer.GetData(sRequete, ParamAppli.ConnectionStringBaseAppli);

                sRequete = "SELECT B.CCT_TASK_ID,A.ID_PACKAGE,A.DT_LAUNCHED from M4RDL_RAM_PACKS A,M4RDL_PACKAGES B where A.ID_PACKAGE = B.ID_PACKAGE AND B.CCT_TASK_ID IN (";
                bool   bPremier = true;
                string sCCT;

                if ((dsDataSet != null) && (dsDataSet.Tables[0].Rows.Count > 0))
                {
                    foreach (DataRow drRow in dsDataSet.Tables[0].Rows)
                    {
                        sCCT = drRow[0].ToString();
                        if (lListeCCTManquants.Contains(sCCT) == false)
                        {
                            lListeCCTManquants.Add(sCCT);
                        }
                        if (bPremier == true)
                        {
                            bPremier = false;
                        }
                        else
                        {
                            sRequete += ",";
                        }
                        sRequete += "'" + sCCT + "'";
                        lTacheCCT.Add(new TacheCCT(drRow[0].ToString(), drRow[1].ToString(), drRow[2].ToString(), drRow[3].ToString()));
                    }
                }
                sRequete += ")";

                // Recherche sur la base du client si les tâches ont été installées
                if (bPremier == false)
                {
                    dsDataSet = dataManagerSQLServer.GetData(sRequete, ParamAppli.ListeInfoClient[Process.CLIENT_ID].ConnectionStringQA1);
                    if ((dsDataSet != null) && (dsDataSet.Tables[0].Rows.Count > 0))
                    {
                        foreach (DataRow drRow in dsDataSet.Tables[0].Rows)
                        {
                            sCCT = drRow[0].ToString();
                            if (lListeCCTManquants.Contains(sCCT) == true)
                            {
                                lListeCCTManquants.Remove(sCCT);
                                for (int cpt = 0; cpt < lTacheCCT.Count; cpt++)
                                {
                                    if (lTacheCCT[cpt].CCT_TASK_ID == sCCT)
                                    {
                                        lTacheCCT.RemoveAt(cpt);
                                        cpt--;
                                    }
                                }
                            }
                        }
                    }
                }

                //POUR TEST

                /*lListeCCTManquants.Clear();
                 * lListeCCTManquants.Add("PLFR_74326");
                 * lListeCCTManquants.Add("PLFR_137306");*/
                //FIN POUR TEST

                // Recherche si la tâche CCT a été installée via une tâche générée par l'outil PNPU
                if (lListeCCTManquants.Count > 0)
                {
                    Dictionary <string, string> dCorrespondanceCCT = new Dictionary <string, string>();
                    sRequete = "SELECT CCT_TASK_ID,CCT_TASK_ID_ORG FROM PNPU_H_CCT WHERE CLIENT_ID='" + Process.CLIENT_ID + "' AND LEVEL_DEPENDANCE = 1 AND CCT_TASK_ID_ORG IN (";
                    bPremier = true;
                    foreach (string sTacheCCT in lListeCCTManquants)
                    {
                        if (bPremier == true)
                        {
                            bPremier = false;
                        }
                        else
                        {
                            sRequete += ",";
                        }
                        sRequete += "'" + sTacheCCT + "'";
                    }
                    sRequete += ")";

                    dsDataSet = dataManagerSQLServer.GetData(sRequete, ParamAppli.ConnectionStringBaseAppli);
                    if ((dsDataSet != null) && (dsDataSet.Tables[0].Rows.Count > 0))
                    {
                        sRequete = "SELECT B.CCT_TASK_ID,A.ID_PACKAGE,A.DT_LAUNCHED from M4RDL_RAM_PACKS A,M4RDL_PACKAGES B where A.ID_PACKAGE = B.ID_PACKAGE AND B.CCT_TASK_ID IN (";
                        bPremier = true;
                        foreach (DataRow drRow in dsDataSet.Tables[0].Rows)
                        {
                            dCorrespondanceCCT.Add(drRow[0].ToString(), drRow[1].ToString());
                            if (bPremier == true)
                            {
                                bPremier = false;
                            }
                            else
                            {
                                sRequete += ",";
                            }
                            sRequete += "'" + drRow[0].ToString() + "'";
                        }
                        sRequete += ")";

                        dsDataSet = dataManagerSQLServer.GetData(sRequete, ParamAppli.ListeInfoClient[Process.CLIENT_ID].ConnectionStringQA1);
                        {
                            foreach (DataRow drRow in dsDataSet.Tables[0].Rows)
                            {
                                sCCT = drRow[0].ToString();
                                if (lListeCCTManquants.Contains(dCorrespondanceCCT[sCCT]) == true)
                                {
                                    lListeCCTManquants.Remove(dCorrespondanceCCT[sCCT]);
                                    for (int cpt = 0; cpt < lTacheCCT.Count; cpt++)
                                    {
                                        if (lTacheCCT[cpt].CCT_TASK_ID == dCorrespondanceCCT[sCCT])
                                        {
                                            lTacheCCT.RemoveAt(cpt);
                                            cpt--;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                //POUR TEST
                lListeCCTManquants.Clear();
                lListeCCTManquants.Add("SFR_152319");
                lTacheCCT.Clear();
                lTacheCCT.Add(new TacheCCT("SFR_152319", "ITEM", "CFR_CALC_IJSS", "CFR_H_HR_ABSENCES_PAIE"));
                //FIN POUR TEST

                // La liste ne doit contenir que les tâches CCT non instalées sur le client
                if (lListeCCTManquants.Count > 0)
                {
                    List <string> lListeTacheCrees = new List <string>();
                    if (DupliqueTachesCCTN3(lListeCCTManquants, lTacheCCT, "PNPUN3_" + Process.WORKFLOW_ID.ToString("########0") + "_" + Process.CLIENT_ID, ref lListeTacheCrees) == false)
                    {
                        bResultat = ResultatErreur;
                    }
                    else if (lListeTacheCrees.Count > 0)
                    {
                        string              sName          = "TEST";
                        GereMDBDansBDD      gereMDBDansBDD = new GereMDBDansBDD();
                        PNPUTools.RamdlTool ramdlTool      = new RamdlTool(Process.CLIENT_ID, Process.WORKFLOW_ID);
                        ramdlTool.GeneratePackFromCCT(sName, lListeTacheCrees.ToArray());
                        Process.AjouteRapport("Génération du fichier MDB.");
                        sName = ParamAppli.GeneratePackPath + "\\" + Process.WORKFLOW_ID + "_" + Process.CLIENT_ID + "\\" + sName + ".mdb";
                        if (gereMDBDansBDD.AjouteFichiersMDBBDD(new string[] { sName }, Process.WORKFLOW_ID, ParamAppli.DossierTemporaire, ParamAppli.ConnectionStringBaseAppli, Process.CLIENT_ID, 3) == 0)
                        {
                            Process.AjouteRapport("Ajout du fichier MDB en base de données.");
                        }
                        else
                        {
                            Process.AjouteRapport("Erreur lors de l'ajout du fichier MDB en base de données.");
                            Logger.Log(Process, this, ParamAppli.StatutError, "Erreur lors de l'ajout du fichier MDB en base de données.");
                            bResultat = ParamAppli.StatutError;
                        }

                        // test MHUM
                        string[] ListeFichier = null;
                        gereMDBDansBDD.ExtraitFichiersMDBBDD(ref ListeFichier, Process.WORKFLOW_ID, ParamAppli.DossierTemporaire, ParamAppli.ConnectionStringBaseAppli);
                        ListeFichier = null;
                        gereMDBDansBDD.ExtraitFichiersMDBBDD(ref ListeFichier, Process.WORKFLOW_ID, ParamAppli.DossierTemporaire, ParamAppli.ConnectionStringBaseAppli, Process.CLIENT_ID, 1);
                        ListeFichier = null;
                        gereMDBDansBDD.ExtraitFichiersMDBBDD(ref ListeFichier, Process.WORKFLOW_ID, ParamAppli.DossierTemporaire, ParamAppli.ConnectionStringBaseAppli, Process.CLIENT_ID, 2);
                        ListeFichier = null;
                        gereMDBDansBDD.ExtraitFichiersMDBBDD(ref ListeFichier, Process.WORKFLOW_ID, ParamAppli.DossierTemporaire, ParamAppli.ConnectionStringBaseAppli, Process.CLIENT_ID, 3);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(Process, this, ParamAppli.StatutError, ex.Message);
                bResultat = ParamAppli.StatutError;
            }

            return(bResultat);
        }