public void CopyPropToNewPropRow(CswNbtMetaDataNodeTypeProp NewProp) //DataRow NewPropRow ) { CswTableSelect MappingSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswTableSelect("PropCollDataRelational_mapping", "jct_dd_ntp"); DataTable MappingTable = MappingSelect.getTable(); foreach (DataColumn Column in _ObjectClassPropRow.Table.Columns) { string ColumnName = Column.ColumnName; if (ColumnName != "display_rowadd" && ColumnName != "display_coladd" && ColumnName != "setvalonadd" && ColumnName != "defaultvalueid") { if (false == _ObjectClassPropRow.IsNull(ColumnName)) { if (_CswNbtMetaDataResources.CswNbtResources.DataDictionary.isColumnDefined("nodetype_props", Column.ColumnName)) { _CswNbtMetaDataResources.CswNbtResources.DataDictionary.setCurrentColumn("nodetype_props", Column.ColumnName); DataRow MappingRow = MappingTable.Rows.Cast <DataRow>() .FirstOrDefault(r => NewProp.DesignNode.NodeType.getNodeTypePropIds().Contains(CswConvert.ToInt32(r["nodetypepropid"])) && CswConvert.ToInt32(r["datadictionaryid"]) == _CswNbtMetaDataResources.CswNbtResources.DataDictionary.TableColId); if (null != MappingRow) { NewProp.DesignNode.Node.Properties[CswConvert.ToInt32(MappingRow["nodetypepropid"])].SetSubFieldValue((CswEnumNbtSubFieldName)MappingRow["subfieldname"].ToString(), _ObjectClassPropRow[ColumnName]); } } // if( _CswNbtMetaDataResources.CswNbtResources.DataDictionary.isColumnDefined( "nodetype_props", Column.ColumnName ) ) } // if( false == _ObjectClassPropRow.IsNull( ColumnName ) ) } // if( ColumnName != "displayrowadd" && ... ) } // foreach( DataColumn Column in _ObjectClassPropRow.Table.Columns ) } // CopyPropToNewPropRow()
public CswNbtView restoreView(CswNbtViewId NbtViewId) { CswNbtView ReturnVal = null; CswTableSelect ViewsTableSelect = _CswNbtResources.makeCswTableSelect("restoreView_select", "node_views"); if (NbtViewId.isSet()) { Int32 ViewId = NbtViewId.get(); if (Int32.MinValue != ViewId) { DataTable ViewTable = ViewsTableSelect.getTable("nodeviewid", ViewId); if (ViewTable.Rows.Count > 0) { string ViewAsString = ViewTable.Rows[0]["viewxml"].ToString(); ReturnVal = restoreView(ViewAsString); ReturnVal.ViewId = NbtViewId; ReturnVal.Visibility = (CswEnumNbtViewVisibility)ViewTable.Rows[0]["visibility"].ToString(); ReturnVal.VisibilityRoleId = new CswPrimaryKey("nodes", CswConvert.ToInt32(ViewTable.Rows[0]["roleid"])); ReturnVal.VisibilityUserId = new CswPrimaryKey("nodes", CswConvert.ToInt32(ViewTable.Rows[0]["userid"])); ReturnVal.Category = ViewTable.Rows[0]["category"].ToString(); ReturnVal.ViewName = ViewTable.Rows[0]["viewname"].ToString(); ReturnVal.IsDemo = CswConvert.ToBoolean(ViewTable.Rows[0]["isdemo"].ToString()); ReturnVal.IsSystem = CswConvert.ToBoolean(ViewTable.Rows[0]["issystem"].ToString()); } } } else { throw new CswDniException(CswEnumErrorType.Error, "Attempt to restore view failed.", "CswNbtViewSelect was handed an invalid NbtViewId in restoreView()."); } return(ReturnVal); }//restoreView()
public CswPrimaryKey getNodeIdByRelationalId(CswPrimaryKey RelationalId) { CswPrimaryKey ret = null; if (_NodeIdByRelationalIdDict.ContainsKey(RelationalId)) { ret = _NodeIdByRelationalIdDict[RelationalId]; } else { CswTableSelect NodesSelect = _CswNbtResources.makeCswTableSelect("getNodeByRelationalId", "nodes"); DataTable NodesTable = NodesSelect.getTable(new CswCommaDelimitedString() { "nodeid", "relationalid" }, "where relationaltable = '" + RelationalId.TableName + "'"); //" and relationalid='" + RelationalId.PrimaryKey.ToString() + "'" ); foreach (DataRow row in NodesTable.Rows) { CswPrimaryKey thisRelId = new CswPrimaryKey(RelationalId.TableName, CswConvert.ToInt32(row["relationalid"])); CswPrimaryKey thisNodeId = new CswPrimaryKey("nodes", CswConvert.ToInt32(row["nodeid"])); if (false == _NodeIdByRelationalIdDict.ContainsKey(thisRelId)) { _NodeIdByRelationalIdDict.Add(thisRelId, thisNodeId); } if (thisRelId == RelationalId) { ret = thisNodeId; } } } return(ret); } // getNodeIdByRelationalId()
} // getPropsNotInLayout() public Collection <CswNbtObjClassDesignNodeTypeProp> getPropNodesInLayout(Int32 NodeTypeId, Int32 TabId, CswEnumNbtLayoutType LayoutType, bool NumberedOnly = false, CswDateTime Date = null) { Collection <CswNbtObjClassDesignNodeTypeProp> ret = new Collection <CswNbtObjClassDesignNodeTypeProp>(); CswTableSelect LayoutSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswTableSelect("getPropNodesInLayout_select", "nodetype_layout"); string WhereClause = "where nodetypeid = " + NodeTypeId.ToString() + " and nodetypetabsetid = " + TabId.ToString() + " and layouttype = '" + LayoutType.ToString() + "'"; if (NumberedOnly) { WhereClause += " and nodetypepropid in (select nodetypepropid " + " from nodetype_props " + " where " + CswEnumNbtNodeTypePropAttributes.usenumbering + " = '" + CswConvert.ToDbVal(true) + "')"; } Collection <OrderByClause> orderBy = new Collection <OrderByClause>() { new OrderByClause("display_row", CswEnumOrderByType.Ascending), new OrderByClause("display_column", CswEnumOrderByType.Descending) }; DataTable LayoutTable = LayoutSelect.getTable(WhereClause, orderBy); foreach (DataRow Row in LayoutTable.Rows) { Int32 PropId = CswConvert.ToInt32(Row["nodetypepropid"]); CswNbtObjClassDesignNodeTypeProp PropNode = _CswNbtMetaDataResources.CswNbtResources.Nodes.getNodeByRelationalId(new CswPrimaryKey("nodetype_props", PropId)); ret.Add(PropNode); } return(ret); } // getPropNodesInLayout()
public override void update() { //Get all views with a category of "Lab Safety" and add '(demo)' to 'viewname' and 'category' CswTableSelect nodeViewsTS = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "select_by_category_26772", "node_views" ); DataTable nodeViews = nodeViewsTS.getTable( "where category = 'Lab Safety'" ); foreach( DataRow row in nodeViews.Rows ) { CswNbtView curView = _CswNbtSchemaModTrnsctn.restoreView( row["viewname"].ToString() ); if( null != curView ) //paranoid { curView.ViewName += " (demo)"; curView.Category += " (demo)"; curView.save(); } } //get all nodetypes with a category of 'Labe Safety' and add '(demo)' to 'category' and 'nodetypename' CswTableUpdate nodetypeTU = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "select_nt_category_26772", "nodetypes" ); DataTable nodeTypes = nodetypeTU.getTable( "where category = 'Lab Safety'" ); foreach( DataRow row in nodeTypes.Rows ) { row["nodetypename"] += " (demo)"; row["category"] += " (demo)"; } nodetypeTU.update( nodeTypes ); }//Update()
private void _init() { if (Int32.MinValue != _fkDefId) { CswTableSelect FkeyDefsSelect = _CswNbtResources.makeCswTableSelect("fetch_fkey_def_sql", "fkey_definitions"); DataTable FkeyDefsTable = FkeyDefsSelect.getTable("fkeydefid", _fkDefId); string Sql = FkeyDefsTable.Rows[0]["sql"].ToString(); CswArbitrarySelect ListOptsSelect = _CswNbtResources.makeCswArbitrarySelect("list_options_query", Sql); DataTable ListOptsTable = ListOptsSelect.getTable(); _Options = new Collection <CswNbtNodeTypePropListOption>(); _Options.Add(new CswNbtNodeTypePropListOption("", "")); foreach (DataRow CurrentRow in ListOptsTable.Rows) { _Options.Add(new CswNbtNodeTypePropListOption(CurrentRow[FkeyDefsTable.Rows[0]["ref_column"].ToString()].ToString(), CurrentRow[FkeyDefsTable.Rows[0]["pk_column"].ToString()].ToString())); }//iterate listopts rows } else { CswCommaDelimitedString Opts = new CswCommaDelimitedString(); Opts.FromString(_ListOptions); Override(Opts); } }
public void getQuickLaunchJson( ref ViewSelect.Response.Category Category ) { CswTableSelect SessionDataSelect = _CswNbtResources.makeCswTableSelect( "getQuickLaunchXml_select", "session_data" ); Collection<OrderByClause> OrderBy = new Collection<OrderByClause>(); OrderBy.Add( new OrderByClause( SessionDataColumn_PrimaryKey, CswEnumOrderByType.Descending ) ); string WhereClause = @"where " + SessionDataColumn_SessionId + "='" + _CswNbtResources.Session.SessionId + "' and " + SessionDataColumn_QuickLaunch + " = '" + CswConvert.ToDbVal( true ).ToString() + "'"; DataTable SessionDataTable = SessionDataSelect.getTable( WhereClause, OrderBy ); Int32 RowCount = 0; foreach( DataRow Row in SessionDataTable.Rows ) { bool KeepInQuickLaunch = CswConvert.ToBoolean( Row[SessionDataColumn_KeepInQuickLaunch] ); if( KeepInQuickLaunch ) { _addQuickLaunchProp( Row, Category ); } else if( RowCount < 5 ) { _addQuickLaunchProp( Row, Category ); RowCount++; } } } // getQuickLaunchJson()
/// <summary> /// Loads import definition bindings from the database /// </summary> private void _loadBindings() { if (Int32.MinValue != ImportDefinitionId) { // Order CswTableSelect OrderSelect = _CswNbtResources.makeCswTableSelect("loadBindings_order_select", CswNbtImportTables.ImportDefOrder.TableName); DataTable OrderDataTable = OrderSelect.getTable(CswNbtImportTables.ImportDefOrder.importdefid, ImportDefinitionId); foreach (DataRow OrderRow in OrderDataTable.Rows) { this.ImportOrder.Add(CswConvert.ToInt32(OrderRow[CswNbtImportTables.ImportDefOrder.importorder]), new CswNbtImportDefOrder(_CswNbtResources, OrderRow)); } // Bindings CswTableSelect BindingsSelect = _CswNbtResources.makeCswTableSelect("loadBindings_bindings_select", CswNbtImportTables.ImportDefBindings.TableName); DataTable BindingsDataTable = BindingsSelect.getTable(CswNbtImportTables.ImportDefBindings.importdefid, ImportDefinitionId); foreach (DataRow BindingRow in BindingsDataTable.Rows) { Bindings.Add(new CswNbtImportDefBinding(_CswNbtResources, BindingRow)); } // Row Relationships CswTableSelect RelationshipsSelect = _CswNbtResources.makeCswTableSelect("loadBindings_rel_select", CswNbtImportTables.ImportDefRelationships.TableName); DataTable RelationshipsDataTable = RelationshipsSelect.getTable(CswNbtImportTables.ImportDefRelationships.importdefid, ImportDefinitionId); foreach (DataRow RelRow in RelationshipsDataTable.Rows) { RowRelationships.Add(new CswNbtImportDefRelationship(_CswNbtResources, RelRow)); } } } // _loadBindings()
} //ctor public override void update() { _CswTstCaseRsrc = new CswTestCaseRsrc(_CswNbtSchemaModTrnsctn); _CswTstCaseRsrc_014.CswNbtSchemaModTrnsctn = _CswNbtSchemaModTrnsctn; CswTableSelect CswTableSelectNodeTypes = _CswNbtSchemaModTrnsctn.makeCswTableSelect(Description, "nodetypes"); DataTable NodetypesTable = CswTableSelectNodeTypes.getTable(" where lower(tablename)='materials'"); Int32 NodeTypeId = Convert.ToInt32(NodetypesTable.Rows[0]["nodetypeid"]); CswNbtMetaDataNodeType NodeType = _CswNbtSchemaModTrnsctn.MetaData.getNodeType(NodeTypeId); CswTableUpdate CswTableUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate(Description, NodeType.TableName); string PkColumnName = _CswNbtSchemaModTrnsctn.getPrimeKeyColName(NodeType.TableName); //bz # 9102: This is the way of getting the record that causes the updated record disappear CswCommaDelimitedString SelectColumns = null; //new CswCommaDelimitedString(); //foreach( CswNbtMetaDataNodeTypeProp CurrentNodeTypeProp in NodeType.getNodeTypeProps() ) //{ // foreach( CswNbtSubField CurrentSubField in CurrentNodeTypeProp.getFieldTypeRule().SubFields ) // { // if( CurrentSubField.RelationalColumn != string.Empty ) // SelectColumns.Add( CurrentSubField.RelationalColumn ); // } //}//iterate node type props to set up select columns DataTable DataTable = CswTableUpdate.getTable(SelectColumns, PkColumnName, _CswTstCaseRsrc_014.InsertedMaterialsRecordPk, string.Empty, false); DataTable.Rows[0]["materialname"] = "nu _CswTstCaseRsrc_014.Purpose"; CswTableUpdate.update(DataTable); }
public CswNbtMetaDataResources(CswNbtResources Resources, CswNbtMetaData MetaData) { CswNbtResources = Resources; CswNbtMetaData = MetaData; CswNbtFieldResources = new CswNbtFieldResources(Resources); _ExcludeDisabledModules = ExcludeDisabledModules; ObjectClassTableSelect = CswNbtResources.makeCswTableSelect("MetaData_ObjectClass_Select", "object_class"); ObjectClassPropTableSelect = CswNbtResources.makeCswTableSelect("MetaData_ObjectClassProp_Select", "object_class_props"); NodeTypeTableSelect = CswNbtResources.makeCswTableSelect("MetaData_NodeType_Select", "nodetypes"); FieldTypeTableSelect = CswNbtResources.makeCswTableSelect("MetaData_FieldType_Select", "field_types"); NodeTypePropTableSelect = CswNbtResources.makeCswTableSelect("MetaData_NodeTypeProp_Select", "nodetype_props"); NodeTypeTabTableSelect = CswNbtResources.makeCswTableSelect("MetaData_NodeTypeTab_Select", "nodetype_tabset"); PropertySetTableSelect = CswNbtResources.makeCswTableSelect("MetaData_PropertySet_Select", "property_set"); ObjectClassTableUpdate = CswNbtResources.makeCswTableUpdate("MetaData_ObjectClass_update", "object_class"); ObjectClassPropTableUpdate = CswNbtResources.makeCswTableUpdate("MetaData_ObjectClassProp_update", "object_class_props"); NodeTypeTableUpdate = CswNbtResources.makeCswTableUpdate("MetaData_NodeType_update", "nodetypes"); FieldTypeTableUpdate = CswNbtResources.makeCswTableUpdate("MetaData_FieldType_update", "field_types"); NodeTypePropTableUpdate = CswNbtResources.makeCswTableUpdate("MetaData_NodeTypeProp_update", "nodetype_props"); NodeTypeTabTableUpdate = CswNbtResources.makeCswTableUpdate("MetaData_NodeTypeTab_update", "nodetype_tabset"); PropertySetTableUpdate = CswNbtResources.makeCswTableUpdate("MetaData_PropertySet_update", "property_set"); JctNodesPropsTableUpdate = CswNbtResources.makeCswTableUpdate("MetaData_JctNodesProps_update", "jct_nodes_props"); ObjectClassesCollection = new CswNbtMetaDataCollectionObjectClass(this); ObjectClassPropsCollection = new CswNbtMetaDataCollectionObjectClassProp(this); FieldTypesCollection = new CswNbtMetaDataCollectionFieldType(this); NodeTypesCollection = new CswNbtMetaDataCollectionNodeType(this); NodeTypePropsCollection = new CswNbtMetaDataCollectionNodeTypeProp(this); NodeTypeTabsCollection = new CswNbtMetaDataCollectionNodeTypeTab(this); PropertySetsCollection = new CswNbtMetaDataCollectionPropertySet(this); }
public override void update() { // Adapted from CswNbtSessionDataMgr.removeAllSessionData() CswTableSelect NodesSelect = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "30983_nodes_select", "nodes" ); DataTable NodesTable = NodesSelect.getTable( new CswCommaDelimitedString { "nodeid" }, "where istemp = '1'" ); if( NodesTable.Rows.Count > 0 ) { Collection<CswNbtNode> DoomedNodes = new Collection<CswNbtNode>(); foreach( DataRow Row in NodesTable.Rows ) { CswPrimaryKey NodeId = new CswPrimaryKey( "nodes", CswConvert.ToInt32( Row["nodeid"] ) ); if( CswTools.IsPrimaryKey( NodeId ) ) { CswNbtNode TempNode = _CswNbtSchemaModTrnsctn.Nodes[NodeId]; if( null != TempNode ) { DoomedNodes.Add( TempNode ); } } } foreach( CswNbtNode DoomedNode in DoomedNodes ) { DoomedNode.delete( DeleteAllRequiredRelatedNodes: true, OverridePermissions: true ); } } //there are nodes rows } // update()
/// <summary> /// Determines if the Node is marked as Favorite for the given user /// </summary> /// <returns>true if the node is marked as favorite</returns> public bool isFavorite(Int32 UserId) { CswTableSelect FavoriteSelect = _CswNbtResources.makeCswTableSelect("favoriteSelect", "favorites"); DataTable FavoriteTable = FavoriteSelect.getTable("where itemid = " + NodeId.PrimaryKey + " and userid = " + UserId); return(FavoriteTable.Rows.Count > 0); }
}//_getMasterSchemaResources() /// <summary> /// Get the number of rows in the current schema's session_data that do not have a corresponding sessionid in Master's sessionlist /// </summary> /// <remarks> /// This assumes you have initialized _MasterSchemaResources. /// Note that the first part of the threadCallBack() might generate more orphans, so this select needs to be re-done after we remove session ids /// </remarks> private Int32 _getOrphanRowCount(CswNbtResources CswNbtResources) { CswTableSelect DoomedSessionDataTS = CswNbtResources.makeCswTableSelect("purge_doomed_session_data", "session_data"); DataTable DoomedSessionDataDT = DoomedSessionDataTS.getTable(_getMasterSessionIdsWhere()); return(DoomedSessionDataDT.Rows.Count); }
/// <summary> /// Compares this prop's Text value with all existing values that share the same NodeTypePropId and changes it until it becomes unqiue. /// </summary> public void makeUnique() { bool isUnique = false; CswTableSelect JctNodePropSelect = _CswNbtResources.makeCswTableSelect(NodeTypePropId + "_matching select", "jct_nodes_props"); int PropNum = 2; string NewText = Text; while (false == isUnique) { DataTable MatchingPropsTable = JctNodePropSelect.getTable("where nodetypepropid = " + NodeTypePropId + " " + " and nodeid <> " + this.NodeId.PrimaryKey + " and lower(" + _TextSubField.Column + ") = '" + CswTools.SafeSqlParam(NewText).ToLower() + "'"); if (MatchingPropsTable.Rows.Count > 0) { NewText = Text + " " + PropNum; PropNum++; } else { isUnique = true; } } Text = NewText; } // makeUnique()
} // GetNodeCountForNodeType /// <summary> /// Returns the number of locked nodes for an object class /// </summary> public Int32 GetLockedNodeCountForObjectClass( Int32 ObjectClassId ) { CswTableSelect NodesSelect = _CswNbtResources.makeCswTableSelect( "CswNbtActQuotas_SelectLockedNodes", "nodes" ); string WhereClause = @"where nodetypeid in (select nodetypeid from nodetypes where objectclassid = " + ObjectClassId.ToString() + @") and locked = '" + CswConvert.ToDbVal( true ).ToString() + @"'"; return NodesSelect.getRecordCount( WhereClause ); } // GetLockedNodeCountForObjectClass()
public bool ModuleHasPrereq(CswEnumNbtModuleName Module) { int moduleId = _CswNbtResources.Modules.GetModuleId(Module); CswTableSelect modulesTS = _CswNbtResources.makeCswTableSelect("modulehasparent", "modules"); DataTable modulesDT = modulesTS.getTable("where prereq is not null and moduleid = " + moduleId); return(modulesDT.Rows.Count > 0); }
public void beforeDeleteNode(bool DeleteAllRequiredRelatedNodes, bool ValidateRequiredRelationships) { beforeDeleteNodeLogic(); if (ValidateRequiredRelationships) { // case 22486 - Don't allow deleting targets of required relationships CswTableSelect JctSelect = _CswNbtResources.makeCswTableSelect("defaultBeforeDeleteNode_jnp_select", "jct_nodes_props"); // Case CIS-52536 - Delete validation should ignore temp nodes string WhereClause = @"np WHERE nodetypepropid IN (SELECT nodetypepropid FROM nodetype_props WHERE isrequired = '1') AND field1_fk = " + _CswNbtNode.NodeId.PrimaryKey.ToString() + @" AND (SELECT istemp FROM nodes n WHERE n.nodeid = np.nodeid) <> '1' "; CswCommaDelimitedString SelectClause = new CswCommaDelimitedString() { "nodeid" }; DataTable MatchTable = JctSelect.getTable(SelectClause, WhereClause); if (MatchTable.Rows.Count > 0) { CswCommaDelimitedString InUseStr = new CswCommaDelimitedString(); foreach (DataRow MatchRow in MatchTable.Rows) { CswPrimaryKey MatchNodePk = new CswPrimaryKey("nodes", CswConvert.ToInt32(MatchRow["nodeid"])); if (DeleteAllRequiredRelatedNodes) { CswNbtNode NodeToDelete = _CswNbtResources.Nodes.GetNode(MatchNodePk); if (null != NodeToDelete) { NodeToDelete.delete(DeleteAllRequiredRelatedNodes: DeleteAllRequiredRelatedNodes); } } else { CswNbtNode RelatedNode = _CswNbtResources.Nodes[MatchNodePk]; if (null != RelatedNode) { InUseStr.Add(RelatedNode.NodeLink); } } } // foreach( DataRow MatchRow in MatchTable.Rows ) if (false == DeleteAllRequiredRelatedNodes) { throw new CswDniException(CswEnumErrorType.Warning, "This " + _CswNbtNode.getNodeType().NodeTypeName + " cannot be deleted because it is in use by: " + InUseStr, "Current user (" + _CswNbtResources.CurrentUser.Username + ") tried to delete a " + _CswNbtNode.getNodeType().NodeTypeName + " that is in use by: " + InUseStr); } } // if( MatchTable.Rows.Count > 0 ) } // if( ValidateRequiredRelationships ) } // baseBeforeDeleteNode()
public static void runCrystalReport( ICswResources CswResources, CswNbtWebServiceReport.CrystalReportReturn Return, CswNbtWebServiceReport.ReportData reportParams ) { CswNbtResources CswNbtResources = (CswNbtResources) CswResources; DataTable ReportTable = _getReportTable( CswNbtResources, reportParams ); if( ReportTable.Rows.Count > 0 ) { // Get the Report Layout File Int32 JctNodePropId = reportParams.ReportNode.RPTFile.JctNodePropId; if( JctNodePropId > 0 ) { CswFilePath FilePathTools = new CswFilePath( CswNbtResources ); string ReportTempFileName = FilePathTools.getFullReportFilePath( JctNodePropId.ToString() ); if( !File.Exists( ReportTempFileName ) ) { DirectoryInfo DirectoryInfo = ( new FileInfo( ReportTempFileName ) ).Directory; if( DirectoryInfo != null ) { DirectoryInfo.Create(); //creates the /rpt directory if it doesn't exist } CswTableSelect JctSelect = CswNbtResources.makeCswTableSelect( "getReportLayoutBlob_select", "blob_data" ); JctSelect.AllowBlobColumns = true; CswCommaDelimitedString SelectColumns = new CswCommaDelimitedString(); SelectColumns.Add( "blobdata" ); DataTable JctTable = JctSelect.getTable( SelectColumns, "jctnodepropid", JctNodePropId, "", true ); if( JctTable.Rows.Count > 0 ) { if( !JctTable.Rows[0].IsNull( "blobdata" ) ) { byte[] BlobData = JctTable.Rows[0]["blobdata"] as byte[]; FileStream fs = new FileStream( ReportTempFileName, FileMode.CreateNew ); BinaryWriter BWriter = new BinaryWriter( fs, System.Text.Encoding.Default ); if( BlobData != null ) { BWriter.Write( BlobData ); } } else { throw new CswDniException( CswEnumErrorType.Warning, "Report is missing RPT file", "Report's RPTFile blobdata is null" ); } } } if( File.Exists( ReportTempFileName ) ) { Return.Data.reportUrl = _saveCrystalReport( CswNbtResources, ReportTempFileName, reportParams.ReportNode.ReportName.Text, ReportTable ); Return.Data.hasResults = true; } } // if( JctNodePropId > 0 ) } // if(ReportTable.Rows.Count > 0) else { Return.Data.hasResults = false; } } // LoadReport()
public CswNbtImportDataJob(CswNbtResources CswNbtResources, Int32 ImportJobId) { CswTableSelect JobSelect = CswNbtResources.makeCswTableSelect("CswNbtImportDataJob_select", CswNbtImportTables.ImportDataJob.TableName); DataTable JobDataTable = JobSelect.getTable(CswNbtImportTables.ImportDataJob.PkColumnName, ImportJobId); if (JobDataTable.Rows.Count > 0) { _finishConstructor(CswNbtResources, JobDataTable.Rows[0]); } }
/// <summary> /// Convenience function for hiding all views in a category /// </summary> /// <param name="hidden">true if the views should be hidden</param> /// <param name="category">the category to get all views in</param> /// <param name="visibility">the original visibility of the view when not hidden</param> public void ToggleViewsInCategory(bool hidden, string category, CswEnumNbtViewVisibility visibility) { CswTableSelect tu = _CswNbtResources.makeCswTableSelect("toggleViewsInCategory_26717", "node_views"); DataTable nodeviews = tu.getTable("where category = '" + category + "'"); foreach (DataRow row in nodeviews.Rows) { ToggleView(hidden, row["viewname"].ToString(), visibility); } }
/// <summary> /// Constructor /// </summary> public CswNbtActionCollection(CswNbtResources Resources, bool ExcludeDisabledActions) { _CswNbtResources = Resources; _ActionSL = new SortedList(); _ActionHash = new Hashtable(); // Actions DataTable ActionsTable = null; if (ExcludeDisabledActions) { CswStaticSelect ActionsSelect = _CswNbtResources.makeCswStaticSelect("CswNbtActionCollection.ActionsSelect", "getActiveActions"); ActionsTable = ActionsSelect.getTable(); } else { CswTableSelect ActionsSelect = _CswNbtResources.makeCswTableSelect("CswNbtActionCollection.AllActionsSelect", "actions"); ActionsTable = ActionsSelect.getTable(); } foreach (DataRow ActionRow in ActionsTable.Rows) { try { CswEnumNbtActionName CurrentActionName = CswNbtAction.ActionNameStringToEnum(ActionRow["actionname"].ToString()); if (CurrentActionName != CswResources.UnknownEnum) { Int32 ActionId = CswConvert.ToInt32(ActionRow["actionid"]); CswNbtAction Action = new CswNbtAction(_CswNbtResources, ActionId, ActionRow["url"].ToString(), CurrentActionName, CswConvert.ToBoolean(ActionRow["showinlist"]), ActionRow["category"].ToString(), CswConvert.ToString(ActionRow["iconfilename"])); string ActionNameAsString = CswNbtAction.ActionNameEnumToString(CurrentActionName); if (false == _ActionSL.ContainsKey(ActionNameAsString)) { _ActionSL.Add(ActionNameAsString, Action); } if (false == _ActionHash.ContainsKey(ActionId)) { _ActionHash.Add(ActionId, Action); } } } catch (Exception ex) { // Log the error but keep going _CswNbtResources.logError(new CswDniException(CswEnumErrorType.Error, "System Error", "Encountered an invalid Action: " + ActionRow["actionname"] + " (" + ActionRow["actionid"] + ")", ex)); } } }
public override void update() { CswTableSelect select = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "31006_select", "nodetype_props" ); DataTable tbl = select.getTable( "where oraviewcolname = 'Q12147483648'" ); foreach( DataRow row in tbl.Rows ) { Int32 PropId = CswConvert.ToInt32( row["nodetypepropid"] ); CswNbtMetaDataNodeTypeProp nodeTypeProp = _CswNbtSchemaModTrnsctn.MetaData.getNodeTypeProp( PropId ); nodeTypeProp.resetDbViewColumnName(); } } // update()
private List <Int32> _getNodesAboveHighWaterMark() { List <Int32> TestNodeIds = new List <Int32>(); CswTableSelect NodesSelect = _CswNbtResources.makeCswTableSelect("NodesAboveHWM", "nodes"); DataTable TestNodesTable = NodesSelect.getTable("where nodeid > " + _NodeIdHighWaterMark); TestNodeIds.AddRange(from DataRow Row in TestNodesTable.Rows select CswConvert.ToInt32(Row["nodeid"])); return(TestNodeIds); }
/// <summary> /// Retrieve a session data item /// </summary> public CswNbtSessionDataItem getSessionDataItem( CswNbtSessionDataId SessionDataId ) { CswTableSelect SessionDataSelect = _CswNbtResources.makeCswTableSelect( "getSessionDataItem_select", "session_data" ); DataTable SessionDataTable = SessionDataSelect.getTable( "sessiondataid", SessionDataId.get() ); CswNbtSessionDataItem ret = null; if( SessionDataTable.Rows.Count > 0 ) { ret = new CswNbtSessionDataItem( _CswNbtResources, SessionDataTable.Rows[0] ); } return ret; }
private string _getDeficientInspectionsActionIdFromDB() { string actionId = string.Empty; CswTableSelect tableActionUpdate = _CswNbtSchemaModTrnsctn.makeCswTableSelect( "DeleteDefInspAct", "actions" ); DataTable actTable = tableActionUpdate.getTable( "where actionname = 'Deficient Inspections'" ); foreach( DataRow row in actTable.Rows ) { actionId = row["actionid"].ToString(); } return actionId; }
// getDefinitions() /// <summary> /// Returns the set of available Import Jobs /// </summary> public static Collection <CswNbtImportDataJob> getJobs(CswNbtResources CswNbtResources) { Collection <CswNbtImportDataJob> ret = new Collection <CswNbtImportDataJob>(); CswTableSelect JobSelect = CswNbtResources.makeCswTableSelect("getJobs_select", CswNbtImportTables.ImportDataJob.TableName); DataTable JobDataTable = JobSelect.getTable(); foreach (DataRow jobrow in JobDataTable.Rows) { ret.Add(new CswNbtImportDataJob(CswNbtResources, jobrow)); } return(ret); }
/// <summary> /// Get the filename for a file property /// </summary> /// <param name="JctNodePropId"></param> /// <returns></returns> public string GetFileName(CswNbtNodePropBlob BlobProp) { string ret = ""; CswTableSelect ts = _CswNbtResources.makeCswTableSelect("getFirstFileName", "blob_data"); DataTable dt = ts.getTable("where jctnodepropid = " + BlobProp.JctNodePropId); if (dt.Rows.Count > 0) { ret = dt.Rows[0]["filename"].ToString(); } return(ret); }
public void threadCallBack(ICswResources CswResources) { _LogicRunStatus = CswEnumScheduleLogicRunStatus.Running; CswNbtResources CswNbtResources = (CswNbtResources)CswResources; //CswNbtResources.AuditContext = "Scheduler Task: Update MTBF"; CswNbtResources.AuditContext = "Scheduler Task: " + RuleName; if (CswEnumScheduleLogicRunStatus.Stopping != _LogicRunStatus) { try { // BZ 6779 // Set all MTBF fields pendingupdate = 1 Int32 MTBFId = CswNbtResources.MetaData.getFieldType(ChemSW.Nbt.MetaData.CswEnumNbtFieldType.MTBF).FieldTypeId; CswTableSelect NTPSelect = CswNbtResources.makeCswTableSelect("UpdateMTBF_NTP_Select", "nodetype_props"); DataTable NTPTable = NTPSelect.getTable("fieldtypeid", MTBFId); string NTPIds = string.Empty; foreach (DataRow NTPRow in NTPTable.Rows) { if (NTPIds != string.Empty) { NTPIds += ","; } NTPIds += CswConvert.ToInt32(NTPRow["nodetypepropid"]); } if (NTPIds != string.Empty) { CswTableUpdate JNPUpdate = CswNbtResources.makeCswTableUpdate("UpdateMTBF_JNP_Update", "jct_nodes_props"); DataTable JNPTable = JNPUpdate.getTable("where nodetypepropid in (" + NTPIds + ")"); foreach (DataRow JNPRow in JNPTable.Rows) { JNPRow["pendingupdate"] = CswConvert.ToDbVal(true); } JNPUpdate.update(JNPTable); } _CswScheduleLogicDetail.StatusMessage = "Completed without error"; _LogicRunStatus = CswEnumScheduleLogicRunStatus.Succeeded; //last line }//try catch (Exception Exception) { _CswScheduleLogicDetail.StatusMessage = "CswScheduleLogicNbtUpdtMTBF::GetUpdatedItems() exception: " + Exception.Message + "; " + Exception.StackTrace; CswNbtResources.logError(new CswDniException(_CswScheduleLogicDetail.StatusMessage)); _LogicRunStatus = CswEnumScheduleLogicRunStatus.Failed; } //catch } //if we're not shutting down } //threadCallBack()
/// <summary> /// Returns true if the script has already been run sucessfully. /// </summary> /// <returns></returns> public bool AlreadyRun() { bool Ret = false; CswTableSelect ts = _CswNbtSchemaModTrnsctn.makeCswTableSelect("HasScriptAlreadyRun", "update_history"); DataTable dt = ts.getTable("where scriptname = '" + _CswUpdateSchemaTo.ScriptName + "' and succeeded = 1"); if (dt.Rows.Count > 0) { Ret = true; } return(Ret); }//AlreadyRun()
public bool doesS4Exist(string S4Name) { bool Ret = false; CswTableSelect S4Ts = _CswNbtResources.makeCswTableSelect("unqique_static_sql_selects_queryids", "static_sql_selects"); DataTable Data = S4Ts.getTable(" where lower(queryid) = '" + S4Name.ToLower().Trim() + "' "); if (Data.Rows.Count > 0) { Ret = true; } return(Ret); }