Пример #1
0
        public void ServiceLogCreditSafeLtdData(string regNumber, int customerId)
        {
            Log.Debug("Downloading data from CreditSafe for company {0} and customer {1}...", regNumber, customerId);

            string uname      = CurrentValues.Instance.CreditSafeUserName;
            string pass       = CurrentValues.Instance.CreditSafePassword;
            string requestXml = GetResource("Ezbob.Backend.Strategies.CreditSafe.Tamplets.CreditSafeLtdRequestTemplate.xml", uname, pass, regNumber);

            CreditsafeServicesSoapClient client = new CreditsafeServicesSoapClient("CreditsafeServicesSoap");
            string newResponse = client.GetData(requestXml);

            var pkg = new WriteToLogPackage(requestXml, newResponse, ExperianServiceType.CreditSafeLtd, customerId, companyRefNum: regNumber);

            new ServiceLogWriter(pkg).Execute();

            Log.Debug("Downloading data from CreditSafe for company {0} and customer {1} complete.", regNumber, customerId);
        }//ServiceLogCreditSafeLtdData
Пример #2
0
        public void ServiceLogCreditSafeNonLtdData(int customerId)
        {
            SafeReader addressSR = this.m_oDB.GetFirst(
                "GetCompanyAddress",
                CommandSpecies.StoredProcedure,
                new QueryParameter("CustomerId", customerId)
                );
            SafeReader companySR = this.m_oDB.GetFirst(
                "GetCompanyName",
                CommandSpecies.StoredProcedure,
                new QueryParameter("CustomerId", customerId)
                );

            string companyName = companySR["CompanyName"];

            companyName = HttpUtility.HtmlEncode(companyName);
            if (string.IsNullOrEmpty(companyName))
            {
                Log.Info("CreditSafeNonLtd not retrieving data - customer has no company name.");
                return;
            }
            string companyId = companySR["CompanyId"];
            string address   = addressSR["Line1"];
            string postcode  = addressSR["Postcode"];
            string uname     = CurrentValues.Instance.CreditSafeUserName;
            string pass      = CurrentValues.Instance.CreditSafePassword;

            Log.Debug("Targeting data from CreditSafe for Company: {0} With CompanyId:{1} and CustomerId: {2}", companyName, companyId, customerId);

            string targetingRequest = GetResource("Ezbob.Backend.Strategies.CreditSafe.Tamplets.CreditSafeNonLtdSearchTemplate.xml", uname, pass, companyName, address, postcode);

            CreditsafeServicesSoapClient client = new CreditsafeServicesSoapClient("CreditsafeServicesSoap");
            string targetingResponse            = client.GetData(targetingRequest);

            var targetingPkg = new WriteToLogPackage(targetingRequest, targetingResponse, ExperianServiceType.CreditSafeNonLtdTargeting, customerId);

            new ServiceLogWriter(targetingPkg).Execute();

            XmlSerializer searchSerializer = new XmlSerializer(typeof(CreditSafeNonLtdSearchResponse), new XmlRootAttribute("xmlresponse"));
            CreditSafeNonLtdSearchResponse targetingResult = (CreditSafeNonLtdSearchResponse)searchSerializer.Deserialize(new StringReader(targetingResponse));

            try
            {
                xmlresponsesearchBody body = (xmlresponsesearchBody)targetingResult.Items[1];
                if (body.results != null && body.results.Length == 1)
                {
                    string companyNum = body.results[0].number;
                    Log.Debug("Downloading data from CreditSafeNonLtd for company {0} and customer {1}...", companyNum, customerId);
                    string requestXml  = GetResource("Ezbob.Backend.Strategies.CreditSafe.Tamplets.CreditSafeNonLtdRequestTemplate.xml", uname, pass, companyNum);
                    string newResponse = client.GetData(requestXml);
                    var    pkg         = new WriteToLogPackage(requestXml, newResponse, ExperianServiceType.CreditSafeNonLtd, customerId, companyRefNum: companyNum);
                    new ServiceLogWriter(pkg).Execute();
                    Log.Debug("Downloading data from CreditSafeNonLtd for company {0} and customer {1} complete.", companyNum, customerId);
                }//if
                else
                {
                    Log.Info("CreditSafeNonLtd Targeting failed for customer {0}", customerId);
                } //else
            }     //try
            catch (Exception ex)
            {
                Log.Error(ex, "failed to retrieve CreditSafe data for customerId:{0}", customerId);
            } //catch
        }     //ServiceLogCreditSafeNonLtdData