Skip to content

Commit

Permalink
Add HelperClass to check if service is available to avoid errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanDeveloper committed Jun 19, 2017
1 parent a9e83f2 commit 3ac4311
Show file tree
Hide file tree
Showing 42 changed files with 1,151 additions and 253 deletions.
10 changes: 5 additions & 5 deletions LigaManagerAdminClient/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IBettorClientService" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
<binding name="BasicHttpBinding_IBettorClientService" closeTimeout="00:10:00"
openTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/LigaManagerServer/AdminClientService/"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IBettorClientService"
contract="AdminClientService.IAdminClientService" name="BasicHttpBinding_IBettorClientService" />
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IBettorClientService"
contract="AdminClientService.IAdminClientService" name="BasicHttpBinding_IBettorClientService" />
</client>
</system.serviceModel>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ public int Sequence {
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="AdminClientService.IAdminClientService")]
public interface IAdminClientService {

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILigaManagerService/IsOpen", ReplyAction="http://tempuri.org/ILigaManagerService/IsOpenResponse")]
bool IsOpen();

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILigaManagerService/IsOpen", ReplyAction="http://tempuri.org/ILigaManagerService/IsOpenResponse")]
System.Threading.Tasks.Task<bool> IsOpenAsync();

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILigaManagerService/GetMatches", ReplyAction="http://tempuri.org/ILigaManagerService/GetMatchesResponse")]
LigaManagerAdminClient.AdminClientService.Match[] GetMatches(LigaManagerAdminClient.AdminClientService.Season season);

Expand Down Expand Up @@ -488,6 +494,12 @@ public interface IAdminClientService {
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILigaManagerService/GetTeams", ReplyAction="http://tempuri.org/ILigaManagerService/GetTeamsResponse")]
System.Threading.Tasks.Task<LigaManagerAdminClient.AdminClientService.SeasonToTeamRelation[]> GetTeamsAsync(LigaManagerAdminClient.AdminClientService.Season season);

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILigaManagerService/GetAllTeams", ReplyAction="http://tempuri.org/ILigaManagerService/GetAllTeamsResponse")]
LigaManagerAdminClient.AdminClientService.SeasonToTeamRelation[] GetAllTeams();

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ILigaManagerService/GetAllTeams", ReplyAction="http://tempuri.org/ILigaManagerService/GetAllTeamsResponse")]
System.Threading.Tasks.Task<LigaManagerAdminClient.AdminClientService.SeasonToTeamRelation[]> GetAllTeamsAsync();

[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IAdminClientService/AddBettor", ReplyAction="http://tempuri.org/IAdminClientService/AddBettorResponse")]
bool AddBettor(LigaManagerAdminClient.AdminClientService.Bettor bettor);

Expand Down Expand Up @@ -594,6 +606,14 @@ public AdminClientServiceClient(System.ServiceModel.Channels.Binding binding, Sy
base(binding, remoteAddress) {
}

public bool IsOpen() {
return base.Channel.IsOpen();
}

public System.Threading.Tasks.Task<bool> IsOpenAsync() {
return base.Channel.IsOpenAsync();
}

public LigaManagerAdminClient.AdminClientService.Match[] GetMatches(LigaManagerAdminClient.AdminClientService.Season season) {
return base.Channel.GetMatches(season);
}
Expand Down Expand Up @@ -650,6 +670,14 @@ public LigaManagerAdminClient.AdminClientService.SeasonToTeamRelation[] GetTeams
return base.Channel.GetTeamsAsync(season);
}

public LigaManagerAdminClient.AdminClientService.SeasonToTeamRelation[] GetAllTeams() {
return base.Channel.GetAllTeams();
}

public System.Threading.Tasks.Task<LigaManagerAdminClient.AdminClientService.SeasonToTeamRelation[]> GetAllTeamsAsync() {
return base.Channel.GetAllTeamsAsync();
}

public bool AddBettor(LigaManagerAdminClient.AdminClientService.Bettor bettor) {
return base.Channel.AddBettor(bettor);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
<xsd:import namespace="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="IAdminClientService_IsOpen_InputMessage">
<wsdl:part name="parameters" element="tns:IsOpen" />
</wsdl:message>
<wsdl:message name="IAdminClientService_IsOpen_OutputMessage">
<wsdl:part name="parameters" element="tns:IsOpenResponse" />
</wsdl:message>
<wsdl:message name="IAdminClientService_GetMatches_InputMessage">
<wsdl:part name="parameters" element="tns:GetMatches" />
</wsdl:message>
Expand Down Expand Up @@ -49,6 +55,12 @@
<wsdl:message name="IAdminClientService_GetTeams_OutputMessage">
<wsdl:part name="parameters" element="tns:GetTeamsResponse" />
</wsdl:message>
<wsdl:message name="IAdminClientService_GetAllTeams_InputMessage">
<wsdl:part name="parameters" element="tns:GetAllTeams" />
</wsdl:message>
<wsdl:message name="IAdminClientService_GetAllTeams_OutputMessage">
<wsdl:part name="parameters" element="tns:GetAllTeamsResponse" />
</wsdl:message>
<wsdl:message name="IAdminClientService_AddBettor_InputMessage">
<wsdl:part name="parameters" element="tns:AddBettor" />
</wsdl:message>
Expand Down Expand Up @@ -128,6 +140,10 @@
<wsdl:part name="parameters" element="tns:GenerateMatchesResponse" />
</wsdl:message>
<wsdl:portType name="IAdminClientService">
<wsdl:operation name="IsOpen">
<wsdl:input wsaw:Action="http://tempuri.org/ILigaManagerService/IsOpen" message="tns:IAdminClientService_IsOpen_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/ILigaManagerService/IsOpenResponse" message="tns:IAdminClientService_IsOpen_OutputMessage" />
</wsdl:operation>
<wsdl:operation name="GetMatches">
<wsdl:input wsaw:Action="http://tempuri.org/ILigaManagerService/GetMatches" message="tns:IAdminClientService_GetMatches_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/ILigaManagerService/GetMatchesResponse" message="tns:IAdminClientService_GetMatches_OutputMessage" />
Expand Down Expand Up @@ -156,6 +172,10 @@
<wsdl:input wsaw:Action="http://tempuri.org/ILigaManagerService/GetTeams" message="tns:IAdminClientService_GetTeams_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/ILigaManagerService/GetTeamsResponse" message="tns:IAdminClientService_GetTeams_OutputMessage" />
</wsdl:operation>
<wsdl:operation name="GetAllTeams">
<wsdl:input wsaw:Action="http://tempuri.org/ILigaManagerService/GetAllTeams" message="tns:IAdminClientService_GetAllTeams_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/ILigaManagerService/GetAllTeamsResponse" message="tns:IAdminClientService_GetAllTeams_OutputMessage" />
</wsdl:operation>
<wsdl:operation name="AddBettor">
<wsdl:input wsaw:Action="http://tempuri.org/IAdminClientService/AddBettor" message="tns:IAdminClientService_AddBettor_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IAdminClientService/AddBettorResponse" message="tns:IAdminClientService_AddBettor_OutputMessage" />
Expand Down Expand Up @@ -211,6 +231,15 @@
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IAdminClientService" type="tns:IAdminClientService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="IsOpen">
<soap:operation soapAction="http://tempuri.org/ILigaManagerService/IsOpen" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetMatches">
<soap:operation soapAction="http://tempuri.org/ILigaManagerService/GetMatches" style="document" />
<wsdl:input>
Expand Down Expand Up @@ -274,6 +303,15 @@
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetAllTeams">
<soap:operation soapAction="http://tempuri.org/ILigaManagerService/GetAllTeams" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="AddBettor">
<soap:operation soapAction="http://tempuri.org/IAdminClientService/AddBettor" style="document" />
<wsdl:input>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://tempuri.org/" elementFormDefault="qualified" targetNamespace="http://tempuri.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" />
<xs:element name="IsOpen">
<xs:complexType>
<xs:sequence />
</xs:complexType>
</xs:element>
<xs:element name="IsOpenResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="IsOpenResult" type="xs:boolean" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetMatches">
<xs:complexType>
<xs:sequence>
Expand Down Expand Up @@ -93,10 +105,22 @@
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetAllTeams">
<xs:complexType>
<xs:sequence />
</xs:complexType>
</xs:element>
<xs:element name="GetAllTeamsResponse">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q11="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="GetAllTeamsResult" nillable="true" type="q11:ArrayOfSeasonToTeamRelation" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="AddBettor">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q11="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="bettor" nillable="true" type="q11:Bettor" />
<xs:element xmlns:q12="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="bettor" nillable="true" type="q12:Bettor" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -110,7 +134,7 @@
<xs:element name="UpdateBettor">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q12="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="bettor" nillable="true" type="q12:Bettor" />
<xs:element xmlns:q13="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="bettor" nillable="true" type="q13:Bettor" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -124,7 +148,7 @@
<xs:element name="DeleteBettor">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q13="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="bettor" nillable="true" type="q13:Bettor" />
<xs:element xmlns:q14="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="bettor" nillable="true" type="q14:Bettor" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -138,7 +162,7 @@
<xs:element name="AddTeam">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q14="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="team" nillable="true" type="q14:Team" />
<xs:element xmlns:q15="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="team" nillable="true" type="q15:Team" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -152,7 +176,7 @@
<xs:element name="UpdateTeam">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q15="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="team" nillable="true" type="q15:Team" />
<xs:element xmlns:q16="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="team" nillable="true" type="q16:Team" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -166,7 +190,7 @@
<xs:element name="DeleteTeam">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q16="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="team" nillable="true" type="q16:Team" />
<xs:element xmlns:q17="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="team" nillable="true" type="q17:Team" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -180,7 +204,7 @@
<xs:element name="DeleteSeason">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q17="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="season" nillable="true" type="q17:Season" />
<xs:element xmlns:q18="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="season" nillable="true" type="q18:Season" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -194,7 +218,7 @@
<xs:element name="AddSeason">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q18="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="season" nillable="true" type="q18:Season" />
<xs:element xmlns:q19="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="season" nillable="true" type="q19:Season" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -208,7 +232,7 @@
<xs:element name="UpdateSeason">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q19="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="season" nillable="true" type="q19:Season" />
<xs:element xmlns:q20="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="season" nillable="true" type="q20:Season" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -222,7 +246,7 @@
<xs:element name="DeleteMatch">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q20="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="match" nillable="true" type="q20:Match" />
<xs:element xmlns:q21="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="match" nillable="true" type="q21:Match" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -236,7 +260,7 @@
<xs:element name="AddMatch">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q21="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="match" nillable="true" type="q21:Match" />
<xs:element xmlns:q22="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="match" nillable="true" type="q22:Match" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand All @@ -250,7 +274,7 @@
<xs:element name="UpdateMatch">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q22="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="match" nillable="true" type="q22:Match" />
<xs:element xmlns:q23="http://schemas.datacontract.org/2004/07/LigaManagerServer.Models" minOccurs="0" name="match" nillable="true" type="q23:Match" />
</xs:sequence>
</xs:complexType>
</xs:element>
Expand Down
41 changes: 41 additions & 0 deletions LigaManagerAdminClient/Controllers/AddBettorWindowController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using LigaManagerAdminClient.AdminClientService;
using LigaManagerAdminClient.ViewModels;
using LigaManagerAdminClient.Views;
using LigaManagerBettorClient.Frameworks;

namespace LigaManagerAdminClient.Controllers
{
public class AddBettorWindowController
{
private AddBettorWindow _view;
private AddBettorWindowViewModel _viewModel;

public Bet Bet { get; set; }

public Bettor ShowBettor()
{
#region View and ViewModel
_view = new AddBettorWindow();
_viewModel = new AddBettorWindowViewModel
{
OkCommand = new RelayCommand(ExecuteOkCommand),
CancelCommand = new RelayCommand(ExecuteCancelCommand)
};
#endregion

return _view.ShowDialog() == true ? _viewModel.Bettor : null;
}

public void ExecuteOkCommand(object obj)
{
_view.DialogResult = true;
_view.Close();
}

public void ExecuteCancelCommand(object obj)
{
_view.DialogResult = false;
_view.Close();
}
}
}
5 changes: 4 additions & 1 deletion LigaManagerAdminClient/Controllers/BettorWindowController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Linq;
using System.Windows;
using LigaManagerAdminClient.AdminClientService;
using LigaManagerAdminClient.Framework;
using LigaManagerAdminClient.ViewModels;
using LigaManagerAdminClient.Views;
using LigaManagerBettorClient.Frameworks;
Expand All @@ -15,10 +16,12 @@ public class BettorWindowController
private MainWindow _mainWindow;
private AdminClientServiceClient _adminClient;

public void Initialize(MainWindow mainWindow)
public async void Initialize(MainWindow mainWindow)
{
_mainWindow = mainWindow;
_adminClient = new AdminClientServiceClient();
// Check if service is available
if (!await AdminClientHelper.IsAvailable(_adminClient)) return;
// Get all bettors
var bettors = _adminClient.GetBettors();

Expand Down
Loading

0 comments on commit 3ac4311

Please sign in to comment.