private void closeToolStripMenuItem_Click(object sender, EventArgs e) { if (!checkModified()) { return; } _source = null; _device = null; IsModified = false; toolStripHelper.SetHelperButtons(null); init(); }
public static MetaSource CreateSource(Repository repository) { // Create No Sql data source var source = MetaSource.Create(repository); source.Name = "Telelogos Data Source"; source.IsNoSQL = true; source.IsDefault = true; foreach (var src in repository.Sources) { src.IsDefault = false; } repository.Sources.Add(source); return(source); }
// Add the source to the repository as the default source public void AddSource(DataTable table) { if (_repository == null) { CreateRepository(); } var source = MetaSource.Create(_repository); source.Name = "Telelogos Data Source"; source.IsNoSQL = true; source.IsDefault = true; AddMasterTable(source, table); _repository.Sources.All(s => s.IsDefault = false); _repository.Sources.Add(source); }
MetaSource getSource(ITypeDescriptorContext context) { MetaSource source = context.Instance as MetaSource; if (context.Instance is ReportModel) { source = ((ReportModel)context.Instance).Source; } else if (context.Instance is ReportTask) { source = ((ReportTask)context.Instance).Source; } else if (context.Instance is MetaEV) { source = ((MetaEV)context.Instance).MetaEnum.Source; } return(source); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (!checkModified()) { return; } _source = null; _device = null; object entityToSelect = null; if (sender == dataSourceToolStripMenuItem || sender == noSQLdataSourceToolStripMenuItem) { _source = MetaSource.Create(_repository); _source.IsNoSQL = sender == noSQLdataSourceToolStripMenuItem; if (_source.IsNoSQL) { //Add master table MetaTable master = MetaTable.Create(); master.DynamicColumns = true; master.IsEditable = true; master.Alias = MetaData.MasterTableName; master.Source = _source; _source.MetaData.Tables.Add(master); entityToSelect = master; } else { entityToSelect = _source.Connection; } } else if (sender == emailOutputDeviceToolStripMenuItem) { _device = OutputEmailDevice.Create(); } else if (sender == fileServerDeviceToolStripMenuItem) { _device = OutputWinSCPDevice.Create(); } IsModified = true; init(entityToSelect); }
private void openFile(string path) { bool openOK = true; try { if (Path.GetDirectoryName(path).ToLower() == _repository.SourcesFolder.ToLower()) { _source = MetaSource.LoadFromFile(path); _source.InitReferences(_repository); _device = null; } else if (Path.GetDirectoryName(path).ToLower() == _repository.DevicesEmailFolder.ToLower()) { _source = null; _device = OutputEmailDevice.LoadFromFile(path, false); } else if (Path.GetDirectoryName(path).ToLower() == _repository.DevicesFileServerFolder.ToLower()) { _source = null; _device = OutputFileServerDevice.LoadFromFile(path, false); } else { openOK = false; MessageBox.Show("The configuration file must be in a repository folder.\r\nA sub-folder of " + _repository.RepositoryPath, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { openOK = false; MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (openOK) { Properties.Settings.Default.LastUsedFile = path; } IsModified = false; init(); }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { string[] choices = new string[] { "" }; MetaSource source = getSource(context); if (source != null) { List <string> choices2 = (from s in source.Connections select s.Name + (!s.IsEditable ? " (Repository)" : "")).ToList(); if (source.Report != null && (source is ReportSource || context.Instance is ReportView) && !string.IsNullOrEmpty(((ReportSource)source).MetaSourceGUID)) { string defaultRepConnectionStr = string.Format("{0} ({1})", DefaultRepositoryStr, ((ReportSource)source).RepositoryConnection.Name); choices2.Insert(0, defaultRepConnectionStr); } if (source.Report != null && (context.Instance is ReportModel || context.Instance is ReportTask) && !string.IsNullOrEmpty(((ReportSource)source).MetaSourceGUID)) { choices2.Insert(0, DefaultReportStr); } choices = choices2.ToArray(); } return(new StandardValuesCollection(choices.OrderBy(i => i).ToList())); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { MetaSource source = getSource(context); if (source != null) { if (source is ReportSource && ((ReportSource)source).RepositoryConnection != null && value.ToString() == string.Format("{0} ({1})", DefaultRepositoryStr, ((ReportSource)source).RepositoryConnection.Name)) { return(ReportSource.DefaultRepositoryConnectionGUID); } if (value.ToString() == ReportSource.DefaultReportConnectionGUID) { return(DefaultReportStr); } MetaConnection connection = source.Connections.FirstOrDefault(i => i.Name + (!i.IsEditable ? " (Repository)" : "") == value.ToString()); if (connection != null) { return(connection.GUID); } } return(base.ConvertFrom(context, culture, value)); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (!checkModified()) { return; } _source = null; _device = null; object entityToSelect = null; if (sender == dataSourceToolStripMenuItem || sender == noSQLdataSourceToolStripMenuItem) { _source = MetaSource.Create(_repository); _source.IsNoSQL = (sender == noSQLdataSourceToolStripMenuItem); if (_source.IsNoSQL) { entityToSelect = _source.TableFolder; _source.Connection.ConnectionString = ""; } else { entityToSelect = _source.Connection; } } else if (sender == emailOutputDeviceToolStripMenuItem) { _device = OutputEmailDevice.Create(); } else if (sender == fileServerDeviceToolStripMenuItem) { _device = OutputFileServerDevice.Create(); } IsModified = true; init(entityToSelect); }
public void checkSQL() { string initialSQL = "", error = ""; try { if (Instance is ReportModel) { ReportModel model = Instance as ReportModel; if (PropertyName == "PreSQL" || PropertyName == "PostSQL") { if (sqlTextBox.Text.StartsWith("@")) { FormHelper.CheckRazorSyntax(sqlTextBox, "", model, _compilationErrors); } error = model.Source.CheckSQL(RazorHelper.CompileExecute(sqlTextBox.Text, model), null, model, true); } else { var sql = !string.IsNullOrEmpty(SqlToCheck) ? SqlToCheck : sqlTextBox.Text; if (model.IsLINQ) { error = model.Source.CheckLINQ(sql, model.FromTables, model); } else { error = model.Source.CheckSQL(sql, model.FromTables, model, false); } } } if (Instance is MetaEnum) { MetaEnum anEnum = Instance as MetaEnum; if (sqlTextBox.Text.StartsWith("@")) { FormHelper.CheckRazorSyntax(sqlTextBox, "", anEnum, _compilationErrors); } error = anEnum.Source.CheckSQL(RazorHelper.CompileExecute(sqlTextBox.Text, anEnum), null, null, false); } else if (Instance is MetaSource) { MetaSource source = Instance as MetaSource; if (PropertyName == "PreSQL" || PropertyName == "PostSQL") { if (sqlTextBox.Text.StartsWith("@")) { FormHelper.CheckRazorSyntax(sqlTextBox, "", source, _compilationErrors); } error = source.CheckSQL(RazorHelper.CompileExecute(sqlTextBox.Text, source), null, null, true); } } else if (Instance is MetaTable) { MetaTable table = Instance as MetaTable; if (PropertyName == "PreSQL" || PropertyName == "PostSQL") { if (sqlTextBox.Text.StartsWith("@")) { FormHelper.CheckRazorSyntax(sqlTextBox, "", table, _compilationErrors); } error = table.Source.CheckSQL(RazorHelper.CompileExecute(sqlTextBox.Text, table), null, null, true); } else { if (PropertyName == "WhereSQL") { initialSQL = table.WhereSQL; if (sqlTextBox.Text.StartsWith("@")) { FormHelper.CheckRazorSyntax(sqlTextBox, "", table, _compilationErrors); } table.WhereSQL = RazorHelper.CompileExecute(sqlTextBox.Text, table); } else { initialSQL = table.Sql; table.Sql = sqlTextBox.Text; } try { table.CheckTable(null); if (sqlTextBox.ReadOnly) { table.SetReadOnly(); } error = table.Error; } finally { if (PropertyName == "WhereSQL") { table.WhereSQL = initialSQL; } else { table.Sql = initialSQL; } } } } else if (Instance is MetaJoin) { MetaJoin join = Instance as MetaJoin; initialSQL = join.Clause; try { join.Clause = sqlTextBox.Text; join.CheckJoin(); if (sqlTextBox.ReadOnly) { join.SetReadOnly(); } error = join.Error; } finally { join.Clause = initialSQL; } } else if (Instance is ReportTask) { ReportTask task = Instance as ReportTask; if (sqlTextBox.Text.StartsWith("@")) { FormHelper.CheckRazorSyntax(sqlTextBox, "", task, _compilationErrors); } error = task.Source.CheckSQL(RazorHelper.CompileExecute(sqlTextBox.Text, task), null, null, false); } } catch (Exception ex) { error = ex.Message; } errorTextBox.Text = error; if (!string.IsNullOrEmpty(error)) { toolStripStatusLabel.Text = "Error"; toolStripStatusLabel.Image = global::Seal.Properties.Resources.error2; } else { toolStripStatusLabel.Text = "Script checked successfully"; toolStripStatusLabel.Image = global::Seal.Properties.Resources.checkedGreen; } }
void helperButton_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (sender is ToolStripItem) { var toolStrip = (ToolStripItem)sender; Keys?key = null; if (toolStrip.Tag != null) { key = (Keys)toolStrip.Tag; } if (SelectedEntity is MetaSource) { if (key == Keys.F7) { MetaSource source = ((MetaSource)SelectedEntity); source.Connection.CheckConnection(); source.Information = source.Connection.Information; source.Error = source.Connection.Error; source.InitEditor(); } } else if (SelectedEntity is MetaConnection) { if (key == Keys.F7) { ((MetaConnection)SelectedEntity).CheckConnection(); } } else if (SelectedEntity is MetaTable) { if (key == Keys.F7) { ((MetaTable)SelectedEntity).CheckTable(null); } if (key == Keys.F8) { if (((MetaTable)SelectedEntity).IsSQL) { EditProperty("SQL Select Statement"); } else { EditProperty("Definition Script"); } } if (key == Keys.F9 && ((MetaTable)SelectedEntity).DynamicColumns) { ((MetaTable)SelectedEntity).Refresh(); if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.InitEntity(SelectedEntity); } } if (key == Keys.F12) { EditProperty("Default Load Script"); } } else if (SelectedEntity is MetaColumn) { if (key == Keys.F7) { EditProperty("Check column SQL syntax"); } if (key == Keys.F8) { EditProperty("Show column values"); } } else if (SelectedEntity is MetaEnum) { if (key == Keys.F7) { EditProperty("SQL Select Statement"); } if (key == Keys.F8) { EditProperty("Script"); } if (key == Keys.F9) { if (EntityHandler != null) { EntityHandler.SetModified(); } ((MetaEnum)SelectedEntity).RefreshEnum(); } } else if (SelectedEntity is MetaJoin) { if (key == Keys.F7) { ((MetaJoin)SelectedEntity).CheckJoin(); } if (key == Keys.F8) { EditProperty("Join clause"); } } else if (SelectedEntity is ReportTask) { if (key == Keys.F7) { EditProperty("Script"); } if (key == Keys.F8) { EditProperty("SQL Statement"); } } else if (SelectedEntity is ReportModel) { ReportModel model = SelectedEntity as ReportModel; if (key == null && model.IsLINQ) { model.BuildQuery(false, true); EntityHandler.UpdateModelNode(); MessageBox.Show(string.Format("The LINQ Model has been refreshed...\r\n\r\nIt contains {0} SQL Sub-Model(s) and {1} NoSQL Sub-Table(s).", model.LINQSubModels.Count, model.LINQSubTables.Count), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (key == Keys.F7 || key == Keys.F8) { if (model.IsLINQ) { var frm = new TemplateTextEditorForm(); frm.Text = "LINQ Editor" + (!string.IsNullOrEmpty(model.LoadScript) ? " (WARNING: Script got from the 'Load Script' property of the model)" : ""); frm.ObjectForCheckSyntax = model; ScintillaHelper.Init(frm.textBox, Lexer.Cpp); if (string.IsNullOrEmpty(model.LoadScript)) { model.Report.CheckingExecution = true; try { model.BuildQuery(); frm.textBox.Text = model.LINQLoadScript; model.Report.CheckingExecution = false; model.BuildQuery(); } finally { model.Report.CheckingExecution = false; } if (!string.IsNullOrEmpty(model.ExecutionError)) { throw new Exception(model.ExecutionError); } frm.textBox.Text = model.LINQLoadScript; } else { frm.textBox.Text = model.LoadScript; } if (key == Keys.F8) { frm.CheckSyntax(); } frm.textBox.ReadOnly = true; frm.okToolStripButton.Visible = false; frm.cancelToolStripButton.Text = "Close"; frm.ShowDialog(); } else { var frm = new SQLEditorForm(); frm.Instance = SelectedEntity; frm.PropertyName = ""; frm.InitLexer(Lexer.Sql); if (model.IsSQLModel && key == Keys.F7) { frm.Text = "SQL Editor: Edit the SQL Select Statement"; frm.SetSamples(new List <string>() { "SELECT * FROM Orders", "SELECT *\r\nFROM Employees\r\nWHERE {CommonRestriction_LastName}", "SELECT * FROM Orders", "SELECT *\r\nFROM Employees\r\nWHERE EmployeeID > {CommonValue_ID}" }); frm.WarningOnError = true; frm.sqlTextBox.Text = model.Table.Sql; if (frm.ShowDialog() == DialogResult.OK) { try { Cursor.Current = Cursors.WaitCursor; model.Table.Sql = frm.sqlTextBox.Text; model.RefreshMetaTable(true); } finally { Cursor.Current = Cursors.Default; } if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.RefreshModelTreeView(); } if (!string.IsNullOrEmpty(model.Table.Error)) { throw new Exception("Error when building columns from the SQL Select Statement:\r\n" + model.Table.Error); } } } else { model.Report.CheckingExecution = true; try { model.BuildQuery(); frm.SqlToCheck = model.Sql; model.Report.CheckingExecution = false; model.BuildQuery(); } finally { model.Report.CheckingExecution = false; } if (!string.IsNullOrEmpty(model.ExecutionError)) { throw new Exception("Error building the SQL Statement...\r\nPlease fix these errors first.\r\n" + model.ExecutionError); } frm.sqlTextBox.Text = model.Sql; frm.SetReadOnly(); if (key == Keys.F8) { frm.checkSQL(); } frm.ShowDialog(); } } } } else if (SelectedEntity is ReportView) { if (key == Keys.F8) { EditProperty("Custom template"); } } else if (SelectedEntity is Report) { if (key == Keys.F7) { EditProperty("Common Scripts"); } if (key == Keys.F8) { EditProperty("Report Input Values"); } } else if (SelectedEntity is ReportSchedule) { if (key == Keys.F8) { EditProperty("Edit schedule properties"); } if (key == Keys.F9) { EditProperty("Run Task Scheduler MMC"); } } } } finally { Cursor.Current = Cursors.Default; } }
void helperButton_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (sender is ToolStripItem) { Keys key = (Keys)((ToolStripItem)sender).Tag; if (SelectedEntity is MetaSource) { if (key == Keys.F7) { MetaSource source = ((MetaSource)SelectedEntity); source.Connection.CheckConnection(); source.Information = source.Connection.Information; source.Error = source.Connection.Error; source.InitEditor(); } if (key == Keys.F12) { MetaTable table = ((MetaSource)SelectedEntity).MetaData.MasterTable; if (table != null) { TreeViewHelper.SelectNode(MainTreeView, MainTreeView.SelectedNode.Nodes, table); EditProperty("Default Load Script"); } } } else if (SelectedEntity is MetaConnection) { if (key == Keys.F7) { ((MetaConnection)SelectedEntity).CheckConnection(); } } else if (SelectedEntity is MetaTable) { if (key == Keys.F7) { ((MetaTable)SelectedEntity).CheckTable(null); } if (key == Keys.F8) { if (((MetaTable)SelectedEntity).IsSQL) { EditProperty("SQL Select Statement"); } else { EditProperty("Definition Script"); } } if (key == Keys.F9 && ((MetaTable)SelectedEntity).DynamicColumns) { ((MetaTable)SelectedEntity).Refresh(); if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.InitEntity(SelectedEntity); } } if (key == Keys.F12) { EditProperty("Default Load Script"); } } else if (SelectedEntity is MetaColumn) { if (key == Keys.F7) { EditProperty("Check column SQL syntax"); } if (key == Keys.F8) { EditProperty("Show column values"); } } else if (SelectedEntity is MetaEnum) { if (key == Keys.F8) { EditProperty("SQL Select Statement"); } if (key == Keys.F9) { if (EntityHandler != null) { EntityHandler.SetModified(); } ((MetaEnum)SelectedEntity).RefreshEnum(); } } else if (SelectedEntity is MetaJoin) { if (key == Keys.F7) { ((MetaJoin)SelectedEntity).CheckJoin(); } if (key == Keys.F8) { EditProperty("SQL Clause"); } } else if (SelectedEntity is TasksFolder) { if (key == Keys.F7) { EditProperty("Common Scripts"); } } else if (SelectedEntity is ReportTask) { if (key == Keys.F7) { EditProperty("Script"); } if (key == Keys.F8) { EditProperty("SQL Statement"); } } else if (SelectedEntity is ReportModel) { if (key == Keys.F7 || key == Keys.F8) { var frm = new SQLEditorForm(); frm.Instance = SelectedEntity; frm.PropertyName = ""; ReportModel model = SelectedEntity as ReportModel; if (model.IsSQLModel && key == Keys.F7) { frm.Text = "SQL Editor: Edit the SQL Select Statement"; frm.SetSamples(new List <string>() { "SELECT * FROM Orders", "SELECT *\r\nFROM Employees\r\nWHERE {CommonRestriction_LastName}", "SELECT * FROM Orders", "SELECT *\r\nFROM Employees\r\nWHERE EmployeeID > {CommonValue_ID}" }); frm.WarningOnError = true; frm.sqlTextBox.Text = model.Table.Sql; if (frm.ShowDialog() == DialogResult.OK) { try { Cursor.Current = Cursors.WaitCursor; model.Table.Sql = frm.sqlTextBox.Text; model.RefreshMetaTable(true); } finally { Cursor.Current = Cursors.Default; } if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.RefreshModelTreeView(); } if (!string.IsNullOrEmpty(model.Table.Error)) { throw new Exception("Error when building columns from the SQL Select Statement:\r\n" + model.Table.Error); } } } else { model.Report.CheckingExecution = true; try { model.BuildSQL(); frm.SqlToCheck = model.Sql; model.Report.CheckingExecution = false; model.BuildSQL(); } finally { model.Report.CheckingExecution = false; } if (!string.IsNullOrEmpty(model.ExecutionError)) { throw new Exception("Error building the SQL Statement...\r\nPlease fix these errors first.\r\n" + model.ExecutionError); } frm.sqlTextBox.Text = model.Sql; frm.SetReadOnly(); if (key == Keys.F8) { frm.checkSQL(); } frm.ShowDialog(); } } } else if (SelectedEntity is ReportView) { if (key == Keys.F8) { EditProperty("Custom template"); } } else if (SelectedEntity is ViewFolder) { if (key == Keys.F8) { EditProperty("Report Input Values"); } } else if (SelectedEntity is ReportSchedule) { if (key == Keys.F8) { EditProperty("Edit schedule properties"); } if (key == Keys.F9) { EditProperty("Run Task Scheduler MMC"); } } } } finally { Cursor.Current = Cursors.Default; } }
void helperButton_Click(object sender, EventArgs e) { try { Cursor.Current = Cursors.WaitCursor; if (sender is ToolStripItem) { Keys key = (Keys)((ToolStripItem)sender).Tag; if (SelectedEntity is MetaSource) { if (key == Keys.F7) { MetaSource source = ((MetaSource)SelectedEntity); source.Connection.CheckConnection(); source.Information = source.Connection.Information; source.Error = source.Connection.Error; source.InitEditor(); } if (key == Keys.F8 || key == Keys.F10) { MetaTable table = ((MetaSource)SelectedEntity).MetaData.MasterTable; if (table != null) { TreeViewHelper.SelectNode(MainTreeView, MainTreeView.SelectedNode.Nodes, table); EditProperty(table.IsSQL ? "SQL Statement" : "Default Load Script"); } } } else if (SelectedEntity is MetaConnection) { if (key == Keys.F7) { ((MetaConnection)SelectedEntity).CheckConnection(); } } else if (SelectedEntity is MetaTable) { if (key == Keys.F7) { ((MetaTable)SelectedEntity).CheckTable(null); } if (key == Keys.F8) { if (((MetaTable)SelectedEntity).IsSQL) { EditProperty("SQL Statement"); } else { EditProperty("Definition Script"); } } if (key == Keys.F9 && ((MetaTable)SelectedEntity).DynamicColumns) { ((MetaTable)SelectedEntity).Refresh(); if (EntityHandler != null) { EntityHandler.SetModified(); EntityHandler.InitEntity(SelectedEntity); } } if (key == Keys.F10) { EditProperty("Default Load Script"); } } else if (SelectedEntity is MetaColumn) { if (key == Keys.F7) { EditProperty("Check column SQL syntax"); } if (key == Keys.F8) { EditProperty("Show column values"); } } else if (SelectedEntity is MetaEnum) { if (key == Keys.F8) { EditProperty("Select SQL Statement"); } if (key == Keys.F9) { ((MetaEnum)SelectedEntity).RefreshEnum(); } } else if (SelectedEntity is MetaJoin) { if (key == Keys.F7) { ((MetaJoin)SelectedEntity).CheckJoin(); } if (key == Keys.F8) { EditProperty("SQL Clause"); } } else if (SelectedEntity is ReportTask) { if (key == Keys.F7) { EditProperty("Script"); } if (key == Keys.F8) { EditProperty("SQL Statement"); } } else if (SelectedEntity is ReportModel) { if (key == Keys.F7 || key == Keys.F8) { var frm = new SQLEditorForm(); frm.Instance = SelectedEntity; frm.PropertyName = ""; ReportModel model = SelectedEntity as ReportModel; model.Report.CheckingExecution = true; try { model.BuildSQL(); } finally { model.Report.CheckingExecution = false; } if (!string.IsNullOrEmpty(model.ExecutionError)) { throw new Exception("Error building the SQL Statement...\r\nPlease fix these errors first.\r\n" + model.ExecutionError); } frm.sqlTextBox.Text = model.Sql; frm.SetReadOnly(); if (key == Keys.F8) { frm.checkSQLToolStripButton_Click(null, null); } frm.ShowDialog(); } } else if (SelectedEntity is ReportView) { if (key == Keys.F7) { EditProperty("General Parameters"); } else if (key == Keys.F8) { EditProperty("CSS"); } else if (key == Keys.F9) { EditProperty("Data Table Configuration"); } else if (key == Keys.F10) { EditProperty("NVD3 Chart Configuration"); } } else if (SelectedEntity is ReportSchedule) { if (key == Keys.F8) { EditProperty("Edit schedule properties"); } if (key == Keys.F9) { EditProperty("Run Task Scheduler MMC"); } } } } finally { Cursor.Current = Cursors.Default; } }
public void checkSQLToolStripButton_Click(object sender, EventArgs e) { string initialSQL = "", error = ""; try { if (Instance is ReportModel) { ReportModel model = Instance as ReportModel; if (PropertyName == "PreSQL" || PropertyName == "PostSQL") { error = model.Source.CheckSQL(Helper.ParseRazor(sqlTextBox.Text, model), null, model, true); } else { error = model.Source.CheckSQL(sqlTextBox.Text, model.FromTables, model, false); } } if (Instance is MetaEnum) { MetaEnum anEnum = Instance as MetaEnum; error = anEnum.Source.CheckSQL(sqlTextBox.Text, null, null, false); } else if (Instance is MetaSource) { MetaSource source = Instance as MetaSource; if (PropertyName == "PreSQL" || PropertyName == "PostSQL") { error = source.CheckSQL(Helper.ParseRazor(sqlTextBox.Text, source), null, null, true); } } else if (Instance is MetaTable) { MetaTable table = Instance as MetaTable; if (PropertyName == "PreSQL" || PropertyName == "PostSQL") { error = table.Source.CheckSQL(Helper.ParseRazor(sqlTextBox.Text, table), null, null, true); } else { if (PropertyName == "WhereSQL") { initialSQL = table.WhereSQL; table.WhereSQL = Helper.ParseRazor(sqlTextBox.Text, table); } else { initialSQL = table.Sql; table.Sql = sqlTextBox.Text; } try { table.CheckTable(null); if (sqlTextBox.IsReadOnly) { table.SetReadOnly(); } error = table.Error; } finally { if (PropertyName == "WhereSQL") { table.WhereSQL = initialSQL; } else { table.Sql = initialSQL; } } } } else if (Instance is MetaJoin) { MetaJoin join = Instance as MetaJoin; initialSQL = join.Clause; try { join.Clause = sqlTextBox.Text; join.CheckJoin(); if (sqlTextBox.IsReadOnly) { join.SetReadOnly(); } error = join.Error; } finally { join.Clause = initialSQL; } } else if (Instance is ReportTask) { ReportTask task = Instance as ReportTask; error = task.Source.CheckSQL(Helper.ParseRazor(sqlTextBox.Text, task), null, null, false); } } catch (Exception ex) { error = ex.Message; } errorTextBox.Text = error; if (!string.IsNullOrEmpty(error)) { toolStripStatusLabel.Text = "Error"; toolStripStatusLabel.Image = global::Seal.Properties.Resources.error2; } else { toolStripStatusLabel.Text = "SQL checked successfully"; toolStripStatusLabel.Image = global::Seal.Properties.Resources.checkedGreen; } }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { MetaColumn column = context.Instance as MetaColumn; ReportElement element = context.Instance as ReportElement; ReportOutput output = context.Instance as ReportOutput; MetaSource source = context.Instance as MetaSource; List <string> choices = new List <string>(); choices.Add(""); if (element != null) { if (element.IsNumeric) { addNumericChoices(choices); } else if (element.IsDateTime) { addDateTimeChoices(choices); } else { addStringChoices(choices); } if (!string.IsNullOrEmpty(element.FormatEl) && !choices.Contains(element.FormatEl)) { choices.Add(element.FormatEl); } } else if (column != null) { if (column.Type == ColumnType.Numeric) { addNumericChoices(choices); } else if (column.Type == ColumnType.DateTime) { addDateTimeChoices(choices); } else { addStringChoices(choices); } if (!string.IsNullOrEmpty(column.Format) && !choices.Contains(column.Format)) { choices.Add(column.Format); } } else if (output != null) { choices.Clear(); choices.Add(Repository.SealReportDisplayNameKeyword); choices.Add(Repository.SealReportDisplayNameKeyword + "_{0:yyyy_MM_dd}"); choices.Add(Repository.SealReportDisplayNameKeyword + "_{0:yyyy_MM_dd HH_mm_ss}"); choices.Add(output.Report.ExecutionName); choices.Add(output.Report.ExecutionName + "_{0:yyyy_MM_dd}"); choices.Add(output.Report.ExecutionName + "_{0:yyyy_MM_dd HH_mm_ss}"); choices.Add(output.Name); choices.Add(output.Name + "_{0:yyyy_MM_dd}"); choices.Add(output.Name + "_{0:yyyy_MM_dd HH_mm_ss}"); if (!string.IsNullOrEmpty(output.FileName) && !choices.Contains(output.FileName)) { choices.Add(output.FileName); } } else if (source != null) { if (context.PropertyDescriptor.Name == "NumericFormat") { addNumericChoices(choices); } else if (context.PropertyDescriptor.Name == "DateTimeFormat") { addDateTimeChoices(choices); } else { addStringChoices(choices); } } return(new StandardValuesCollection(choices.ToArray())); }