/// <summary> /// Gets URL upon calling which the required study data can be retrieved. /// </summary> /// <param name="studyUIDs">List of UIDs for the studies to be retrieved</param> /// <param name="endPointUrl">URL of the NBIA Data Service to query. This is NOT the Data Transfer URL!</param> /// <returns>URL that returns zip file with the studies</returns> public string retrieveStudyURL(string[] studyUIDs, string endPointUrl) { TransferServiceContextService.DataTransferDescriptor dtd; using (NCIACoreServicePortTypeClient proxy = new NCIACoreServicePortTypeClient("NCIACoreServicePortTypePort", endPointUrl)) { try { TransferServiceContextReference tras = proxy.retrieveDicomDataByStudyUIDs(studyUIDs); // new TransferServiceContextReference(); EndpointReferenceType endPoint = tras.EndpointReference; // new EndpointReferenceType(); AddressHeader[] ah = new AddressHeader[endPoint.ReferenceProperties.Any.Length]; for (int lcv = 0; lcv < ah.Length; lcv++) { XmlElement refProp = endPoint.ReferenceProperties.Any[lcv]; ah[lcv] = AddressHeader.CreateAddressHeader(refProp.LocalName, refProp.NamespaceURI, refProp.InnerText); } EndpointAddress ea = new EndpointAddress(new Uri(endPoint.Address.Value), ah); // create binding by hand so we don't have to associate a config file with a dll BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.Name = "TransferServiceContextPortTypePort"; TransferServiceContextPortTypeClient transProxy = new TransferServiceContextPortTypeClient(binding, ea); dtd = transProxy.getDataTransferDescriptor(); } catch (System.Net.WebException ex) { System.Console.WriteLine(ex.Message); //never gets here throw new GridServicerException("Error querying NCIA Grid", ex); } catch (Exception e) { System.Console.WriteLine(e.Message); //never gets here throw new GridServicerException("Error retrieving from NCIA Grid", e); } } if (string.IsNullOrEmpty(dtd.url)) { return(dtd.url); } else { return(null); } }
public string retrieveStudyURL(string[] studyUIDs, string endPointUrl) { TransferServiceContextService.DataTransferDescriptor dtd; try { var proxy = new NCIACoreServicePortTypeClient(); var tras = proxy.retrieveDicomDataByStudyUIDs(studyUIDs); var endPoint = tras.EndpointReference; var ah = new AddressHeader[endPoint.ReferenceProperties.Any.Length]; proxy.Endpoint.Address = new EndpointAddress(endPointUrl); for (var lcv = 0; lcv < ah.Length; lcv++) { var refProp = endPoint.ReferenceProperties.Any[lcv]; ah[lcv] = AddressHeader.CreateAddressHeader(refProp.LocalName, refProp.NamespaceURI, refProp.InnerText); } var ea = new EndpointAddress(new Uri(endPoint.Address.Value), ah); var binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.Name = "TransferServiceContextPortTypePort"; var transProxy = new TransferServiceContextPortTypeClient(binding, ea); dtd = transProxy.getDataTransferDescriptor(); } catch (WebException ex) { Console.WriteLine(ex.Message); throw new GridServicerException("Error querying NCIA Grid", ex); } catch (Exception e) { Console.WriteLine(e.Message); throw new GridServicerException("Error retrieving from NCIA Grid", e); } if (dtd.url != null || dtd.url.Equals("")) { return(dtd.url); } else { return(null); } }
public string retrieveStudyURL(string[] studyUIDs, string endPointUrl) { TransferServiceContextService.DataTransferDescriptor dtd; try { var proxy = new NCIACoreServicePortTypeClient(); var tras = proxy.retrieveDicomDataByStudyUIDs(studyUIDs); var endPoint = tras.EndpointReference; var ah = new AddressHeader[endPoint.ReferenceProperties.Any.Length]; proxy.Endpoint.Address = new EndpointAddress(endPointUrl); for (var lcv = 0; lcv < ah.Length; lcv++) { var refProp = endPoint.ReferenceProperties.Any[lcv]; ah[lcv] = AddressHeader.CreateAddressHeader(refProp.LocalName, refProp.NamespaceURI, refProp.InnerText); } var ea = new EndpointAddress(new Uri(endPoint.Address.Value), ah); var binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.Name = "TransferServiceContextPortTypePort"; var transProxy = new TransferServiceContextPortTypeClient(binding, ea); dtd = transProxy.getDataTransferDescriptor(); } catch (WebException ex) { Console.WriteLine(ex.Message); throw new GridServicerException("Error querying NCIA Grid", ex); } catch (Exception e) { Console.WriteLine(e.Message); throw new GridServicerException("Error retrieving from NCIA Grid", e); } if (dtd.url != null || dtd.url.Equals("")) return dtd.url; else return null; }
/// <summary> /// Gets URL upon calling which the required study data can be retrieved. /// </summary> /// <param name="studyUIDs">List of UIDs for the studies to be retrieved</param> /// <param name="endPointUrl">URL of the NBIA Data Service to query. This is NOT the Data Transfer URL!</param> /// <returns>URL that returns zip file with the studies</returns> public string retrieveStudyURL(string[] studyUIDs, string endPointUrl) { TransferServiceContextService.DataTransferDescriptor dtd; using (NCIACoreServicePortTypeClient proxy = new NCIACoreServicePortTypeClient("NCIACoreServicePortTypePort", endPointUrl)) { try { TransferServiceContextReference tras = proxy.retrieveDicomDataByStudyUIDs(studyUIDs); // new TransferServiceContextReference(); EndpointReferenceType endPoint = tras.EndpointReference; // new EndpointReferenceType(); AddressHeader[] ah = new AddressHeader[endPoint.ReferenceProperties.Any.Length]; for (int lcv = 0; lcv < ah.Length; lcv++) { XmlElement refProp = endPoint.ReferenceProperties.Any[lcv]; ah[lcv] = AddressHeader.CreateAddressHeader(refProp.LocalName, refProp.NamespaceURI, refProp.InnerText); } EndpointAddress ea = new EndpointAddress(new Uri(endPoint.Address.Value), ah); // create binding by hand so we don't have to associate a config file with a dll BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.Name = "TransferServiceContextPortTypePort"; TransferServiceContextPortTypeClient transProxy = new TransferServiceContextPortTypeClient(binding, ea); dtd = transProxy.getDataTransferDescriptor(); } catch (System.Net.WebException ex) { System.Console.WriteLine(ex.Message); //never gets here throw new GridServicerException("Error querying NCIA Grid", ex); } catch (Exception e) { System.Console.WriteLine(e.Message); //never gets here throw new GridServicerException("Error retrieving from NCIA Grid", e); } } if (string.IsNullOrEmpty(dtd.url)) return dtd.url; else return null; }
private void retrieveStudyUID(string[] str) { TransferServiceContextService.DataTransferDescriptor dtd =null; TransferServiceContextPortTypeClient transProxy = null; NCIACoreServicePortTypeClient proxy = null; try { proxy = new NCIACoreServicePortTypeClient(); TransferServiceContextReference tras = proxy.retrieveDicomDataByStudyUIDs(str); // new TransferServiceContextReference(); EndpointReferenceType endPoint = tras.EndpointReference; // new EndpointReferenceType(); AddressHeader[] ah = new AddressHeader[endPoint.ReferenceProperties.Any.Length]; for (int lcv = 0; lcv < ah.Length; lcv++) { XmlElement refProp = endPoint.ReferenceProperties.Any[lcv]; ah[lcv] = AddressHeader.CreateAddressHeader(refProp.LocalName, refProp.NamespaceURI, refProp.InnerText); } EndpointAddress ea = new EndpointAddress(new Uri(endPoint.Address.Value), ah); // create binding by hand so we don't have to associate a config file with a dll BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.Name = "TransferServiceContextPortTypePort"; transProxy = new TransferServiceContextPortTypeClient(binding, ea); dtd = transProxy.getDataTransferDescriptor(); } catch (System.Net.WebException ex) { System.Console.WriteLine(ex.Message); } catch (Exception e) { System.Console.WriteLine(e.Message); throw new GridServicerException("Error querying NCIA Grid", e); } if (dtd.url != null && dtd.url.Equals("")) { WebRequest wr = WebRequest.Create(dtd.url); WebResponse resp = wr.GetResponse(); byte[] buf = new byte[8192]; int read; if (transProxy != null && proxy != null) { try { Stream stream = resp.GetResponseStream(); FileStream fs = new FileStream(_directory + "/" + str[0] + ".zip", FileMode.Create, FileAccess.Write); while ((read = stream.Read(buf, 0, buf.Length)) > 0) { fs.Write(buf, 0, read); } fs.Close(); stream.Close(); resp.Close(); proxy.Close(); transProxy.Close(); } catch (IOException ioe) { throw new GridServicerException("Error writting zip file from caGrid", ioe); } } } }
private void retrieveStudyUID(string[] str) { TransferServiceContextService.DataTransferDescriptor dtd = null; TransferServiceContextPortTypeClient transProxy = null; NCIACoreServicePortTypeClient proxy = null; try { proxy = new NCIACoreServicePortTypeClient(); var tras = proxy.retrieveDicomDataByStudyUIDs(str); var endPoint = tras.EndpointReference; var ah = new AddressHeader[endPoint.ReferenceProperties.Any.Length]; for (var lcv = 0; lcv < ah.Length; lcv++) { var refProp = endPoint.ReferenceProperties.Any[lcv]; ah[lcv] = AddressHeader.CreateAddressHeader(refProp.LocalName, refProp.NamespaceURI, refProp.InnerText); } var ea = new EndpointAddress(new Uri(endPoint.Address.Value), ah); var binding = new BasicHttpBinding(BasicHttpSecurityMode.None); binding.Name = "TransferServiceContextPortTypePort"; transProxy = new TransferServiceContextPortTypeClient(binding, ea); dtd = transProxy.getDataTransferDescriptor(); } catch (WebException ex) { Console.WriteLine(ex.Message); } catch (Exception e) { Console.WriteLine(e.Message); throw new GridServicerException("Error querying NCIA Grid", e); } if (dtd.url != null && dtd.url.Equals("")) { var wr = WebRequest.Create(dtd.url); var resp = wr.GetResponse(); var buf = new byte[8192]; int read; if (transProxy != null && proxy != null) { try { var stream = resp.GetResponseStream(); var fs = new FileStream(_directory + "/" + str[0] + ".zip", FileMode.Create, FileAccess.Write); while ((read = stream.Read(buf, 0, buf.Length)) > 0) { fs.Write(buf, 0, read); } fs.Close(); stream.Close(); resp.Close(); proxy.Close(); transProxy.Close(); } catch (IOException ioe) { throw new GridServicerException("Error writting zip file from caGrid", ioe); } } } }