private DataSet FillGrid() 
		{
			this.connectionObject = ConnectionObject.CreateInstance(this.model.ReportSettings.ConnectionString,
			                                                      System.Data.Common.DbProviderFactories.GetFactory("System.Data.OleDb"));
			
			this.txtSqlString.Text = String.Empty;
			SqlQueryChecker.Check(model.ReportSettings.CommandType,
			                      model.ReportSettings.CommandText);
			DataSet dataSet = ResultPanel.CreateDataSet ();
			
			this.txtSqlString.Text = model.ReportSettings.CommandText;
			if (model.ReportSettings.CommandType == CommandType.StoredProcedure){
				
				if (reportStructure.SharpQueryProcedure == null) {
					throw new IllegalQueryException();
				}

				SharpQueryProcedure procedure = reportStructure.SharpQueryProcedure;
				SharpQuerySchemaClassCollection sc = procedure.GetSchemaParameters();
				
				if ((sc != null) && sc.Count > 0) {
					dataSet = ExecuteStoredProc (procedure);
				}else {
					dataSet = ExecuteStoredProc ();
				}
			}
			
			// from here we create from an SqlString like "Select...."
			if (model.ReportSettings.CommandType == CommandType.Text){
				this.txtSqlString.Text = model.ReportSettings.CommandText;
				dataSet = BuildFromSqlString();
			}
			return dataSet;
		}
        private ReportDataSource(ConnectionObject connectionObject, ReportSettings reportSettings)
        {
            this.connectionObject = connectionObject;
            this.reportSettings   = reportSettings;

            this.connection = connectionObject.Connection;
            if (this.connection.State == ConnectionState.Open)
            {
                this.connection.Close();
            }
            if (this.reportSettings.DataModel != GlobalEnums.PushPullModel.PushData)
            {
                SqlQueryChecker.Check(this.reportSettings.CommandType, this.reportSettings.CommandText);
            }
            this.dataSource = this.FillDataSet().Tables[0];
            CheckDataSource();

            /*
             *      this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
             *                                                reportSettings);
             *
             *      this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
             *
             */
        }
Example #3
0
        public static IDataManager CreateDataManager(IReportModel reportModel, ReportParameters reportParameters)
        {
            if (reportModel == null)
            {
                throw new ArgumentNullException("reportModel");
            }
            IDataManager        dataManager      = null;
            ConnectionObject    connectionObject = null;
            IDataAccessStrategy accesStrategy    = null;

            if (reportParameters != null)
            {
                connectionObject = reportParameters.ConnectionObject;
            }

            if (connectionObject != null)
            {
                accesStrategy = new SqlDataAccessStrategy(reportModel.ReportSettings, connectionObject);
            }
            else
            {
                accesStrategy = new SqlDataAccessStrategy(reportModel.ReportSettings, null);
            }
            dataManager = DataManager.CreateInstance(reportModel.ReportSettings, accesStrategy);
            if (dataManager == null)
            {
                throw new MissingDataManagerException();
            }
            return(dataManager);
        }
Example #4
0
		private DataSet FillGrid() 
		{
			SqlQueryChecker.Check(model.ReportSettings.CommandType,
			                      model.ReportSettings.CommandText);
			
			DataSet dataSet = ResultPanel.CreateDataSet ();
			
			this.txtSqlString.Text = model.ReportSettings.CommandText;
			switch (model.ReportSettings.CommandType) {
				case CommandType.Text:
						this.connectionObject = CreateConnection ();
						var dataAccess = new SqlDataAccessStrategy(model.ReportSettings,connectionObject);
						dataSet = dataAccess.ReadData();
						dataSet.Tables[0].TableName = CreateTableName (reportStructure);
					break;
				case CommandType.StoredProcedure:
					dataSet = DatasetFromStoredProcedure();
					break;
				case CommandType.TableDirect:
					MessageService.ShowError("TableDirect is not suppurted at the moment");
					break;
				default:
					throw new Exception("Invalid value for CommandType");
			}
			return dataSet;
		}
Example #5
0
 public static ConnectionObject BuildConnectionObject(ReportSettings reportSettings)
 {
     if (reportSettings == null)
     {
         throw new ArgumentNullException("reportSettings");
     }
     return(ConnectionObject.CreateInstance(reportSettings.ConnectionString,
                                            DbProviderFactories.GetFactory("System.Data.OleDb")));
 }
Example #6
0
 public static ConnectionObject BuildConnectionObject(string connectionString)
 {
     if (String.IsNullOrEmpty(connectionString))
     {
         throw new ArgumentNullException("connectionString");
     }
     return(ConnectionObject.CreateInstance(connectionString,
                                            DbProviderFactories.GetFactory("System.Data.OleDb")));
 }
		/// <summary>
		/// use this Constructor for PullDataReports
		/// </summary>
		/// <param name="connection">A valid connection</param>
		/// <param name="reportSettings">a <see cref="ReportSettings"></see></param>
		
		#region Constructores
		
		public static ReportDataSource CreateInstance (ConnectionObject connectionObject, ReportSettings reportSettings)
		{
			if (connectionObject == null) {
				throw new ArgumentNullException("connectionObject");
			}
			if (reportSettings == null) {
				throw new ArgumentNullException("reportSettings");
			}
			ReportDataSource instance = new ReportDataSource(connectionObject,reportSettings);
			return instance;
		}
		public SqlDataAccessStrategy(ReportSettings reportSettings,ConnectionObject connectionObject)
		{
			if (reportSettings == null) {
				throw new ArgumentNullException("reportSettings");
			}
			this.reportSettings = reportSettings;
			if (connectionObject == null) {
				this.connectionObject = ConnectionObjectFactory.BuildConnectionObject(reportSettings.ConnectionString);
			} else {
				this.connectionObject = connectionObject;
			}
		}
Example #9
0
		private DataSet FillGrid() 
		{
			this.connectionObject = ConnectionObject.CreateInstance(this.model.ReportSettings.ConnectionString,
			                                                      System.Data.Common.DbProviderFactories.GetFactory("System.Data.OleDb"));
			
			this.txtSqlString.Text = String.Empty;
			SqlQueryChecker.Check(model.ReportSettings.CommandType,
			                      model.ReportSettings.CommandText);
			DataSet dataSet = ResultPanel.CreateDataSet ();
			
			
			switch (model.ReportSettings.CommandType) {
				case CommandType.Text:
						this.txtSqlString.Text = model.ReportSettings.CommandText;
						dataSet = BuildFromSqlString();
					break;
				case CommandType.StoredProcedure:
					MessageService.ShowError("Stored Procedures are not suppurted at the moment");
					break;
				case CommandType.TableDirect:
					MessageService.ShowError("TableDirect is not suppurted at the moment");
					break;
				default:
					throw new Exception("Invalid value for CommandType");
			}
			
			
			if (model.ReportSettings.CommandType == CommandType.StoredProcedure){
				/*
				if (reportStructure.SharpQueryProcedure == null) {
					throw new IllegalQueryException();
				}

				SharpQueryProcedure procedure = reportStructure.SharpQueryProcedure;
				SharpQuerySchemaClassCollection sc = procedure.GetSchemaParameters();
				
				if ((sc != null) && sc.Count > 0) {
					dataSet = ExecuteStoredProc (procedure);
				}else {
					dataSet = ExecuteStoredProc ();
				}
				*/
			}
			
			// from here we create from an SqlString like "Select...."
//			if (model.ReportSettings.CommandType == CommandType.Text){
//				this.txtSqlString.Text = model.ReportSettings.CommandText;
//				dataSet = BuildFromSqlString();
//			}
			return dataSet;
		}
        /// <summary>
        /// use this Constructor for PullDataReports
        /// </summary>
        /// <param name="connection">A valid connection</param>
        /// <param name="reportSettings">a <see cref="ReportSettings"></see></param>

        #region Constructores

        public static ReportDataSource CreateInstance(ConnectionObject connectionObject, ReportSettings reportSettings)
        {
            if (connectionObject == null)
            {
                throw new ArgumentNullException("connectionObject");
            }
            if (reportSettings == null)
            {
                throw new ArgumentNullException("reportSettings");
            }
            ReportDataSource instance = new ReportDataSource(connectionObject, reportSettings);

            return(instance);
        }
		public static ConnectionObject CreateInstance (IDbConnection connection,
		                                               DbProviderFactory providerFactory)
		{
			if (connection == null) {
				throw new ArgumentNullException("connection");
			}
			if (providerFactory == null) {
				throw new ArgumentNullException("providerFactory");
			}
			ConnectionObject instance = new ConnectionObject ();
			instance.connection = connection;
			instance.providerFactory = providerFactory;
			return instance;
		
		}
Example #12
0
 public SqlDataAccessStrategy(ReportSettings reportSettings, ConnectionObject connectionObject)
 {
     if (reportSettings == null)
     {
         throw new ArgumentNullException("reportSettings");
     }
     this.reportSettings = reportSettings;
     if (connectionObject == null)
     {
         this.connectionObject = ConnectionObjectFactory.BuildConnectionObject(reportSettings.ConnectionString);
     }
     else
     {
         this.connectionObject = connectionObject;
     }
 }
Example #13
0
        public static ConnectionObject CreateInstance(IDbConnection connection,
                                                      DbProviderFactory providerFactory)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (providerFactory == null)
            {
                throw new ArgumentNullException("providerFactory");
            }
            ConnectionObject instance = new ConnectionObject();

            instance.connection      = connection;
            instance.providerFactory = providerFactory;
            return(instance);
        }
Example #14
0
		public static ConnectionObject CreateInstance (string connectionString,
		                                               DbProviderFactory providerFactory)
		{
			if (String.IsNullOrEmpty(connectionString)) {
				throw new ArgumentNullException("connectionString");
			}
			if (providerFactory == null) {
				throw new ArgumentNullException("providerFactory");
			}
			
			IDbConnection con = providerFactory.CreateConnection();
			con.ConnectionString = connectionString;
			ConnectionObject instance = new ConnectionObject ();
			instance.connection = con;
			instance.providerFactory = providerFactory;
			return instance;
		}
Example #15
0
        public static ConnectionObject CreateInstance(string connectionString,
                                                      DbProviderFactory providerFactory)
        {
            if (String.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException("connectionString");
            }
            if (providerFactory == null)
            {
                throw new ArgumentNullException("providerFactory");
            }

            IDbConnection con = providerFactory.CreateConnection();

            con.ConnectionString = connectionString;

            return(ConnectionObject.CreateInstance(con, providerFactory));
        }
		private ReportDataSource(ConnectionObject connectionObject, ReportSettings reportSettings)
		{
			this.connectionObject = connectionObject;
			this.reportSettings = reportSettings;
			
			this.connection = connectionObject.Connection;
			if (this.connection.State == ConnectionState.Open) {
				this.connection.Close();
			}
			if (this.reportSettings.DataModel != GlobalEnums.PushPullModel.PushData) {
				SqlQueryChecker.Check(this.reportSettings.CommandType,this.reportSettings.CommandText);
			}
			this.dataSource = this.FillDataSet().Tables[0];
			CheckDataSource();
			/*
				this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
				                                          reportSettings);
				
				this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
				
			 */
		}
Example #17
0
        public static ConnectionObject PrepareConnectionFromParameters(ReportSettings settings,
                                                                       ReportParameters reportParameters)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            ConnectionObject conObj = null;

            if (reportParameters != null)
            {
                if (reportParameters.ConnectionObject != null)
                {
                    conObj = reportParameters.ConnectionObject;
                }
            }

            if (!String.IsNullOrEmpty(settings.ConnectionString))
            {
                conObj = ConnectionObjectFactory.BuildConnectionObject(settings.ConnectionString);
            }
            return(conObj);
        }
		public ReportParameters(ConnectionObject connectionObject)
		{
			this.connectionObject = connectionObject;
		}
Example #19
0
 public ReportParameters(ConnectionObject connectionObject)
 {
     this.connectionObject = connectionObject;
 }
Example #20
0
		DataSet DatasetFromStoredProcedure()
		{
			this.connectionObject = CreateConnection();
			DataSet dataSet = ResultPanel.CreateDataSet();
			IProcedure procedure = reportStructure.IDatabaseObjectBase as IProcedure;
			
			var paramCollection = CheckParameters(procedure);
			
			
			if (paramCollection.Count > 0) {
				FillParameters(paramCollection);
				reportStructure.SqlQueryParameters.AddRange(paramCollection);
			}
			
			var dataAccess = new SqlDataAccessStrategy(model.ReportSettings,connectionObject);
			dataSet = dataAccess.ReadData();
			dataSet.Tables[0].TableName = procedure.Name;
			
			return dataSet;
		}