void Tables_CurrentChanged(object sender, EventArgs e) { if (_dt != null) { _dt.PropertyChanged -= _dt_PropertyChanged; } _dt = _ds.Tables.CurrentItem as DataTable; if (_dt != null) { _dt.PropertyChanged += _dt_PropertyChanged; } OnCanExecuteChanged(); }
/// <summary> /// Navigate to a linked table. /// </summary> /// <param name="url">Url of the linked table.</param> public void NavigateTo(TableLink link) { // create new child DataTable var dt = new DataTable(_source, link.Name); // populate the new DataTable var url = string.Format("{0}/{1}", link.Url, link.Href); if (Top > 0 && link.Type.IndexOf("feed") > -1) { url += url.IndexOf('?') > -1 ? "&" : "?"; url += "$top=" + Top.ToString(); } dt._dt = new C1.Silverlight.Data.DataTable(); dt.GetTableRows(url); // add it to child table list and notify _childTables.Add(dt); OnPropertyChanged("DefaultView"); OnPropertyChanged("SourceUrl"); }
public void Refresh() { if (!string.IsNullOrEmpty(_url)) { // create web client var wc = new WebClient(); if (!string.IsNullOrEmpty(_user) && !string.IsNullOrEmpty(_password)) { wc.Credentials = new NetworkCredential(_user, _password); } // get schema (list of tables) wc.DownloadStringCompleted += (s, e) => { Model.ActiveConnections--; if (e.Error != null) { OnLoadingError(e.Error); } else { try { // build list of table names var tableNames = new List<string>(); var settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Ignore; settings.CheckCharacters = false; settings.CloseInput = true; var xr = XmlReader.Create(new StringReader(e.Result), settings); while (xr.Read()) { if (xr.NodeType == XmlNodeType.Element && xr.Name == "collection") { var name = xr.GetAttribute("href"); if (!string.IsNullOrEmpty(name)) { tableNames.Add(name); } } } // sort list and create tables tableNames.Sort(); foreach (var name in tableNames) { var dt = new DataTable(this, name); _dataTables.Add(dt); } } catch (Exception x) { OnLoadingError(x); } } }; Model.ActiveConnections++; wc.DownloadStringAsync(new Uri(_url, UriKind.Absolute)); } }