Example #1
0
    public DBCopy GetDBCopy(int id)
    {
        DBCopy db = null;

        DictCopy.TryGetValue(id, out db);
        return(db);
    }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="datastore"></param>
        /// <param name="keys">les parametres utilisés dans la requete</param>
        /// <param name="values"></param>
        /// <param name="superParamKey">mot cle utilise dans les parametres de nom de fichiers etc...</param>
        /// <param name="superParamValue">la valeur du mot cle</param>
        private void output(string datastore, string[] keys = null, string[] values        = null,
                            string superParamKey            = null, string superParamValue = null)
        {
            BP2SText bp2stext = null;
            string   sql      = CommandLine["sql"];
            DataSet  DS       = new DataSet();

            // fichier de la requete SQL utilisée pour extraire les données
            if (sql != null)
            {
                // formater les paramètres:
                SQLrequest p = null;
                try
                {
                    // tester si il y a des pararametres personnalise
                    if (keys != null && keys.Length > 0)
                    {
                        IntegratorBatch.InfoLogger.Debug("Lecture d une requete avec parametres : " + keys);
                        p = new SQLrequest(sql, datastore, keys, values);
                    }
                    else
                    {
                        p = new SQLrequest(sql, datastore);
                    }
                    p.Execute(out DS);
                }
                catch (Exception e)
                {
                    IntegratorBatch.ExceptionLogger.Fatal("Impossible d executer la requete " + sql, e);
                    throw e;
                }
            }
            else
            {
                Console.WriteLine(usage());
                IntegratorBatch.ExceptionLogger.Fatal("Parametre obligatoire -sql inexistant");
                // sortie car aucune requete à jouer
                return;
            }
            //------------------------------------------------------------------------------------------

            // declencher un calcul de BondPricer
            string bondPricer = CommandLine["bondPricer"];

            if (bondPricer != null)
            {
                BondPricer.OPTION opt;
                switch (bondPricer)
                {
                case "DURATION": opt = BondPricer.OPTION.DURATION; break;

                case "ACCRUEDINTEREST": opt = BondPricer.OPTION.ACCRUEDINTEREST; break;

                case "CLEANPRICE": opt = BondPricer.OPTION.CLEANPRICE; break;

                case "DIRTYPRICE": opt = BondPricer.OPTION.DIRTYPRICE; break;

                default: opt = BondPricer.OPTION.ALL; break;
                }

                BondPricer bp = new BondPricer();
                DS = bp.Execute(DS, opt);
            }

            //------------------------------------------------------------------------------------------
            if (CommandLine["bp2s"] != null)
            {
                bp2stext = new BP2SText();
                string bp2sValid = (CommandLine["bp2sregex"] == null ? @"Resources/Consumer/BP2StextValidation.txt" : CommandLine["bp2sregex"]);
                IntegratorBatch.InfoLogger.Debug("Lecture d un fichier de validation des champs (regex) " + bp2sValid);

                string bp2s = CommandLine["bp2s"];
                bp2stext.ValidationPath = bp2sValid;

                IntegratorBatch.InfoLogger.Debug("Configuration pour une sortie BP2S " + bp2s);
                bp2s = bp2s.Replace("YYYYMMDD", now.ToString("yyyyMMdd"));
                // remplacer le mot cle par sa valeur
                if (superParamKey != null)
                {
                    bp2s = bp2s.Replace(superParamKey, superParamValue);
                }

                bp2stext.CreateFile(DS, bp2s, now);
            }

            //------------------------------------------------------------------------------------------
            string excel = CommandLine["xls"];

            if (excel != null)
            {
                excel = excel.Replace("YYYYMMDD", now.ToString("yyyyMMdd"));
                // remplacer le mot cle par sa valeur
                if (superParamKey != null)
                {
                    excel = excel.Replace(superParamKey, superParamValue);
                }

                IntegratorBatch.InfoLogger.Debug("Configuration pour une sortie Excel " + excel);

                ExcelFile.CreateWorkbook(DS, excel);
            }
            //------------------------------------------------------------------------------------------
            string openXMLExcel = CommandLine["oxlsx"];

            if (openXMLExcel != null)
            {
                openXMLExcel = openXMLExcel.Replace("YYYYMMDD", now.ToString("yyyyMMdd"));
                // remplacer le mot cle par sa valeur
                if (superParamKey != null)
                {
                    openXMLExcel = openXMLExcel.Replace(superParamKey, superParamValue);
                }

                IntegratorBatch.InfoLogger.Debug("Configuration pour une sortie Open XML Excel " + openXMLExcel);

                // tester si il y a des pararametres personnalise
                string date = CommandLine["#date"] == null?now.ToString("yyyyMMdd") : CommandLine["#date"];

                string sheetNames    = CommandLine["#names"];
                string style         = CommandLine["#style"];
                string template      = CommandLine["#template"];
                string graph         = CommandLine["#graph"];
                bool   monoSheetFlag = ((CommandLine["#monoSheetFlag"] == null || CommandLine["#monoSheetFlag"] == "F" || CommandLine["#monoSheetFlag"] == "N") ? false : true);

                OpenXMLFile.CreateExcelWorkbook(DS, openXMLExcel, style, template, graph, date, sheetNames.Split(';'), monoSheetFlag);
            }
            //------------------------------------------------------------------------------------------
            string csv = CommandLine["csv"];

            if (csv != null)
            {
                string fileNames = CommandLine["#names"];
                if (fileNames != null)
                {
                    fileNames = fileNames.Replace("YYYYMMDD", now.ToString("yyyyMMdd"));
                }
                else
                {
                    fileNames = "";
                }
                // remplacer le mot cle par sa valeur
                if (superParamKey != null)
                {
                    fileNames = fileNames.Replace(superParamKey, superParamValue);
                }

                CSVFile.WriteToCSV(DS, csv, fileNames);
            }
            //------------------------------------------------------------------------------------------
            //Si include et exclude sont vide : copie la BDD en entier
            //Si include et exclude non vide : aucune table ne sera copiée
            //Si include est vide : copie tout sauf les tables comprises dans exclude
            //Si exclude est vide : copie uniquement les tables dans include
            string bdd = CommandLine["dbCopy"];

            if (bdd != null)
            {
                MSDBIntegration.InfoLogger      = IntegratorBatch.InfoLogger;
                MSDBIntegration.ExceptionLogger = IntegratorBatch.ExceptionLogger;

                string connection1 = CommandLine["#connectionSource"];
                string connection2 = CommandLine["#connectionDest"];
                // une seule liste autorisée
                List <string> liste = null;
                ListeMode     mode;
                if (CommandLine["#include"] != null)
                {
                    liste = CommandLine["#include"].Split(';').ToList();
                    mode  = ListeMode.Include;
                }
                else if (CommandLine["#include"] != null)
                {
                    liste = CommandLine["#exclude"].Split(';').ToList();
                    mode  = ListeMode.Exclude;
                }
                else
                {
                    mode = ListeMode.Aucune;
                }

                List <string> nomTable = null;
                // si il y a une option -sql , le resultat de la requete sera mis dans la ou les tables nommées nomtable
                if (sql != null)
                {
                    nomTable = CommandLine["#nomTable"].Split(';').ToList();
                    DBCopy.DataBaseCopy(connection1, connection2, DS, nomTable);
                }
                else
                {
                    //TODO
                }
            }

            //------------------------------------------------------------------------------------------
        }