Ejemplo n.º 1
0
        public static void Write(OleDbDataReader reader, System.IO.StreamWriter file, string sep, string[] header, long ean)
        {
            if (header != null)
            {
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    if (i != 0)
                    {
                        file.Write(sep);
                    }
                    file.Write(header[i]);
                }
            }
            else
            {
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    if (i != 0)
                    {
                        file.Write(sep);
                    }
                    file.Write(reader.GetName(i));
                }
            }

            file.Write("\r\n");

            while (reader.Read())
            {
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    if (i != 0)
                    {
                        file.Write(sep);
                        file.Write(reader[i]);
                    }
                    else
                    {
                        if (ean > 0)
                        {
                            int  h  = (int)reader[i];
                            long hh = EAN13.Create(h, ean);// 2700000000000
                            file.Write(hh);
                        }
                        else
                        {
                            file.Write(reader[i]);
                        };
                    }
                }
                file.Write("\r\n");
            }
            file.Flush();
        }
Ejemplo n.º 2
0
        public static void Write(OleDbDataReader reader, System.IO.StreamWriter file, string[] header, long ean)
        {
            if (header == null)
            {
                header = new string[reader.FieldCount];
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    header[i] = reader.GetName(i);
                }
            }

            file.Write("[\r\n");
            while (reader.Read())
            {
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    if (i != 0)
                    {
                        file.Write(",\"");
                        file.Write(header[i]);
                        file.Write("\": \"");
                        file.Write(reader[i]);
                        file.Write("\"");
                    }
                    else
                    {
                        file.Write("{\"");
                        file.Write(header[i]);

                        if (ean > 0)
                        {
                            file.Write("\": ");
                            int  h  = (int)reader[i];
                            long hh = EAN13.Create(h, ean);// 2700000000000
                            file.Write(hh);
                        }
                        else
                        {
                            file.Write("\": \"");
                            file.Write(reader[i]);
                            file.Write("\"");
                        };
                    }
                }
                file.Write("},\r\n");
            }
            file.Write("{}]\r\n");
            file.Flush();
        }