/// <summary>
        /// Loads LOT-based addresses to database.
        /// </summary>
        /// <param name="filepaths">List of XML document paths.</param>
        private void LoadLotBasedAddresses(IEnumerable <string> filepaths)
        {
            var serialiser = new XmlSerializer(typeof(LotBasedAddresses));

            foreach (var filepath in filepaths)
            {
                var filename = ConversionHelper.GetFilenameFromFilepath(filepath, this._settings);

                using (var context = new KoreanPostcodeAddressDataContext())
                {
                    this.OnStatusChanged(new StatusChangedEventArgs(String.Format("Loading a file - {0} - to database", filename)));

                    using (var stream = new FileStream(filepath, FileMode.Open))
                    {
                        var collection = (LotBasedAddresses)serialiser.Deserialize(stream);
                        foreach (var address in collection.LotBasedAddress
                                 .Select(p => new LotBasedAddress()
                        {
                            Postcode = ConversionHelper.ConvertToString(p.Postcode),
                            SequenceNumber = ConversionHelper.ConvertToInt32(p.SequenceNumber),
                            Province = ConversionHelper.GetProvince(p.Province),
                            City = ConversionHelper.GetCity(p.Province),
                            County = ConversionHelper.GetCounty(p.Province, p.County),
                            District = ConversionHelper.GetDistrict(p.Province, p.County),
                            Suburb = ConversionHelper.GetSuburb(p.Suburb),
                            Village = ConversionHelper.GetVillage(p.Village),
                            Island = ConversionHelper.GetIsland(p.Island),
                            San = ConversionHelper.GetSan(p.San),
                            LotNumberMajorFrom = ConversionHelper.ConvertToNullableInt32(p.LotNumberMajorFrom),
                            LotNumberMinorFrom = ConversionHelper.ConvertToNullableInt32(p.LotNumberMinorFrom),
                            LotNumberMajorTo = ConversionHelper.ConvertToNullableInt32(p.LotNumberMajorTo),
                            LotNumberMinorTo = ConversionHelper.ConvertToNullableInt32(p.LotNumberMinorTo),
                            BuildingName = ConversionHelper.ConvertToString(p.BuildingName),
                            BuildingNumberFrom = ConversionHelper.ConvertToNullableInt32(p.BuildingNumberFrom),
                            BuildingNumberTo = ConversionHelper.ConvertToNullableInt32(p.BuildingNumberTo),
                            DateUpdated = p.DateUpdated,
                            Address = ConversionHelper.ConvertToString(p.Address)
                        }))
                        {
                            context.LotBasedAddresses.AddObject(address);
                        }
                    }
                    context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);

                    this.OnStatusChanged(new StatusChangedEventArgs(String.Format("Loaded the file - {0} - to database", filename)));
                }
            }
        }
        /// <summary>
        /// Loads street-based addresses to database.
        /// </summary>
        /// <param name="filepaths">List of XML document paths.</param>
        private void LoadStreetBasedAddresses(IEnumerable <string> filepaths)
        {
            foreach (var filepath in filepaths)
            {
                var filename = ConversionHelper.GetFilenameFromFilepath(filepath, this._settings);

                using (var context = new KoreanPostcodeAddressDataContext())
                {
                    this.OnStatusChanged(new StatusChangedEventArgs(String.Format("Loading a file - {0} - to database", filename)));

                    var csv = new DelimitedFileEngine <Aliencube.Utilities.KoreanPostcodeAddressConverter.Services.Models.StreetBasedAddress>()
                    {
                        Encoding = Encoding.GetEncoding(949)
                    };
                    csv.AfterReadRecord         += Csv_AfterReadRecord;
                    csv.Options.Delimiter        = "|";
                    csv.Options.IgnoreFirstLines = 1;

                    //  Loads objects directly from the CSV file.
                    var addresses = csv.ReadFile(filepath);

                    var blockSize = this._settings.GetProcessRequests <int>("databaseLoadingBlockSize");
                    var block     = (int)Math.Ceiling((double)addresses.Length / blockSize);
                    for (var i = 0; i < block; i++)
                    {
                        this.OnStatusChanged(new StatusChangedEventArgs(String.Format("Loading a file - {0} - to database ({1}/{2})", filename, i + 1, block)));

                        var records = i < block - 2
                                          ? blockSize
                                          : addresses.Length - (i * block);
                        foreach (var address in addresses.Skip(i * (int)blockSize)
                                 .Take((int)records)
                                 .Select(p => new StreetBasedAddress()
                        {
                            Postcode = ConversionHelper.ConvertToString(p.Postcode),
                            SequenceNumber = ConversionHelper.ConvertToString(p.SequenceNumber),
                            Province = ConversionHelper.GetProvince(p.Province),
                            ProvinceEng = ConversionHelper.GetProvinceEng(p.ProvinceEng),
                            City = ConversionHelper.GetCity(p.Province),
                            CityEng = ConversionHelper.GetCityEng(p.ProvinceEng),
                            County = ConversionHelper.GetCounty(p.Province, p.County),
                            CountyEng = ConversionHelper.GetCountyEng(p.ProvinceEng, p.CountyEng),
                            District = ConversionHelper.GetDistrict(p.Province, p.County),
                            DistrictEng = ConversionHelper.GetDistrictEng(p.ProvinceEng, p.CountyEng),
                            Suburb = ConversionHelper.GetSuburb(p.Suburb),
                            SuburbEng = ConversionHelper.GetSuburbEng(p.SuburbEng),
                            StreetNameCode = ConversionHelper.ConvertToString(p.StreetNameCode),
                            StreetName = ConversionHelper.GetStreet(p.StreetName, p.StreetNameEng),
                            StreetNameEng = ConversionHelper.GetStreetEng(p.StreetNameEng),
                            Basement = ConversionHelper.ConvertToNullableInt32(p.Basement),
                            BuildingNumberMajor = ConversionHelper.ConvertToNullableInt32(p.BuildingNumberMajor),
                            BuildingNumberMinor = ConversionHelper.ConvertToNullableInt32(p.BuildingNumberMinor),
                            BuildingCode = ConversionHelper.ConvertToString(p.BuildingCode),
                            BuildingNameForBulk = ConversionHelper.ConvertToString(p.BuildingNameForBulk),
                            BuildingName = ConversionHelper.ConvertToString(p.BuildingName),
                            RegisteredSuburbCode = ConversionHelper.ConvertToString(p.RegisteredSuburbCode),
                            RegisteredSuburb = ConversionHelper.GetSuburb(p.RegisteredSuburb),
                            SuburbSequenceNumber = ConversionHelper.ConvertToNullableInt32(p.SuburbSequenceNumber),
                            Village = ConversionHelper.GetVillage(p.Village),
                            San = ConversionHelper.ConvertToNullableBoolean(p.San),
                            LotNumberMajor = ConversionHelper.ConvertToNullableInt32(p.LotNumberMajor),
                            LotNumberMinor = ConversionHelper.ConvertToNullableInt32(p.LotNumberMinor)
                        }))
                        {
                            context.StreetBasedAddresses.AddObject(address);
                        }
                        context.SaveChanges(SaveOptions.AcceptAllChangesAfterSave);

                        this.OnStatusChanged(new StatusChangedEventArgs(String.Format("Loaded the file - {0} - to database ({1}/{2})", filename, i + 1, block)));
                    }
                }
            }
        }