/// <summary> /// Get all categories in a range. /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="authentication"></param> /// <param name="client"></param> /// <returns></returns> public static List <Category> getCategoryRange(string start, string end, string authentication, CV3DataxsdPortTypeClient client) { try { string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<CV3Data version=\"2.0\">" + "<request>" + authentication + "<requests>" + "<reqCategories>" + $"<reqCategoryRange start='{start}' end='{end}' />" + "</reqCategories>" + "</requests>" + "</request>" + "</CV3Data>"; string responseStr = Encoding.UTF8.GetString(client.CV3Data(convertToBase64(xml))); //File.WriteAllText("C:\\Test\\cv3.xml", responseStr); //TODO: Check for errors XmlSerializer serializer = new XmlSerializer(typeof(CV3Data)); StringReader reader = new StringReader(responseStr); CV3Data data = (CV3Data)serializer.Deserialize(reader); List <Category> outCategories = data.categories.category; return(outCategories); } catch (Exception ex) { //log.Error("Error in getCategoryRange", ex); return(null); } }
/// <summary> /// Get all products in a range from Start to End. Used in GetCV3Products because the data must be retreived in chunks. /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="authentication"></param> /// <param name="client"></param> /// <returns></returns> public static List <Product> getProductRange(string start, string end, string authentication, CV3DataxsdPortTypeClient client) { string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<CV3Data version=\"2.0\">" + "<request>" + authentication + "<requests>" + "<reqProducts>" + "<reqProductRange start=\"" + start + "\" end=\"" + end + "\" />" + "</reqProducts>" + "</requests>" + "</request>" + "</CV3Data>"; string responseStr = Encoding.UTF8.GetString(client.CV3Data(convertToBase64(xml))); //File.WriteAllText("C:\\Test\\cv3.xml", responseStr); //TODO: Check for errors XmlSerializer serializer = new XmlSerializer(typeof(CV3Data)); StringReader reader = new StringReader(responseStr); CV3Data data = (CV3Data)serializer.Deserialize(reader); return(data.Products.ProductList); }
/// <summary> /// Gets a Category object from CV3 for the given categoryID. /// </summary> /// <param name="categoryID"></param> /// <param name="authentication"></param> /// <param name="client"></param> /// <returns></returns> public static Category getCategoryByID(string categoryID, string authentication, CV3DataxsdPortTypeClient client) { string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<CV3Data version=\"2.0\">" + "<request>" + authentication + "<requests>" + "<reqCategories>" + "<reqCategorySingle>" + categoryID + "</reqCategorySingle>" + "</reqCategories>" + "</requests>" + "</request>" + "</CV3Data>"; string responseStr = Encoding.UTF8.GetString(client.CV3Data(convertToBase64(xml))); //File.WriteAllText("C:\\Test\\cv3.xml", responseStr); //TODO: Check for errors XmlSerializer serializer = new XmlSerializer(typeof(CV3Data)); StringReader reader = new StringReader(responseStr); CV3Data data = (CV3Data)serializer.Deserialize(reader); Category outCategory = data.categories.category[0]; return(outCategory); }