/// <summary>
        /// Construit la liste des objets de donnees avec la reflection
        /// </summary>
        /// <param name="o"></param>
        /// <param name="recordClass"></param>
        /// <returns></returns>
        private static List <Object> analyse(EtlFullResult o, Type recordClass)
        {
            IEnumerable <Row> all     = o.Data;
            List <Object>     objects = new List <Object>();

            foreach (Row items in all)
            {
                string member   = null;
                object instance = Activator.CreateInstance(recordClass);

                foreach (PropertyInfo info in GetProperties(instance))
                {
                    member = info.Name;
                    if (items.Contains(info.Name) && info.CanWrite)
                    {
                        info.SetValue(instance, items[info.Name], null);
                    }
                }
                foreach (FieldInfo info in GetFields(instance))
                {
                    member = info.Name;
                    if (items.Contains(info.Name))
                    {
                        info.SetValue(instance, items[info.Name]);
                    }
                }

                objects.Add(instance);
            }
            return(objects);
        }
        public void PortfolioOmegaHoldingETLTest()
        {
            string request = SQLRequest.SelectPortfolio.Replace("***", "18/04/2012").Replace("%%%", "'MN'");

            // classe dynamique generee par un fichier xml
            ClassBuilder cd          = ClassBuilder.LoadFromXml(ROOT + "PortfolioOmega.fhw");
            Type         recordClass = cd.CreateRecordClass();

            EtlFullResult result =
                Input.Query("OMEGA_PROD", request)
                //               .Transform(UsersToPeopleActions.SplitUserName)
                .WriteFile("resultfileOMEGA_ETL.txt", recordClass)
                //                .DbCommand("test", UsersToPeopleActions.WritePeople)
                //.Record()
                //.ConsoleCount("Omega Load")
                .Execute();

            analyse(result, recordClass);
        }
示例#3
0
        public static void VerifyResult(EtlFullResult result)
        {
            result.Completed.ShouldBe(true);
            result.Count.ShouldBe(4);
            result.CountExceptions.ShouldBe(0);

            System.Collections.Generic.List <string[]> names = Use.Transaction <System.Collections.Generic.List <string[]> >("test", delegate(IDbCommand cmd)
            {
                System.Collections.Generic.List <string[]> tuples = new System.Collections.Generic.List <string[]>();
                cmd.CommandText = "SELECT firstname, lastname from people order by userid";
                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        tuples.Add(new string[] { reader.GetString(0), reader.GetString(1) });
                    }
                }
                return(tuples);
            });
            BaseUserToPeopleTest.AssertNames(names);
        }
        public static void VerifyResult(EtlFullResult result)
        {
            Assert.True(result.Completed);
            Assert.Equal(4, result.Count);
            Assert.Equal(0, result.CountExceptions);

            System.Collections.Generic.List<string[]> names = Use.Transaction<System.Collections.Generic.List<string[]>>("test", delegate(IDbCommand cmd)
            {
                System.Collections.Generic.List<string[]> tuples = new System.Collections.Generic.List<string[]>();
                cmd.CommandText = "SELECT firstname, lastname from people order by userid";
                using (IDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        tuples.Add(new string[] { reader.GetString(0), reader.GetString(1) });
                    }
                }
                return tuples;
            });
            BaseUserToPeopleTest.AssertNames(names);
        }