Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ChoETLFrxBootstrap.TraceLevel = System.Diagnostics.TraceLevel.Off;
            ChoETLFramework.Initialize();
            POCOSortUsingSqlite();

            //LoadDataFile();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ChoETLFrxBootstrap.TraceLevel = System.Diagnostics.TraceLevel.Error;
            ChoETLFramework.Initialize();

            dynamic hl7Message = ChoHL7Message.Parse("Sample1.csv", new ChoHL7Configuration()
            {
                Comments = new string[] { ";" }
            });

            Console.WriteLine($"Version: {hl7Message.Version}");
            Console.WriteLine($"Name: {hl7Message.GetType().FullName}");
            Console.WriteLine($"MessageType: {hl7Message.MessageType}");
            Console.WriteLine($"IsValid: {hl7Message.IsValid}");
            Console.WriteLine($"Error Line No: {hl7Message.ErrorLineNo}");
            Console.WriteLine($"Error Line: {hl7Message.ErrorLine}");
            Console.WriteLine($"Err: {hl7Message.ErrorMsg}");
            Console.WriteLine($"Err Detail: {hl7Message.ErrorDetail}");

            return;

            MSH msh = hl7Message.MSH;

            Console.WriteLine("*** Encoding Chars: " + msh.MessageType);
            //Console.WriteLine("*** PatientID: " + hl7Message.ORU_R01_RESULTS_GROUP[0]);
            //foreach (var s in hl7Message.MSH)
            Console.WriteLine(hl7Message.MSH);
            Console.WriteLine(hl7Message.EVN);
            return;

            foreach (var g in hl7Message.ORU_R01_RESULTS_GROUP)
            {
                foreach (var g1 in g.ORU_R01_PATIENT_GROUP)
                {
                    Console.WriteLine(g1.PID.PatientID);
                    Console.WriteLine(g1.PID.PatientExternalID);

                    foreach (var pi in g1.PID.PatientInternalID)
                    {
                        Console.WriteLine(pi);
                    }
                    foreach (var pi in g1.PID.PatientName)
                    {
                        Console.WriteLine(pi);
                    }

                    Console.WriteLine(g1.PID.DateOfBirth);
                    Console.WriteLine(g1.PID.Sex);
                }
                //Console.WriteLine(g1.PID.PatientID);
            }
            //Console.WriteLine(hl7Message.ToString());
            //var hl7Message = new ChoHL7Message(ChoHL7Version.v2_3);
            //var hl7MSHSegment = new ChoHL7Segment("MSH");
            //hl7MSHSegment.Fields.Add(new ChoHL7Field("1"));

            //hl7Message.Segments.Add(hl7MSHSegment);
            //Console.WriteLine(hl7Message.ToString());

            //using (var p = new ChoHL7Reader("sample1.csv"))
            //{
            //    foreach (var r in p)
            //        Console.WriteLine(r);
            //}
        }
Exemplo n.º 3
0
        private static void OldTest()
        {
            //var t = ChoTypeDescriptor.GetPropetyAttributes<ChoTypeConverterAttribute>(ChoTypeDescriptor.GetProperty<ChoTypeConverterAttribute>(typeof(EmployeeRecMeta), "Name")).ToArray();
            //return;

            //ChoMetadataObjectCache.Default.Attach(typeof(EmployeeRec), new EmployeeRecMeta());
            //string v = @"4,'123\r\n4,abc'";
            //foreach (var ss in v.SplitNTrim(",", ChoStringSplitOptions.None, '\''))
            //    Console.WriteLine(ss + "-");
            //return;

            ChoCSVRecordConfiguration config = new ChoCSVRecordConfiguration();

            //config.AutoDiscoverColumns = false;
            config.FileHeaderConfiguration.HasHeaderRecord = true;
            //config.CSVFileHeaderConfiguration.FillChar = '$';
            config.ThrowAndStopOnMissingField = false;
            //config.HasExcelSeparator = true;
            config.ColumnCountStrict = false;
            //config.MapRecordFields<EmployeeRec>();
            ChoCSVRecordFieldConfiguration idConfig = new ChoCSVRecordFieldConfiguration("Id", 1);

            idConfig.AddConverter(new IntConverter());
            config.CSVRecordFieldConfigurations.Add(idConfig);
            config.CSVRecordFieldConfigurations.Add(new ChoCSVRecordFieldConfiguration("Name", 2));
            config.CSVRecordFieldConfigurations.Add(new ChoCSVRecordFieldConfiguration("Name1", 2));

            dynamic rec = new ExpandoObject();

            rec.Id   = 1;
            rec.Name = "Raj";

            //using (var wr = new ChoCSVWriter("EmpOut.csv", config))
            //{
            //    wr.Write(new List<ExpandoObject>() { rec });
            //}

            //List<EmployeeRec> recs = new List<EmployeeRec>();
            //recs.Add(new EmployeeRec() { Id = 1, Name = "Raj" });
            //recs.Add(new EmployeeRec() { Id = 2, Name = "Mark" });

            //using (var stream = new MemoryStream())
            //using (var reader = new StreamReader(stream))
            //using (var writer = new StreamWriter(stream))
            //using (var parser = new ChoCSVWriter<EmployeeRec>(writer, config))
            //{
            //    parser.Write(recs);
            //    writer.Flush();
            //    stream.Position = 0;

            //    Console.WriteLine(reader.ReadToEnd());
            //}
            //return;

            //string txt = "Id, Name\r\n1, Mark";
            //foreach (var e in ChoCSVReader.LoadText(txt))
            //    Console.WriteLine(e.ToStringEx());
            //return;
            //dynamic row;
            //using (var stream = new MemoryStream())
            //using (var reader = new StreamReader(stream))
            //using (var writer = new StreamWriter(stream))
            //using (var parser = new ChoCSVReader(reader, config))
            //{
            //    //writer.WriteLine("Id,Name");
            //    writer.WriteLine("1,Carl");
            //    writer.WriteLine("2,Mark");
            //    writer.Flush();
            //    stream.Position = 0;

            //    while ((row = parser.Read()) != null)
            //    {
            //        Console.WriteLine(row.Id);
            //    }
            //}
            //return;

            //DataTable dt = new ChoCSVReader<EmployeeRec>("Emp.csv").AsDataTable();
            //var z = dt.Rows.Count;
            //return;

            foreach (var item in new ChoCSVReader <EmployeeRec>("Emp.csv"))
            {
                Console.WriteLine(item.ToStringEx());
            }
            return;

            //var reader = new ChoCSVReader<EmployeeRec>("Emp.csv");
            //var rec = (object)null;

            //while ((rec = reader.Read()) != null)
            //    Console.WriteLine(rec.ToStringEx());

            //var config = new ChoCSVRecordConfiguration(typeof(EmployeeRec));
            //var e = new ChoCSVReader("Emp.csv", config);
            //dynamic i;
            //while ((i = e.Read()) != null)
            //    Console.WriteLine(i.Id);

            ChoETLFramework.Initialize();
            using (var stream = new MemoryStream())
                using (var reader = new StreamReader(stream))
                    using (var writer = new StreamWriter(stream))
                        using (var parser = new ChoCSVReader <EmployeeRec>(reader))
                        {
                            writer.WriteLine("Id,Name");
                            writer.WriteLine("1,Carl");
                            writer.WriteLine("2,Mark");
                            writer.Flush();
                            stream.Position = 0;
                            //var dr = parser.AsDataReader();
                            //while (dr.Read())
                            //{
                            //    Console.WriteLine(dr[0]);
                            //}
                            object row1 = null;

                            //parser.Configuration.ColumnCountStrict = true;
                            while ((row1 = parser.Read()) != null)
                            {
                                Console.WriteLine(row1.ToStringEx());
                            }
                        }
        }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     ChoETLFramework.Initialize();
     SortByCity();
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            //string v = @"4,'123\r\n4,abc'";
            //foreach (var ss in v.SplitNTrim(",", ChoStringSplitOptions.None, '\''))
            //    Console.WriteLine(ss + "-");
            //return;
            dynamic rec = new ExpandoObject();

            rec.Id   = 1;
            rec.Name = "Raj";

            using (var wr = new ChoCSVWriter("EmpOut.csv"))
            {
                wr.Write(new List <ExpandoObject>()
                {
                    rec
                });
            }
            return;

            ChoCSVRecordConfiguration config = new ChoCSVRecordConfiguration();

            //config.AutoDiscoverColumns = false;
            config.CSVFileHeaderConfiguration.HasHeaderRecord = true;
            config.ThrowAndStopOnMissingField = true;
            //config.MapRecordFields<EmployeeRec>();
            //config.RecordFieldConfigurations.Add(new ChoCSVRecordFieldConfiguration("Id", 1));
            //config.RecordFieldConfigurations.Add(new ChoCSVRecordFieldConfiguration("Name", 2));

            //dynamic row;
            //using (var stream = new MemoryStream())
            //using (var reader = new StreamReader(stream))
            //using (var writer = new StreamWriter(stream))
            //using (var parser = new ChoCSVReader(reader, config))
            //{
            //    writer.WriteLine("Id,Name");
            //    writer.WriteLine("1,Carl");
            //    writer.WriteLine("2,Mark");
            //    writer.Flush();
            //    stream.Position = 0;

            //    while ((row = parser.Read()) != null)
            //    {
            //        Console.WriteLine(row.Id);
            //    }
            //}
            //return;

            //DataTable dt = new ChoCSVReader<EmployeeRec>("Emp.csv").AsDataTable();
            //var z = dt.Rows.Count;
            //return;

            foreach (var e in new ChoCSVReader <EmployeeRec>("Emp.csv"))
            {
                Console.WriteLine(e.ToStringEx());
            }
            return;

            //var reader = new ChoCSVReader<EmployeeRec>("Emp.csv");
            //var rec = (object)null;

            //while ((rec = reader.Read()) != null)
            //    Console.WriteLine(rec.ToStringEx());

            //var config = new ChoCSVRecordConfiguration(typeof(EmployeeRec));
            //var e = new ChoCSVReader("Emp.csv", config);
            //dynamic i;
            //while ((i = e.Read()) != null)
            //    Console.WriteLine(i.Id);

            ChoETLFramework.Initialize();
            using (var stream = new MemoryStream())
                using (var reader = new StreamReader(stream))
                    using (var writer = new StreamWriter(stream))
                        using (var parser = new ChoCSVReader <EmployeeRec>(reader))
                        {
                            writer.WriteLine("Id,Name");
                            writer.WriteLine("1,Carl");
                            writer.WriteLine("2,Mark");
                            writer.Flush();
                            stream.Position = 0;
                            //var dr = parser.AsDataReader();
                            //while (dr.Read())
                            //{
                            //    Console.WriteLine(dr[0]);
                            //}
                            object row = null;

                            //parser.Configuration.ColumnCountStrict = true;
                            while ((row = parser.Read()) != null)
                            {
                                Console.WriteLine(row.ToStringEx());
                            }
                        }
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            ChoCSVRecordConfiguration config = new ChoCSVRecordConfiguration();

            config.RecordFieldConfigurations.Add(new ChoCSVRecordFieldConfiguration("Id", 1));
            config.RecordFieldConfigurations.Add(new ChoCSVRecordFieldConfiguration("Name", 2));

            dynamic row;

            using (var stream = new MemoryStream())
                using (var reader = new StreamReader(stream))
                    using (var writer = new StreamWriter(stream))
                        using (var parser = new ChoCSVReader(reader, config))
                        {
                            writer.WriteLine("1,Carl");
                            writer.WriteLine("2,Mark");
                            writer.Flush();
                            stream.Position = 0;

                            while ((row = parser.Read()) != null)
                            {
                                Console.WriteLine(row.Name);
                            }
                        }
            return;

            //DataTable dt = new ChoCSVReader<EmployeeRec>("Emp.csv").AsDataTable();
            //var z = dt.Rows.Count;
            //return;

            //foreach (var e in new ChoCSVReader<EmployeeRec>("Emp.csv"))
            //    Console.WriteLine(e.ToStringEx());

            //var reader = new ChoCSVReader<EmployeeRec>("Emp.csv");
            //var rec = (object)null;

            //while ((rec = reader.Read()) != null)
            //    Console.WriteLine(rec.ToStringEx());

            //var config = new ChoCSVRecordConfiguration(typeof(EmployeeRec));
            //var e = new ChoCSVReader("Emp.csv", config);
            //dynamic i;
            //while ((i = e.Read()) != null)
            //    Console.WriteLine(i.Id);

            ChoETLFramework.Initialize();
            using (var stream = new MemoryStream())
                using (var reader = new StreamReader(stream))
                    using (var writer = new StreamWriter(stream))
                        using (var parser = new ChoCSVReader <EmployeeRec>(reader))
                        {
                            //writer.WriteLine("Id,Name");
                            writer.WriteLine("1,Carl");
                            writer.WriteLine("2,Mark");
                            writer.Flush();
                            stream.Position = 0;
                            var dr = parser.AsDataReader();
                            while (dr.Read())
                            {
                                Console.WriteLine(dr[0]);
                            }
                            //object row = null;

                            //parser.Configuration.ColumnCountStrict = true;
                            //while ((row = parser.Read()) != null)
                            //{
                            //    Console.WriteLine(row.ToStringEx());
                            //}
                        }
        }