コード例 #1
0
        private static void InsertLoanToSalesforce(EnterpriseWsdl.SoapClient apiClient, Applicant2 applicant2, string applicantId)
        {
            EnterpriseWsdl.Loan__c loan2 = new EnterpriseWsdl.Loan__c();

            loan2.Applicant__c = applicantId;

            loan2.LAS_Loan_Id__c = applicant2.LAS_Loan_Id__c;

            loan2.Bank_Account__c = applicant2.Bank_Account__c.Replace("-", "").Replace(" ", "").Trim();
            loan2.Sort_Code__c    = applicant2.Sort_Code__c.Replace("-", "").Replace(" ", "").Trim();

            if (!String.IsNullOrEmpty(applicant2.Loan_Amount__c))
            {
                loan2.Loan_Amount__c          = double.Parse(applicant2.Loan_Amount__c);
                loan2.Loan_Amount__cSpecified = true;
            }

            if (!String.IsNullOrEmpty(applicant2.Loan_Days__c))
            {
                loan2.Loan_Days__c          = double.Parse(applicant2.Loan_Days__c);
                loan2.Loan_Days__cSpecified = true;
            }

            if (!String.IsNullOrEmpty(applicant2.Monthly_Net_Income__c))
            {
                loan2.Monthly_Net_Income__c          = double.Parse(applicant2.Monthly_Net_Income__c);
                loan2.Monthly_Net_Income__cSpecified = true;
            }

            if (!String.IsNullOrEmpty(applicant2.AppliedOn__c))
            {
                string appliedOn = DateFormat(applicant2.AppliedOn__c);
                //DateTime dt2 = Convert.ToDateTime(appliedOn);
                loan2.AppliedOn__c          = DateTime.ParseExact(appliedOn, "d/M/yyyy", CultureInfo.InvariantCulture);
                loan2.AppliedOn__cSpecified = true;
            }

            EnterpriseWsdl.sObject[] outreachArray2 = new EnterpriseWsdl.sObject[] { loan2 };

            EnterpriseWsdl.SaveResult[] createResult2;
            EnterpriseWsdl.LimitInfo[]  limitInfo2;

            apiClient.create(header, null, null, null, null, null, null, null, null, null, null, outreachArray2, out limitInfo2, out createResult2);

            if (createResult2[0].success)
            {
                LogLoanInformation(sw, applicant2);
            }
            else
            {
                LogErrorMessage(sw, "Loan insertion failed due to : " + createResult2[0].errors[0].statusCode);
            }
        }
コード例 #2
0
        private static void InsertRecordsTosalesForce2(EnterpriseWsdl.SoapClient apiClient)
        {
            foreach (var applicant in applc)
            {
                //Console.WriteLine("Adding new applicant ...");
                LogErrorMessage(sw, "Adding new applicant ...");

                EnterpriseWsdl.Applicant__c applic = new EnterpriseWsdl.Applicant__c();
                EnterpriseWsdl.Loan__c      loan   = new EnterpriseWsdl.Loan__c();

                string   dateofbirth = applicant.DateOfBirth;
                DateTime dt          = Convert.ToDateTime(dateofbirth);
                applic.Date_Of_Birth__c          = dt;
                applic.Date_Of_Birth__cSpecified = true;

                string email = applicant.Email;
                applic.Email__c = email;

                string mobile = PhoneFormat(applicant.MobilePhone);
                applic.Mobile__c = mobile;

                string street = applicant.Street;
                applic.Street__c = street;

                string postalcode = applicant.PostalCode;
                applic.Postal_Code__c = postalcode;

                string county = applicant.County;
                applic.County__c = county;

                string landline = PhoneFormat(applicant.Landline);
                applic.Landline__c = landline;

                string workphone = PhoneFormat(applicant.WorkPhone);
                applic.Work_Phone__c = workphone;

                EnterpriseWsdl.sObject[] outreachArray = new EnterpriseWsdl.sObject[] { applic };

                EnterpriseWsdl.SaveResult[] createResult;
                EnterpriseWsdl.LimitInfo[]  limitInfo;

                apiClient.create(header, null, null, null, null, null, null, null, null, null, null, outreachArray, out limitInfo, out createResult);

                if (createResult[0].success)
                {
                    //Console.WriteLine(createResult[0].id + " applicant added successfully.");
                    LogErrorMessage(sw, createResult[0].id + " applicant added successfully.");

                    loan.Applicant__c = createResult[0].id;

                    loan.LAS_Loan_Id__c  = applicant.LASLoanId;
                    loan.Bank_Account__c = applicant.BankAccount.Replace("-", "").Replace(" ", "").Trim();
                    loan.Sort_Code__c    = applicant.SortCode.Replace("-", "").Replace(" ", "").Trim();

                    string loanamount = applicant.LoanAmount;
                    loan.Loan_Amount__c          = double.Parse(loanamount);
                    loan.Loan_Amount__cSpecified = true;

                    string   lastpaymentdate = applicant.LastPaymentDate;
                    DateTime lpd             = Convert.ToDateTime(lastpaymentdate);
                    loan.Last_Payment_Date__c          = lpd;
                    loan.Last_Payment_Date__cSpecified = true;

                    string amountpaid = applicant.AmountPaid;
                    loan.Amount_Paid__c          = double.Parse(amountpaid);
                    loan.Amount_Paid__cSpecified = true;

                    EnterpriseWsdl.sObject[] outreachArray2 = new EnterpriseWsdl.sObject[] { loan };

                    EnterpriseWsdl.SaveResult[] createResult2;
                    EnterpriseWsdl.LimitInfo[]  limitInfo2;

                    apiClient.create(header, null, null, null, null, null, null, null, null, null, null, outreachArray2, out limitInfo2, out createResult2);

                    if (createResult2[0].success)
                    {
                        //Console.WriteLine(createResult2[0].id + " Record added successfully.");
                        LogErrorMessage(sw, createResult2[0].id + " Record added successfully.");
                    }
                    else
                    {
                        //Console.WriteLine("Insertion failed.");
                        //Console.WriteLine(createResult2[0].errors[0].statusCode);
                        LogErrorMessage(sw, createResult2[0].errors[0].statusCode.ToString());
                    }
                    //}
                }
                else
                {
                    //Console.WriteLine("Insertion failed.");
                    //Console.WriteLine(createResult[0].errors[0].statusCode);
                    LogErrorMessage(sw, createResult[0].errors[0].statusCode.ToString());
                }
            }
        }