public FormsData[] GetDataviewFormsData() { FormsData[] localAssembliesFormsData = new FormsData[0]; try { // Load the static forms from the same directory (and all subdirectories) where the Curator Tool was launched... System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory()); System.IO.FileInfo[] dllFiles = null; if(System.IO.Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "\\Forms")) dllFiles = di.GetFiles("Forms\\*.dll", System.IO.SearchOption.AllDirectories); if (dllFiles != null && dllFiles.Length > 0) { localAssembliesFormsData = new FormsData[dllFiles.Length]; for (int i = 0; i < dllFiles.Length; i++) { System.Reflection.Assembly newAssembly = System.Reflection.Assembly.LoadFile(dllFiles[i].FullName); foreach (System.Type t in newAssembly.GetTypes()) { if (t.GetInterface("IGRINGlobalDataForm", true) != null) { System.Reflection.ConstructorInfo constInfo = t.GetConstructor(new Type[] { typeof(BindingSource), typeof(bool), typeof(SharedUtils), typeof(bool) }); if (constInfo != null) { // Instantiate an object of this type to inspect... Form f = (Form)constInfo.Invoke(new object[] { new BindingSource(), false, this, false }); // Get the Form Name and save it to the array... System.Reflection.PropertyInfo propInfo = t.GetProperty("FormName", typeof(string)); string formName = (string)propInfo.GetValue(f, null); if (string.IsNullOrEmpty(formName)) formName = t.Name; localAssembliesFormsData[i].FormName = formName; // Get the preferred dataview name and save it to the array... propInfo = t.GetProperty("PreferredDataview", typeof(string)); string preferredDataview = (string)propInfo.GetValue(f, null); if (string.IsNullOrEmpty(preferredDataview)) preferredDataview = ""; localAssembliesFormsData[i].PreferredDataviewName = preferredDataview; // Save the constructor info object to the array... localAssembliesFormsData[i].ConstInfo = constInfo; localAssembliesFormsData[i].StrongFormName = constInfo.Module.FullyQualifiedName + " : " + formName + " : " + preferredDataview; } } } } } } catch (Exception err) { //MessageBox.Show("Error binding to dataview Form.\nError Message: " + err.Message); GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error binding to dataview Form.\nError Message: {0}", "Form Binding Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1); ggMessageBox.Name = "GrinGlobalClient_LoadMessage1"; this.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name); //if (ggMessageBox.MessageText.Contains("{0}")) ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, err.Message); string[] argsArray = new string[100]; argsArray[0] = err.Message; ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray); ggMessageBox.ShowDialog(); } return localAssembliesFormsData; }
public FormsData[] GetDataviewFormsData() { FormsData[] localAssembliesFormsData = new FormsData[0]; try { // Load the static forms from the same directory (and all subdirectories) where the Curator Tool was launched... System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory()); System.IO.FileInfo[] dllFiles = null; if (System.IO.Directory.Exists(System.IO.Directory.GetCurrentDirectory() + "\\Forms")) { dllFiles = di.GetFiles("Forms\\*.dll", System.IO.SearchOption.AllDirectories); } if (dllFiles != null && dllFiles.Length > 0) { localAssembliesFormsData = new FormsData[dllFiles.Length]; for (int i = 0; i < dllFiles.Length; i++) { System.Reflection.Assembly newAssembly = System.Reflection.Assembly.LoadFile(dllFiles[i].FullName); foreach (System.Type t in newAssembly.GetTypes()) { if (t.GetInterface("IGRINGlobalDataForm", true) != null) { System.Reflection.ConstructorInfo constInfo = t.GetConstructor(new Type[] { typeof(BindingSource), typeof(bool), typeof(SharedUtils), typeof(bool) }); if (constInfo != null) { // Instantiate an object of this type to inspect... Form f = (Form)constInfo.Invoke(new object[] { new BindingSource(), false, this, false }); // Get the Form Name and save it to the array... System.Reflection.PropertyInfo propInfo = t.GetProperty("FormName", typeof(string)); string formName = (string)propInfo.GetValue(f, null); if (string.IsNullOrEmpty(formName)) { formName = t.Name; } localAssembliesFormsData[i].FormName = formName; // Get the preferred dataview name and save it to the array... propInfo = t.GetProperty("PreferredDataview", typeof(string)); string preferredDataview = (string)propInfo.GetValue(f, null); if (string.IsNullOrEmpty(preferredDataview)) { preferredDataview = ""; } localAssembliesFormsData[i].PreferredDataviewName = preferredDataview; // Save the constructor info object to the array... localAssembliesFormsData[i].ConstInfo = constInfo; localAssembliesFormsData[i].StrongFormName = constInfo.Module.FullyQualifiedName + " : " + formName + " : " + preferredDataview; } } } } } } catch (Exception err) { //MessageBox.Show("Error binding to dataview Form.\nError Message: " + err.Message); GRINGlobal.Client.Common.GGMessageBox ggMessageBox = new GRINGlobal.Client.Common.GGMessageBox("Error binding to dataview Form.\nError Message: {0}", "Form Binding Error", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1); ggMessageBox.Name = "GrinGlobalClient_LoadMessage1"; this.UpdateControls(ggMessageBox.Controls, ggMessageBox.Name); if (ggMessageBox.MessageText.Contains("{0}")) { ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, err.Message); } ggMessageBox.ShowDialog(); } return(localAssembliesFormsData); }