示例#1
0
        private async Task<StateDataViewModel> GetStateDataAsync(TISWebServiceGetStateSupportIN stateIn)
        {
            GetStateResponse result = new GetStateResponse();

            using (TISWebService.TISWebServiceSoapClient client = GetClient())
            using (var scope = new FlowingOperationContextScope(client.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = CreateRequestMessageProperty();
                string strIn = DCSerializer.SerializeWithDCS(stateIn);
                try
                {
                    var webResponse = await client.GetStateAsync(strIn).ContinueOnScope(scope);
                    return GetStateData(webResponse.Body);
                }
                catch (Exception ex)
                {
                    return new StateDataViewModel { Error = ex.Message };
                }

            }
        }
示例#2
0
 private void OnTimerGetState()
 {
     if (!this.m_bInsideTimerForTrains)
     {
         this.m_bInsideTimerForTrains = true;
         TISWebServiceSoapClient client = this.GetClient();
         client.GetStateCompleted += new EventHandler<GetStateCompletedEventArgs>(this.TISWebService_GetStateCompleted);
         TISWebServiceGetStateSupportIN tin = new TISWebServiceGetStateSupportIN {
             clientLastRealTimeTrainGraphTime = this.m_serverInfo.LastTrainGraphTime,
             getRegularTraingraphData = this.m_needToFillTrainGraph,
             traingraphStart = (this.m_tgd != null) ? this.m_tgd.TimeStart : DateTime.MinValue,
             traingraphStop = (this.m_tgd != null) ? this.m_tgd.TimeStop : DateTime.MinValue
         };
         string strIn = DCSerializer.SerializeWithDCS(tin);
         if (Application.get_Current().get_Host().get_Source().AbsoluteUri.StartsWith("https") && client.Endpoint.Address.Uri.AbsoluteUri.StartsWith("http"))
         {
             client.Endpoint.Address = new EndpointAddress(client.Endpoint.Address.Uri.AbsoluteUri.Replace("http", "https"));
             (client.Endpoint.Binding as BasicHttpBinding).Security.Mode = BasicHttpSecurityMode.Transport;
         }
         client.GetStateAsync(strIn);
     }
 }