public static JObject getSizeNodeProps(CswNbtResources CswNbtResources, Int32 SizeNodeTypeId, string SizeDefinition, bool WriteNode) { JObject SizeObj = CswConvert.ToJObject(SizeDefinition, true, "size"); CswNbtNode SizeNode; return(getSizeNodeProps(CswNbtResources, SizeNodeTypeId, SizeObj, WriteNode, out SizeNode)); }
public override void setDBValuesFromRequest(LandingPageData.Request Request) { CswEnumNbtViewType ViewType = (CswEnumNbtViewType)Request.ViewType; if (ViewType == CswEnumNbtViewType.View) { _ItemRow["to_nodeviewid"] = CswConvert.ToDbVal(new CswNbtViewId(Request.PkValue).get()); } else if (ViewType == CswEnumNbtViewType.Action) { _ItemRow["to_actionid"] = CswConvert.ToDbVal(Request.PkValue); } else if (ViewType == CswEnumNbtViewType.Report) { CswPrimaryKey ReportPk = CswConvert.ToPrimaryKey(Request.PkValue); _ItemRow["to_reportid"] = CswConvert.ToDbVal(ReportPk.PrimaryKey); } else if (ViewType == CswEnumNbtViewType.Search) { CswPrimaryKey SearchPk = CswConvert.ToPrimaryKey(Request.PkValue); _ItemRow["to_searchid"] = CswConvert.ToDbVal(SearchPk.PrimaryKey); } else { throw new CswDniException(CswEnumErrorType.Warning, "You must select a view", "No view was selected for new Link LandingPage Item"); } _setCommonDbValuesFromRequest(Request); }
} // getNodeTypes() public JObject getNodeTypeTabs(string NodeTypeName, string NodeTypeId, string FilterToPermission) { JObject ReturnVal = new JObject(); CswNbtMetaDataNodeType NodeType; if (false == String.IsNullOrEmpty(NodeTypeName)) { NodeType = _CswNbtResources.MetaData.getNodeType(NodeTypeName); } else { NodeType = _CswNbtResources.MetaData.getNodeType(CswConvert.ToInt32(NodeTypeId)); } if (null != NodeType) { IEnumerable <CswNbtMetaDataNodeTypeTab> Tabs = NodeType.getNodeTypeTabs(); foreach (CswNbtMetaDataNodeTypeTab Tab in Tabs) { if (_userHasTabPermission(FilterToPermission, NodeType, Tab)) { string TabName = "tab_" + Tab.TabId; ReturnVal[TabName] = new JObject(); ReturnVal[TabName]["id"] = Tab.TabId; ReturnVal[TabName]["name"] = Tab.TabName; } } } return(ReturnVal); }
private Collection <CswNbtNodeKey> _loadNodeAsChildFromRow(CswNbtNodeKey ParentNodeKey, DataRow DataRowToAdd, bool UseGrouping, string GroupName, CswNbtViewRelationship Relationship, bool Selectable, bool ShowInTree, CswEnumNbtViewAddChildrenSetting AddChildren, Int32 RowCount, bool Included = true, bool Favorited = false) { CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(CswConvert.ToInt32(DataRowToAdd[_CswNbtColumnNames.NodeTypeId.ToLower()].ToString())); //string TableName = NodeType.TableName; //string PkColumnName = _CswNbtResources.getPrimeKeyColName( TableName ); return(_loadNodeAsChild(ParentNodeKey, UseGrouping, GroupName, Relationship, Selectable, ShowInTree, AddChildren, RowCount, Included, DataRowToAdd[_CswNbtColumnNames.IconFileName.ToLower()].ToString(), DataRowToAdd[_CswNbtColumnNames.NameTemplate.ToLower()].ToString(), new CswPrimaryKey("nodes", CswConvert.ToInt32(DataRowToAdd["nodeid"])), new CswPrimaryKey(CswConvert.ToString(DataRowToAdd["relationaltable"]), CswConvert.ToInt32(DataRowToAdd["relationalid"])), DataRowToAdd[_CswNbtColumnNames.NodeName.ToLower()].ToString(), CswConvert.ToInt32(DataRowToAdd[_CswNbtColumnNames.NodeTypeId.ToLower()].ToString()), DataRowToAdd[_CswNbtColumnNames.NodeTypeName.ToLower()].ToString(), CswConvert.ToInt32(DataRowToAdd[_CswNbtColumnNames.ObjectClassId.ToLower()].ToString()), DataRowToAdd[_CswNbtColumnNames.ObjectClassName.ToLower()].ToString(), CswConvert.ToBoolean(DataRowToAdd[_CswNbtColumnNames.Locked.ToLower()]), Favorited )); }
public void RefreshViewName() { CachedViewNames.Clear(); if( SelectedViewIds.Count > 0 ) { if( SelectMode != CswEnumNbtPropertySelectMode.Multiple && CswConvert.ToInt32( SelectedViewIds[0] ) > 0 ) { CswNbtView ThisView = _CswNbtResources.ViewSelect.restoreView( new CswNbtViewId( CswConvert.ToInt32( SelectedViewIds[0] ) ) ); if( null != ThisView ) { CachedViewNames.Add( ThisView.ViewName ); } } else { Collection<Int32> SelectedViewIdCollection = SelectedViewIds.ToIntCollection(); foreach( Int32 ViewId in SelectedViewIdCollection ) { CswNbtView ThisView = _CswNbtResources.ViewSelect.restoreView( new CswNbtViewId( ViewId ) ); if( null != ThisView ) { CachedViewNames.Add( ThisView.ViewName ); } } // foreach( Int32 ViewId in SelectedViewIdCollection ) } } // if( SelectedViewIds.Count > 0 ) this.PendingUpdate = false; } // RefreshViewName()
private void _createNotScannedContainerLocation(ContainerData.ReconciliationActions Action, CswEnumNbtContainerLocationTypeOptions Type) { CswNbtMetaDataObjectClass ContLocOc = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerLocationClass); CswNbtMetaDataNodeType ContLocNt = ContLocOc.FirstNodeType; if (null != ContLocNt) { _CswNbtResources.Nodes.makeNodeFromNodeTypeId(ContLocNt.NodeTypeId, delegate(CswNbtNode NewNode) { CswNbtObjClassContainerLocation ContLocNode = NewNode; ContLocNode.Container.RelatedNodeId = CswConvert.ToPrimaryKey(Action.ContainerId); ContLocNode.Location.SelectedNodeId = CswConvert.ToPrimaryKey(Action.LocationId); ContLocNode.Type.Value = Type.ToString(); ContLocNode.Status.Value = CswEnumNbtContainerLocationStatusOptions.NotScanned.ToString(); ContLocNode.ActionApplied.Checked = CswEnumTristate.False; if (Type == CswEnumNbtContainerLocationTypeOptions.Missing) { ContLocNode.Action.Value = CswEnumNbtContainerLocationActionOptions.MarkMissing.ToString(); } else if (Type == CswEnumNbtContainerLocationTypeOptions.Ignore) { ContLocNode.Action.Value = CswEnumNbtContainerLocationActionOptions.Ignore.ToString(); } ContLocNode.ActionByUser.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId; ContLocNode.ScanDate.DateTimeValue = DateTime.Now; ContLocNode.User.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId; }); } }
public CswNbtNode GetNode(string NodeId, string NodeKey, CswDateTime Date = null) { CswNbtNode Node = null; if (!string.IsNullOrEmpty(NodeKey)) { //CswNbtNodeKey RealNodeKey = new CswNbtNodeKey( CswNbtResources, FromSafeJavaScriptParam( NodeKey ) ); CswNbtNodeKey RealNodeKey = new CswNbtNodeKey(NodeKey); Node = _CswNbtResources.getNode(RealNodeKey, Date); } else if (!string.IsNullOrEmpty(NodeId)) { CswPrimaryKey RealNodeId = new CswPrimaryKey(); if (CswTools.IsInteger(NodeId)) { RealNodeId.TableName = "nodes"; RealNodeId.PrimaryKey = CswConvert.ToInt32(NodeId); } else { RealNodeId.FromString(NodeId); } Node = _CswNbtResources.getNode(RealNodeId, Date); } return(Node); } // getNode()
/// <summary> /// Updates the default Expiration Date on containers to receive based on Receipt Lot's Manufactured Date /// </summary> public ContainerData.ReceivingData updateExpirationDate(ContainerData.ReceiptLotRequest Request) { ContainerData.ReceivingData ReceiveData = new ContainerData.ReceivingData(); JObject ReceiptLotPropsObj = CswConvert.ToJObject(Request.ReceiptLotProps); if (ReceiptLotPropsObj.HasValues) { CswPrimaryKey ReceiptLotId = CswConvert.ToPrimaryKey(Request.ReceiptLotId); if (CswTools.IsPrimaryKey(ReceiptLotId)) { CswNbtObjClassReceiptLot ReceiptLot = _CswNbtResources.Nodes.GetNode(ReceiptLotId); _CswNbtSdTabsAndProps.saveNodeProps(ReceiptLot.Node, ReceiptLotPropsObj); CswPrimaryKey ContainerId = CswConvert.ToPrimaryKey(Request.ContainerId); if (CswTools.IsPrimaryKey(ContainerId) && ReceiptLot.ManufacturedDate.DateTimeValue != DateTime.MinValue) { CswNbtObjClassContainer Container = _CswNbtResources.Nodes.GetNode(ContainerId); CswNbtPropertySetMaterial Material = _CswNbtResources.Nodes.GetNode(Container.Material.RelatedNodeId); Container.ExpirationDate.DateTimeValue = Material.getDefaultExpirationDate(ReceiptLot.ManufacturedDate.DateTimeValue); Container.postChanges(false); JObject ContainerProps = getContainerAddProps(Container); ReceiveData.ContainerProps = ContainerProps.ToString(); } } } return(ReceiveData); }
public override void setItemDataForUI(DataRow LandingPageRow, LandingPageData.Request Request) { Int32 NodeTypeId = CswConvert.ToInt32(LandingPageRow["to_nodetypeid"]); Int32 TabId = CswConvert.ToInt32(LandingPageRow["to_tabid"]); if (NodeTypeId != Int32.MinValue && TabId != Int32.MinValue) { CswNbtMetaDataNodeType NodeType = _CswNbtResources.MetaData.getNodeType(NodeTypeId); if (NodeType != null) { CswNbtMetaDataNodeTypeTab Tab = NodeType.getNodeTypeTab(TabId); if (null != Tab) { CswNbtView TabView = getTabView(Request.NodeId, Request.NodeViewId, NodeType); if (null != TabView && TabView.IsFullyEnabled()) { String DisplayText = LandingPageRow["displaytext"].ToString(); _ItemData.Text = false == String.IsNullOrEmpty(DisplayText) ? DisplayText : TabView.ViewName + " " + Tab.TabName; _ItemData.ViewId = TabView.SessionViewId.ToString(); _ItemData.ViewMode = TabView.ViewMode.ToString().ToLower(); _ItemData.Type = "view"; _ItemData.TabId = TabId.ToString(); _ItemData.ButtonIcon = CswNbtMetaDataObjectClass.IconPrefix100 + NodeType.IconFileName; _setCommonItemDataForUI(LandingPageRow); } } } } }
public CswNbtMetaDataNodeType(CswNbtMetaDataResources CswNbtMetaDataResources, DataRow Row, CswDateTime Date) { _CswNbtMetaDataResources = CswNbtMetaDataResources; _Date = Date; _NodeTypeRow = Row; _UniqueId = CswConvert.ToInt32(Row[UniqueIdFieldName]); }
public override void update() { CswNbtMetaDataFieldType QuantityFT = _CswNbtSchemaModTrnsctn.MetaData.getFieldType(CswEnumNbtFieldType.Quantity); CswTableUpdate QtyUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("QuantityVal_kgLiters_Update", "jct_nodes_props"); DataTable QtyPropsTable = QtyUpdate.getTable("where nodetypepropid in (select nodetypepropid from nodetype_props where fieldtypeid = " + QuantityFT.FieldTypeId + ") "); foreach (DataRow Row in QtyPropsTable.Rows) { CswPrimaryKey UnitId = new CswPrimaryKey("nodes", CswConvert.ToInt32(Row["field1_fk"].ToString())); CswNbtObjClassUnitOfMeasure CurrentUnit = _CswNbtSchemaModTrnsctn.Nodes[UnitId]; if (null != CurrentUnit && (CurrentUnit.UnitType.Value == CswEnumNbtUnitTypes.Weight.ToString() || CurrentUnit.UnitType.Value == CswEnumNbtUnitTypes.Volume.ToString())) { Double Quantity = CswConvert.ToDouble(Row["field1_numeric"].ToString()); if (CswTools.IsDouble(Quantity)) { CswNbtObjClassUnitOfMeasure kgUnit = getUnit("kg", "Unit_Weight"); CswNbtObjClassUnitOfMeasure LitersUnit = getUnit("Liters", "Unit_Volume"); if (null != kgUnit && CurrentUnit.UnitType.Value == kgUnit.UnitType.Value) { Double Val_kg = Quantity * CurrentUnit.ConversionFactor.RealValue / kgUnit.ConversionFactor.RealValue; Row["field2_numeric"] = Val_kg.ToString(); } if (null != LitersUnit && CurrentUnit.UnitType.Value == LitersUnit.UnitType.Value) { Double Val_Liters = Quantity * CurrentUnit.ConversionFactor.RealValue / LitersUnit.ConversionFactor.RealValue; Row["field3_numeric"] = Val_Liters.ToString(); } } } } QtyUpdate.update(QtyPropsTable); }
protected override void afterPromoteNodeLogic() { // ------------------------------------------------------------ // This logic from makeNewTab in CswNbtMetaData.cs // ------------------------------------------------------------ if (CswTools.IsPrimaryKey(RelationalId)) { Int32 TabId = RelationalId.PrimaryKey; //CswTableUpdate TabsUpdate = _CswNbtResources.makeCswTableUpdate( "DesignNodeTypeTab_afterCreateNode_TabsUpdate", "nodetype_tabset" ); //DataTable TabsTable = TabsUpdate.getTable( "nodetypetabsetid", TabId ); //if( TabsTable.Rows.Count > 0 ) //{ // Version, if necessary //NodeType = CheckVersioning( NodeType ); //DataRow Row = TabsTable.Rows[0]; DataRow Row = RelationalNodeTypeTab._DataRow; if (null != Row) { Row["firsttabversionid"] = CswConvert.ToDbVal(TabId); //TabsUpdate.update( TabsTable ); } CswNbtMetaDataNodeTypeProp SaveNtp = NodeType.getNodeTypeProp(CswNbtObjClass.PropertyName.Save); if (null != SaveNtp) //Case 29181 - Save prop on new tabs { //Note - when first creating a new NodeType and creating its first tab this will be null, which is expected SaveNtp.updateLayout(CswEnumNbtLayoutType.Edit, false, TabId: TabId, DisplayColumn: 1, DisplayRow: Int32.MaxValue); } //} // if( TabsTable.Rows.Count > 0 ) } // if( CswTools.IsPrimaryKey( RelationalId ) ) } // afterPromoteNode()
private void _setHighWaterMark() { DataTable MaxNodeTable = CswNbtResources.execArbitraryPlatformNeutralSqlSelect("getHWM", "select max(nodeid) as hwm from nodes"); _NodeIdHighWaterMark = CswConvert.ToInt32(MaxNodeTable.Rows[0]["hwm"]); _NodeTypeHighWaterMark = _CswNbtResources.MetaData.getNodeTypeIds().Keys.Max(); }
/// <summary> /// Make nodes for defined sizes, else remove undefinable sizes from the JArray /// </summary> private void _addMaterialSizes(JArray SizesArray, CswNbtNode MaterialNode) { JArray ArrayToIterate = (JArray)SizesArray.DeepClone(); foreach (JObject SizeObj in ArrayToIterate) { if (SizeObj.HasValues) { CswNbtNode SizeNode; Int32 SizeNtId = CswConvert.ToInt32(SizeObj["nodeTypeId"]["value"]); if (Int32.MinValue != SizeNtId) { getSizeNodeProps(_CswNbtResources, SizeNtId, SizeObj, false, out SizeNode, MaterialNode.NodeId); if (null == SizeNode) { SizesArray.Remove(SizeObj); } } else { SizesArray.Remove(SizeObj); } } else { SizesArray.Remove(SizeObj); } } }
public ICswResources make() { CswSetupVbls SetupVbls = new CswSetupVbls(CswEnumSetupMode.NbtExe); CswEnumPooledConnectionState PooledConnectionState; if (SetupVbls.doesSettingExist("CloseSchedulerDbConnections")) { if (true == CswConvert.ToBoolean(SetupVbls["CloseSchedulerDbConnections"])) { PooledConnectionState = CswEnumPooledConnectionState.Closed; } else { PooledConnectionState = CswEnumPooledConnectionState.Open; } } else { PooledConnectionState = CswEnumPooledConnectionState.Closed; } CswNbtResources ReturnVal = CswNbtResourcesFactory.makeCswNbtResources(CswEnumAppType.Nbt, CswEnumSetupMode.NbtExe, true, null, PooledConnectionState); ReturnVal.InitCurrentUser = InitUser; return(ReturnVal); }
public void IncrementHash( Hashtable HT, object Key ) { if ( HT.Contains( Key ) ) HT[ Key ] = CswConvert.ToInt32( HT[ Key ] ) + 1; else HT[ Key ] = 1; }
public void saveContainerActions(ContainerData.ReconciliationRequest Request) { if (null != Request.ContainerActions) { foreach (ContainerData.ReconciliationActions Action in Request.ContainerActions) { if (Action.Action == CswEnumNbtContainerLocationActionOptions.MarkMissing.ToString()) { _createNotScannedContainerLocation(Action, CswEnumNbtContainerLocationTypeOptions.Missing); } else { CswPrimaryKey ContLocNodeId = CswConvert.ToPrimaryKey(Action.ContainerLocationId); if (CswTools.IsPrimaryKey(ContLocNodeId)) { CswNbtObjClassContainerLocation ContLocNode = _CswNbtResources.Nodes.GetNode(ContLocNodeId); ContLocNode.Action.Value = Action.Action; ContLocNode.ActionByUser.RelatedNodeId = _CswNbtResources.CurrentNbtUser.UserId; ContLocNode.postChanges(false); } else if (Action.Action == CswEnumNbtContainerLocationActionOptions.Ignore.ToString()) { _createNotScannedContainerLocation(Action, CswEnumNbtContainerLocationTypeOptions.Ignore); } } } } }
//private string _TableName = "logicalsetitem"; // ToXml() public override void ToJSON(JObject ParentObject) { ParentObject[_ElemName_LogicalSetJson] = new JObject(); CswCheckBoxArrayOptions CBAOptions = new CswCheckBoxArrayOptions(); DataTable Data = GetDataAsTable(_NameColumn, _KeyColumn); foreach (DataColumn Column in Data.Columns) { if (Column.ColumnName != _NameColumn && Column.ColumnName != _KeyColumn && false == CBAOptions.Columns.Contains(Column.ColumnName)) { CBAOptions.Columns.Add(Column.ColumnName); } } foreach (DataRow Row in Data.Rows) { CswCheckBoxArrayOptions.Option Option = new CswCheckBoxArrayOptions.Option(); Option.Key = Row[_KeyColumn].ToString(); Option.Label = Row[_NameColumn].ToString(); for (Int32 i = 0; i < CBAOptions.Columns.Count; i++) { Option.Values.Add(CswConvert.ToBoolean(Row[CBAOptions.Columns[i]].ToString())); } CBAOptions.Options.Add(Option); } CBAOptions.ToJSON((JObject)ParentObject[_ElemName_LogicalSetJson]); } // ToJSON()
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()
public static string generateImportQueueTableSQL(ICswResources CswResources) { string Ret = string.Empty; CswArbitrarySelect ImportDefSelect = CswResources.makeCswArbitrarySelect("importdef_get_caf_rows", "select distinct pkcolumnname, coalesce(viewname, tablename) as sourcename " + "from import_def_order io, import_def id " + "where id.importdefid = io.importdefid " + "and id.definitionname = '" + DefinitionName + "'"); DataTable ImportDefTable = ImportDefSelect.getTable(); bool FirstRow = true; foreach (DataRow DefRow in ImportDefTable.Rows) { string CurrentDefRowSql = @"insert into nbtimportqueue(nbtimportqueueid, state, itempk, sheetname, priority, errorlog) " + " select seq_nbtimportqueueid.nextval, '" + State.I + "', " + CswConvert.ToString(DefRow[CswNbtImportTables.ImportDefOrder.pkcolumnname]) + ", " + "'" + CswConvert.ToString(DefRow["sourcename"]) + "', " + "0, " + "'' from " + CswConvert.ToString(DefRow["sourcename"]) + " where deleted = '0';"; CurrentDefRowSql = CurrentDefRowSql + "\ncommit;"; if (FirstRow) { Ret = CurrentDefRowSql + Environment.NewLine; FirstRow = false; } else { Ret = Ret + Environment.NewLine + CurrentDefRowSql + Environment.NewLine; } } return(Ret); }
//public void clear() //{ //}//clear() public void makeNewNodeEntry(CswNbtNode Node, bool SyncProps) { // Don't sync for temp nodes if (false == Node.IsTemp) { string TableName = Node.getNodeType().TableName; string PkColumnName = _CswNbtResources.getPrimeKeyColName(TableName); CswTableUpdate CswTableUpdate = _CswNbtResources.makeCswTableUpdate("CswNbtNodeWriterRelationalDb.makeNewNodeEntry_update", TableName); DataTable NewNodeTable = CswTableUpdate.getEmptyTable(); DataRow NewNodeRow = NewNodeTable.NewRow(); NewNodeTable.Rows.Add(NewNodeRow); Node.RelationalId = new CswPrimaryKey(TableName, CswConvert.ToInt32(NewNodeTable.Rows[0][PkColumnName])); CswTableUpdate.update(NewNodeTable); if (SyncProps) { // It is possible for the node to have existed as a temp node, and therefore already have property values. // Now that the node has a relationalid, this will sync the current property values to the new relational row Node.Properties.update(Node, IsCopy: false, OverrideUniqueValidation: false, Creating: false, AllowAuditing: true, SkipEvents: false); } } }
public override void ToJSON(JObject ParentObject) { ParentObject[_SelectedNodeTypeIdsSubField.ToXmlNodeName().ToLower()] = SelectedNodeTypeIds.ToString(); ParentObject["selectmode"] = SelectMode.ToString(); ParentObject[_ElemName_Options] = new JObject(); CswCheckBoxArrayOptions CBAOptions = new CswCheckBoxArrayOptions(); CBAOptions.Columns.Add("Include"); DataTable Data = Options; foreach (DataRow Row in Data.Rows) { bool isSelected = SelectedNodeTypeIds.Contains(Row[KeyColumn]); if (IsEditModeEditable || isSelected) { CswCheckBoxArrayOptions.Option Option = new CswCheckBoxArrayOptions.Option(); Option.Key = CswConvert.ToString(Row[KeyColumn]); Option.Label = CswConvert.ToString(Row[NameColumn]); Option.Values.Add(CswConvert.ToBoolean(Row[ValueColumn])); CBAOptions.Options.Add(Option); } } CBAOptions.ToJSON((JObject)ParentObject[_ElemName_Options]); } // ToJSON()
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()
} // ReadJSON() private string _HandleReferences(string NodeTypeIds, Dictionary <Int32, Int32> NodeTypeMap) { string ret = NodeTypeIds; if (NodeTypeMap != null) { ret = ""; string[] NodeTypeIdsArray = NodeTypeIds.Split(','); foreach (string NodeTypeIdString in NodeTypeIdsArray) { Int32 IdToAdd = CswConvert.ToInt32(NodeTypeIdString); if (NodeTypeMap.ContainsKey(IdToAdd)) { IdToAdd = CswConvert.ToInt32(NodeTypeMap[IdToAdd].ToString()); } if (ret != "") { ret += ","; } ret += IdToAdd.ToString(); } } return(ret); }
public override void ToJSON( JObject ParentObject ) { ParentObject[_SelectedViewIdsSubField.ToXmlNodeName()] = SelectedViewIds.ToString(); ParentObject["selectmode"] = SelectMode.ToString(); ParentObject[_CachedViewNameSubField.ToXmlNodeName()] = CachedViewNames.ToString(); ParentObject[ElemName_Options] = new JObject(); CswCheckBoxArrayOptions CBAOptions = new CswCheckBoxArrayOptions(); CBAOptions.Columns.Add( "Include" ); DataTable ViewsTable = ViewsForCBA(); foreach( DataRow ViewRow in ViewsTable.Rows ) { bool isSelected = SelectedViewIds.Contains( ViewRow[KeyColumn] ); if( IsEditModeEditable || isSelected ) { CswCheckBoxArrayOptions.Option Option = new CswCheckBoxArrayOptions.Option(); Option.Key = ViewRow[KeyColumn].ToString(); Option.Label = ViewRow[NameColumn].ToString(); Option.Values.Add( CswConvert.ToBoolean( ViewRow[ValueColumn] ) ); CBAOptions.Options.Add( Option ); } } CBAOptions.ToJSON( (JObject) ParentObject[ElemName_Options] ); } // ToJSON()
/// <summary> /// Update logic /// </summary> public override void update() { CswNbtMetaDataNodeType TimeNT = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Unit (Time)" ); if( null != TimeNT ) { foreach( CswNbtObjClassUnitOfMeasure TimeNode in TimeNT.getNodes( false, false ) ) { if( "Months" == TimeNode.Name.Text ) { //According to Google, 1 month = 30.4368 days (based on averages, I'm assuming) TimeNode.ConversionFactor.Base = 3.285496; TimeNode.ConversionFactor.Exponent = -2; TimeNode.postChanges( false ); } } } CswNbtMetaDataObjectClass MaterialOc = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( NbtObjectClass.MaterialClass ); foreach( CswNbtMetaDataNodeType MaterialNt in MaterialOc.getNodeTypes() ) { CswNbtMetaDataNodeTypeProp SpecificGravityNtp = MaterialNt.getNodeTypePropByObjectClassProp( CswNbtObjClassMaterial.PropertyName.SpecificGravity ); if( null != SpecificGravityNtp ) { SpecificGravityNtp.Attribute1 = CswConvert.ToDbVal( true ).ToString(); } } }
public override void update() { // Fix any remnants of the old Design Mode (Design.aspx) CswTableUpdate ActionUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "31509_Action_Update", "actions" ); DataTable ActionTable = ActionUpdate.getTable( "where actionname = '" + CswEnumNbtActionName.Design + "'" ); if( ActionTable.Rows.Count > 0 ) { DataRow ActionRow = ActionTable.Rows[0]; // Fix the action row ActionRow["showinlist"] = CswConvert.ToDbVal( false ); ActionRow["url"] = DBNull.Value; ActionUpdate.update( ActionTable ); // Remove button from landing pages Int32 DesignActionId = CswConvert.ToInt32( ActionRow["actionid"] ); if( DesignActionId != Int32.MinValue ) { CswTableUpdate LandingPageUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate( "31509_LandingPage_update", "landingpage" ); DataTable LandingPageTable = LandingPageUpdate.getTable( "to_actionid", DesignActionId ); foreach( DataRow LandingPageRow in LandingPageTable.Rows ) { LandingPageRow.Delete(); } LandingPageUpdate.update( LandingPageTable ); } } // if( ActionTable.Rows.Count > 0 ) } // update()
}//SessionListWhere public Int32 getLoadCount(ICswResources CswResources) { Int32 ReturnVal = 0; _MasterSchemaResources = _getMasterSchemaResources((CswNbtResources)CswResources); if (null != _MasterSchemaResources) { CswArbitrarySelect CswArbitrarySelectSessionList = _MasterSchemaResources.makeCswArbitrarySelect("expired_session_list_query", "select count(*) as cnt from sessionlist" + _SessionListWhere(CswResources.AccessId)); DataTable SessionListTable = CswArbitrarySelectSessionList.getTable(); Int32 ExpiredSessionRecordCount = CswConvert.ToInt32(SessionListTable.Rows[0]["cnt"]); Int32 OrhpanSessionDataCount = _getOrphanRowCount((CswNbtResources)CswResources); CswArbitrarySelect ArbitrarySelectOrphanedNodes = _MasterSchemaResources.makeCswArbitrarySelect("orphaned_temp_nodes", "select count(*) as cnt from nodes n left outer join sessionlist s on n.sessionid=s.sessionid where istemp=1 and s.sessionid is null"); Int32 OrphanTempNodeCount = CswConvert.ToInt32(ArbitrarySelectOrphanedNodes.getTable().Rows[0]["cnt"]); ReturnVal = ExpiredSessionRecordCount + OrhpanSessionDataCount + OrphanTempNodeCount; _StaleDataExists = (ExpiredSessionRecordCount > 0 || OrhpanSessionDataCount > 0 || OrphanTempNodeCount > 0); } else { CswResources.CswLogger.reportError(new CswDniException("Unable to get load count of sessionlist records: The master schema resource object is null")); } return(ReturnVal); }//getLoadCount()
public JObject getNodeTypeProps(string NodeTypeName, string NodeTypeId, bool EditablePropsOnly) { JObject ReturnVal = new JObject(); CswNbtMetaDataNodeType NodeType; if (false == String.IsNullOrEmpty(NodeTypeName)) { NodeType = _CswNbtResources.MetaData.getNodeType(NodeTypeName); } else { NodeType = _CswNbtResources.MetaData.getNodeType(CswConvert.ToInt32(NodeTypeId)); } if (null != NodeType) { if (_userHasPermission(CswEnumNbtNodeTypePermission.View, NodeType)) { foreach (CswNbtMetaDataNodeTypeProp Prop in NodeType.getNodeTypeProps() .Where(p => EditablePropsOnly && false == p.getFieldType().IsDisplayType()) .OrderBy(p => p.PropName)) { string PropKey = "prop_" + Prop.PropId; ReturnVal[PropKey] = new JObject(); ReturnVal[PropKey]["id"] = Prop.PropId; ReturnVal[PropKey]["name"] = Prop.PropName; } } } return(ReturnVal); } // getNodeTypeProps()
/// <summary> /// Finalize the new Material /// </summary> public JObject commitMaterial(string MaterialDefinition) { JObject RetObj = new JObject(); JObject MaterialObj = CswConvert.ToJObject(MaterialDefinition); if (MaterialObj.HasValues) { JArray SizesArray = CswConvert.ToJArray(MaterialObj["sizeNodes"]); CswPrimaryKey MaterialId = new CswPrimaryKey(); MaterialId.FromString(CswConvert.ToString(MaterialObj["materialId"])); if (CswTools.IsPrimaryKey(MaterialId)) { CswNbtNode MaterialNode = _CswNbtResources.Nodes[MaterialId]; if (null != MaterialNode) { /* 1. Validate the new material and get its properties */ MaterialNode = _commitMaterialNode(MaterialObj); RetObj["createdmaterial"] = true; /* 2. Add the sizes */ if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.Containers)) { SizesArray = _removeDuplicateSizes(SizesArray); _addMaterialSizes(SizesArray, MaterialNode); RetObj["sizescount"] = SizesArray.Count; } /* 3. Add landingpage data */ RetObj["landingpagedata"] = _getLandingPageData(MaterialNode); } } } return(RetObj); }