Exemple #1
0
        private static void InsertLandmarks(object o)
        {
            using (var context = new MyDataContext())
            {
                context.ExecuteCommand("TRUNCATE TABLE [FIAS].[dbo].[Landmark]");
                context.SubmitChanges();
            }

            var reader = XmlReader.Create(o.ToString());

            reader.Read();
            reader.Read();

            int counter = 0;

            using (var context = new MyDataContext())
            {
                var oList = new List <Landmark>();

                while (reader.Read())
                {
                    if (reader.Name == "Landmark")
                    {
                        var obj = new Landmark();
                        obj.ENDDATE    = Convert.ToDateTime(reader.GetAttribute("ENDDATE"));
                        obj.TERRIFNSFL = reader.GetAttribute("TERRIFNSFL");
                        obj.TERRIFNSUL = reader.GetAttribute("TERRIFNSUL");
                        obj.UPDATEDATE = Convert.ToDateTime(reader.GetAttribute("UPDATEDATE"));
                        obj.IFNSFL     = reader.GetAttribute("IFNSFL");
                        obj.IFNSUL     = reader.GetAttribute("IFNSUL");
                        obj.OKATO      = reader.GetAttribute("OKATO");
                        obj.OKTMO      = reader.GetAttribute("OKTMO");
                        obj.POSTALCODE = reader.GetAttribute("POSTALCODE");
                        obj.AOGUID     = reader.GetAttribute("AOGUID");
                        obj.STARTDATE  = Convert.ToDateTime(reader.GetAttribute("STARTDATE"));
                        obj.LANDGUID   = reader.GetAttribute("LANDGUID");
                        obj.LANDID     = reader.GetAttribute("LANDID");
                        obj.LOCATION   = reader.GetAttribute("LOCATION");
                        obj.NORMDOC    = reader.GetAttribute("NORMDOC");

                        oList.Add(obj);
                        counter++;

                        if (counter % 1000 == 0)
                        {
                            context.BulkInsertAll(oList);
                            context.SubmitChanges();
                            oList.Clear();
                        }
                    }
                }

                context.BulkInsertAll(oList);
                context.SubmitChanges();
            }

            reader.Close();
            reader.Dispose();
        }
Exemple #2
0
        private static void InsertHouses(object o)
        {
            using (var context = new MyDataContext())
            {
                context.ExecuteCommand("TRUNCATE TABLE [FIAS].[dbo].[House]");
                context.SubmitChanges();
            }

            var reader = XmlReader.Create(o.ToString());

            reader.Read();
            reader.Read();

            int counter = 0;

            using (var context = new MyDataContext())
            {
                var oList = new List <House>();

                while (reader.Read())
                {
                    if (reader.Name == "House")
                    {
                        var t = reader.ReadString();
                        Console.WriteLine(t);


                        var house = new House();
                        house.AOGUID     = reader.GetAttribute("AOGUID");
                        house.BUILDNUM   = reader.GetAttribute("BUILDNUM");
                        house.COUNTER    = Convert.ToInt32(reader.GetAttribute("COUNTER"));
                        house.ENDDATE    = Convert.ToDateTime(reader.GetAttribute("ENDDATE"));
                        house.ESTSTATUS  = Convert.ToInt32(reader.GetAttribute("ESTSTATUS"));
                        house.IFNSFL     = reader.GetAttribute("IFNSFL");
                        house.IFNSUL     = reader.GetAttribute("IFNSUL");
                        house.HOUSEGUID  = reader.GetAttribute("HOUSEGUID");
                        house.HOUSEID    = reader.GetAttribute("HOUSEID");
                        house.HOUSENUM   = reader.GetAttribute("HOUSENUM");
                        house.NORMDOC    = reader.GetAttribute("NORMDOC");
                        house.TERRIFNSFL = reader.GetAttribute("TERRIFNSFL");
                        house.TERRIFNSUL = reader.GetAttribute("TERRIFNSUL");
                        house.UPDATEDATE = Convert.ToDateTime(reader.GetAttribute("UPDATEDATE"));
                        house.OKATO      = reader.GetAttribute("OKATO");
                        house.OKTMO      = reader.GetAttribute("OKTMO");
                        house.POSTALCODE = reader.GetAttribute("POSTALCODE");
                        house.STARTDATE  = Convert.ToDateTime(reader.GetAttribute("STARTDATE"));
                        house.STATSTATUS = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("STATSTATUS")));

                        if (reader.GetAttribute("STRSTATUS") != null)
                        {
                            house.STRSTATUS = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("STRSTATUS")));
                        }

                        house.STRUCNUM = reader.GetAttribute("STRUCNUM");

                        oList.Add(house);
                        counter++;

                        if (counter % 1000 == 0)
                        {
                            context.BulkInsertAll(oList);
                            context.SubmitChanges();
                            oList.Clear();
                        }
                    }
                }

                context.BulkInsertAll(oList);
                context.SubmitChanges();
            }

            reader.Close();
            reader.Dispose();
        }
Exemple #3
0
        private static void InsertNormativeDocument(object o)
        {
            using (var context = new MyDataContext())
            {
                context.ExecuteCommand("TRUNCATE TABLE [FIAS].[dbo].[NormativeDocument]");
                context.SubmitChanges();
            }

            var reader = XmlReader.Create(o.ToString());

            reader.Read();
            reader.Read();

            int counter = 0;

            using (var context = new MyDataContext())
            {
                var oList = new List <NormativeDocument>();

                while (reader.Read())
                {
                    if (reader.Name == "NormativeDocument")
                    {
                        var obj = new NormativeDocument();

                        if (reader.GetAttribute("DOCDATE") != null)
                        {
                            obj.DOCDATE = Convert.ToDateTime(reader.GetAttribute("DOCDATE"));
                        }


                        if (reader.GetAttribute("DOCIMGID") != null)
                        {
                            obj.DOCIMGID = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("DOCIMGID")));
                        }

                        obj.DOCNAME = reader.GetAttribute("DOCNAME");
                        obj.DOCNUM  = reader.GetAttribute("DOCNUM");


                        if (reader.GetAttribute("DOCTYPE") != null)
                        {
                            obj.DOCTYPE = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("DOCTYPE")));
                        }

                        obj.NORMDOCID = reader.GetAttribute("NORMDOCID");


                        oList.Add(obj);
                        counter++;

                        if (counter % 1000 == 0)
                        {
                            context.BulkInsertAll(oList);
                            context.SubmitChanges();
                            oList.Clear();
                        }
                    }
                }

                context.BulkInsertAll(oList);
                context.SubmitChanges();
            }

            reader.Close();
            reader.Dispose();
        }
Exemple #4
0
        private static void InsertHouseInterval(object o)
        {
            using (var context = new MyDataContext())
            {
                context.ExecuteCommand("TRUNCATE TABLE [FIAS].[dbo].[HouseInterval]");
                context.SubmitChanges();
            }

            var reader = XmlReader.Create(o.ToString());

            reader.Read();
            reader.Read();

            int counter = 0;

            using (var context = new MyDataContext())
            {
                var oList = new List <HouseInterval>();

                while (reader.Read())
                {
                    // your code here.
                    if (reader.Name == "HouseInterval")
                    {
                        var obj = new HouseInterval();
                        obj.AOGUID     = reader.GetAttribute("AOGUID");
                        obj.ENDDATE    = Convert.ToDateTime(reader.GetAttribute("ENDDATE"));
                        obj.TERRIFNSFL = reader.GetAttribute("TERRIFNSFL");
                        obj.TERRIFNSUL = reader.GetAttribute("TERRIFNSUL");
                        obj.UPDATEDATE = Convert.ToDateTime(reader.GetAttribute("UPDATEDATE"));
                        obj.IFNSFL     = reader.GetAttribute("IFNSFL");
                        obj.IFNSUL     = reader.GetAttribute("IFNSUL");
                        obj.INTEND     = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("INTEND")));
                        obj.INTGUID    = reader.GetAttribute("INTGUID");
                        obj.INTSTART   = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("INTSTART")));
                        obj.INTSTATUS  = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("INTSTATUS")));
                        obj.OKATO      = reader.GetAttribute("OKATO");
                        obj.OKTMO      = reader.GetAttribute("OKTMO");
                        obj.POSTALCODE = reader.GetAttribute("POSTALCODE");
                        obj.STARTDATE  = Convert.ToDateTime(reader.GetAttribute("STARTDATE"));
                        obj.HOUSEINTID = reader.GetAttribute("HOUSEINTID");
                        obj.COUNTER    = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("COUNTER")));
                        obj.NORMDOC    = reader.GetAttribute("NORMDOC");

                        oList.Add(obj);
                        counter++;

                        if (counter % 1000 == 0)
                        {
                            context.BulkInsertAll(oList);
                            context.SubmitChanges();
                            oList.Clear();
                        }
                    }
                }

                context.BulkInsertAll(oList);
                context.SubmitChanges();
            }

            reader.Close();
            reader.Dispose();
        }
Exemple #5
0
        private static void InsertObjects(object o)
        {
            using (var context = new MyDataContext())
            {
                context.ExecuteCommand("TRUNCATE TABLE [FIAS].[dbo].[Object]");
                context.SubmitChanges();
            }

            var reader = XmlReader.Create(o.ToString());

            reader.Read();
            reader.Read();

            int counter = 0;

            using (var context = new MyDataContext())
            {
                var oList = new List <Object>();

                while (reader.Read())
                {
                    if (reader.Name == "Object")
                    {
                        var obj = new Object();
                        obj.ACTSTATUS  = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("ACTSTATUS")));
                        obj.AOGUID     = reader.GetAttribute("AOGUID");
                        obj.AOID       = reader.GetAttribute("AOID");
                        obj.AOLEVEL    = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("AOLEVEL")));
                        obj.AREACODE   = reader.GetAttribute("AREACODE");
                        obj.AUTOCODE   = reader.GetAttribute("AUTOCODE");
                        obj.ENDDATE    = Convert.ToDateTime(reader.GetAttribute("ENDDATE"));
                        obj.EXTRCODE   = reader.GetAttribute("EXTRCODE");
                        obj.REGIONCODE = reader.GetAttribute("REGIONCODE");
                        obj.TERRIFNSFL = reader.GetAttribute("TERRIFNSFL");
                        obj.TERRIFNSUL = reader.GetAttribute("TERRIFNSUL");
                        obj.UPDATEDATE = Convert.ToDateTime(reader.GetAttribute("UPDATEDATE"));
                        obj.IFNSFL     = reader.GetAttribute("IFNSFL");
                        obj.IFNSUL     = reader.GetAttribute("IFNSUL");
                        obj.OFFNAME    = reader.GetAttribute("OFFNAME");
                        obj.OKATO      = reader.GetAttribute("OKATO");
                        obj.OKTMO      = reader.GetAttribute("OKTMO");
                        obj.OPERSTATUS = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("OPERSTATUS")));
                        obj.PARENTGUID = reader.GetAttribute("PARENTGUID");
                        obj.PLACECODE  = reader.GetAttribute("PLACECODE");
                        obj.PLAINCODE  = reader.GetAttribute("PLAINCODE");
                        obj.POSTALCODE = reader.GetAttribute("POSTALCODE");
                        obj.PREVID     = reader.GetAttribute("PREVID");
                        obj.SEXTCODE   = reader.GetAttribute("SEXTCODE");
                        obj.SHORTNAME  = reader.GetAttribute("SHORTNAME");
                        obj.STARTDATE  = Convert.ToDateTime(reader.GetAttribute("STARTDATE"));
                        obj.STREETCODE = reader.GetAttribute("STREETCODE");
                        obj.FORMALNAME = reader.GetAttribute("FORMALNAME");
                        obj.LIVESTATUS = Convert.ToInt16(reader.GetAttribute("LIVESTATUS"));
                        obj.CENTSTATUS = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("CENTSTATUS")));
                        obj.CITYCODE   = reader.GetAttribute("CITYCODE");
                        obj.CODE       = reader.GetAttribute("CODE");
                        obj.CTARCODE   = reader.GetAttribute("CTARCODE");
                        obj.CURRSTATUS = Convert.ToBoolean(Convert.ToInt32(reader.GetAttribute("CURRSTATUS")));
                        obj.NEXTID     = reader.GetAttribute("NEXTID");
                        obj.NORMDOC    = reader.GetAttribute("NORMDOC");

                        oList.Add(obj);
                        counter++;

                        if (counter % 1000 == 0)
                        {
                            context.BulkInsertAll(oList);
                            context.SubmitChanges();
                            oList.Clear();
                        }
                    }
                }

                context.BulkInsertAll(oList);
                context.SubmitChanges();
            }

            reader.Close();
            reader.Dispose();
        }
Exemple #6
0
        private static void InsertObjects(object o)
        {
            using (var context = new MyDataContext())
            {
                context.ExecuteCommand("TRUNCATE TABLE [dbo].[Object]");
                context.SubmitChanges();
            }

            var reader = XmlReader.Create(o.ToString());

            reader.Read();
            reader.Read();

            int counter = 0;

            using (var context = new MyDataContext())
            {
                var oList = new List <Object>();

                while (reader.Read())
                {
                    if (reader.Name == "Object")
                    {
                        var obj = new Object();
                        obj.AOLEVEL    = Convert.ToInt32(reader.GetAttribute("AOLEVEL"));
                        obj.AOGUID     = reader.GetAttribute("AOGUID");
                        obj.PARENTGUID = reader.GetAttribute("PARENTGUID");
                        obj.REGIONCODE = reader.GetAttribute("REGIONCODE");
                        obj.CITYCODE   = reader.GetAttribute("CITYCODE");
                        obj.LIVESTATUS = Convert.ToInt16(reader.GetAttribute("LIVESTATUS"));

                        if (obj.REGIONCODE == "02"
                            // obj.CITYCODE == "014" // Стерлитамак

                            /*&& obj.AOLEVEL <= 7
                             * && (
                             *     obj.AOGUID == "6f2cbfd8-692a-4ee4-9b16-067210bde3fc" // Башкортостан
                             || obj.AOGUID == "450ce765-f993-4ceb-95e3-f11c6fd35778" // Стерлитамакский район
                             || obj.AOGUID == "84e0b23d-82fe-40a8-8739-55e679780dc3" // Стерлитамак город
                             || obj.AOGUID == "2b8b65ca-9421-4c25-b20f-b57dcdbb20c4" // Мариинский село
                             ||
                             || obj.PARENTGUID == "84e0b23d-82fe-40a8-8739-55e679780dc3" // Стерлитамак город
                             || obj.PARENTGUID == "2b8b65ca-9421-4c25-b20f-b57dcdbb20c4" // Мариинский село
                             ||)*/
                            && obj.LIVESTATUS == 1)
                        {
                            obj.ACTSTATUS  = Convert.ToInt32(reader.GetAttribute("ACTSTATUS"));
                            obj.AOID       = reader.GetAttribute("AOID");
                            obj.AREACODE   = reader.GetAttribute("AREACODE");
                            obj.AUTOCODE   = reader.GetAttribute("AUTOCODE");
                            obj.ENDDATE    = Convert.ToDateTime(reader.GetAttribute("ENDDATE"));
                            obj.EXTRCODE   = reader.GetAttribute("EXTRCODE");
                            obj.TERRIFNSFL = reader.GetAttribute("TERRIFNSFL");
                            obj.TERRIFNSUL = reader.GetAttribute("TERRIFNSUL");
                            obj.UPDATEDATE = Convert.ToDateTime(reader.GetAttribute("UPDATEDATE"));
                            obj.IFNSFL     = reader.GetAttribute("IFNSFL");
                            obj.IFNSUL     = reader.GetAttribute("IFNSUL");
                            obj.OFFNAME    = reader.GetAttribute("OFFNAME");
                            obj.OKATO      = reader.GetAttribute("OKATO");
                            obj.OKTMO      = reader.GetAttribute("OKTMO");
                            obj.OPERSTATUS = Convert.ToInt32(reader.GetAttribute("OPERSTATUS"));
                            obj.PLACECODE  = reader.GetAttribute("PLACECODE");
                            obj.PLANCODE   = reader.GetAttribute("PLANCODE");
                            obj.PLAINCODE  = reader.GetAttribute("PLAINCODE");
                            obj.POSTALCODE = reader.GetAttribute("POSTALCODE");
                            obj.PREVID     = reader.GetAttribute("PREVID");
                            obj.SEXTCODE   = reader.GetAttribute("SEXTCODE");
                            obj.SHORTNAME  = reader.GetAttribute("SHORTNAME");
                            obj.STARTDATE  = Convert.ToDateTime(reader.GetAttribute("STARTDATE"));
                            obj.STREETCODE = reader.GetAttribute("STREETCODE");
                            obj.FORMALNAME = reader.GetAttribute("FORMALNAME");
                            obj.CENTSTATUS = Convert.ToInt32(reader.GetAttribute("CENTSTATUS"));
                            obj.CODE       = reader.GetAttribute("CODE");
                            obj.CTARCODE   = reader.GetAttribute("CTARCODE");
                            obj.CURRSTATUS = Convert.ToInt32(reader.GetAttribute("CURRSTATUS"));
                            obj.NEXTID     = reader.GetAttribute("NEXTID");
                            obj.NORMDOC    = reader.GetAttribute("NORMDOC");
                            obj.DIVTYPE    = Convert.ToInt32(reader.GetAttribute("DIVTYPE"));

                            oList.Add(obj);
                            counter++;

                            /*if (obj.AOGUID == "f274f290-1a5f-457c-9cc6-7f8bad433e31")
                             * {
                             *  Console.Out.WriteLine(obj.OFFNAME);
                             *  Console.Out.WriteLine(obj.AOGUID);
                             * }*/

                            //if (/*obj.AOLEVEL == 7 // Street
                            //    &&*/ Objects02.BinarySearch(obj.AOGUID) < 0)
                            //{
                            //Objects02.Add(obj.AOGUID);
                            //Objects02.Sort();
                            //}

                            if (counter % 100 == 0)
                            {
                                Console.Out.WriteLine("InsertObjects * 100");
                                context.BulkInsertAll(oList);
                                context.SubmitChanges();
                                oList.Clear();
                            }
                        }
                    }
                }

                context.BulkInsertAll(oList);
                context.SubmitChanges();
            }

            reader.Close();
            reader.Dispose();
        }
Exemple #7
0
        private static void InsertHouses(object o)
        {
            using (var context = new MyDataContext())
            {
                context.ExecuteCommand("TRUNCATE TABLE [dbo].[House]");
                context.SubmitChanges();
            }

            var reader = XmlReader.Create(o.ToString());

            reader.Read();
            reader.Read();

            int counter = 0;

            using (var context = new MyDataContext())
            {
                var oList = new List <House>();

                while (reader.Read())
                {
                    if (reader.Name == "House")
                    {
                        var house = new House();

                        house.AOGUID = reader.GetAttribute("AOGUID");

                        /*if (house.AOGUID == "f274f290-1a5f-457c-9cc6-7f8bad433e31")
                         * {
                         *  Console.Out.WriteLine(house.AOGUID);
                         *  //Console.Out.WriteLine(house.HOUSEGUID);
                         * }*/

                        //if (Objects02.BinarySearch(house.AOGUID) >= 0)
                        if (house.REGIONCODE == "02")
                        {
                            house.POSTALCODE = reader.GetAttribute("POSTALCODE");
                            house.REGIONCODE = reader.GetAttribute("REGIONCODE");
                            house.BUILDNUM   = reader.GetAttribute("BUILDNUM");
                            house.COUNTER    = Convert.ToInt32(reader.GetAttribute("COUNTER"));
                            house.ENDDATE    = Convert.ToDateTime(reader.GetAttribute("ENDDATE"));
                            house.ESTSTATUS  = Convert.ToInt32(reader.GetAttribute("ESTSTATUS"));
                            house.IFNSFL     = reader.GetAttribute("IFNSFL");
                            house.IFNSUL     = reader.GetAttribute("IFNSUL");
                            house.HOUSEGUID  = reader.GetAttribute("HOUSEGUID");
                            house.HOUSEID    = reader.GetAttribute("HOUSEID");
                            house.HOUSENUM   = reader.GetAttribute("HOUSENUM");
                            house.NORMDOC    = reader.GetAttribute("NORMDOC");
                            house.TERRIFNSFL = reader.GetAttribute("TERRIFNSFL");
                            house.TERRIFNSUL = reader.GetAttribute("TERRIFNSUL");
                            house.UPDATEDATE = Convert.ToDateTime(reader.GetAttribute("UPDATEDATE"));
                            house.OKATO      = reader.GetAttribute("OKATO");
                            house.OKTMO      = reader.GetAttribute("OKTMO");
                            house.CADNUM     = reader.GetAttribute("CADNUM");
                            house.DIVTYPE    = Convert.ToInt32(reader.GetAttribute("DIVTYPE"));
                            house.STARTDATE  = Convert.ToDateTime(reader.GetAttribute("STARTDATE"));
                            house.STATSTATUS = Convert.ToInt32(reader.GetAttribute("STATSTATUS"));
                            house.STRUCNUM   = reader.GetAttribute("STRUCNUM");

                            if (reader.GetAttribute("STRSTATUS") != null)
                            {
                                house.STRSTATUS = Convert.ToInt32(reader.GetAttribute("STRSTATUS"));
                            }

                            oList.Add(house);
                            counter++;

                            if (counter % 100 == 0)
                            {
                                System.Console.Out.WriteLine("InsertHouses * 100");
                                context.BulkInsertAll(oList);
                                context.SubmitChanges();
                                oList.Clear();
                            }
                        }
                    }
                }

                context.BulkInsertAll(oList);
                context.SubmitChanges();
            }

            reader.Close();
            reader.Dispose();
        }