//Ctrl + 6: Gen Info / Controller public void GenInfoController() { string str = MethodInfo.GetCurrentMethod().Name; string strTableName = ""; MessageBoxResult result = PromptForm.ShowCombobox(str, "Table Name", ref strTableName); if (result == MessageBoxResult.Cancel) { return; } string strType = string.Empty; result = PromptForm.ShowCombobox(str, "Gen Controller", new string[] { "YES", "NO" }, ref strType); if (result == MessageBoxResult.Cancel) { return; } string strQuery = SQLApp.GetFile(strPath + "GenInfo.sql"); strQuery = strQuery.Replace("@TableName@", strTableName); strQuery = strQuery.Replace("@Version@", System.Windows.Forms.Application.ProductName + " - " + System.Windows.Forms.Application.ProductVersion); strQuery = strQuery.Replace("@CreatedDate@", DateTime.Now.ToShortDateString()); DataTable dt = SQLDBUtil.GetDataTable(strQuery); if (dt != null) { string strContent = Convert.ToString(dt.Rows[0][0]); SQLApp.WriteFile("D:\\" + strTableName + "Info.cs", strContent); //NotifycationAler aler = new NotifycationAler(); //aler.ShowDialog(); } if (strType == "YES") { strQuery = SQLApp.GetFile(strPath + "GenController.sql"); strQuery = strQuery.Replace("@TableName@", strTableName); strQuery = strQuery.Replace("@Version@", System.Windows.Forms.Application.ProductName + " - " + System.Windows.Forms.Application.ProductVersion); strQuery = strQuery.Replace("@CreatedDate@", DateTime.Now.ToShortDateString()); dt = SQLDBUtil.GetDataTable(strQuery); if (dt != null) { string strContent = Convert.ToString(dt.Rows[0][0]); SQLApp.WriteFile("D:\\" + strTableName + "Controller.cs", strContent); } } }
protected void ShowScriptCommand(string output, string strType) { if (strType.Equals("table")) { string[] arr = output.Split('\n'); DataTable dtSoure = new DataTable(); dtSoure.TableName = "Route List"; int idx = 0; arr.ToList().ForEach(r => { string[] row = r.Split('|'); if (row.Length > 1) { if (idx == 0) { row.Where(c => !string.IsNullOrEmpty(c.Trim())).ToList().ForEach(c => { DataColumn col = new DataColumn(c.Trim(), typeof(string)); dtSoure.Columns.Add(col); }); } else { dtSoure.LoadDataRow(row.Where(c => !string.IsNullOrEmpty(c.Trim())).Select(c => c.Trim()).ToArray(), false); } idx++; } }); ShowResultData(null, dtSoure); } else { SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = "*." + strType.Replace("file", ""); if (saveFile.ShowDialog() == DialogResult.OK) { SQLApp.WriteFile(saveFile.FileName, output); } } }