public static DataView GetExportEntityOptions(projectsettingsEntityexport pEntityExport, XmlDocument pDbDefinitionDocument) { DataTable dt = new DataTable(); dt.Columns.Add("Entity", typeof(string)); dt.Columns.Add("SortNo", typeof(int)); dt.Columns.Add("ExportStructure", typeof(bool)); dt.Columns.Add("ExportData", typeof(bool)); dt.Columns.Add("ExportDrop", typeof(bool)); dt.Columns["ExportStructure"].DefaultValue = false; dt.Columns["ExportData"].DefaultValue = false; dt.Columns["ExportDrop"].DefaultValue = false; ArrayList alEntity = new ArrayList(); if (pEntityExport.exportentities != null) { alEntity.AddRange(pEntityExport.exportentities); } ArrayList alEntityName = new ArrayList(); foreach (XmlNode node in pDbDefinitionDocument.SelectNodes("/db-definition/entities/entity")) { string strEntity = node.Attributes["name"].Value; alEntityName.Add(strEntity); projectsettingsEntityexportExportentity expentity = null; foreach (projectsettingsEntityexportExportentity e in alEntity) { if (e.entity.Equals(strEntity)) { expentity = e; break; } } if (expentity == null) { expentity = new projectsettingsEntityexportExportentity(); expentity.entity = strEntity; expentity.exportstructure = true; expentity.exportdata = true; expentity.exportdrop = false; alEntity.Add(expentity); } DataRow row = dt.NewRow(); row["Entity"] = expentity.entity; if (PVFormatUtil.ParseInt(expentity.sortno) != 0) { row["SortNo"] = expentity.sortno; } row["ExportStructure"] = expentity.exportstructure; row["ExportData"] = expentity.exportdata; row["ExportDrop"] = expentity.exportdrop; dt.Rows.Add(row); } foreach (projectsettingsEntityexportExportentity expentity in alEntity) { if (!alEntityName.Contains(expentity.entity)) { alEntityName.Add(expentity.entity); DataRow row = dt.NewRow(); row["Entity"] = expentity.entity; if (PVFormatUtil.ParseInt(expentity.sortno) != 0) { row["SortNo"] = expentity.sortno; } row["ExportStructure"] = expentity.exportstructure; row["ExportData"] = expentity.exportdata; row["ExportDrop"] = expentity.exportdrop; dt.Rows.Add(row); } } pEntityExport.exportentities = (projectsettingsEntityexportExportentity[])alEntity.ToArray(typeof(projectsettingsEntityexportExportentity)); DataView dv = new DataView(dt); dv.AllowEdit = true; dv.AllowNew = true; dv.AllowDelete = true; dv.Sort = "SortNo, Entity"; return(dv); }
public void ImportTable_Export() { string strSQL = "SELECT Tabelle,Reihenfolge,Export,ExportData,DropOnly " + "FROM _Export ORDER BY Reihenfolge"; OleDbCommand cmd = mcon.CreateCommand(); cmd.CommandText = strSQL; OleDbDataReader dr = null; try { dr = cmd.ExecuteReader(); if (mProjectSettings.entityexport == null) { mProjectSettings.entityexport = new projectsettingsEntityexport(); } ArrayList alEntityExport = new ArrayList(); while (dr.Read()) { string strTable = dr.GetString(dr.GetOrdinal("Tabelle")); //ignore System-Tables if (strTable.ToLower().Equals("_export") || strTable.ToLower().Equals("_pventitygenerator")) { continue; } projectsettingsEntityexportExportentity e = new projectsettingsEntityexportExportentity(); e.entity = strTable; object val = dr.GetValue(dr.GetOrdinal("Reihenfolge")); if (!val.Equals(DBNull.Value)) { e.sortno = val.ToString(); } e.exportstructure = false; val = dr.GetValue(dr.GetOrdinal("Export")); if (!val.Equals(DBNull.Value)) { e.exportstructure = (bool)val; } e.exportdata = false; val = dr.GetValue(dr.GetOrdinal("ExportData")); if (!val.Equals(DBNull.Value)) { e.exportdata = (bool)val; } e.exportdrop = false; val = dr.GetValue(dr.GetOrdinal("DropOnly")); if (!val.Equals(DBNull.Value)) { e.exportdrop = (bool)val; } alEntityExport.Add(e); } dr.Close(); if (alEntityExport.Count > 0) { mProjectSettings.entityexport.exportentities = (projectsettingsEntityexportExportentity[]) alEntityExport.ToArray(typeof(projectsettingsEntityexportExportentity)); } } finally { if (dr != null) { dr.Close(); } } }