public object Search(queryrequest xml) { SemWeb.Query.Query query = null; string q = string.Empty; try { query = new SparqlEngine(new StringReader(xml.query)); } catch (QueryFormatException ex) { var malformed = new malformedquery(); malformed.faultdetails = ex.Message; return malformed; } // Load the data from sql server SemWeb.Stores.SQLStore store; string connstr = ConfigurationManager.ConnectionStrings["SemWebDB"].ConnectionString; DebugLogging.Log(connstr); store = (SemWeb.Stores.SQLStore)SemWeb.Store.CreateForInput(connstr); //Create a Sink for the results to be writen once the query is run. MemoryStream ms = new MemoryStream(); XmlTextWriter writer = new XmlTextWriter(ms, System.Text.Encoding.UTF8); QueryResultSink sink = new SparqlXmlQuerySink(writer); try { // Run the query. query.Run(store, sink); } catch (Exception ex) { // Run the query. query.Run(store, sink); DebugLogging.Log("Run the query a second time"); DebugLogging.Log(ex.Message); } //flush the writer then load the memory stream writer.Flush(); ms.Seek(0, SeekOrigin.Begin); //Write the memory stream out to the response. ASCIIEncoding ascii = new ASCIIEncoding(); DebugLogging.Log(ascii.GetString(ms.ToArray()).Replace("???", "")); writer.Close(); DebugLogging.Log("End of Processing"); return SerializeXML.DeserializeObject(ascii.GetString(ms.ToArray()).Replace("???", ""), typeof(sparql)) as sparql; }
public VehicleSpecification GetWebdata() { Model modal = new Model(); decodersettings decoder_settings = new decodersettings(); commondatapacks common_data_packs = new commondatapacks(); styledatapacks style_data_packs = new styledatapacks(); queryrequest query_requests = new queryrequest(); requestsample Request_Sample = new requestsample(); Request_Sample.vin = vinApprisal_txb.Value.ToString(); Request_Sample.year = ""; query_requests.Request_Sample = Request_Sample; common_data_packs.basic_data = "on"; common_data_packs.single_stock = "on"; style_data_packs.basic_data = "on"; style_data_packs.engines = "on"; style_data_packs.transmissions = "on"; style_data_packs.single_stock = "on"; decoder_settings.common_data_packs = common_data_packs; decoder_settings.style_data_packs = style_data_packs; decoder_settings.display = "full"; decoder_settings.version = "7.0.1"; decoder_settings.styles = "on"; decoder_settings.common_data = "on"; modal.decoder_settings = decoder_settings; modal.query_requests = query_requests; string jsondata = JsonConvert.SerializeObject(modal); //CallLink(); VehicleSpecification spec = new VehicleSpecification(); spec.VIN = vinApprisal_txb.Value.ToString(); WebServiceRepository wr = new WebServiceRepository(); spec = wr.CallLink(jsondata); return(spec); }