Exemple #1
0
        public questStatus Read(DbMgrTransaction trans, FilterOperationId filterOperationId, out List <Quest.Functional.MasterPricing.FilterValue> filterValueList)
        {
            // Initialize
            questStatus status = null;

            filterValueList = null;


            // Perform read
            List <Quest.Services.Dbio.MasterPricing.FilterValues> _filterValuesList = null;

            status = read((MasterPricingEntities)trans.DbContext, filterOperationId, out _filterValuesList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            filterValueList = new List <FilterValue>();
            foreach (Quest.Services.Dbio.MasterPricing.FilterValues _filterValue in _filterValuesList)
            {
                Quest.Functional.MasterPricing.FilterValue filterValue = new Quest.Functional.MasterPricing.FilterValue();
                BufferMgr.TransferBuffer(_filterValue, filterValue);
                filterValueList.Add(filterValue);
            }
            return(new questStatus(Severity.Success));
        }
        private questStatus update(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.FilterOperation filterOperation)
        {
            // Initialize
            questStatus status = null;


            try
            {
                // Read the record.
                FilterOperationId filterOperationId = new FilterOperationId(filterOperation.Id);
                Quest.Services.Dbio.MasterPricing.FilterOperations _filterOperations = null;
                status = read(dbContext, filterOperationId, out _filterOperations);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Update the record.
                BufferMgr.TransferBuffer(filterOperation, _filterOperations);
                dbContext.SaveChanges();
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
        /*----------------------------------------------------------------------------------------------------------------------------------
        * FilterColumns
        *---------------------------------------------------------------------------------------------------------------------------------*/
        private questStatus create(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.FilterOperation filterOperation, out FilterOperationId filterOperationId)
        {
            // Initialize
            filterOperationId = null;


            // Perform create
            try
            {
                Quest.Services.Dbio.MasterPricing.FilterOperations _filterOperations = new Quest.Services.Dbio.MasterPricing.FilterOperations();
                BufferMgr.TransferBuffer(filterOperation, _filterOperations);
                dbContext.FilterOperations.Add(_filterOperations);
                dbContext.SaveChanges();
                if (_filterOperations.Id == 0)
                {
                    return(new questStatus(Severity.Error, "Quest.Functional.MasterPricing.FilterOperation not created"));
                }
                filterOperationId = new FilterOperationId(_filterOperations.Id);
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
Exemple #4
0
        public questStatus Delete(DbMgrTransaction trans, FilterOperationId filterOperationId)
        {
            // Initialize
            questStatus status = null;


            // Delete filterOperation
            status = _dbFilterOperationsMgr.Delete(trans, filterOperationId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Exemple #5
0
        public questStatus Delete(FilterOperationId filterOperationId)
        {
            // Initialize
            questStatus status = null;


            // Delete all tableTables in this table.
            status = _dbFilterValuesMgr.Delete(filterOperationId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Exemple #6
0
 private questStatus delete(MasterPricingEntities dbContext, FilterOperationId filterOperationId)
 {
     try
     {
         dbContext.FilterValues.RemoveRange(dbContext.FilterValues.Where(r => r.FilterOperationId == filterOperationId.Id));
         dbContext.SaveChanges();
     }
     catch (System.Exception ex)
     {
         return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                              this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                              ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
     }
     return(new questStatus(Severity.Success));
 }
Exemple #7
0
        public questStatus Delete(DbMgrTransaction trans, FilterOperationId filterOperationId)
        {
            // Initialize
            questStatus status = null;


            // Perform delete in this transaction.
            status = delete((MasterPricingEntities)trans.DbContext, filterOperationId);
            if (!questStatusDef.IsSuccess(status))
            {
                RollbackTransaction(trans);
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Exemple #8
0
        /*==================================================================================================================================
        * Properties
        *=================================================================================================================================*/
        #endregion


        #region Public Methods

        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Create(FilterOperation filterOperation, out FilterOperationId filterOperationId)
        {
            // Initialize
            questStatus status = null;

            filterOperationId = null;


            // Create filterOperation
            status = _dbFilterOperationsMgr.Create(filterOperation, out filterOperationId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Exemple #9
0
        public questStatus Read(DbMgrTransaction trans, FilterOperationId filterOperationId, out FilterOperation filterOperation)
        {
            // Initialize
            questStatus status = null;

            filterOperation = null;


            // Read filterOperation
            status = _dbFilterOperationsMgr.Read(trans, filterOperationId, out filterOperation);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Exemple #10
0
        public questStatus Read(FilterOperationId filterOperationId, out List <FilterValue> filterValueList)
        {
            // Initialize
            questStatus status = null;

            filterValueList = null;


            // Read filterValue
            status = _dbFilterValuesMgr.Read(filterOperationId, out filterValueList);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
Exemple #11
0
        public questStatus Delete(FilterOperationId filterOperationId)
        {
            // Initialize
            questStatus status = null;


            // Perform delete.
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = delete(dbContext, filterOperationId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Read(DbMgrTransaction trans, FilterOperationId filterOperationId, out Quest.Functional.MasterPricing.FilterOperation filterOperation)
        {
            // Initialize
            questStatus status = null;

            filterOperation = null;


            // Perform read
            Quest.Services.Dbio.MasterPricing.FilterOperations _filterOperations = null;
            status = read((MasterPricingEntities)trans.DbContext, filterOperationId, out _filterOperations);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            filterOperation = new Quest.Functional.MasterPricing.FilterOperation();
            BufferMgr.TransferBuffer(_filterOperations, filterOperation);

            return(new questStatus(Severity.Success));
        }
Exemple #13
0
        private questStatus read(MasterPricingEntities dbContext, FilterOperationId filterOperationId, out List <Quest.Services.Dbio.MasterPricing.FilterValues> filterValueList)
        {
            // Initialize
            filterValueList = null;


            try
            {
                filterValueList = dbContext.FilterValues.Where(r => r.FilterOperationId == filterOperationId.Id).ToList();
                if (filterValueList == null)
                {
                    return(new questStatus(Severity.Error, String.Format("ERROR: {0}.{1}: {2}",
                                                                         this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                         String.Format("FilterOperationId {0} not found", filterOperationId.Id))));
                }
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Save(DbMgrTransaction trans, FilterId filterId, Filter filter)
        {
            // Initialize
            questStatus status    = null;
            Mgr         mgr       = new Mgr(this.UserSession);
            ColumnsMgr  columnMgr = new ColumnsMgr(this.UserSession);


            try
            {
                // Validate filter
                status = Verify(filterId, filter);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }


                // Remove filter entities, items and values.  Also, tables and columns.
                status = _dbFilterMgr.Clear(trans, filterId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }

                // Save filter tables
                FilterTablesMgr filterTablesMgr = new FilterTablesMgr(this.UserSession);
                foreach (FilterTable filterTable in filter.FilterTableList)
                {
                    filterTable.FilterId = filter.Id;
                    FilterTableId filterTableId = null;
                    status = filterTablesMgr.Create(trans, filterTable, out filterTableId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    filterTable.Id = filterTableId.Id;
                }

                // Save filter views
                FilterViewsMgr filterViewsMgr = new FilterViewsMgr(this.UserSession);
                foreach (FilterView _filterView in filter.FilterViewList)
                {
                    _filterView.FilterId = filter.Id;
                    FilterViewId filterViewId = null;
                    status = filterViewsMgr.Create(trans, _filterView, out filterViewId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    _filterView.Id = filterViewId.Id;
                }

                // Save filter columns
                DbFilterMgr      dbFilterMgr      = new DbFilterMgr(this.UserSession);
                FilterColumnsMgr filterColumnsMgr = new FilterColumnsMgr(this.UserSession);
                foreach (FilterColumn filterColumn in filter.FilterColumnList)
                {
                    if (filterColumn.FilterEntityId < BaseId.VALID_ID)
                    {
                        // Get the FilterTable or FilterView Id.
                        // This is a klugie.  Gotta rework DataManager panel first, though.  No time to do that.
                        if (filterColumn.FilterEntityTypeId == FilterEntityType.Table)
                        {
                            TablesetTable tablesetTable = null;
                            status = dbFilterMgr.GetTablesetTable(filterColumn, out tablesetTable);
                            if (!questStatusDef.IsSuccess(status))
                            {
                                return(status);
                            }
                            FilterTable filterTable = filter.FilterTableList.Find(delegate(FilterTable t) { return(t.Schema == tablesetTable.Schema && t.Name == tablesetTable.Name); });
                            if (filterTable == null)
                            {
                                return(new questStatus(Severity.Error, String.Format("ERROR: FilterTable not found for TableSetTable Schema:{0} Name:{1}",
                                                                                     tablesetTable.Schema, tablesetTable.Name)));
                            }
                            filterColumn.FilterEntityId = filterTable.Id;
                        }
                        else if (filterColumn.FilterEntityTypeId == FilterEntityType.View)
                        {
                            TablesetView tablesetView = null;
                            status = dbFilterMgr.GetTablesetView(filterColumn, out tablesetView);
                            if (!questStatusDef.IsSuccess(status))
                            {
                                return(status);
                            }
                            FilterView filterView = filter.FilterViewList.Find(delegate(FilterView v) { return(v.Schema == tablesetView.Schema && v.Name == tablesetView.Name); });
                            if (filterView == null)
                            {
                                return(new questStatus(Severity.Error, String.Format("ERROR: FilterView not found for TableSetTable Schema:{0} Name:{1}",
                                                                                     tablesetView.Schema, tablesetView.Name)));
                            }
                            filterColumn.FilterEntityId = filterView.Id;
                        }
                        else
                        {
                            return(new questStatus(Severity.Error, String.Format("ERROR: FilterColumn FilterEntityTypeId {0} not supported.  FilterColumn {1}",
                                                                                 filterColumn.FilterEntityTypeId, filterColumn.Id)));
                        }
                    }

                    // Save
                    FilterColumnId filterColumnId = null;
                    status = filterColumnsMgr.Create(trans, filterColumn, out filterColumnId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    filterColumn.Id = filterColumnId.Id;
                }


                // Save filter items.
                FilterItemsMgr      filterItemsMgr      = new FilterItemsMgr(this.UserSession);
                FilterItemJoinsMgr  filterItemJoinsMgr  = new FilterItemJoinsMgr(this.UserSession);
                FilterOperationsMgr filterOperationsMgr = new FilterOperationsMgr(this.UserSession);
                FilterValuesMgr     filterValuesMgr     = new FilterValuesMgr(this.UserSession);
                foreach (FilterItem filterItem in filter.FilterItemList)
                {
                    FilterColumn filterColumn = null;

                    // Get filterItem FilterEntityId
                    if (filterItem.FilterEntityId < BaseId.VALID_ID)
                    {
                        status = dbFilterMgr.GetFilterColumn(filter, filterItem, out filterColumn);
                        if (!questStatusDef.IsSuccess(status))
                        {
                            return(status);
                        }
                        filterItem.FilterEntityId = filterColumn.Id;
                        filterItem.FilterColumn   = filterColumn;      // helps with bookkeeping further down.
                    }

                    // Save FilterItem
                    FilterItemId filterItemId = null;
                    status = filterItemsMgr.Create(trans, filterItem, out filterItemId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                    filterItem.Id = filterItemId.Id;


                    //  Save filter item joins
                    foreach (FilterItemJoin filterItemJoin in filterItem.JoinList)
                    {
                        filterItemJoin.FilterItemId = filterItemId.Id;


                        if (string.IsNullOrEmpty(filterItemJoin.SourceSchema) || string.IsNullOrEmpty(filterItemJoin.SourceEntityName) || string.IsNullOrEmpty(filterItemJoin.SourceColumnName))
                        {
                            // Get join target type (Table or View)
                            TablesetColumnId tablesetColumnId = new TablesetColumnId(filterItemJoin.ColumnId);
                            TablesetTable    tablesetTable    = null;
                            TablesetView     tablesetView     = null;
                            status = getJoinTarget(tablesetColumnId, out tablesetTable, out tablesetView);
                            if (!questStatusDef.IsSuccess(status))
                            {
                                return(status);
                            }
                            filterItemJoin.TargetEntityTypeId = tablesetTable == null ? FilterEntityType.View : FilterEntityType.Table;

                            // Get target identifier parts.
                            string targetSchema     = null;
                            string targetEntityName = null;
                            string targetColumnName = null;
                            SQLIdentifier.ParseThreePartIdentifier(filterItemJoin.Identifier, out targetSchema, out targetEntityName, out targetColumnName);
                            filterItemJoin.TargetSchema     = targetSchema;
                            filterItemJoin.TargetEntityName = targetEntityName;
                            filterItemJoin.TargetColumnName = targetColumnName;


                            // Get source identifier parts.
                            string sourceSchema     = null;
                            string sourceEntityName = null;
                            string sourceColumnName = null;
                            if (filterColumn.FilterEntityTypeId == FilterEntityType.Table)
                            {
                                FilterTable filterTable = filter.FilterTableList.Find(delegate(FilterTable t) { return(filterColumn.FilterEntityId == t.Id); });
                                if (filterTable == null)
                                {
                                    return(new questStatus(Severity.Error, String.Format("ERROR: building Join on {0}, FilterTable {1} not found",
                                                                                         filterItemJoin.Identifier, filterColumn.FilterEntityId)));
                                }
                                sourceSchema     = filterTable.Schema;
                                sourceEntityName = filterTable.Name;
                            }
                            else if (filterColumn.FilterEntityTypeId == FilterEntityType.View)
                            {
                                FilterView filterView = filter.FilterViewList.Find(delegate(FilterView v) { return(filterColumn.FilterEntityId == v.Id); });
                                if (filterView == null)
                                {
                                    return(new questStatus(Severity.Error, String.Format("ERROR: building Join on {0}, FilterView {1} not found",
                                                                                         filterItemJoin.Identifier, filterColumn.FilterEntityId)));
                                }
                                sourceSchema     = filterView.Schema;
                                sourceEntityName = filterView.Name;
                            }
                            sourceColumnName                = filterColumn.Name;
                            filterItemJoin.SourceSchema     = sourceSchema;
                            filterItemJoin.SourceEntityName = sourceEntityName;
                            filterItemJoin.SourceColumnName = sourceColumnName;
                        }

                        // Create FilterItemJoin
                        FilterItemJoinId filterItemJoinId = null;
                        status = filterItemJoinsMgr.Create(trans, filterItemJoin, out filterItemJoinId);
                        if (!questStatusDef.IsSuccess(status))
                        {
                            return(status);
                        }
                    }

                    // Save filter operations
                    foreach (FilterOperation filterOperation in filterItem.OperationList)
                    {
                        filterOperation.FilterItemId = filterItem.Id;

                        FilterOperationId filterOperationId = null;
                        status = filterOperationsMgr.Create(trans, filterOperation, out filterOperationId);
                        if (!questStatusDef.IsSuccess(status))
                        {
                            return(status);
                        }

                        // Save filter values
                        foreach (FilterValue filterValue in filterOperation.ValueList)
                        {
                            filterValue.FilterOperationId = filterOperationId.Id;
                            FilterValueId filterValueId = null;
                            status = filterValuesMgr.Create(trans, filterValue, out filterValueId);
                            if (!questStatusDef.IsSuccess(status))
                            {
                                return(status);
                            }
                        }
                    }
                }

                // Save filter procedures
                //     Get the filter's database.
                Quest.Functional.MasterPricing.Database database = null;
                status = GetFilterDatabase(filterId, out database);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
                // NOTE: business rules reads in procedure parameters and writes them.
                FilterProceduresMgr filterProceduresMgr = new FilterProceduresMgr(this.UserSession);
                foreach (FilterProcedure filterProcedure in filter.FilterProcedureList)
                {
                    if (string.IsNullOrEmpty(filterProcedure.Name))
                    {
                        continue;
                    }
                    filterProcedure.FilterId = filter.Id;
                    FilterProcedureId filterProcedureId = null;
                    status = filterProceduresMgr.Create(trans, database, filterProcedure, out filterProcedureId);
                    if (!questStatusDef.IsSuccess(status))
                    {
                        return(status);
                    }
                }

                // NOTE: YOU STILL HAVE TO UPDATE THE FILTER'S SQL.  BUT, CAN'T HERE, B/C YOU'RE IN A TRANSACTION.
                // TODO: REFACTOR SO YOU CAN, BUT GOTTA GET A PARAMETERS MAKE-REQUIRED UPDATE OUT THERE FIRST.
            }
            catch (System.Exception ex)
            {
                return(new questStatus(Severity.Fatal, String.Format("EXCEPTION: {0}.{1}: {2}",
                                                                     this.GetType().Name, MethodBase.GetCurrentMethod().Name,
                                                                     ex.InnerException != null ? ex.InnerException.Message : ex.Message)));
            }
            return(new questStatus(Severity.Success));
        }
        public questStatus Create(DbMgrTransaction trans, Quest.Functional.MasterPricing.FilterOperation filterOperation, out FilterOperationId filterOperationId)
        {
            // Initialize
            questStatus status = null;

            filterOperationId = null;


            // Data rules.


            // Create the filterOperation in this transaction.
            status = create((MasterPricingEntities)trans.DbContext, filterOperation, out filterOperationId);
            if (!questStatusDef.IsSuccess(status))
            {
                return(status);
            }
            return(new questStatus(Severity.Success));
        }
        /*==================================================================================================================================
        * Properties
        *=================================================================================================================================*/
        #endregion


        #region Public Methods

        /*==================================================================================================================================
        * Public Methods
        *=================================================================================================================================*/
        public questStatus Create(Quest.Functional.MasterPricing.FilterOperation filterOperation, out FilterOperationId filterOperationId)
        {
            // Initialize
            questStatus status = null;

            filterOperationId = null;


            // Data rules.


            // Create the filterOperation
            using (MasterPricingEntities dbContext = new MasterPricingEntities())
            {
                status = create(dbContext, filterOperation, out filterOperationId);
                if (!questStatusDef.IsSuccess(status))
                {
                    return(status);
                }
            }
            return(new questStatus(Severity.Success));
        }