public void GenerateAccessClass() { MainPanel.Enabled = false; SetConfig(false, FolderDestinyTextBox.Text, NamespaceMapTextBox.Text, LenguajeComboBox.SelectedIndex, this.ConexionesChecked, this.IsMobileCheckBox.Checked, this.UseFramework2CheckBox.Checked); var unMappedSelectedObjects = (XsdDataBase.TBL_ObjectRow[])(DataBaseDataSet.TBL_Object.Select("Selected = 1 AND Mapped = 0")); foreach (var unMappedSelectedObject in unMappedSelectedObjects) { RefreshObject(unMappedSelectedObject); } try { if (this.FileName == "") { MessageBox.Show(@"Para poder generar la clase de acceso a datos primero debe almacenar el archivo de configuración", Program.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var FolderDestiny = FolderDestinyTextBox.Text; if (FolderDestiny == "") { var directoryName = Path.GetDirectoryName(this.FileName); if (directoryName == null) throw new ArgumentOutOfRangeException(this.FileName); FolderDestiny = directoryName.TrimEnd('\\') + '\\'; } ((Main)MdiParent).AnimateProgressBar(); var codeCreator = new DataBaseClassWriter(DataBaseDataSet); var ConnectionRow = (CMData.Schemas.XsdDataBase.TBL_ConnectionRow)((DataRowView)ConnectionsListBox.SelectedItem).Row; RefreshCatalog(ConnectionRow.id_Connection); RefreshSchema(ConnectionRow.id_Connection); codeCreator.GenerateClassCode(ConnectionRow, FolderDestiny, NamespaceMapTextBox.Text, LenguajeComboBox.SelectedIndex == 0 ? LanguajeType.VB : LanguajeType.CSharp, IsMobileCheckBox.Checked, UseFramework2CheckBox.Checked); codeCreator.GenerateSchemaXML(ConnectionRow,DataBaseDataSet, FolderDestiny); if (codeCreator.Log.ToString() != "") throw new Exception(codeCreator.Log.ToString()); MessageBox.Show(@"Las clases de acceso a datos se generaron exitosamente", Program.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(@"Error al generar las clases de conexión, " + ex.Message, Program.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { MainPanel.Enabled = true; } }
public void GenerateAccessClass() { MainPanel.Enabled = false; SetConfig(false, FolderDestinyTextBox.Text, NamespaceMapTextBox.Text, LenguajeComboBox.SelectedIndex, this.ConexionesChecked, this.IsMobileCheckBox.Checked, this.UseFramework2CheckBox.Checked); var unMappedSelectedObjects = (XsdDataBase.TBL_ObjectRow[])(DataBaseDataSet.TBL_Object.Select("Selected = 1 AND Mapped = 0")); foreach (var unMappedSelectedObject in unMappedSelectedObjects) { RefreshObject(unMappedSelectedObject); } try { if (this.FileName == "") { MessageBox.Show(@"Para poder generar la clase de acceso a datos primero debe almacenar el archivo de configuración", Program.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var FolderDestiny = FolderDestinyTextBox.Text; if (FolderDestiny == "") { var directoryName = Path.GetDirectoryName(this.FileName); if (directoryName == null) { throw new ArgumentOutOfRangeException(this.FileName); } FolderDestiny = directoryName.TrimEnd('\\') + '\\'; } ((Main)MdiParent).AnimateProgressBar(); var codeCreator = new DataBaseClassWriter(DataBaseDataSet); var ConnectionRow = (CMData.Schemas.XsdDataBase.TBL_ConnectionRow)((DataRowView)ConnectionsListBox.SelectedItem).Row; RefreshCatalog(ConnectionRow.id_Connection); RefreshSchema(ConnectionRow.id_Connection); codeCreator.GenerateClassCode(ConnectionRow, FolderDestiny, NamespaceMapTextBox.Text, LenguajeComboBox.SelectedIndex == 0 ? LanguajeType.VB : LanguajeType.CSharp, IsMobileCheckBox.Checked, UseFramework2CheckBox.Checked); codeCreator.GenerateSchemaXML(ConnectionRow, DataBaseDataSet, FolderDestiny); if (codeCreator.Log.ToString() != "") { throw new Exception(codeCreator.Log.ToString()); } MessageBox.Show(@"Las clases de acceso a datos se generaron exitosamente", Program.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(@"Error al generar las clases de conexión, " + ex.Message, Program.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { MainPanel.Enabled = true; } }