Created
January 24, 2012 17:02
-
-
Save sclarson/1671161 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static IList<OurServiceProduct> GetServiceProducts() | |
| { | |
| var products = new List<OurServiceProduct>(); | |
| var client = new RightNowSyncPortClient(); | |
| client.ClientCredentials.UserName.UserName = "####"; | |
| client.ClientCredentials.UserName.Password = "####"; | |
| var clientInfoHeader = new ClientInfoHeader { AppID = "Basic Query CSV" }; | |
| const string queryString = "SELECT ID,Name FROM SERVICEPRODUCT"; | |
| try | |
| { | |
| CSVTableSet queryCSV = client.QueryCSV(clientInfoHeader, queryString, 10000); | |
| CSVTable[] csvTables = queryCSV.CSVTables; | |
| foreach (CSVTable table in csvTables) | |
| { | |
| foreach (var row in table.Rows) | |
| { | |
| using(var x = new TextFieldParser(new StringReader(row))) | |
| { | |
| x.TextFieldType = FieldType.Delimited; | |
| x.Delimiters = new string[]{","}; | |
| x.HasFieldsEnclosedInQuotes = true; | |
| var rowColumns = x.ReadFields(); | |
| products.Add(new OurServiceProduct | |
| {Id = Convert.ToInt32(rowColumns[0]), Name = rowColumns[1]}); | |
| } | |
| } | |
| } | |
| } | |
| return products; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment