public override bool Save() { TrainsCacheStorage storage = new TrainsCacheStorage(); string data = DCSerializer.SerializeWithDCS(this); storage.Clear(); bool flag = storage.Save(data, out this.LastError); base.LastError = base.LastError + string.Format(" Len={0}", data.Length); return(flag); }
public void Post(TISWebServiceGetStateSupportIN model) { TISMonitorWebService.TISWebServiceSoapClient client = this.GetClient(); string strOut, strError, strTrainOnlineData, strTrainOfflineData, strTrainGraphData, strOnlineButNotOnMapData; using (new OperationContextScope(client.InnerChannel)) { HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty(); requestMessage.Headers["Referer"] = "http://blb.csie-data.com/ClientBin/TISMonitor.xap?version22=16010101010000000"; requestMessage.Headers["Content-Type"] = "text/xml; charset=utf-8"; OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage; client.GetStateCompleted += new EventHandler <GetStateCompletedEventArgs>(this.TISWebService_GetStateCompleted); //var result = client.GetState(DCSerializer.SerializeWithDCS(model), out strOut, out strTrainOnlineData, out strTrainOfflineData, out strOnlineButNotOnMapData, out strTrainOnlineData, out strError); client.GetStateAsync(DCSerializer.SerializeWithDCS(model)); //var result = client.GetStateAsync(DCSerializer.SerializeWithDCS(model);); //result.ContinueWith(x => //{ // var x2 = x.Result.Body; // var xv = x; //}); } //client. += new EventHandler<GetStateCompletedEventArgs>(this.TISWebService_GetStateCompleted); //string strIn = DCSerializer.SerializeWithDCS(model); //var result = new TISWebServiceGetStateSupportOUT(); //var resultAsync = client.GetStateAsync(strIn); //resultAsync.ContinueWith(t => //{ // result = TISWebService_GetStateCompleted(t.Result.Body); //}); //return null; //this.m_stateIn = null; }
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); } }
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 }); } } }