Пример #1
0
        public static void ExercicioH(string cs, String isin, DateTime date, decimal val)
        {
            try
            {
                using (var ts = new TransactionScope())
                {
                    IMapperInstrumento mapper       = new MapperInstrumento();
                    IMapperTriplo      mapperTriplo = new MapperTriplo();

                    Console.WriteLine("Instrumento Antes do Procedimento:");
                    Console.WriteLine(mapper.Read(isin).ToString());

                    Triplo triplo = new Triplo()
                    {
                        Identificacao = isin,
                        Dia           = date,
                        Valor         = val
                    };

                    Console.WriteLine("Criação de triplo");
                    mapperTriplo.Create(triplo);

                    Console.WriteLine("\nChamada ao procedimento.\n");
                    P_atualizaValorFunc(new SqlConnection(cs));

                    Console.WriteLine("Instrumento Depois do Procedimento:");
                    Console.WriteLine(mapper.Read(isin).ToString());
                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Excepção apanhada : " + ex.Message);
            }
        }
Пример #2
0
        public static void ExercicioG(string cs, string isin)
        {
            try
            {
                Console.WriteLine("\nInformação de instrumento :");

                IMapperInstrumento mapper = new MapperInstrumento();
                Console.WriteLine(mapper.Read(isin).ToString());

                using (var ts = new TransactionScope())
                {
                    //Processar novos triplos, caso existam
                    P_atualizaValorFunc(new SqlConnection(cs));

                    Media6meses(new SqlConnection(cs), isin);

                    ts.Complete();
                }

                Console.WriteLine("\nInformação de instrumento :");
                Console.WriteLine(mapper.Read(isin).ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Excepção apanhada : " + ex.Message);
            }
        }
Пример #3
0
        public static void Exercicio1B_Update(string isin, DateTime date, int val)
        {
            try
            {
                using (var ts = new TransactionScope())
                {
                    RegistoKey            key                  = new RegistoKey(isin, date.Date);
                    IMapperRegisto        mapperRegisto        = new MapperRegisto();
                    IMapperValoresMercado mapperValoresMercado = new MapperValoresMercado();
                    IMapperInstrumento    mapperInstrumento    = new MapperInstrumento();

                    Instrumento instrumento = mapperInstrumento.Read(isin);

                    Console.WriteLine("Informação de valores de mercado antes do update:");
                    Console.WriteLine(mapperValoresMercado.Read(new ValoresMercadoKey(instrumento.CodigoMercado, date)).ToString());

                    //Update
                    Registo registo = mapperRegisto.Read(key);
                    registo.ValorAbertura = val;
                    mapperRegisto.Update(registo);
                    Console.WriteLine("\nUpdate\n");

                    Console.WriteLine("Informação de valores de mercado depois do update:");
                    Console.WriteLine(mapperValoresMercado.Read(new ValoresMercadoKey(instrumento.CodigoMercado, date)).ToString() + "\n");

                    ts.Complete();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Excepção apanhada : " + ex.Message);
            }
        }