示例#1
0
        public void TestLREnquiry()
        {
            var s = new LandRegistryEnquiry(21340, null, "test", null, null, "E12 6AY");

            s.Execute();
            Assert.IsTrue(String.IsNullOrEmpty(s.Result));
        }
        }         // ExecuteStep

        private void QueryLandRegistry()
        {
            var customerAddressesHelper = new CustomerAddressHelper(this.customerID);

            customerAddressesHelper.Execute();

            foreach (CustomerAddressModel address in customerAddressesHelper.OwnedAddresses)
            {
                LandRegistryDataModel model = null;

                if (!string.IsNullOrEmpty(address.HouseName))
                {
                    model = LandRegistryEnquiry.Get(
                        this.customerID,
                        null,
                        address.HouseName,
                        null,
                        null,
                        address.PostCode
                        );
                }
                else if (!string.IsNullOrEmpty(address.HouseNumber))
                {
                    model = LandRegistryEnquiry.Get(
                        this.customerID,
                        address.HouseNumber,
                        null,
                        null,
                        null,
                        address.PostCode
                        );
                }
                else if (
                    !string.IsNullOrEmpty(address.FlatOrApartmentNumber) &&
                    string.IsNullOrEmpty(address.HouseNumber)
                    )
                {
                    model = LandRegistryEnquiry.Get(
                        this.customerID,
                        address.FlatOrApartmentNumber,
                        null,
                        null,
                        null,
                        address.PostCode
                        );
                }                 // if

                bool doLandRegistry =
                    (model != null) &&
                    (model.Enquery != null) &&
                    (model.ResponseType == LandRegistryResponseType.Success) &&
                    (model.Enquery.Titles != null) &&
                    (model.Enquery.Titles.Count == 1);

                if (doLandRegistry)
                {
                    var lrr = new LandRegistryRes(this.customerID, model.Enquery.Titles[0].TitleNumber);
                    lrr.PartialExecute();

                    LandRegistryDB dbLandRegistry = lrr.LandRegistry;

                    LandRegistryDataModel landRegistryDataModel = lrr.RawResult;

                    if (landRegistryDataModel.ResponseType == LandRegistryResponseType.Success)
                    {
                        bool isOwnerAccordingToLandRegistry = LandRegistryRes.IsOwner(
                            this.customerID,
                            this.customerFullName,
                            landRegistryDataModel.Response,
                            landRegistryDataModel.Res.TitleNumber
                            );

                        DB.ExecuteNonQuery(
                            "AttachCustomerAddrToLandRegistryAddr",
                            CommandSpecies.StoredProcedure,
                            new QueryParameter("@LandRegistryAddressID", dbLandRegistry.Id),
                            new QueryParameter("@CustomerAddressID", address.AddressId),
                            new QueryParameter("@IsOwnerAccordingToLandRegistry", isOwnerAccordingToLandRegistry)
                            );
                    }                     // if
                }
                else
                {
                    int num = 0;

                    if (model != null && model.Enquery != null && model.Enquery.Titles != null)
                    {
                        num = model.Enquery.Titles.Count;
                    }

                    Log.Warn(
                        "No land registry retrieved for customer id: {5}," +
                        "house name: {0}, house number: {1}, flat number: {2}, postcode: {3}, # of inquiries {4}",
                        address.HouseName,
                        address.HouseNumber,
                        address.FlatOrApartmentNumber,
                        address.PostCode,
                        num,
                        this.customerID
                        );
                } // if
            }     // for each
        }         // QueryLandRegistry