diff --git a/.vs/ExportDataToFile/FileContentIndex/1fdd26f4-9f97-4ac0-9d0c-0e5ef70067a1.vsidx b/.vs/ExportDataToFile/FileContentIndex/1fdd26f4-9f97-4ac0-9d0c-0e5ef70067a1.vsidx new file mode 100644 index 0000000..57c2b40 Binary files /dev/null and b/.vs/ExportDataToFile/FileContentIndex/1fdd26f4-9f97-4ac0-9d0c-0e5ef70067a1.vsidx differ diff --git a/.vs/ExportDataToFile/FileContentIndex/read.lock b/.vs/ExportDataToFile/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 diff --git a/.vs/ExportDataToFile/v16/.suo b/.vs/ExportDataToFile/v16/.suo index fba774e..0ffe2f1 100644 Binary files a/.vs/ExportDataToFile/v16/.suo and b/.vs/ExportDataToFile/v16/.suo differ diff --git a/.vs/ExportDataToFile/v17/.suo b/.vs/ExportDataToFile/v17/.suo new file mode 100644 index 0000000..5c72166 Binary files /dev/null and b/.vs/ExportDataToFile/v17/.suo differ diff --git a/ExportDataToFile.sln b/ExportDataToFile.sln index 845d81e..54c5333 100644 --- a/ExportDataToFile.sln +++ b/ExportDataToFile.sln @@ -1,12 +1,10 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31410.357 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExportDataToFile", "ExportDataToFile.csproj", "{4DC47324-7EF1-449D-99C4-04C49E44D113}" EndProject -Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "ExportProject", "..\ExportProject\ExportProject.vdproj", "{77BEA279-337F-40B2-A6D5-C57E2C30F640}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -17,9 +15,6 @@ Global {4DC47324-7EF1-449D-99C4-04C49E44D113}.Debug|Any CPU.Build.0 = Debug|Any CPU {4DC47324-7EF1-449D-99C4-04C49E44D113}.Release|Any CPU.ActiveCfg = Release|Any CPU {4DC47324-7EF1-449D-99C4-04C49E44D113}.Release|Any CPU.Build.0 = Release|Any CPU - {77BEA279-337F-40B2-A6D5-C57E2C30F640}.Debug|Any CPU.ActiveCfg = Debug - {77BEA279-337F-40B2-A6D5-C57E2C30F640}.Release|Any CPU.ActiveCfg = Release - {77BEA279-337F-40B2-A6D5-C57E2C30F640}.Release|Any CPU.Build.0 = Release EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Form1.Designer.cs b/Form1.Designer.cs index 2e84d10..32bb200 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -57,11 +57,6 @@ namespace ExportDataToFile this.dgvExportList = new System.Windows.Forms.DataGridView(); this.label11 = new System.Windows.Forms.Label(); this.dgvColumnMapping = new System.Windows.Forms.DataGridView(); - this.clExpColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); - this.clClean = new System.Windows.Forms.DataGridViewButtonColumn(); - this.clSourceColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.clType = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.clTargetColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.txtWhere = new System.Windows.Forms.TextBox(); this.label13 = new System.Windows.Forms.Label(); this.label14 = new System.Windows.Forms.Label(); @@ -78,6 +73,19 @@ namespace ExportDataToFile this.btnImportXML = new System.Windows.Forms.Button(); this.ofPath = new System.Windows.Forms.OpenFileDialog(); this.btnClean = new System.Windows.Forms.Button(); + this.clExport = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.clCancel = new System.Windows.Forms.DataGridViewButtonColumn(); + this.clShow = new System.Windows.Forms.DataGridViewButtonColumn(); + this.clSourceTable = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.clTargetTable = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.clTableDel = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.clWhere = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.clMappingData = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.clExpColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.clClean = new System.Windows.Forms.DataGridViewButtonColumn(); + this.clSourceColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.clType = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.clTargetColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dgvExportList)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvColumnMapping)).BeginInit(); this.SuspendLayout(); @@ -89,7 +97,7 @@ namespace ExportDataToFile this.txtTargetID.Name = "txtTargetID"; this.txtTargetID.Size = new System.Drawing.Size(135, 29); this.txtTargetID.TabIndex = 11; - this.txtTargetID.Text = "postgres"; + this.txtTargetID.Text = "sa"; // // label7 // @@ -342,9 +350,19 @@ namespace ExportDataToFile this.dgvExportList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.dgvExportList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvExportList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.clExport, + this.clCancel, + this.clShow, + this.clSourceTable, + this.clTargetTable, + this.clTableDel, + this.clWhere, + this.clMappingData}); this.dgvExportList.Location = new System.Drawing.Point(18, 125); this.dgvExportList.Name = "dgvExportList"; this.dgvExportList.RowTemplate.Height = 25; + this.dgvExportList.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dgvExportList.Size = new System.Drawing.Size(1204, 920); this.dgvExportList.TabIndex = 17; this.dgvExportList.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvExportList_CellClick); @@ -378,48 +396,11 @@ namespace ExportDataToFile this.dgvColumnMapping.Location = new System.Drawing.Point(1228, 183); this.dgvColumnMapping.Name = "dgvColumnMapping"; this.dgvColumnMapping.RowTemplate.Height = 25; + this.dgvColumnMapping.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect; this.dgvColumnMapping.Size = new System.Drawing.Size(556, 342); this.dgvColumnMapping.TabIndex = 19; this.dgvColumnMapping.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvColumnMapping_CellContentClick); // - // clExpColumn - // - this.clExpColumn.HeaderText = "匯出"; - this.clExpColumn.Name = "clExpColumn"; - this.clExpColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.clExpColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; - this.clExpColumn.Width = 65; - // - // clClean - // - this.clClean.HeaderText = "清除"; - this.clClean.Name = "clClean"; - this.clClean.Width = 50; - // - // clSourceColumn - // - this.clSourceColumn.DataPropertyName = "COLUMN_NAME"; - this.clSourceColumn.HeaderText = "來源欄位"; - this.clSourceColumn.Name = "clSourceColumn"; - this.clSourceColumn.ReadOnly = true; - this.clSourceColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.clSourceColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.clSourceColumn.Width = 200; - // - // clType - // - this.clType.DataPropertyName = "DATA_TYPE"; - this.clType.HeaderText = "型態"; - this.clType.Name = "clType"; - this.clType.Width = 80; - // - // clTargetColumn - // - this.clTargetColumn.HeaderText = "目標欄位"; - this.clTargetColumn.Name = "clTargetColumn"; - this.clTargetColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; - this.clTargetColumn.Width = 200; - // // txtWhere // this.txtWhere.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -572,6 +553,100 @@ namespace ExportDataToFile this.btnClean.UseVisualStyleBackColor = true; this.btnClean.Click += new System.EventHandler(this.btnClean_Click); // + // clExport + // + this.clExport.HeaderText = "匯出"; + this.clExport.Name = "clExport"; + this.clExport.Width = 70; + // + // clCancel + // + this.clCancel.HeaderText = "清除"; + this.clCancel.Name = "clCancel"; + this.clCancel.Text = "..."; + this.clCancel.UseColumnTextForButtonValue = true; + this.clCancel.Width = 70; + // + // clShow + // + this.clShow.HeaderText = "顯示來源"; + this.clShow.Name = "clShow"; + this.clShow.Text = "..."; + this.clShow.UseColumnTextForButtonValue = true; + // + // clSourceTable + // + this.clSourceTable.DataPropertyName = "TableName"; + this.clSourceTable.HeaderText = "來源資料表名稱"; + this.clSourceTable.Name = "clSourceTable"; + this.clSourceTable.ReadOnly = true; + this.clSourceTable.Width = 200; + // + // clTargetTable + // + this.clTargetTable.HeaderText = "目標資料表名稱"; + this.clTargetTable.Name = "clTargetTable"; + this.clTargetTable.ReadOnly = true; + this.clTargetTable.Width = 200; + // + // clTableDel + // + this.clTableDel.HeaderText = "清除目標資料表內容"; + this.clTableDel.Name = "clTableDel"; + this.clTableDel.Width = 200; + // + // clWhere + // + this.clWhere.HeaderText = "過濾條件"; + this.clWhere.Name = "clWhere"; + this.clWhere.Visible = false; + // + // clMappingData + // + this.clMappingData.HeaderText = "欄位對應"; + this.clMappingData.Name = "clMappingData"; + this.clMappingData.Visible = false; + // + // clExpColumn + // + this.clExpColumn.HeaderText = "匯出"; + this.clExpColumn.Name = "clExpColumn"; + this.clExpColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.clExpColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; + this.clExpColumn.Width = 65; + // + // clClean + // + this.clClean.HeaderText = "清除"; + this.clClean.Name = "clClean"; + this.clClean.Text = "..."; + this.clClean.UseColumnTextForButtonValue = true; + this.clClean.Width = 50; + // + // clSourceColumn + // + this.clSourceColumn.DataPropertyName = "COLUMN_NAME"; + this.clSourceColumn.HeaderText = "來源欄位"; + this.clSourceColumn.Name = "clSourceColumn"; + this.clSourceColumn.ReadOnly = true; + this.clSourceColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.clSourceColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.clSourceColumn.Width = 200; + // + // clType + // + this.clType.DataPropertyName = "DATA_TYPE"; + this.clType.HeaderText = "型態"; + this.clType.Name = "clType"; + this.clType.Width = 80; + // + // clTargetColumn + // + this.clTargetColumn.HeaderText = "目標欄位"; + this.clTargetColumn.Name = "clTargetColumn"; + this.clTargetColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; + this.clTargetColumn.Width = 200; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 20F); @@ -680,6 +755,14 @@ namespace ExportDataToFile private System.Windows.Forms.Button btnImportXML; private System.Windows.Forms.OpenFileDialog ofPath; private System.Windows.Forms.Button btnClean; + private System.Windows.Forms.DataGridViewCheckBoxColumn clExport; + private System.Windows.Forms.DataGridViewButtonColumn clCancel; + private System.Windows.Forms.DataGridViewButtonColumn clShow; + private System.Windows.Forms.DataGridViewTextBoxColumn clSourceTable; + private System.Windows.Forms.DataGridViewTextBoxColumn clTargetTable; + private System.Windows.Forms.DataGridViewCheckBoxColumn clTableDel; + private System.Windows.Forms.DataGridViewTextBoxColumn clWhere; + private System.Windows.Forms.DataGridViewTextBoxColumn clMappingData; private System.Windows.Forms.DataGridViewCheckBoxColumn clExpColumn; private System.Windows.Forms.DataGridViewButtonColumn clClean; private System.Windows.Forms.DataGridViewTextBoxColumn clSourceColumn; diff --git a/Form1.cs b/Form1.cs index 2637633..32d1bce 100644 --- a/Form1.cs +++ b/Form1.cs @@ -45,8 +45,7 @@ namespace ExportDataToFile } private void Form1_Load(object sender, EventArgs e) - { - ResetDataGridView(); + { } @@ -328,7 +327,7 @@ namespace ExportDataToFile string strPath = ""; sfPath.AddExtension = false; sfPath.Filter = "All files (*.*)|*.*"; - sfPath.FileName = "Output" + DateTime.Now.ToString("_yyyyMMddHHmmss"); + sfPath.FileName = "Output" + DateTime.Now.ToString("_yyyyMMddHHmmss"); if (sfPath.ShowDialog() == DialogResult.Cancel) //如果按下取消,放棄後面動作 return; @@ -601,10 +600,9 @@ namespace ExportDataToFile txtTargetPWD.Text = ""; cbTargetTable.SelectedIndex = -1; cbTargetTable.Enabled = false; - dgvExportList.DataSource = null; - dgvColumnMapping.DataSource = null; - ResetDataGridView(); //重建DataGridView欄位 - + CleanRows(dgvExportList); + CleanRows(dgvColumnMapping); + sqlMSSourceConn = null; sqlMSTargetConn = null; sqlPsgSourceConn = null; @@ -949,7 +947,6 @@ namespace ExportDataToFile return "[" + strSourceCol + "] AS " + strTargetCol; case "DATETIME": return "Convert(varchar,[" + strSourceCol + "],21) AS " + strTargetCol; - //return "[" + strSourceCol + "] AS " + strTargetCol; default: return "[" + strSourceCol + "] AS " + strTargetCol; } @@ -964,13 +961,13 @@ namespace ExportDataToFile switch (strType.ToUpper()) { case "STRING": - return "'" + strData.ToString().Trim() + "'"; + return "'" + strData.ToString().Replace("'","''") + "'"; case "INT32": return strData.ToString().Trim(); case "DECIMAL": return strData.ToString().Trim(); default: - return "'" + strData.ToString().Trim() + "'"; + return "'" + strData.ToString().Replace("'", "''").Trim() + "'"; } } @@ -1652,13 +1649,13 @@ namespace ExportDataToFile switch (strType.ToUpper()) { case "STRING": - return "'" + strData.ToString().Trim() + "'"; + return "'" + strData.ToString().Replace("'", "''") + "'"; case "INT32": return strData.ToString().Trim(); case "DECIMAL": return strData.ToString().Trim(); default: - return "'" + strData.ToString().Trim() + "'"; + return "'" + strData.ToString().Replace("'", "''") + "'"; } } #endregion //End of MySQL @@ -1999,11 +1996,11 @@ namespace ExportDataToFile switch (strType.ToUpper()) { case "SYSTEM.STRING": - return "'" + strData.ToString().Trim() + "'"; + return "'" + strData.ToString().Replace("'","''") + "'"; case "SYSTEM.DECIMAL": return strData.ToString().Trim(); default: - return "'" + strData.ToString().Trim() + "'"; + return "'" + strData.ToString().Replace("'", "''") + "'"; } } @@ -2368,7 +2365,7 @@ namespace ExportDataToFile senderGrid.Rows[intRowIndex].Cells["clTableDel"].Value = false; senderGrid.Rows[intRowIndex].Cells["clWhere"].Value = ""; senderGrid.Rows[intRowIndex].Cells["clMappingData"].Value = ""; - CleanMappingRow(senderGrid, intRowIndex); + //CleanRows(senderGrid, intRowIndex); txtWhere.Text = ""; Application.DoEvents(); } @@ -2411,11 +2408,16 @@ namespace ExportDataToFile } } - private void CleanMappingRow(DataGridView senderGrid,int intRowIndex) - { - DataTable CleanTable = (DataTable)dgvColumnMapping.DataSource; - CleanTable.Rows.Clear(); - dgvColumnMapping.DataSource = CleanTable; + private void CleanRows(DataGridView senderGrid) + { + if (senderGrid.DataSource != null) + { + DataTable CleanTable = (DataTable)senderGrid.DataSource; + CleanTable.Rows.Clear(); + senderGrid.DataSource = CleanTable; + CleanTable.Dispose(); + } + } private void EnableExport() @@ -2581,99 +2583,6 @@ namespace ExportDataToFile } } - private void ResetDataGridView() - { - #region dgvExportList - dgvExportList.Columns.Clear(); - //匯出 - DataGridViewCheckBoxColumn clExport = new DataGridViewCheckBoxColumn(); - clExport.HeaderText = "匯出"; - clExport.Name = "clExport"; - clExport.Width = 50; - //清除 - DataGridViewButtonColumn clCancel = new DataGridViewButtonColumn(); - clCancel.HeaderText = "清除"; - clCancel.Name = "clCancel"; - clCancel.Width = 50; - //顯示來源 - DataGridViewButtonColumn clShow = new DataGridViewButtonColumn(); - clShow.HeaderText = "顯示來源"; - clShow.Name = "clShow"; - //來源資料表名稱 - DataGridViewTextBoxColumn clSourceTable = new DataGridViewTextBoxColumn(); - clSourceTable.HeaderText = "來源資料表名稱"; - clSourceTable.Name = "clSourceTable"; - clSourceTable.DataPropertyName = "TableName"; - clSourceTable.Width = 200; - //目標資料表名稱 - DataGridViewTextBoxColumn clTargetTable = new DataGridViewTextBoxColumn(); - clTargetTable.HeaderText = "目標資料表名稱"; - clTargetTable.Name = "clTargetTable"; - clTargetTable.Width = 200; - //清除目標資料表內容 - DataGridViewCheckBoxColumn clTableDel = new DataGridViewCheckBoxColumn(); - clTableDel.HeaderText = "清除目標資料表內容"; - clTableDel.Name = "clTableDel"; - clTableDel.Width = 200; - //過濾條件 - DataGridViewTextBoxColumn clWhere = new DataGridViewTextBoxColumn(); - clWhere.HeaderText = "過濾條件"; - clWhere.Name = "clWhere"; - clWhere.Visible = false; - //欄位對應 - DataGridViewTextBoxColumn clMappingData = new DataGridViewTextBoxColumn(); - clMappingData.HeaderText = "欄位對應"; - clMappingData.Name = "clMappingData"; - clMappingData.Visible = false; - - dgvExportList.Columns.Add(clExport); - dgvExportList.Columns.Add(clCancel); - dgvExportList.Columns.Add(clShow); - dgvExportList.Columns.Add(clSourceTable); - dgvExportList.Columns.Add(clTargetTable); - dgvExportList.Columns.Add(clTableDel); - dgvExportList.Columns.Add(clWhere); - dgvExportList.Columns.Add(clMappingData); - #endregion - - #region dgvColumnMapping - //匯出 - dgvColumnMapping.Columns.Clear(); - DataGridViewCheckBoxColumn clExpColumn = new DataGridViewCheckBoxColumn(); - clExpColumn.HeaderText = "匯出"; - clExpColumn.Name = "clExpColumn"; - clExpColumn.Width = 50; - //清除 - DataGridViewButtonColumn clClean = new DataGridViewButtonColumn(); - clClean.HeaderText = "清除"; - clClean.Name = "clClean"; - clClean.Width = 50; - //來源欄位 - DataGridViewTextBoxColumn clSourceColumn = new DataGridViewTextBoxColumn(); - clSourceColumn.HeaderText = "來源欄位"; - clSourceColumn.Name = "clSourceColumn"; - clSourceColumn.DataPropertyName = "COLUMN_NAME"; - clSourceColumn.Width = 100; - //型態 - DataGridViewTextBoxColumn clType = new DataGridViewTextBoxColumn(); - clType.HeaderText = "型態"; - clType.Name = "clType"; - clType.DataPropertyName = "DATA_TYPE"; - clType.Width = 100; - //目標欄位 - DataGridViewComboBoxColumn clTargetColumn = new DataGridViewComboBoxColumn(); - clTargetColumn.HeaderText = "目標欄位"; - clTargetColumn.Name = "clTargetColumn"; - clTargetColumn.Width = 100; - - dgvColumnMapping.Columns.Add(clExpColumn); - dgvColumnMapping.Columns.Add(clClean); - dgvColumnMapping.Columns.Add(clSourceColumn); - dgvColumnMapping.Columns.Add(clType); - dgvColumnMapping.Columns.Add(clTargetColumn); - #endregion - - } #endregion } } diff --git a/Form1.resx b/Form1.resx index 3710c45..e654215 100644 --- a/Form1.resx +++ b/Form1.resx @@ -117,6 +117,30 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + True diff --git a/Oracle.DataAccess.Common.Configuration.Section.xsd b/Oracle.DataAccess.Common.Configuration.Section.xsd new file mode 100644 index 0000000..eee2d5c --- /dev/null +++ b/Oracle.DataAccess.Common.Configuration.Section.xsd @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Oracle.ManagedDataAccess.Client.Configuration.Section.xsd b/Oracle.ManagedDataAccess.Client.Configuration.Section.xsd new file mode 100644 index 0000000..70935a1 --- /dev/null +++ b/Oracle.ManagedDataAccess.Client.Configuration.Section.xsd @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +