public questStatus Update(DbMgrTransaction trans, Quest.Functional.MasterPricing.Filter filter) { // Initialize questStatus status = null; bool bCreateTransaction = trans == null; // Perform update in this transaction. status = update((MasterPricingEntities)trans.DbContext, filter); if (bLogging) { FilterLog filterLog = new FilterLog(); filterLog.Database = ""; filterLog.Tableset = "Tableset.Id=" + filter.TablesetId.ToString(); filterLog.Name = filter.Name == null ? "(null)" : filter.Name; filterLog.Event = "UPDATE"; filterLog.Data = status.ToString(); FilterLogId filterLogId = null; _dbFilterLogsMgr.Create(filterLog, out filterLogId); } if (!questStatusDef.IsSuccess(status)) { RollbackTransaction(trans); return(status); } return(new questStatus(Severity.Success)); }
public questStatus Read(DbMgrTransaction trans, FolderId folderId, out List <Quest.Functional.MasterPricing.Filter> filterList) { // Initialize questStatus status = null; filterList = null; // Perform read List <Quest.Services.Dbio.MasterPricing.Filters> _filtersList = null; status = read((MasterPricingEntities)trans.DbContext, folderId, out _filtersList); if (!questStatusDef.IsSuccess(status)) { return(status); } filterList = new List <Filter>(); foreach (Quest.Services.Dbio.MasterPricing.Filters _filter in _filtersList) { Quest.Functional.MasterPricing.Filter filter = new Quest.Functional.MasterPricing.Filter(); BufferMgr.TransferBuffer(_filter, filter); filterList.Add(filter); } return(new questStatus(Severity.Success)); }
/*---------------------------------------------------------------------------------------------------------------------------------- * Filters *---------------------------------------------------------------------------------------------------------------------------------*/ private questStatus create(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.Filter filter, out FilterId filterId) { // Initialize filterId = null; // Perform create try { Quest.Services.Dbio.MasterPricing.Filters _filters = new Quest.Services.Dbio.MasterPricing.Filters(); BufferMgr.TransferBuffer(filter, _filters); dbContext.Filters.Add(_filters); dbContext.SaveChanges(); if (_filters.Id == 0) { return(new questStatus(Severity.Error, "Quest.Functional.MasterPricing.Filter not created")); } filterId = new FilterId(_filters.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 Read(FilterId filterId, out FilterSQLViewModel filterSQLViewModel) { // Initialize questStatus status = null; filterSQLViewModel = null; // Read filter Quest.Functional.MasterPricing.Filter filter = null; FilterMgr filterMgr = new FilterMgr(this.UserSession); status = filterMgr.GetFilter(filterId, out filter); if (!questStatusDef.IsSuccess(status)) { return(status); } // Transfer model filterSQLViewModel = new FilterSQLViewModel(); BufferMgr.TransferBuffer(filter, filterSQLViewModel); if (string.IsNullOrEmpty(filterSQLViewModel.SQL)) { return(new questStatus(Severity.Warning, "Filter has no SQL")); } return(new questStatus(Severity.Success)); }
/*================================================================================================================================== * Public Methods *=================================================================================================================================*/ public questStatus Create(Quest.Functional.MasterPricing.Filter filter, out FilterId filterId) { // Initialize questStatus status = null; filterId = null; // Data rules. // Create the filter using (MasterPricingEntities dbContext = new MasterPricingEntities()) { status = create(dbContext, filter, out filterId); if (bLogging) { FilterLog filterLog = new FilterLog(); filterLog.Database = ""; filterLog.Tableset = "Tableset.Id=" + filter.TablesetId.ToString(); filterLog.Name = filter.Name == null ? "(null)" : filter.Name; filterLog.Event = "CREATE"; filterLog.Data = status.ToString(); FilterLogId filterLogId = null; _dbFilterLogsMgr.Create(filterLog, out filterLogId); } if (!questStatusDef.IsSuccess(status)) { return(status); } } return(new questStatus(Severity.Success)); }
public questStatus Read(TablesetId tablesetId, out List <Quest.Functional.MasterPricing.Filter> filterList) { // Initialize questStatus status = null; filterList = null; // Perform read using (MasterPricingEntities dbContext = new MasterPricingEntities()) { List <Quest.Services.Dbio.MasterPricing.Filters> _filtersList = null; status = read(dbContext, tablesetId, out _filtersList); if (!questStatusDef.IsSuccess(status)) { return(status); } filterList = new List <Filter>(); foreach (Quest.Services.Dbio.MasterPricing.Filters _filter in _filtersList) { Quest.Functional.MasterPricing.Filter filter = new Quest.Functional.MasterPricing.Filter(); BufferMgr.TransferBuffer(_filter, filter); filterList.Add(filter); } } return(new questStatus(Severity.Success)); }
private questStatus update(MasterPricingEntities dbContext, Quest.Functional.MasterPricing.Filter filter) { // Initialize questStatus status = null; try { // Read the record. FilterId filterId = new FilterId(filter.Id); Quest.Services.Dbio.MasterPricing.Filters _filters = null; status = read(dbContext, filterId, out _filters); if (!questStatusDef.IsSuccess(status)) { return(status); } // Update the record. BufferMgr.TransferBuffer(filter, _filters); 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)); }
public questStatus FormatBootstrapTreeviewNode(Quest.Functional.MasterPricing.Filter filter, out BootstrapTreenodeViewModel bootstrapTreenodeViewModel) { bootstrapTreenodeViewModel = new BootstrapTreenodeViewModel(); bootstrapTreenodeViewModel.Id = filter.Id; bootstrapTreenodeViewModel.type = "filter"; bootstrapTreenodeViewModel.icon = "fa fa-filter padding-right-20"; bootstrapTreenodeViewModel.text = filter.Name; bootstrapTreenodeViewModel.Name = filter.Name; bootstrapTreenodeViewModel.selectable = "true"; return(new questStatus(Severity.Success)); }
public questStatus List(QueryOptions queryOptions, out List <Quest.Functional.MasterPricing.Filter> filterList, out QueryResponse queryResponse) { // Initialize questStatus status = null; filterList = null; queryResponse = null; using (MasterPricingEntities dbContext = new MasterPricingEntities()) { using (DbContextTransaction tx = dbContext.Database.BeginTransaction(IsolationLevel.ReadUncommitted)) { try { PropertyInfo[] dbProperties = typeof(Quest.Services.Dbio.MasterPricing.Filters).GetProperties().ToArray(); int totalRecords = dbContext.Filters.Where(BuildWhereClause(queryOptions, dbProperties)).Count(); List <Quest.Services.Dbio.MasterPricing.Filters> _filtersList = dbContext.Filters.Where(BuildWhereClause(queryOptions, dbProperties)) .OrderBy(BuildSortString(queryOptions.SortColumns)) .Skip(queryOptions.Paging.PageSize * (queryOptions.Paging.PageNumber - 1)) .Take(queryOptions.Paging.PageSize).ToList(); if (_filtersList == null) { return(new questStatus(Severity.Warning)); } filterList = new List <Quest.Functional.MasterPricing.Filter>(); foreach (Quest.Services.Dbio.MasterPricing.Filters _filters in _filtersList) { Quest.Functional.MasterPricing.Filter filter = new Quest.Functional.MasterPricing.Filter(); BufferMgr.TransferBuffer(_filters, filter); filterList.Add(filter); } status = BuildQueryResponse(totalRecords, queryOptions, out queryResponse); if (!questStatusDef.IsSuccess(status)) { return(status); } } 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 Read(DbMgrTransaction trans, string name, out Quest.Functional.MasterPricing.Filter filter) { // Initialize questStatus status = null; filter = null; // Read filter status = _dbFiltersMgr.Read(trans, name, out filter); if (!questStatusDef.IsSuccess(status)) { return(status); } return(new questStatus(Severity.Success)); }
public questStatus Read(DbMgrTransaction trans, string name, out Quest.Functional.MasterPricing.Filter filter) { // Initialize questStatus status = null; filter = null; // Perform read Quest.Services.Dbio.MasterPricing.Filters _filters = null; status = read((MasterPricingEntities)trans.DbContext, name, out _filters); if (!questStatusDef.IsSuccess(status)) { return(status); } filter = new Quest.Functional.MasterPricing.Filter(); BufferMgr.TransferBuffer(_filters, filter); return(new questStatus(Severity.Success)); }
public questStatus Read(FilterId filterId, out Quest.Functional.MasterPricing.Filter filter) { // Initialize questStatus status = null; filter = null; // Perform read using (MasterPricingEntities dbContext = new MasterPricingEntities()) { Quest.Services.Dbio.MasterPricing.Filters _filters = null; status = read(dbContext, filterId, out _filters); if (!questStatusDef.IsSuccess(status)) { return(status); } filter = new Quest.Functional.MasterPricing.Filter(); BufferMgr.TransferBuffer(_filters, filter); } return(new questStatus(Severity.Success)); }
/*================================================================================================================================== * Public Methods *=================================================================================================================================*/ public questStatus Save(FilterPanelViewModel filterPanelViewModel) { // Initialize questStatus status = null; Quest.Functional.MasterPricing.Filter filter = null; FilterId filterId = null; // Validate if (filterPanelViewModel.Editor.TablesetId < BaseId.VALID_ID) { return(new questStatus(Severity.Error, "Invalid Tableset Id")); } if (filterPanelViewModel.Editor.FilterId < BaseId.VALID_ID) { // For headless agents that want to save all-in-one, not via the Filters panel. filter = new Functional.MasterPricing.Filter(); BufferMgr.TransferBuffer(filterPanelViewModel.Editor, filter); filterId = null; FiltersMgr filtersMgr = new FiltersMgr(this.UserSession); status = filtersMgr.Create(filter, out filterId); if (!questStatusDef.IsSuccess(status)) { return(status); } filterPanelViewModel.Editor.Id = filterId.Id; filterPanelViewModel.Editor.FilterId = filterId.Id; } // Read tableset configuration TablesetId tablesetId = new TablesetId(filterPanelViewModel.Editor.TablesetId); TablesetDataManagement tablesetDataManagement = null; TablesetMgr tablesetMgr = new TablesetMgr(this.UserSession); status = tablesetMgr.ReadTablesetDataManagement(tablesetId, out tablesetDataManagement); if (!questStatusDef.IsSuccess(status)) { return(status); } #region Transfer filter entities // // Transfer filter entities // filter = new Functional.MasterPricing.Filter(); filter.TablesetId = filterPanelViewModel.Editor.TablesetId; filter.Id = filterPanelViewModel.Editor.Id; foreach (BootstrapTreenodeViewModel filterEntity in filterPanelViewModel.Entities) { if (filterEntity.type == "table") { FilterTable filterTable = new FilterTable(); filterTable.FilterId = filterPanelViewModel.Editor.Id; filterTable.Schema = filterEntity.Schema; filterTable.Name = filterEntity.Name; filter.FilterTableList.Add(filterTable); } else if (filterEntity.type == "view") { FilterView filterView = new FilterView(); filterView.FilterId = filterPanelViewModel.Editor.Id; filterView.Schema = filterEntity.Schema; filterView.Name = filterEntity.Name; filter.FilterViewList.Add(filterView); } else if (filterEntity.type == "column") { FilterColumn filterColumn = new FilterColumn(); filterColumn.FilterId = filterPanelViewModel.Editor.Id; filterColumn.Name = filterEntity.Name; filterColumn.TablesetEntityId = filterEntity.ParentId; if (filterEntity.parentType == "table") { TablesetTable parentTablesetTable = tablesetDataManagement.TablesetConfiguration.TablesetTables.Find(delegate(TablesetTable tt) { return(tt.Id == filterEntity.ParentId); }); if (parentTablesetTable == null) { return(new questStatus(Severity.Error, String.Format("ERROR: column filter entity \"{0}\" (Id {1}) table parent Id {2} not found.", filterEntity.text, filterEntity.Id, filterEntity.ParentId))); } filterColumn.FilterEntityTypeId = FilterEntityType.Table; // If column table not in filter entities, add it. BootstrapTreenodeViewModel filterColumnTable = filterPanelViewModel.Entities.Find(delegate(BootstrapTreenodeViewModel n) { return(n.type == "table" && n.Id == filterEntity.ParentId); }); if (filterColumnTable == null) { FilterTable filterTable = filter.FilterTableList.Find(delegate(FilterTable t) { return(filterEntity.ParentId == t.TablesetTable.Id); }); if (filterTable == null) { filterTable = new FilterTable(); filterTable.FilterId = filterPanelViewModel.Editor.Id; filterTable.TablesetTable = parentTablesetTable; filterTable.Schema = parentTablesetTable.Schema; filterTable.Name = parentTablesetTable.Name; filter.FilterTableList.Add(filterTable); } } } else if (filterEntity.parentType == "view") { TablesetView parentTablesetView = tablesetDataManagement.TablesetConfiguration.TablesetViews.Find(delegate(TablesetView tv) { return(tv.Id == filterEntity.ParentId); }); if (parentTablesetView == null) { return(new questStatus(Severity.Error, String.Format("ERROR: column filter entity \"{0}\" (Id {1}) view parent Id {2} not found.", filterEntity.text, filterEntity.Id, filterEntity.ParentId))); } filterColumn.FilterEntityTypeId = FilterEntityType.View; // If column view not in filter entities, add it. BootstrapTreenodeViewModel filterColumnView = filterPanelViewModel.Entities.Find(delegate(BootstrapTreenodeViewModel n) { return(n.type == "view" && n.Id == filterEntity.ParentId); }); if (filterColumnView == null) { FilterView filterView = filter.FilterViewList.Find(delegate(FilterView v) { return(filterEntity.ParentId == v.TablesetView.Id); }); if (filterView == null) { filterView = new FilterView(); filterView.FilterId = filterPanelViewModel.Editor.Id; filterView.TablesetView = parentTablesetView; filterView.Schema = parentTablesetView.Schema; filterView.Name = parentTablesetView.Name; filter.FilterViewList.Add(filterView); } } } else { return(new questStatus(Severity.Error, String.Format("ERROR: column filter entity \"{0}\" (Id {1}) unknown parent parent type: {2}", filterEntity.text, filterEntity.Id, filterEntity.ParentId, (filterEntity.parentType == null ? "null" : filterEntity.parentType)))); } filter.FilterColumnList.Add(filterColumn); } else { return(new questStatus(Severity.Error, String.Format("Invalid filter entity type: {0}", filterEntity.type))); } } #endregion #region Transfer filter items // // Transfer filter items // foreach (FilterItemViewModel filterItemViewModel in filterPanelViewModel.Items) { // Filter Item FilterItem filterItem = new FilterItem(); filterItem.FilterId = filterPanelViewModel.Editor.FilterId; if (filterItemViewModel.Entity.type == "table") { filterItem.FilterEntityTypeId = FilterEntityType.Table; } if (filterItemViewModel.Entity.type == "view") { filterItem.FilterEntityTypeId = FilterEntityType.View; } else if (filterItemViewModel.Entity.type == "column") { filterItem.FilterEntityTypeId = FilterEntityType.Column; } filterItem.TablesetColumnId = filterItemViewModel.Entity.Id; filterItem.Label = filterItemViewModel.Label; filterItem.ParameterName = filterItemViewModel.ParameterName; filterItem.bHidden = filterItemViewModel.bHidden; filterItem.bBulkUpdateValueRequired = filterItemViewModel.bBulkUpdateValueRequired; // Joins foreach (FilterItemJoinViewModel filterItemJoinViewModel in filterItemViewModel.Joins) { FilterItemJoin filterItemJoin = new FilterItemJoin(); filterItemJoin.ColumnId = filterItemJoinViewModel.ColumnId; filterItemJoin.JoinType = filterItemJoinViewModel.JoinType; filterItemJoin.Identifier = filterItemJoinViewModel.Identifier; filterItem.JoinList.Add(filterItemJoin); } // Operations foreach (FilterOperationViewModel filterOperationViewModel in filterItemViewModel.Operations) { FilterOperation filterOperation = new FilterOperation(); filterOperation.FilterOperatorId = filterOperationViewModel.Operator; // Values foreach (FilterValueViewModel filterValueViewModel in filterOperationViewModel.Values) { FilterValue filterValue = new FilterValue(); filterValue.Value = filterValueViewModel.Value; filterOperation.ValueList.Add(filterValue); } filterItem.OperationList.Add(filterOperation); } // Lookup if (filterItemViewModel.Lookup.Id >= BaseId.VALID_ID) { filterItem.LookupId = filterItemViewModel.Lookup.Id; } // TypeList if (filterItemViewModel.TypeList.Id >= BaseId.VALID_ID) { filterItem.TypeListId = filterItemViewModel.TypeList.Id; } filter.FilterItemList.Add(filterItem); } #endregion #region Transfer filter procedures // // Transfer filter procedures // foreach (FilterProcedureViewModel filterProcedureViewModel in filterPanelViewModel.Procedures) { if (filterProcedureViewModel.Id > BaseId.INVALID_ID) { FilterProcedure filterProcedure = new FilterProcedure(); BufferMgr.TransferBuffer(filterProcedureViewModel, filterProcedure); filterProcedure.FilterId = filterPanelViewModel.Editor.FilterId; filter.FilterProcedureList.Add(filterProcedure); } } #endregion #region Save filter // // Save filter // filterId = new FilterId(filterPanelViewModel.Editor.FilterId); FilterMgr filterMgr = new FilterMgr(this.UserSession); status = filterMgr.Save(filterId, filter); if (!questStatusDef.IsSuccess(status)) { if (questStatusDef.IsWarning(status)) { return(status); } return(new questStatus(status.Severity, String.Format("Error saving filter items: {0}", status.Message))); } #endregion #region Return procedure parameters // // Return procedure parameters // // Get filter database Quest.Functional.MasterPricing.Database database = null; filterMgr.GetFilterDatabase(filterId, out database); if (filter.FilterProcedureList.Count > 0) { foreach (FilterProcedureViewModel filterProcedureViewModel in filterPanelViewModel.Procedures) { if ((filterProcedureViewModel.Id == BaseId.INVALID_ID) || (string.IsNullOrEmpty(filterProcedureViewModel.Name))) { continue; } // Get procedure parameters List <Quest.Functional.MasterPricing.FilterProcedureParameter> filterProcedureParameterList = null; status = filterMgr.GetStoredProdecureParameters(database, filterProcedureViewModel.Name, out filterProcedureParameterList); if (!questStatusDef.IsSuccess(status)) { return(status); } foreach (FilterProcedureParameter filterProcedureParameter in filterProcedureParameterList) { FilterProcedureParameterViewModel filterProcedureParameterViewModel = new FilterProcedureParameterViewModel(); BufferMgr.TransferBuffer(filterProcedureParameter, filterProcedureParameterViewModel, true); filterProcedureParameterViewModel.Precision = filterProcedureParameter.Precision[0]; filterProcedureParameterViewModel.Scale = filterProcedureParameter.Scale[0]; filterProcedureViewModel.Parameters.Add(filterProcedureParameterViewModel); } } } #endregion // Return warning if no items in filter. if (filter.FilterItemList.Count == 0) { return(new questStatus(Severity.Warning, "Filter successfully saved, but has no items")); } return(new questStatus(Severity.Success)); }
//---------------------------------------------------------------------------------------------------------------------------------- // Transfers //---------------------------------------------------------------------------------------------------------------------------------- public questStatus MergeFilterEditorViewModel(FilterRunViewModel filterRunViewModel, Quest.Functional.MasterPricing.Filter filterFROMDatabase, out Quest.Functional.MasterPricing.Filter filter) { // Initialize filter = filterFROMDatabase; // Copy over general stuff. filter = new Functional.MasterPricing.Filter(); filter.Id = filterFROMDatabase.Id; filter.TablesetId = filterFROMDatabase.TablesetId; filter.Name = filterFROMDatabase.Name; filter.Summary = filterFROMDatabase.Summary; filter.FilterTableList = filterFROMDatabase.FilterTableList; filter.FilterViewList = filterFROMDatabase.FilterViewList; filter.FilterColumnList = filterFROMDatabase.FilterColumnList; filter.FilterItemList = new List <FilterItem>(); // Whatever items are sent in is what we're running. filter.FilterProcedureList = filterFROMDatabase.FilterProcedureList; // // Filter Items - *accumualte* given filter items to the database operations. // if (filterRunViewModel.Items == null) { filter.FilterItemList = filterFROMDatabase.FilterItemList; } else { foreach (FilterItemViewModel filterItemViewModel in filterRunViewModel.Items) { // Get the FilterItem from the database copy of the filter. FilterItem filterItem = filterFROMDatabase.FilterItemList.Find(delegate(FilterItem fi) { return(filterItemViewModel.Name == fi.FilterColumn.Name && filterItemViewModel.ParentEntity.type == fi.FilterColumn.ParentEntityType.type && filterItemViewModel.ParentEntity.Schema == fi.FilterColumn.ParentEntityType.Schema && filterItemViewModel.ParentEntity.Name == fi.FilterColumn.ParentEntityType.Name); }); if (filterItem == null) { return(new questStatus(Severity.Error, String.Format("ERROR: Item {0} [{1}].[{2}] not found in filter", filterItemViewModel.ParentEntity.type, filterItemViewModel.ParentEntity.Schema, filterItemViewModel.ParentEntity.Name))); } // Accumulate any operations given to the operations already on the filter. foreach (FilterOperationViewModel filterOperationViewModel in filterItemViewModel.Operations) { FilterOperation filterOperation = new FilterOperation(); filterOperation.FilterOperatorId = filterOperationViewModel.Operator; foreach (FilterValueViewModel filterValueViewModel in filterOperationViewModel.Values) { FilterValue filterValue = new FilterValue(); filterValue.Value = filterValueViewModel.Value; filterOperation.ValueList.Add(filterValue); } filterItem.OperationList.Add(filterOperation); } // Add this item to the filter. filter.FilterItemList.Add(filterItem); } } return(new questStatus(Severity.Success)); }
public questStatus Read(FilterId filterId, out FilterEditorViewModel filterEditorViewModel) { // Initialize questStatus status = null; filterEditorViewModel = null; // Read filter Quest.Functional.MasterPricing.Filter filter = null; FilterMgr filterMgr = new FilterMgr(this.UserSession); status = filterMgr.GetFilter(filterId, out filter); if (!questStatusDef.IsSuccess(status)) { return(status); } // Transfer model filterEditorViewModel = new FilterEditorViewModel(); BufferMgr.TransferBuffer(filter, filterEditorViewModel); foreach (FilterTable filterTable in filter.FilterTableList) { BootstrapTreenodeViewModel bootstrapTreenodeViewModel = null; status = FormatBootstrapTreeviewNode(filterTable, out bootstrapTreenodeViewModel); if (!questStatusDef.IsSuccess(status)) { return(status); } filterEditorViewModel.Entities.Add(bootstrapTreenodeViewModel); } foreach (FilterView filterView in filter.FilterViewList) { BootstrapTreenodeViewModel bootstrapTreenodeViewModel = null; status = FormatBootstrapTreeviewNode(filterView, out bootstrapTreenodeViewModel); if (!questStatusDef.IsSuccess(status)) { return(status); } filterEditorViewModel.Entities.Add(bootstrapTreenodeViewModel); } foreach (FilterItem filterItem in filter.FilterItemList) { FilterItemViewModel filterItemViewModel = new FilterItemViewModel(); filterItemViewModel.Id = filterItem.Id; ////filterItemViewModel.Name = filterItem.TablesetColumn.Name; filterItemViewModel.Name = filterItem.FilterColumn.TablesetColumn.Column.Name; filterItemViewModel.Label = filterItem.Label; filterItemViewModel.ParameterName = filterItem.ParameterName; filterItemViewModel.bHidden = filterItem.bHidden; filterItemViewModel.bBulkUpdateValueRequired = filterItem.bBulkUpdateValueRequired; filterItemViewModel.Entity.type = "column"; // TODO: ALL THAT'S SUPPORTED RIGHT NOW. filterItemViewModel.Entity.Schema = null; filterItemViewModel.Entity.Name = filterItem.FilterColumn.TablesetColumn.Column.Name; BufferMgr.TransferBuffer(filterItem.FilterColumn.TablesetColumn.Column, filterItemViewModel.Entity.Column); filterItemViewModel.ParentEntity.type = filterItem.FilterColumn.ParentEntityType.type; filterItemViewModel.ParentEntity.Schema = filterItem.FilterColumn.ParentEntityType.Schema; filterItemViewModel.ParentEntity.Name = filterItem.FilterColumn.ParentEntityType.Name; // Joins foreach (FilterItemJoin filterItemJoin in filterItem.JoinList) { FilterItemJoinViewModel filterItemJoinViewModel = new FilterItemJoinViewModel(); BufferMgr.TransferBuffer(filterItemJoin, filterItemJoinViewModel); filterItemJoinViewModel.Identifier = '[' + filterItemJoin.TargetSchema + "].[" + filterItemJoin.TargetEntityName + "].[" + filterItemJoin.TargetColumnName + "]"; filterItemViewModel.Joins.Add(filterItemJoinViewModel); } // Operations foreach (FilterOperation filterOperation in filterItem.OperationList) { FilterOperationViewModel filterOperationViewModel = new FilterOperationViewModel(); filterOperationViewModel.Id = filterOperation.Id; filterOperationViewModel.Operator = filterOperation.FilterOperatorId; // Views foreach (FilterValue filterValue in filterOperation.ValueList) { FilterValueViewModel filterValueViewModel = new FilterValueViewModel(); filterValueViewModel.Id = filterValue.Id; filterValueViewModel.Value = filterValue.Value; filterOperationViewModel.Values.Add(filterValueViewModel); } filterItemViewModel.Operations.Add(filterOperationViewModel); } // Lookup if (filterItem.LookupId.HasValue) { FilterItemLookupViewModel filterItemLookupViewModel = new FilterItemLookupViewModel(); filterItemLookupViewModel.Id = filterItem.Lookup.Id; filterItemLookupViewModel.Name = filterItem.Lookup.Name; filterItemViewModel.Lookup = filterItemLookupViewModel; } // TypeList if (filterItem.TypeListId.HasValue) { FilterItemTypeListViewModel filterItemTypeListViewModel = new FilterItemTypeListViewModel(); filterItemTypeListViewModel.Id = filterItem.TypeList.Id; filterItemTypeListViewModel.Name = filterItem.TypeList.Name; filterItemViewModel.TypeList = filterItemTypeListViewModel; } filterEditorViewModel.Items.Add(filterItemViewModel); } foreach (FilterProcedure filterProcedure in filter.FilterProcedureList) { FilterProcedureViewModel filterProcedureViewModel = new FilterProcedureViewModel(); BufferMgr.TransferBuffer(filterProcedure, filterProcedureViewModel); foreach (FilterProcedureParameter filterProcedureParameter in filterProcedure.ParameterList) { FilterProcedureParameterViewModel filterProcedureParameterViewModel = new FilterProcedureParameterViewModel(); BufferMgr.TransferBuffer(filterProcedureParameter, filterProcedureParameterViewModel, true); filterProcedureParameterViewModel.Precision = filterProcedureParameter.Precision[0]; filterProcedureParameterViewModel.Scale = filterProcedureParameter.Scale[0]; filterProcedureViewModel.Parameters.Add(filterProcedureParameterViewModel); } filterEditorViewModel.Procedures.Add(filterProcedureViewModel); } return(new questStatus(Severity.Success)); }
private questStatus getTablesetColumn(Quest.Functional.MasterPricing.Filter filter) { return(new questStatus(Severity.Success)); }
public questStatus Run(FilterRunViewModel filterRunViewModel, out FilterRunViewModel filterRunResultsViewModel, out ResultsSet resultsSet) { // Initialize questStatus status = null; filterRunResultsViewModel = null; resultsSet = null; // NOTE: THIS IS FOR RUNNING A FILTER THAT IS --NOT-- IN THE DATABASE. HOWEVER IT IS *BASED* ON A FILTER IN THE DATABASE, THUS A VALID FILTER ID MUST BE GIVEN. FilterMgr filterMgr = new FilterMgr(this.UserSession); // Get the filter FilterId filterId = new FilterId(filterRunViewModel.FilterId); Quest.Functional.MasterPricing.Filter filterFROMDatabase = null; status = filterMgr.GetFilter(filterId, out filterFROMDatabase); if (!questStatusDef.IsSuccess(status)) { return(status); } // Merge view model into filter from database. Quest.Functional.MasterPricing.Filter filter = null; status = MergeFilterEditorViewModel(filterRunViewModel, filterFROMDatabase, out filter); if (!questStatusDef.IsSuccess(status)) { return(status); } // Verify the filter status = filterMgr.Verify(filter); if (!questStatusDef.IsSuccess(status)) { return(status); } // Generate filter SQL Quest.Functional.MasterPricing.Filter filterWithSQL = null; status = filterMgr.GenerateFilterSQL(filter, out filterWithSQL); if (!questStatusDef.IsSuccess(status)) { return(status); } // Run the filter RunFilterRequest runFilterRequest = new RunFilterRequest(); // Filter Id doesn't matter, non-DB filter run request. runFilterRequest.RowLimit = filterRunViewModel._ResultsOptions.RowLimit; runFilterRequest.ColLimit = filterRunViewModel._ResultsOptions.ColLimit; status = filterMgr.Run(runFilterRequest, filterWithSQL, out resultsSet); if (!questStatusDef.IsSuccess(status)) { return(status); } // Transfer results to view model. status = TransferResults(resultsSet, out filterRunResultsViewModel); if (!questStatusDef.IsSuccess(status)) { return(status); } if (string.IsNullOrEmpty(filterRunViewModel.Name)) { filterRunResultsViewModel.Name = filterFROMDatabase.Name; } return(new questStatus(Severity.Success)); }