public int InsertPolicy(int CustID) { CBLServiceReference.EpicSDK_2017_02Client EpicSDKClient = new CBLServiceReference.EpicSDK_2017_02Client(); CBLServiceReference.PolicyGetResult oPolicyResult = new CBLServiceReference.PolicyGetResult(); CBLServiceReference.PolicyFilter oPolicyFilter = new CBLServiceReference.PolicyFilter(); CBLServiceReference.Policy pol = new CBLServiceReference.Policy(); pol.AccountID = CustID; pol.EffectiveDate = new DateTime(2020, 10, 01); pol.ExpirationDate = new DateTime(2021, 09, 30); pol.IssuingCompanyLookupCode = "SASKA1"; pol.StatusCode = "NEW"; pol.PolicyTypeCode = "BLIA"; pol.Description = "Commercial General Liability/PAL/Special Events"; pol.LineTypeCode = "BLIA"; pol.IssuingLocationCode = "ON"; pol.AgencyCode = "66"; pol.BranchCode = "HIG"; pol.DepartmentCode = "CL"; pol.ProfitCenterCode = "CIPU"; pol.PolicyNumber = "TEST123AC"; IPolicyID = EpicSDKClient.Insert_Policy(oMessageHeader, pol); Console.WriteLine(IPolicyID); //EpicSDKClient.Close(); return(IPolicyID); }
public int InsertPolicySQL(string polNum) { CBLServiceReference.EpicSDK_2017_02Client EpicSDKClient = new CBLServiceReference.EpicSDK_2017_02Client(); CBLServiceReference.PolicyGetResult oPolicyResult = new CBLServiceReference.PolicyGetResult(); CBLServiceReference.PolicyFilter oPolicyFilter = new CBLServiceReference.PolicyFilter(); CBLServiceReference.Policy pol = new CBLServiceReference.Policy(); SqlConnection conn = new SqlConnection(ConnectionString); //List<EpicIntegrator.Policy> pols = new List<EpicIntegrator.Policy>(); //List<EpicIntegrator.Policy> polFirst = new List<EpicIntegrator.Policy>(); string SQL = System.IO.File.ReadAllText(@"C:\Users\Abhishek\Documents\Abhi _ IMP\Sep29\SQLpolDetails.txt"); string query = SQL + polNum + "';"; //Console.WriteLine(query); SqlCommand command = new SqlCommand(query, conn); conn.Open(); SqlDataReader rdr = command.ExecuteReader(); if (rdr.HasRows) { while (rdr.Read()) { pol.AccountID = Convert.ToInt32(rdr["UniqEntity"].ToString()); //pol.EffectiveDate = new DateTime(2000, 01, 01); //pol.ExpirationDate = new DateTime(2000, 01, 01); pol.EffectiveDate = Convert.ToDateTime(rdr["EffectiveDate"]); pol.ExpirationDate = Convert.ToDateTime(rdr["ExpirationDate"]); pol.IssuingCompanyLookupCode = rdr["LookupCode"].ToString(); pol.StatusCode = rdr["CdLineStatusCode"].ToString(); pol.PolicyTypeCode = "BLIA"; pol.Description = "Commercial General Liability/PAL/Special Events"; pol.LineTypeCode = "BLIA"; pol.IssuingLocationCode = rdr["CdStateCodeIssuing"].ToString(); pol.AgencyCode = rdr["AgencyCode"].ToString(); pol.BranchCode = rdr["BranchCode"].ToString(); pol.DepartmentCode = rdr["DepartmentCode"].ToString(); pol.ProfitCenterCode = rdr["ProfitCenterCode"].ToString(); pol.PolicyNumber = rdr["PolicyNumber"].ToString() + "SDK"; IPolicyID = EpicSDKClient.Insert_Policy(oMessageHeader, pol); } } else { IPolicyID = 0; } rdr.Close(); return(IPolicyID); }
//public List<EpicIntegrator.Policy> GetPolicyFields(int CustID) //{ //} public void TestPolicyConnect(int OldPolID) { CBLServiceReference.EpicSDK_2017_02Client EpicSDKClient = new CBLServiceReference.EpicSDK_2017_02Client(); CBLServiceReference.PolicyGetResult oPolicyResult = new CBLServiceReference.PolicyGetResult(); CBLServiceReference.PolicyFilter oPolicyFilter = new CBLServiceReference.PolicyFilter(); CBLServiceReference.Policy oPol = new CBLServiceReference.Policy(); oPolicyFilter.PolicyID = OldPolID; oPolicyResult = EpicSDKClient.Get_Policy(oMessageHeader, oPolicyFilter, 0); oPol = oPolicyResult.Policies[0]; Console.WriteLine(oPol.PolicyID); Console.WriteLine(oPol.PolicyNumber); Console.WriteLine(oPol.Description); //string newDesc = oPol.Description + "_x"; oPol.Description = "Commercial General Liability"; Console.WriteLine(oPol.Description); EpicSDKClient.Update_Policy(oMessageHeader, oPol); }
public CBLServiceReference.Policy GetPolicy(int CustID) { CBLServiceReference.EpicSDK_2017_02Client EpicSDKClient = new CBLServiceReference.EpicSDK_2017_02Client(); CBLServiceReference.PolicyGetResult oPolicyResult = new CBLServiceReference.PolicyGetResult(); CBLServiceReference.PolicyFilter oPolicyFilter = new CBLServiceReference.PolicyFilter(); CBLServiceReference.Policy pol = new CBLServiceReference.Policy(); oPolicyFilter.ClientID = CustID; //oPolicyFilter.ExpirationDateBegins > DateTime.Now.Date; oPolicyResult = EpicSDKClient.Get_Policy(oMessageHeader, oPolicyFilter, 0); Console.WriteLine(oPolicyResult.Policies.Length); Console.WriteLine(oPolicyResult.Policies[0]); Console.WriteLine(oPolicyResult.Policies[1]); Console.WriteLine(oPolicyResult.Policies[2]); pol = oPolicyResult.Policies[0]; return(pol); }
static void RunConversion() { EpicIntegrator.ConversionService cs = new EpicIntegrator.ConversionService(); List <Tuple <int, int> > polList = new List <Tuple <int, int> >(); CBLServiceReference.Policy pol = new CBLServiceReference.Policy(); CBLServiceReference.Line1 lne = new CBLServiceReference.Line1(); CBLServiceReference.MultiCarrierSchedule mcs = new CBLServiceReference.MultiCarrierSchedule(); CBLServiceReference.Applicant9 acs = new CBLServiceReference.Applicant9(); CBLServiceReference.EmployeeClass emp = new CBLServiceReference.EmployeeClass(); string ErrorString2 = ""; // Get all policies polList = cs.GetPolicyList(); if (polList == null) { Console.WriteLine("No record to process!"); Console.ReadKey(); return; } //Reading all policies one at a time int PolzCount = polList.Count; int PolzCounter = 0; Console.WriteLine("CONNS STATE " + conns.State); if (conns.State == ConnectionState.Closed) { conns.Open(); } Console.WriteLine("CONNS STATE NEW " + conns.State); System.Threading.Thread.Sleep(2000); foreach (Tuple <int, int> poli in polList) //Parallel.ForEach(polList, poli => { PolzCounter++; Console.WriteLine("*-*-*- READING POL " + PolzCounter + " OF " + PolzCount + "*-*-*"); string ErrorString3 = ""; int OldPolID = poli.Item1; int CFormExists = poli.Item2; Console.WriteLine("*-*-*-*-*"); Console.WriteLine("Old Policy ID: " + OldPolID); //if (conns.State == ConnectionState.Closed) //For Parallel Processing //{ // conns.Open(); //} // SQL Start Time using (SqlCommand commandOne = conns.CreateCommand()) { string sqltwo = string.Format("update {0} set StartTime = GETDATE() WHERE OldPolID = @OldPolID;", DBtables); commandOne.CommandText = sqltwo; commandOne.Parameters.AddWithValue("@OldPolID", OldPolID); commandOne.ExecuteNonQuery(); } //Check if Policy and Line TypeCodes are valid bool CheckValidLineType = cs.CheckValidTypeCode(OldPolID); if (CheckValidLineType == true) { try { // Create a new policy Tuple <int, bool, string, string, int> NewPolicyResult = cs.CreatePolicy(OldPolID); //finalcheck int NewPolId = NewPolicyResult.Item1; Console.WriteLine("New Pol ID: " + NewPolId); bool HasMCS = NewPolicyResult.Item2; // wait 3 seconds for new policy data to commit to DB System.Threading.Thread.Sleep(2000); if (NewPolId.ToString().Length > 1) { //Update table with new Policy Number using (SqlCommand commandTwo = conns.CreateCommand()) { string sqlnine = string.Format("update {0} set NewPolID = @NewPolID, HasMCS = @hasMCS, NewPolLineTypeCode = @NewPolLineTypeCode, NewPolNum = @NewPolNum, NewPolicyInserted = GETDATE() WHERE OldPolID = @OldPolID;", DBtables); commandTwo.CommandText = sqlnine; commandTwo.Parameters.AddWithValue("@NewPolID", NewPolicyResult.Item1); commandTwo.Parameters.AddWithValue("@hasMCS", NewPolicyResult.Item2); commandTwo.Parameters.AddWithValue("@NewPolLineTypeCode", NewPolicyResult.Item3); commandTwo.Parameters.AddWithValue("@NewPolNum", NewPolicyResult.Item4); commandTwo.Parameters.AddWithValue("@OldPolID", NewPolicyResult.Item5); commandTwo.ExecuteNonQuery(); } //Update line bool LineUpdateSuccess = false; try { cs.UpdateLine(OldPolID, NewPolId); LineUpdateSuccess = true; using (SqlCommand commandUpdateLine = conns.CreateCommand()) { string sqlfour = string.Format("update {0} set LineInfoUpdated = GETDATE() WHERE OldPolID = @OldPolID;", DBtables); commandUpdateLine.CommandText = sqlfour; commandUpdateLine.Parameters.AddWithValue("@OldPolID", OldPolID); commandUpdateLine.ExecuteNonQuery(); } } catch (Exception e) { string e31 = OldPolID + " | Line Update failed | " + e; //ErrorString2 = ErrorString2 + e31 + System.Environment.NewLine; ErrorString3 = ErrorString3 + e31 + System.Environment.NewLine; Console.WriteLine(e31); } finally { if (LineUpdateSuccess == true) { // Try updating line PRBR try { cs.UpdateLinePRBR(OldPolID, NewPolId); } catch (Exception e) { string e32 = OldPolID + " | Line PR/BR failed | " + e; //ErrorString2 = ErrorString2 + e32 + System.Environment.NewLine; ErrorString3 = ErrorString3 + e32 + System.Environment.NewLine; Console.WriteLine(e32); } } } // Update MCS if (HasMCS == true) { try { cs.ReadMCS(OldPolID, NewPolId); using (SqlCommand commandMCSupdate = conns.CreateCommand()) { string sqlthree = string.Format("update {0} set MCSUpdated = GETDATE() WHERE OldPolID = @OldPolID;", DBtables); commandMCSupdate.CommandText = sqlthree; commandMCSupdate.Parameters.AddWithValue("@OldPolID", OldPolID); commandMCSupdate.ExecuteNonQuery(); } } catch (Exception e) { string e33 = OldPolID + " | MCS Update failed | " + e; //ErrorString2 = ErrorString2 + e33 + System.Environment.NewLine; ErrorString3 = ErrorString3 + e33 + System.Environment.NewLine; Console.WriteLine(e33); } } // Updating Custom Forms if (CFormExists == 1) { //Update Policy Info try { cs.UpdatePolicyInfoApplicatLocation(OldPolID, NewPolId); using (SqlCommand commandAppLoc = conns.CreateCommand()) { string sqlfive = string.Format("update {0} set PolAppLocUpdated = GETDATE() WHERE OldPolID = @OldPolID;", DBtables); commandAppLoc.CommandText = sqlfive; commandAppLoc.Parameters.AddWithValue("@OldPolID", OldPolID); commandAppLoc.ExecuteNonQuery(); } } catch (Exception e) { string e34 = OldPolID + " | Policy Info Applicant Location failed | " + e; //ErrorString2 = ErrorString2 + e34 + System.Environment.NewLine; ErrorString3 = ErrorString3 + e34 + System.Environment.NewLine; Console.WriteLine(e34); } // Update Other Long Form Details try { cs.UpdateOtherLongFormDetails(OldPolID, NewPolId); } catch (Exception e) { string e35 = OldPolID + " | Other Long Form Details failed | " + e; //ErrorString2 = ErrorString2 + e35 + System.Environment.NewLine; ErrorString3 = ErrorString3 + e35 + System.Environment.NewLine; Console.WriteLine(e35); } // Update Long Form / Short Form / BSCA1 try { bool LSformUpdate = cs.LongShortFormUpdate(OldPolID, NewPolId); if (LSformUpdate == true) { using (SqlCommand commandLongFormUpdate = conns.CreateCommand()) { string sqlsix = string.Format("update {0} set CFormUpdated = GETDATE() WHERE OldPolID = @OldPolID;", DBtables); commandLongFormUpdate.CommandText = sqlsix; commandLongFormUpdate.Parameters.AddWithValue("@OldPolID", OldPolID); commandLongFormUpdate.ExecuteNonQuery(); } } } catch (Exception e) { string e36 = OldPolID + " | Long/Short/BSCA Form failed | " + e; //ErrorString2 = ErrorString2 + e36 + System.Environment.NewLine; ErrorString3 = ErrorString3 + e36 + System.Environment.NewLine; Console.WriteLine(e36); } } try { using (SqlCommand commandOne = conns.CreateCommand()) { string sql11 = string.Format("update {0} set EndTime = GETDATE(), ConversionSuccessful = 1, Error = @Error WHERE OldPolID = @OldPolID;", DBtables); commandOne.CommandText = sql11; commandOne.Parameters.AddWithValue("@OldPolID", OldPolID); commandOne.Parameters.AddWithValue("@Error", ErrorString3); commandOne.ExecuteNonQuery(); } } catch (Exception e) { string e37 = OldPolID + " | Policy update failed | " + e; //ErrorString2 = ErrorString2 + e37 + System.Environment.NewLine; Console.WriteLine(e37); } } } catch (Exception e) { string e51 = OldPolID + " | Policy has Line Type Code issue | " + e; ErrorString2 = ErrorString2 + e51 + System.Environment.NewLine; Console.WriteLine(e51); } } //conns.Close(); // Fred's Pre Policy insert SSR adjustments come here ////Update Line //cs.UpdateLine(OldPolID, NewPolId); //Update Line PRBR //cs.UpdateLinePRBR(OldPolID, NewPolId); ////Read MCS //if (HasMCS == true) //{ // cs.ReadMCS(OldPolID, NewPolId); //} //if (CFormExists == 1) //{ // //Update Policy Info // cs.UpdatePolicyInfoApplicatLocation(OldPolID, NewPolId); // // Update Other Long Form Details // cs.UpdateOtherLongFormDetails(OldPolID, NewPolId); // // Update Long Form / Short Form / BSCA1 // cs.LongShortFormUpdate(OldPolID, NewPolId); //} //// Fred's Post Policy insert SSR adjustments come here //if (CFormExists == 1) //{ // cs.CFYesFinalUpdate(OldPolID); //} //else if (CFormExists == 0) //{ // cs.CFNoFinalUpdate(OldPolID); //} Console.WriteLine("Completed Policy - " + OldPolID); } //); // Parallel threading for each ending Tuple <string, string> ErrorCarry = cs.CatchErrors(); ErrorString2 = ErrorString2 + ErrorCarry.Item1; string[] ErrorString33 = new string[] { ErrorString2 }; string ErrorPathFull = ErrorCarry.Item2 + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"; File.WriteAllLines(ErrorPathFull, ErrorString33); Console.WriteLine("*-*-*-DONE*-*-*"); conns.Close(); Console.ReadKey(); }