private bool GetBranchList() { var request = new GetBranchListRequest() { PartnerIds = new int[] { PartnerID }, UserRequestInfo = User }; var response = Client.GetBranchList(request); var connection = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString; if (response.WasSuccessful && response.RequestedData != null) { try { //parse response, get a list of branch and update property for next method. BranchList = response.RequestedData[0].BranchCodes.ToList().ConvertAll(c => new Branch() { BranchCode = c }); var branchDataTable = new DataTable(); using (var reader = ObjectReader.Create(BranchList, "BranchCode")) { branchDataTable.Load(reader); } clsLog.LogInfo("GetBranchList - trying to save branch list, Records found " + branchDataTable.Rows.Count); //and send it to DB. Merge this list with existing branch list using (SqlConnection con = new SqlConnection(connection)) { using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con)) { sqlBulkCopy.DestinationTableName = "dyndata.dbo.branch_stg"; con.Open(); sqlBulkCopy.BulkCopyTimeout = 0; sqlBulkCopy.WriteToServer(branchDataTable); SqlCommand cmd = new SqlCommand("dyndata.dbo.SP_BRANCH", con); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); con.Close(); } } clsLog.LogInfo("GetBranchList - saved branch list"); } catch (Exception ex) { clsLog.LogError("GetBranchList - Error while getting branch list from remote. Error " + ex.Message); return false; } return true; } else { clsLog.LogInfo("GetBranchList - didn't get branch list from remote"); clsLog.LogInfo("Response from server : " + response.Errors[0]); return false; } }
public void GetBranchListTest() { var request = new GetBranchListRequest() { PartnerIds = new int[] { PartnerID }, UserRequestInfo = User }; var branchList = Client.GetBranchList(request); Assert.IsTrue(branchList.WasSuccessful); }