예제 #1
0
        public void loadDBFToDb_House(FileInfo dbfFile, SqlConnection connection)
        {
            NDbfReader.Table    dbfTable  = NDbfReader.Table.Open(dbfFile.Open(FileMode.Open));
            NDbfReader.Reader   dbfReader = dbfTable.OpenReader(System.Text.Encoding.GetEncoding(866));
            QueriesTableAdapter qta       = new QueriesTableAdapter();
            int       c  = 1;
            guidparse gp = (string x) => { if (x == null)
                                           {
                                               return(null);
                                           }
                                           else
                                           {
                                               return(Guid.Parse(x));
                                           } };

            while (dbfReader.Read())
            {
                Int32 ESTSTATUS;
                Int32.TryParse(dbfReader.GetValue("ESTSTATUS").ToString(), out ESTSTATUS);
                if (!(bool)qta.CanInsert_tmpHouse_Query(Guid.Parse(dbfReader.GetValue("HOUSEID").ToString())) &&
                    (bool)qta.CanInsert_tmpHouseAO_Query(Guid.Parse(dbfReader.GetValue("AOGUID").ToString()))
                    )
                {
                    qta.Insert_tmpHouse_Query(
                        dbfReader.GetString("POSTALCODE"),
                        dbfReader.GetString("IFNSFL"),
                        dbfReader.GetString("TERRIFNSFL"),
                        dbfReader.GetString("IFNSUL"),
                        dbfReader.GetString("TERRIFNSUL"),
                        dbfReader.GetString("OKATO"),
                        dbfReader.GetString("OKTMO"),
                        dbfReader.GetDateTime("UPDATEDATE"),
                        dbfReader.GetString("HOUSENUM"),
                        Int32.Parse(dbfReader.GetValue("ESTSTATUS").ToString()),
                        dbfReader.GetString("BUILDNUM"),
                        dbfReader.GetString("STRUCNUM"),
                        Int32.Parse(dbfReader.GetValue("STRSTATUS").ToString()),
                        Guid.Parse(dbfReader.GetValue("HOUSEID").ToString()),
                        Guid.Parse(dbfReader.GetValue("HOUSEGUID").ToString()),
                        Guid.Parse(dbfReader.GetValue("AOGUID").ToString()),
                        dbfReader.GetDateTime("STARTDATE").Value,
                        dbfReader.GetDateTime("ENDDATE").Value,
                        Int32.Parse(dbfReader.GetValue("STATSTATUS").ToString()),
                        gp(dbfReader.GetString("NORMDOC")),
                        Int32.Parse(dbfReader.GetValue("COUNTER").ToString()),
                        dbfReader.GetString("CADNUM"),
                        Int32.Parse(dbfReader.GetValue("DIVTYPE").ToString()));
                }
                c++;
                LogInfo(c.ToString() + ". " + Guid.Parse(dbfReader.GetValue("HOUSEID").ToString()));
            }

            dbfTable.Dispose();
            dbfFile.Delete();
        }