/// <summary> /// Invokes all events for this components. /// </summary> public override void InvokeEvents() { base.InvokeEvents(); try { #region Code StiValueEventArgs e = new StiValueEventArgs(); InvokeGetCustomCode(this, e); if (e.Value != null) { this.customCodeValue = e.Value.ToString(); } #endregion } catch (Exception e) { StiLogService.Write(this.GetType(), "DoEvents...ERROR"); StiLogService.Write(this.GetType(), e); if (Report != null) { Report.WriteToReportRenderingMessages(this.Name + " " + e.Message); } } }
public override void CreateConnectionInDataStore(StiDictionary dictionary, StiSqlDatabase database) { try { #region Remove all old data from datastore int index = 0; foreach (StiData data in dictionary.DataStore) { if (data.Name == database.Name) { dictionary.DataStore.RemoveAt(index); break; } index++; } #endregion var sqlConnection = new NpgsqlConnection(database.ConnectionString); var data2 = new StiData(database.Name, sqlConnection); data2.IsReportData = true; dictionary.DataStore.Add(data2); } catch (Exception e) { StiLogService.Write(this.GetType(), e); if (!StiOptions.Engine.HideExceptions) { throw; } } }
internal static void CheckForDataBandsUsedInPageTotals(StiText stiText) { try { StiReport report = stiText.Report; bool storeToPrint = false; object result = ParseTextValue(stiText.Text.Value, stiText, ref storeToPrint, false, true); } catch (Exception ex) { string str = string.Format("Expression in Text property of '{0}' can't be evaluated! {1}", stiText.Name, ex.Message); StiLogService.Write(stiText.GetType(), str); StiLogService.Write(stiText.GetType(), ex.Message); stiText.Report.WriteToReportRenderingMessages(str); } }
/// <summary> /// Raises the GetCustomCode event. /// </summary> public void InvokeGetCustomCode(StiComponent sender, StiValueEventArgs e) { try { OnGetCustomCode(e); StiValueEventHandler handler = base.Events[EventGetCustomCode] as StiValueEventHandler; if (handler != null) { handler(sender, e); } } catch (Exception ex) { string str = string.Format("Expression in CustomCode property of '{0}' can't be evaluated!", this.Name); StiLogService.Write(this.GetType(), str); StiLogService.Write(this.GetType(), ex.Message); Report.WriteToReportRenderingMessages(str); } }
public override StiDataColumnsCollection GetColumnsFromData(StiData data, StiDataSource dataSource, CommandBehavior commandBehavior) { var dataColumns = new StiDataColumnsCollection(); var sqlSource = dataSource as StiSqlSource; try { if (sqlSource.SqlCommand != null && sqlSource.SqlCommand.Length > 0 && data.Data is NpgsqlConnection) { var connection = data.Data as NpgsqlConnection; OpenConnection(connection, data, dataSource.Dictionary); using (var dataAdapter = new NpgsqlDataAdapter(sqlSource.SqlCommand, connection)) using (DataTable dataTable = new DataTable()) { dataTable.TableName = sqlSource.Name; dataAdapter.SelectCommand.CommandTimeout = sqlSource.CommandTimeout; dataAdapter.SelectCommand.Prepare(); dataAdapter.Fill(dataTable); foreach (DataColumn column in dataTable.Columns) { dataColumns.Add(new StiDataColumn(column.ColumnName, column.Caption, column.DataType)); } } CloseConnection(data, connection); } } catch (Exception e) { StiLogService.Write(this.GetType(), e); if (!StiOptions.Engine.HideExceptions) { throw; } } return(dataColumns); }
public override void ConnectDataSourceToData(StiDictionary dictionary, StiDataSource dataSource, bool loadData) { dataSource.Disconnect(); if (!loadData) { dataSource.DataTable = new DataTable(); return; } StiSqlSource sqlSource = dataSource as StiSqlSource; foreach (StiData data in dataSource.Dictionary.DataStore) { if (data.Name != sqlSource.NameInSource) { continue; } try { if (!(data.Data is NpgsqlConnection)) { continue; } var connection = data.ViewData as NpgsqlConnection; OpenConnection(connection, data, dataSource.Dictionary); sqlSource.DataAdapter = new NpgsqlDataAdapter(sqlSource.SqlCommand, connection); foreach (StiDataParameter parameter in sqlSource.Parameters) { ((NpgsqlDataAdapter)sqlSource.DataAdapter).SelectCommand.Parameters.Add( parameter.Name, (NpgsqlTypes.NpgsqlDbType)parameter.Type, parameter.Size); } var dataTable = new DataTable(); dataTable.TableName = sqlSource.Name; dataSource.DataTable = dataTable; sqlSource.DataAdapter.SelectCommand.CommandTimeout = sqlSource.CommandTimeout; if (loadData && sqlSource.Parameters.Count > 0) { sqlSource.DataAdapter.SelectCommand.Prepare(); sqlSource.UpdateParameters(); } else { if (loadData) { ((NpgsqlDataAdapter)sqlSource.DataAdapter).Fill(dataTable); sqlSource.CheckColumnsIndexs(); } else { ((NpgsqlDataAdapter)sqlSource.DataAdapter).FillSchema(dataTable, SchemaType.Source); } } break; } catch (Exception e) { StiLogService.Write(this.GetType(), e); if (!StiOptions.Engine.HideExceptions) { throw; } } } }