Пример #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());
                }
            }
        }
Пример #3
0
        //private static void InsertApplicantsTosalesForce(EnterpriseWsdl.SoapClient apiClient)
        private static void InsertApplicantToSalesForce(EnterpriseWsdl.SoapClient apiClient, Applicant2 applicant2)
        {
            EnterpriseWsdl.Applicant__c applic2 = new EnterpriseWsdl.Applicant__c();

            if (!String.IsNullOrEmpty(applicant2.LAS_Customer_Id__c))
            {
                applic2.LAS_Customer_Id__c = applicant2.LAS_Customer_Id__c;
            }

            if (!String.IsNullOrEmpty(applicant2.LAS_User_Name__c))
            {
                applic2.LAS_User_Name__c = applicant2.LAS_User_Name__c;
            }

            if (!String.IsNullOrEmpty(applicant2.Title__c))
            {
                applic2.Title__c = applicant2.Title__c;
            }

            if (!String.IsNullOrEmpty(applicant2.First_Name__c))
            {
                applic2.First_Name__c = applicant2.First_Name__c.Replace("'", " ").Replace("-", "");
            }

            if (!String.IsNullOrEmpty(applicant2.Middle_Name__c))
            {
                applic2.Middle_Name__c = applicant2.Middle_Name__c.Replace("'", " ").Replace("-", "");
            }

            if (!String.IsNullOrEmpty(applicant2.Last_Name__c))
            {
                applic2.Last_Name__c = applicant2.Last_Name__c.Replace("'", " ").Replace("-", "");
            }

            if (!String.IsNullOrEmpty(applicant2.Email__c))
            {
                applic2.Email__c = applicant2.Email__c;
            }

            if (!String.IsNullOrEmpty(applicant2.Mobile__c))
            {
                applic2.Mobile__c = PhoneFormat(applicant2.Mobile__c);
            }

            if (!String.IsNullOrEmpty(applicant2.Date_Of_Birth__c))
            {
                string dateofbirth = DateFormat(applicant2.Date_Of_Birth__c);
                //DateTime dt = DateTime.Parse(dateofbirth);
                applic2.Date_Of_Birth__c          = DateTime.ParseExact(dateofbirth, "d/M/yyyy", CultureInfo.InvariantCulture);
                applic2.Date_Of_Birth__cSpecified = true;
            }

            if (!String.IsNullOrEmpty(applicant2.Residential_Status__c))
            {
                applic2.Residential_Status__c = applicant2.Residential_Status__c;
            }

            if (!String.IsNullOrEmpty(applicant2.Marital_Status__c))
            {
                applic2.Marital_Status__c = applicant2.Marital_Status__c;
            }

            if (!String.IsNullOrEmpty(applicant2.Postal_Code__c))
            {
                applic2.Postal_Code__c = applicant2.Postal_Code__c;
            }

            if (!String.IsNullOrEmpty(applicant2.Mobile__c))
            {
                applic2.Street__c = applicant2.Street__c;
            }

            if (!String.IsNullOrEmpty(applicant2.County__c))
            {
                applic2.County__c = applicant2.County__c;
            }

            if (!String.IsNullOrEmpty(applicant2.Landline__c))
            {
                applic2.Landline__c = PhoneFormat(applicant2.Landline__c);
            }

            if (!String.IsNullOrEmpty(applicant2.Flat_Number__c))
            {
                applic2.Flat_Number__c = applicant2.Flat_Number__c;
            }

            if (!String.IsNullOrEmpty(applicant2.Town__c))
            {
                applic2.Town__c = applicant2.Town__c;
            }

            if (!String.IsNullOrEmpty(applicant2.Password__c))
            {
                applic2.Password__c = applicant2.Password__c;
            }

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

            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)
            {
                LogApplicantInformation(sw, applicant2);

                InsertLoanToSalesforce(apiClient, applicant2, createResult[0].id);
            }
            else
            {
                LogErrorMessage(sw, "Applicant insertion failed due to : " + createResult[0].errors[0].statusCode);
            }
        }
Пример #4
0
        private static void InsertRecordsTosalesForce(EnterpriseWsdl.SessionHeader header, EnterpriseWsdl.SoapClient apiClient)
        {
            Console.WriteLine("Adding new records ...");

            EnterpriseWsdl.customer_infos__c addCustomer = new EnterpriseWsdl.customer_infos__c();

            while (myReader.Read())
            {
                addCustomer.customerid__c     = myReader["id"].ToString();
                addCustomer.account_number__c = myReader["account_number"].ToString();
                addCustomer.title__c          = myReader["title"].ToString();

                addCustomer.first_name__c  = myReader["first_name"].ToString();
                addCustomer.middle_name__c = myReader["middle_name"].ToString();
                addCustomer.last_name__c   = myReader["last_name"].ToString();

                addCustomer.address_line_1__c  = myReader["address_line_1"].ToString();
                addCustomer.address_line_2__c  = myReader["address_line_2"].ToString();
                addCustomer.address_city__c    = myReader["address_city"].ToString();
                addCustomer.adress_county__c   = myReader["adress_county"].ToString();
                addCustomer.adress_postcode__c = myReader["adress_postcode"].ToString();
                addCustomer.adress_country__c  = myReader["adress_country"].ToString();

                addCustomer.email__c             = myReader["email"].ToString();
                addCustomer.new_email_address__c = myReader["new_email_address"].ToString();

                addCustomer.phone_landline__c     = myReader["phone_landline"].ToString();
                addCustomer.new_phone_landline__c = myReader["new_phone_landline"].ToString();

                addCustomer.mobile__c     = myReader["mobile"].ToString() != "" ? myReader["mobile"].ToString() : "70000000";
                addCustomer.new_mobile__c = myReader["new_mobile"].ToString() != "" ? myReader["new_mobile"].ToString() : "0";

                addCustomer.name_of_bank__c     = myReader["name_of_bank"].ToString();
                addCustomer.name_of_new_bank__c = myReader["name_of_new_bank"].ToString();

                addCustomer.bank_sortcode__c     = myReader["bank_sortcode"].ToString();
                addCustomer.new_bank_sortcode__c = myReader["new_bank_sortcode"].ToString();

                addCustomer.bank_account_number__c = myReader["bank_account_number"].ToString();
                addCustomer.new_account_number__c  = myReader["new_account_number"].ToString();

                addCustomer.name_on_account__c     = myReader["name_on_account"].ToString();
                addCustomer.name_on_new_account__c = myReader["name_on_new_account"].ToString();

                addCustomer.monthly_net_income__c = myReader["monthly_net_income"].ToString() != "" ? myReader["monthly_net_income"].ToString() : "0";

                EnterpriseWsdl.sObject[] outreachArray = new EnterpriseWsdl.sObject[] { addCustomer };
                //outreachArray[0].Id = myReader["id"].ToString();

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

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

                if (createResult[0].success)
                {
                    Console.WriteLine("Record added successfully.");
                }
                else
                {
                    Console.WriteLine("Insertion failed.");
                }
            }
        }