private void fmAllProducts_Load(object sender, EventArgs e) { catalog = GetCatalog(); var listCategory = catalog.Shop.Categories.Category; /* * * var list = new List<CategoryB>(); * var listCategory = new CategoryB().GetListCategory(); * * * foreach (var item in listCategory) * { * var obList = new CategoryB().GetListcategoryToPrice(item.Id); * foreach (var ob in obList) * { * if (!list.Any(x=>x.Id == ob.Id)) * { * o * list.Add(ob); * } * } * } * * * */ GetListNodes(null, listCategory); }
public static Yml_catalog Parse(byte[] xml) { XmlSerializer serializer = new XmlSerializer(typeof(Yml_catalog)); Yml_catalog result = (Yml_catalog)serializer.Deserialize(new MemoryStream(xml)); return(result); }
private Yml_catalog GetCatalog() { XmlSerializer formatter = new XmlSerializer(typeof(Yml_catalog)); //Yml_catalog ob; using (FileStream fs = new FileStream("price.xml", FileMode.Open)) { catalog = (Yml_catalog)formatter.Deserialize(fs); } return(catalog); }
public void hhh() { var yml = new Yml_catalog() { Date = DateTime.Now.ToString("yyyy-MM-dd mm:ss"), Shop = new Shop().GetShops() }; XmlSerializer formatter = new XmlSerializer(typeof(Yml_catalog)); using (FileStream fs = new FileStream("price.xml", FileMode.Create)) { formatter.Serialize(fs, yml); } }
public static async Task <List <Offer> > GetOffers() { try { using (var client = new HttpClient()) { var result = await client.GetAsync("https://yastatic.net/market-export/_/partner/help/YML.xml").ConfigureAwait(false); if (result.IsSuccessStatusCode && result.StatusCode == System.Net.HttpStatusCode.OK) { StreamReader reader = new StreamReader(await result.Content.ReadAsStreamAsync(), System.Text.Encoding.GetEncoding(1251)); XmlSerializer serializer = new XmlSerializer(typeof(Yml_catalog)); Yml_catalog offers = (Yml_catalog)serializer.Deserialize(reader); return(offers.Shop.Offers); } } } catch (Exception e) { return(null); } return(null); }
public MainPage() { InitializeComponent(); byte[] xml = Data.GetAsync(); Yml_catalog cat = Data.Parse(xml); off = cat.Shop.Offers; result = new List <string>(); foreach (var offer in off.Offer) { result.Add(offer.Id); } ListView listView = new ListView(); listView.ItemsSource = result; listView.ItemTapped += this.ToCommonPage; this.Content = new StackLayout { Children = { listView } }; }