Exemplo n.º 1
0
        public async Task <int> CommitToServer(Signal signal)
        {
            var signalDto = Mapper.Map <Signal, SignalService.SignalDto>(signal);

            try
            {
                var client = new SignalService.SignalServiceClient();
                var result = await client.SaveAsync(signalDto);

                if (_SuspendedSignals.Count > 0)
                {
                    Task.Run(() =>
                    {
                        TransferSuspended();
                    });
                }
                return(result);
            }
            catch (CommunicationException ex)
            {
                signal.Errors.Add(ex.Message);
            }
            catch (Exception ex)
            {
                signal.Errors.Add("Can´t connect to server.");
            }

            SuspendedSignals.Add(signalDto);

            return(-1);
        }
Exemplo n.º 2
0
        private void TransferSuspended()
        {
            var tDel    = new List <SignalDto>();
            var tclient = new SignalService.SignalServiceClient();

            foreach (var tSignal in _SuspendedSignals)
            {
                try
                {
                    var tresult = tclient.SaveAsync(tSignal);
                    tDel.Add(tSignal);
                }
                catch
                { }
            }
            foreach (var tSignal in tDel)
            {
                _SuspendedSignals.Remove(tSignal);
            }
            tDel.Clear();
        }
Exemplo n.º 3
0
 private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
 {
     return(SignalServiceClient.GetEndpointAddress(EndpointConfiguration.BasicHttpBinding_ISignalService));
 }
Exemplo n.º 4
0
 private static System.ServiceModel.Channels.Binding GetDefaultBinding()
 {
     return(SignalServiceClient.GetBindingForEndpoint(EndpointConfiguration.BasicHttpBinding_ISignalService));
 }
Exemplo n.º 5
0
 public SignalServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(SignalServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
Exemplo n.º 6
0
 public SignalServiceClient(EndpointConfiguration endpointConfiguration) :
     base(SignalServiceClient.GetBindingForEndpoint(endpointConfiguration), SignalServiceClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
Exemplo n.º 7
0
 public SignalServiceClient() :
     base(SignalServiceClient.GetDefaultBinding(), SignalServiceClient.GetDefaultEndpointAddress())
 {
     this.Endpoint.Name = EndpointConfiguration.BasicHttpBinding_ISignalService.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }