private void searchEntity_TextChaneged(object sender, EventArgs e) { if (searchEntity.Text == "" && dtEntities.Rows.Count > 0 && EntityGridView.Rows.Count != dtEntities.Rows.Count) { EntityFieldAnalyserManager.SetEntitiesGridViewHeaders(dtEntities, EntityGridView); } else if (searchEntity.Text != "Search" && searchEntity.Text != "" && dtEntities.Rows.Count > 0) { string searchValue = searchEntity.Text.ToLower(); try { DataRow[] filtered = dtEntities.Select("DisplayName LIKE '%" + searchValue + "%' OR SchemaName LIKE '%" + searchValue + "%'"); if (filtered.Count() > 0) { EntityFieldAnalyserManager.SetEntitiesGridViewHeaders(filtered.CopyToDataTable(), EntityGridView); } } catch (Exception) { MessageBox.Show("Invalid Search Character. Please do not use ' [ ] within searches."); } } }
private void loadEntities() { InitComponents(); string selectedTypeOfEntities = entityTypeComboBox.SelectedItem.ToString(); searchEntity.Enabled = false; WorkAsync(new WorkAsyncInfo { Message = "Retrieving Entities...", Work = (worker, args) => { #region Variables dtEntities = new DataTable(); #endregion #region getEntitiesMetadata RetrieveMetadataChangesResponse _allEntitiesResp = EntityFieldAnalyserManager.GetEntitiesMetadat(Service, selectedTypeOfEntities); groupBox1.Text = "Entities : " + selectedTypeOfEntities + " " + _allEntitiesResp.EntityMetadata.Count(); #endregion worker.ReportProgress(0, string.Format("Metadata has been retrieved!")); #region Entities Data Table Set dtEntities.Columns.Add("DisplayName", typeof(string)); dtEntities.Columns.Add("SchemaName", typeof(string)); dtEntities.Columns.Add("Analyse", typeof(bool)); foreach (var item in _allEntitiesResp.EntityMetadata) { DataRow row = dtEntities.NewRow(); row["DisplayName"] = item.DisplayName.LocalizedLabels.Count > 0 ? item.DisplayName.UserLocalizedLabel.Label.ToString() : "N/A"; row["SchemaName"] = item.LogicalName; row["Analyse"] = false; dtEntities.Rows.Add(row); } #endregion args.Result = dtEntities; }, ProgressChanged = e => { // If progress has to be notified to user, use the following method: SetWorkingMessage(e.UserState.ToString()); }, PostWorkCallBack = (args) => { if (args.Error != null) { MessageBox.Show(args.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } var result = args.Result; if (result != null) { #region Set Retrieved Data in the Data Grid View EntityFieldAnalyserManager.SetEntitiesGridViewHeaders((DataTable)args.Result, EntityGridView); #endregion #region ManageComponenetVisibility searchEntity.Enabled = true; analyseButton.Enabled = true; #endregion } } }); }