Exemple #1
0
        private static void InsertRecordsToSalesForce(EnterpriseWsdl.SoapClient apiClient)
        {
            //ids = new List<string>();
            int i = 0;

            foreach (var applicant2 in applc2)
            {
                i += 1;
                Console.WriteLine("Processing ..." + i);

                ////build up soql query
                //string query = "SELECT Applicant__c FROM Loan__c where LAS_Loan_Id__c = '" + applicant2.LAS_Loan_Id__c + "'";
                //EnterpriseWsdl.QueryResult apiResult;

                //apiClient.query(header, null, null, null, query, out apiResult);

                //if (apiResult.records == null)
                //{
                try
                {
                    string query = "SELECT Id FROM Applicant__c where LAS_Customer_Id__c = '" + applicant2.Applicant__r + "'";
                    EnterpriseWsdl.QueryResult apiResult;

                    apiClient.query(header, null, null, null, query, out apiResult);

                    if (apiResult.records == null)
                    {
                        InsertApplicantToSalesForce(apiClient, applicant2);
                    }
                    else
                    {
                        EnterpriseWsdl.Applicant__c applicant = (EnterpriseWsdl.Applicant__c)apiResult.records[0];
                        InsertLoanToSalesforce(apiClient, applicant2, applicant.Id);
                    }

                    InsertStatusToSQL(applicant2);
                }
                catch (Exception e)
                {
                    LogErrorMessage(sw, applicant2.Applicant__r + " have some invalid value!");
                }

                //}
            }
        }
Exemple #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());
                }
            }
        }
Exemple #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);
            }
        }