public List <BankDto> GetBankList() { UserDto currentUserDto = (UserDto)Session[Constants.SKCURRENTUSER]; Query query = new Query(); if (Helper.IsCAIdNotNull(currentUserDto)) { query.CAId = Convert.ToInt32(Helper.GetCAIdOfUser(currentUserDto)); } if (Helper.IsCAIdNotNull(currentUserDto)) { Criterion criteriaCAId = new Criterion(Constants.CAID, Helper.GetCAIdOfUser(currentUserDto), CriteriaOperator.Equal); query.Add(criteriaCAId); Criterion criteriaCAIdNULL = new Criterion(Constants.CAID, null, CriteriaOperator.IsNullOrZero); query.Add(criteriaCAIdNULL); query.QueryOperator = QueryOperator.Or; } else { Criterion criteriaCAIdNULL = new Criterion(Constants.CAID, null, CriteriaOperator.IsNullOrZero); query.Add(criteriaCAIdNULL); query.QueryOperator = QueryOperator.And; } Bankclient = new BankServiceClient(); var Banks = Bankclient.FindByQuery(query); Bankclient.Close(); return(Banks.Entities.ToList()); }
/// <summary> /// Gets list of client banks /// </summary> /// <param name="bankType">Bank type should be of client type</param> /// <returns>Returns banks of client type on page load.</returns> private BankSearchItem[] GetBanks(DataConstants.BankSearchTypes bankType) { BankServiceClient bankService = null; BankSearchItem[] banks = null; try { CollectionRequest collectionRequest = new CollectionRequest(); BankSearchCriteria criteria = new BankSearchCriteria(); criteria.IncludeArchived = false; criteria.BankSearchTypes = (int)bankType; bankService = new BankServiceClient(); BankSearchReturnValue returnValue = bankService.BankSearch(_logonSettings.LogonId, collectionRequest, criteria); if (returnValue.Success) { banks = returnValue.Banks.Rows; } else { throw new Exception(returnValue.Message); } return(banks); } catch (System.ServiceModel.EndpointNotFoundException) { _lblMessage.Text = DataConstants.WSEndPointErrorMessage; _lblMessage.CssClass = "errorMessage"; return(banks); } catch (Exception ex) { _lblMessage.CssClass = "errorMessage"; _lblMessage.Text = ex.Message; return(banks); } finally { if (bankService != null) { if (bankService.State != System.ServiceModel.CommunicationState.Faulted) { bankService.Close(); } } } }
/// <summary> /// Gets list of client banks /// </summary> /// <param name="bankType">Bank type should be of client type</param> /// <returns>Returns banks of client type on page load.</returns> private BankSearchItem[] GetBanks(DataConstants.BankSearchTypes bankType) { BankServiceClient bankService = null; BankSearchItem[] banks = null; try { CollectionRequest collectionRequest = new CollectionRequest(); BankSearchCriteria criteria = new BankSearchCriteria(); criteria.IncludeArchived = false; criteria.BankSearchTypes = (int)bankType; bankService = new BankServiceClient(); BankSearchReturnValue returnValue = bankService.BankSearch(_logonSettings.LogonId, collectionRequest, criteria); if (returnValue.Success) { banks = returnValue.Banks.Rows; } else { throw new Exception(returnValue.Message); } return banks; } catch (System.ServiceModel.EndpointNotFoundException) { _lblMessage.Text = DataConstants.WSEndPointErrorMessage; _lblMessage.CssClass = "errorMessage"; return banks; } catch (Exception ex) { _lblMessage.CssClass = "errorMessage"; _lblMessage.Text = ex.Message; return banks; } finally { if (bankService != null) { if (bankService.State != System.ServiceModel.CommunicationState.Faulted) bankService.Close(); } } }
static void Main(string[] args) { BankServiceClient bankServiceClient = new BankServiceClient(); //Doesn't seem to work, returns all records even with state code specified. var banksFromService = bankServiceClient.GetBanksForState("mo").ToList(); //Custom list to hold the branch details. var bankList = new List <BranchDetail>(); //Looping through the service list, converting data into BranchDetail class, //Adding converted branches to list. foreach (var bank in banksFromService) { var x = new BranchDetail(); x.Address = bank.Address; x.BranchName = bank.BranchName; x.ChangeDate = bank.ChangeDate; x.City = bank.City; x.NewRoutingNumber = bank.NewRoutingNumber; x.RoutingNumber = bank.RoutingNumber; x.StateCode = bank.StateCode; x.ZipCode = bank.ZipCode; x.ZipExtension = bank.ZipExtension; bankList.Add(x); } //Retrieve all branches from state code "MO" List <BranchDetail> moBranches = bankList.Where(a => a.StateCode == "MO").ToList(); //Retrieve all branches from Springfield, to write to xml file. List <BranchDetail> springfieldBranches = moBranches.Where(a => a.City == "SPRINGFIELD").ToList(); //Write to an xml file the details for all branches located in Springfield if (springfieldBranches.Any()) { WriteXML(springfieldBranches, "SpringfieldBranches"); } //List to hold branches that fail routing number validation. var validationFailedBranches = new List <BranchDetail>(); foreach (var sb in springfieldBranches) { //If routing number is valid, move on to the next element. if (ValidateRoutingNumber(sb.RoutingNumber)) { continue; } //Otherwise, add the object to list declared above. else { validationFailedBranches.Add(sb); } } //Write to an xml file the details for all branches that fail validation. if (validationFailedBranches.Any()) { WriteXML(validationFailedBranches, "ValidationFailedBranches"); } //List to hold branches returned from date range >= 01-01-2017 var dateRangeBranches = new List <BranchDetail>(); foreach (var b in bankList) { DateTime date = DateTime.MinValue; DateTime minRange = new DateTime(2017, 01, 01); //Assuming all ChangeDate values will contain the yyyy-mm-dd string split = b.ChangeDate.Substring(0, 10); if (DateTime.TryParse(split, out date)) { if (date >= minRange) { dateRangeBranches.Add(b); } } } //Write the xml file if (dateRangeBranches.Any()) { WriteXML(dateRangeBranches, "DateRangeBranches"); } bankServiceClient.Close(); }