Esempio n. 1
0
        public void Inicia(int nRows, bool bPooling, bool bInstanciaCadaVez = false)
        {
            try
            {
                Stopwatch stopWatch = new Stopwatch();
                stopWatch.Start();

                for (int tries = 1; tries <= nRows; tries++)
                {
                    Console.WriteLine("Intento Nr.: " + tries.ToString());
                    Console.WriteLine();
                    ClsRetryLogic   oClsRetry = new ClsRetryLogic();
                    C.SqlConnection con       = new C.SqlConnection();
                    oClsRetry.HazUnaConexionConReintentos(GetConnectionString(bPooling), con, bInstanciaCadaVez);
                    con.Close();
                }
                stopWatch.Stop();
                // Obtenemos el tiempo pasado
                TimeSpan ts = stopWatch.Elapsed;

                // Formateamos y mostramos.
                string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                   ts.Hours, ts.Minutes, ts.Seconds,
                                                   ts.Milliseconds / 10);
                Console.WriteLine("Tipo de Objeto:{0}. Tiempo:{1}", bPooling?"Pooling":"Sin Pooling", elapsedTime);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                Console.WriteLine("Ups!! " + e.Message);
                Console.ReadLine();
            }
        }
Esempio n. 2
0
        public void Inicia()
        {
            try
            {
                ClsRetryLogic oClsRetry     = new ClsRetryLogic();
                SqlConnection sqlConnection = new SqlConnection();
                if (oClsRetry.HazUnaConexionConReintentos(ConfigurationManager.ConnectionStrings["DataMasking"].ToString(), sqlConnection))
                {
                    SqlCommand oCmd = new SqlCommand();
                    oCmd.CommandText = "SELECT * FROM Contacto";
                    oCmd.Connection  = sqlConnection;
                    SqlDataReader oReader = oCmd.ExecuteReader();
                    while (oReader.Read())
                    {
                        Console.WriteLine(oReader.GetName(0) + ":" + oReader.GetSqlInt32(0).ToString());
                        Console.WriteLine(oReader.GetName(1) + ":" + oReader.GetSqlString(1));
                        Console.WriteLine(oReader.GetName(2) + ":" + oReader.GetSqlString(2));
                        Console.WriteLine(oReader.GetName(3) + ":" + oReader.GetSqlString(3));
                        Console.WriteLine(oReader.GetName(4) + ":" + oReader.GetSqlString(4));
                        Console.WriteLine();
                        Console.WriteLine("Pulsar para cerrar");
                        Console.ReadLine();
                    }
                    oReader.Close();
                    Console.WriteLine("Pulsar para mostrar ahora como protegemos a nivel de fila");

                    SqlCommand oCmdV = new SqlCommand();
                    oCmdV.CommandText = "SELECT * FROM Protegido";
                    oCmdV.Connection  = sqlConnection;
                    SqlDataReader oReaderV = oCmdV.ExecuteReader();
                    while (oReaderV.Read())
                    {
                        Console.WriteLine(oReaderV.GetName(0) + ":" + oReaderV.GetSqlInt32(0).ToString());
                        Console.WriteLine(oReaderV.GetName(1) + ":" + oReaderV.GetSqlString(1));
                        Console.WriteLine(oReaderV.GetName(2) + ":" + oReaderV.GetSqlString(2));
                        Console.WriteLine(oReaderV.GetName(3) + ":" + oReaderV.GetSqlString(3));
                        Console.WriteLine(oReaderV.GetName(4) + ":" + oReaderV.GetSqlString(4));
                        Console.WriteLine();
                        Console.WriteLine("Pulsar para cerrar");
                        Console.ReadLine();
                    }
                    oReaderV.Close();
                    Console.WriteLine("Pulsar para cerrar");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Ups!!" + e.Message);
            }
        }