Esempio n. 1
0
        public Dictionary <Int32, string> getPkDict(string Where = "", CswDateTime Date = null)
        {
            if (_PkDictsWhere == null)
            {
                _PkDictsWhere = new Dictionary <PkDictKey, Dictionary <int, string> >();
            }

            PkDictKey Key = new PkDictKey()
            {
                Date = Date, Where = Where
            };

            if (false == _PkDictsWhere.ContainsKey(Key))
            {
                DataTable Table;
                if (null == Date)
                {
                    CswCommaDelimitedString Select = new CswCommaDelimitedString();
                    Select.Add(_PkColumnName);
                    Select.Add(_NameColumnName);

                    string WhereClause = Where;
                    addModuleWhereClause(ref WhereClause);

                    Table = _TableSelect.getTable(Select, string.Empty, Int32.MinValue, WhereClause, false);
                }
                else
                {
                    string Sql = "select " + _PkColumnName + "," + _NameColumnName +
                                 "  from " + CswNbtAuditTableAbbreviation.getAuditTableSql(_CswNbtMetaDataResources.CswNbtResources, _TableSelect.TableName, Date) + " " + _TableSelect.TableName + " ";
                    addModuleWhereClause(ref Where);
                    Sql += Where;

                    CswArbitrarySelect AuditSelect = _CswNbtMetaDataResources.CswNbtResources.makeCswArbitrarySelect("MetaDataCollectionImpl_getpkdict_audit_select", Sql);
                    Table = AuditSelect.getTable();
                }
                Dictionary <Int32, string> Coll = new Dictionary <Int32, string>();
                foreach (DataRow Row in Table.Rows)
                {
                    Coll.Add(CswConvert.ToInt32(Row[_PkColumnName]), CswConvert.ToString(Row[_NameColumnName]));
                }
                _PkDictsWhere[Key] = Coll;
            }
            return(_PkDictsWhere[Key]);
        } // _PkDictsWhere(Where)
        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()
Esempio n. 3
0
        } // GetNodesToReport()

        public void AddNodeToReport(CswNbtNode Node)
        {
            CswCommaDelimitedString NodesStr = new CswCommaDelimitedString();

            NodesStr.FromString(NodesToReport.Text);

            NodesStr.Add(Node.NodeId.PrimaryKey.ToString(), AllowNullOrEmpty: false, IsUnique: true);

            NodesToReport.Text = NodesStr.ToString();
        } // AddNodeToReport()
Esempio n. 4
0
        public override void SyncGestalt()
        {
            CswCommaDelimitedString imageNames = new CswCommaDelimitedString();

            foreach (CswNbtSdBlobData.CswNbtBlob Image in Images)
            {
                imageNames.Add(Image.FileName);
            }
            SetPropRowValue(CswEnumNbtSubFieldName.Gestalt, CswEnumNbtPropColumn.Gestalt, imageNames.ToString());
        }
Esempio n. 5
0
        } // update()

        private void _updateAliasesValue( CswNbtMetaDataObjectClass UoMOC, CswNbtObjClassUnitOfMeasure UoMNode, string NewAliases )
        {
            // The new aliases we want to add
            CswCommaDelimitedString NewAliasesCommaDelimited = new CswCommaDelimitedString( NewAliases );
            CswCommaDelimitedString UpdatedAliases = UoMNode.AliasesAsDelimitedString;

            // Create a view of all UoM nodes and their Aliases property
            CswNbtView UoMView = _CswNbtSchemaModTrnsctn.makeView();
            CswNbtViewRelationship ParentRelationship = UoMView.AddViewRelationship( UoMOC, false );

            CswNbtMetaDataObjectClassProp AliasesOCP = UoMOC.getObjectClassProp( CswNbtObjClassUnitOfMeasure.PropertyName.Aliases );
            UoMView.AddViewProperty( ParentRelationship, AliasesOCP );

            CswCommaDelimitedString AliasesToRemove = new CswCommaDelimitedString();
            ICswNbtTree UoMNodesTree = _CswNbtSchemaModTrnsctn.getTreeFromView( UoMView, false );
            for( int i = 0; i < UoMNodesTree.getChildNodeCount(); i++ )
            {
                UoMNodesTree.goToNthChild( i );
                string CurrentNodeName = UoMNodesTree.getNodeNameForCurrentPosition();
                CswPrimaryKey CurrentNodeId = UoMNodesTree.getNodeIdForCurrentPosition();
                if( CurrentNodeId != UoMNode.NodeId )
                {
                    foreach( CswNbtTreeNodeProp TreeNodeProp in UoMNodesTree.getChildNodePropsOfNode() )
                    {
                        CswCommaDelimitedString CurrentUoMNodeAliases = new CswCommaDelimitedString();
                        CurrentUoMNodeAliases.FromString( TreeNodeProp.Gestalt, false, true );

                        foreach( string alias1 in NewAliasesCommaDelimited )
                        {
                            // If alias1 matches the NodeName or any of the Aliases on the Node, we don't want it
                            if( alias1.Equals( CurrentNodeName ) || CurrentUoMNodeAliases.Any( alias2 => alias1.Equals( alias2 ) ) )
                            {
                                AliasesToRemove.Add( alias1 );
                            }
                        }
                    }
                }
                UoMNodesTree.goToParentNode();
            }

            // Make the updated aliases for the node
            foreach( string alias1 in NewAliasesCommaDelimited )
            {
                if( false == AliasesToRemove.Contains( alias1 ) && false == UoMNode.AliasesAsDelimitedString.Contains( alias1 ) )
                {
                    UpdatedAliases.Add( alias1 );
                }
            }

            // Update the property value
            UoMNode.Aliases.Text = CswConvert.ToString( UpdatedAliases );
            UoMNode.postChanges( false );

        }//_updateAliasesValue()
        public override void update()
        {
            CswNbtMetaDataObjectClass     ChemicalOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass(CswEnumNbtObjectClass.ChemicalClass);
            CswNbtMetaDataObjectClassProp HazCats    = ChemicalOC.getObjectClassProp(CswNbtObjClassChemical.PropertyName.HazardCategories);

            CswCommaDelimitedString ListOpts = new CswCommaDelimitedString(HazCats.ListOptions);

            ListOpts.Add("C = Chronic");

            _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp(HazCats, CswEnumNbtObjectClassPropAttributes.listoptions, ListOpts.ToString());
        }
        private CswCommaDelimitedString _setLocationIds(String LocationId)
        {
            CswCommaDelimitedString     LocationIdCDS = new CswCommaDelimitedString();
            IEnumerable <CswPrimaryKey> LocationPKs   = _getLocationIds(LocationId);

            foreach (CswPrimaryKey LocationPK in LocationPKs)
            {
                LocationIdCDS.Add(LocationPK.PrimaryKey.ToString());
            }
            return(LocationIdCDS);
        }
Esempio n. 8
0
        public override void update()
        {

            CswNbtMetaDataObjectClass ContainerOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ContainerClass );
            CswNbtMetaDataObjectClassProp UndisposeOCP = ContainerOC.getObjectClassProp( CswNbtObjClassContainer.PropertyName.Undispose );
            CswNbtMetaDataObjectClassProp DisposeOCP = ContainerOC.getObjectClassProp( CswNbtObjClassContainer.PropertyName.Dispose );

            CswCommaDelimitedString PropIds = new CswCommaDelimitedString();
            foreach( CswNbtMetaDataNodeTypeProp UndisposeNTP in UndisposeOCP.getNodeTypeProps() )
            {
                PropIds.Add( UndisposeNTP.PropId.ToString() );
            }
            foreach( CswNbtMetaDataNodeTypeProp DisposeNTP in DisposeOCP.getNodeTypeProps() )
            {
                PropIds.Add( DisposeNTP.PropId.ToString() );
            }

            _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql( @"update jct_nodes_props jnp set hidden = 0 where nodetypepropid in (" + PropIds + ")" );

        } // update()
Esempio n. 9
0
        } // runGrid()

        private void _getGridProperties(IEnumerable <CswNbtViewRelationship> ChildRelationships, Collection <CswViewBuilderProp> Ret)
        {
            CswCommaDelimitedString             ColumnNames            = new CswCommaDelimitedString();
            Collection <CswNbtViewProperty>     PropsAtThisLevel       = new Collection <CswNbtViewProperty>();
            Collection <CswNbtViewRelationship> NextChildRelationships = new Collection <CswNbtViewRelationship>();

            //Iterate all Relationships at this level first. This ensures our properties are properly collected.
            foreach (CswNbtViewRelationship Relationship in ChildRelationships)
            {
                foreach (CswNbtViewProperty Property in from CswNbtViewProperty _Property
                         in Relationship.Properties
                         orderby _Property.Order, _Property.Name
                         where _Property.ShowInGrid
                         select _Property)
                {
                    PropsAtThisLevel.Add(Property);
                    _PropNamesOnDisplay.Add(Property.Name);
                }
                //This will make recursion smoother: we're always iterating the collection of relationships at the same distance from root.
                foreach (CswNbtViewRelationship ChildRelationship in Relationship.ChildRelationships)
                {
                    NextChildRelationships.Add(ChildRelationship);
                }
            }
            //Now iterate props
            foreach (CswNbtViewProperty Prop in PropsAtThisLevel)
            {
                CswViewBuilderProp VbProp   = new CswViewBuilderProp(Prop);
                string             PropName = Prop.Name.Trim().Replace(" ", "_").ToLower();
                if (false == ColumnNames.Contains(PropName))
                {
                    ColumnNames.Add(PropName);
                    Ret.Add(VbProp);
                }
                else
                {
                    //The Tree XML won't give us anything to map a "duplicate" prop/column back to the column definition. Leave our own breadcrumbs.
                    foreach (CswViewBuilderProp RetProp in Ret)
                    {
                        if (RetProp.PropNameUnique == PropName && false == RetProp.AssociatedPropIds.Contains(VbProp.MetaDataPropId.ToString()))
                        {
                            RetProp.AssociatedPropIds.Add(VbProp.MetaDataPropId.ToString());
                        }
                    }
                }
            }

            //Now recurse, damn you.
            if (NextChildRelationships.Count > 0)
            {
                _getGridProperties(NextChildRelationships, Ret);
            }
        }
Esempio n. 10
0
        public CswViewBuilderProp(CswNbtMetaDataNodeTypeProp NodeTypeProp)
        {
            CswNbtMetaDataNodeType nt = NodeTypeProp.getNodeType();

            if (null != nt)
            {
                OwnerName = nt.NodeTypeName;
            }
            FieldType = NodeTypeProp.getFieldTypeValue();
            //ListOptions.FromString( NodeTypeProp.ListOptions );
            ListOptions.FromString(NodeTypeProp.DesignNode.AttributeProperty[CswEnumNbtPropertyAttributeName.Options].AsText.Text);
            RelatedIdType = CswEnumNbtViewRelatedIdType.NodeTypeId;
            MetaDataPropNameWithQuestionNo = NodeTypeProp.PropNameWithQuestionNo;
            MetaDataPropId   = NodeTypeProp.FirstPropVersionId;
            MetaDataPropName = NodeTypeProp.PropName;
            MetaDataTypeName = NodeTypeProp.getNodeType().NodeTypeName;
            FieldTypeRule    = NodeTypeProp.getFieldTypeRule();
            Type             = CswEnumNbtViewPropType.NodeTypePropId;
            PropName         = MetaDataPropName;
            AssociatedPropIds.Add(MetaDataPropId.ToString());
            if (NodeTypeProp.ObjectClassPropId != Int32.MinValue)
            {
                AssociatedPropIds.Add(NodeTypeProp.ObjectClassPropId.ToString());
            }
        } //ctor Ntp
        private void onAliasesPropChange(CswNbtNodeProp Prop, bool Creating)
        {
            // Remove duplicates
            CswCommaDelimitedString AliasesWithoutDupes = new CswCommaDelimitedString();

            foreach (string Alias in AliasesAsDelimitedString.Where(Alias => false == AliasesWithoutDupes.Contains(Alias)))
            {
                AliasesWithoutDupes.Add(Alias);
            }
            Aliases.Text = CswConvert.ToString(AliasesWithoutDupes);

            _validateAliasUniqueness();
        }
        public static void getScheduledRuleStatus(ICswResources _CswResources, CswNbtScheduledRuleStatusReturn Return, object Request)
        {
            CswCommaDelimitedString    RuleStatus = new CswCommaDelimitedString();
            CswNbtWebServiceNbtManager ws         = new CswNbtWebServiceNbtManager((CswNbtResources)_CswResources, CswEnumNbtActionName.View_Scheduled_Rules);
            JObject AccessIds = ws.getActiveAccessIds();

            foreach (String AccessId in AccessIds["customerids"])
            {
                CswNbtScheduledRulesReturn Rules = new CswNbtScheduledRulesReturn();
                getScheduledRulesGrid(_CswResources, Rules, AccessId);
                foreach (CswExtJsGridRow GridRow in Rules.Data.Grid.rowData.rows)
                {
                    CswScheduleLogicDetail Rule = _getLogicDetailFromGridRow(GridRow, "ScheduledRules");
                    if (false == Rule.Disabled)
                    {
                        if (Rule.Reprobate)
                        {
                            DateTime TimeOfReprobate = Rule.LastRun > Rule.LastLoadCheck ? Rule.LastRun : Rule.LastLoadCheck;
                            RuleStatus.Add("REPROBATE on " + AccessId + ": " + Rule.RuleName + " as of " + TimeOfReprobate);
                        }
                        else
                        {
                            TimeSpan LastCheckInterval = DateTime.Now - Rule.LastLoadCheck;
                            TimeSpan RunTimeInterval   = Rule.getRunTimeInterval();
                            RunTimeInterval = RunTimeInterval.Add(new TimeSpan(1, 0, 0));    //1 hour buffer
                            if (LastCheckInterval > RunTimeInterval)
                            {
                                RuleStatus.Add("ERROR on " + AccessId + ": " + Rule.RuleName + " last checked load on " + Rule.LastLoadCheck);
                            }
                        }
                    }
                }
            }
            if (RuleStatus.Count == 0)
            {
                RuleStatus.Add("ALL SCHEDULED SERVICE RULES OK");
            }
            Return.Data.RuleStatus = RuleStatus.ToString();
        }
        /// <summary>
        /// Checks to be sure all values assigned are unique and valid against possible options
        /// </summary>
        public void ValidateValues()
        {
            CswCommaDelimitedString newVals = new CswCommaDelimitedString();

            foreach (string aval in Value)
            {
                if (Options.ContainsKey(aval) && false == newVals.Contains(aval))
                {
                    newVals.Add(aval);
                }
            }
            Value = newVals;
        } // ValidateValues()
        } // Options

        public override void SyncGestalt()
        {
            CswCommaDelimitedString NewGestalt = new CswCommaDelimitedString();

            foreach (string Key in this.Value)
            {
                if (Options.ContainsKey(Key))
                {
                    NewGestalt.Add(Options[Key]);
                }
            }
            SetPropRowValue(CswEnumNbtSubFieldName.Gestalt, CswEnumNbtPropColumn.Gestalt, NewGestalt.ToString());
        } // _setGestalt()
        public CswCommaDelimitedString getContainerLocationIds(CswNbtResources _CswNbtResources, CswNbtView ContainerLocationsView)
        {
            CswCommaDelimitedString ContainerLocations     = new CswCommaDelimitedString();
            ICswNbtTree             ContainerLocationsTree = _CswNbtResources.Trees.getTreeFromView(ContainerLocationsView, false, false, false);
            int ContainerLocationCount = ContainerLocationsTree.getChildNodeCount();

            for (int i = 0; i < ContainerLocationCount; i++)
            {
                ContainerLocationsTree.goToNthChild(i);
                ContainerLocations.Add(ContainerLocationsTree.getNodeIdForCurrentPosition().ToString());
                ContainerLocationsTree.goToParentNode();
            }
            return(ContainerLocations);
        }
Esempio n. 16
0
        /// <summary>
        /// Returns the set of available Import Definition Names
        /// </summary>
        public static CswCommaDelimitedString getDefinitionNames(CswNbtResources CswNbtResources)
        {
            CswCommaDelimitedString ret = new CswCommaDelimitedString();
            //CswTableSelect DefSelect = _CswNbtResources.makeCswTableSelect( "loadBindings_def_select1", CswNbtImportTables.ImportDef.TableName );
            string             Sql          = @"select distinct(" + CswNbtImportTables.ImportDef.definitionname + ") from " + CswNbtImportTables.ImportDef.TableName + "";
            CswArbitrarySelect DefSelect    = CswNbtResources.makeCswArbitrarySelect("loadBindings_def_select1", Sql);
            DataTable          DefDataTable = DefSelect.getTable();

            foreach (DataRow defrow in DefDataTable.Rows)
            {
                ret.Add(defrow[CswNbtImportTables.ImportDef.definitionname].ToString(), false, true);
            }
            return(ret);
        }
Esempio n. 17
0
        private CswCommaDelimitedString _getMolsWithNoCTab(CswNbtResources NbtResources)
        {
            CswCommaDelimitedString nonCTabedMols = new CswCommaDelimitedString();

            string             sql           = @"select nodeid from mol_data where ctab is null";
            CswArbitrarySelect arbSelect     = NbtResources.makeCswArbitrarySelect("getNonCTabedMols", sql);
            DataTable          nodesToUpdate = arbSelect.getTable();

            foreach (DataRow row in nodesToUpdate.Rows)
            {
                nonCTabedMols.Add(row["nodeid"].ToString());
            }

            return(nonCTabedMols);
        }
Esempio n. 18
0
        private CswNbtView _getReconciliationScansForOutOfScopeContainersView(ContainerData.ReconciliationRequest Request)
        {
            Collection <CswPrimaryKey> LocationIds = _getLocationIds(Request);

            CswNbtMetaDataObjectClass     LocationOC          = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.LocationClass);
            CswNbtMetaDataObjectClass     ContainerOC         = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerClass);
            CswNbtMetaDataObjectClassProp CLocationOCP        = ContainerOC.getObjectClassProp(CswNbtObjClassContainer.PropertyName.Location);
            CswNbtMetaDataObjectClass     ContainerLocationOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ContainerLocationClass);
            CswNbtMetaDataObjectClassProp ContainerOCP        = ContainerLocationOC.getObjectClassProp(CswNbtObjClassContainerLocation.PropertyName.Container);
            CswNbtMetaDataObjectClassProp TypeOCP             = ContainerLocationOC.getObjectClassProp(CswNbtObjClassContainerLocation.PropertyName.Type);
            CswNbtMetaDataObjectClassProp LocationOCP         = ContainerLocationOC.getObjectClassProp(CswNbtObjClassContainerLocation.PropertyName.Location);
            CswNbtMetaDataObjectClassProp ScanDateOCP         = ContainerLocationOC.getObjectClassProp(CswNbtObjClassContainerLocation.PropertyName.ScanDate);

            CswNbtView ContainerLocationsView = new CswNbtView(_CswNbtResources);
            //Filter to selected location (and all child locations if applicable)
            CswNbtViewRelationship LocationVR = ContainerLocationsView.AddViewRelationship(LocationOC, false);

            LocationVR.NodeIdsToFilterIn = LocationIds;
            CswCommaDelimitedString LocIds = new CswCommaDelimitedString();

            foreach (CswPrimaryKey LocId in LocationIds)
            {
                LocIds.Add(LocId.PrimaryKey.ToString());
            }
            //Filter to Container Location records of type Reconcile Scans in the current time scope
            CswNbtViewRelationship ContainerLocationVR = ContainerLocationsView.AddViewRelationship(LocationVR, CswEnumNbtViewPropOwnerType.Second, LocationOCP, false);
            CswNbtViewProperty     TypeVP = ContainerLocationsView.AddViewProperty(ContainerLocationVR, TypeOCP);

            ContainerLocationsView.AddViewPropertyFilter(TypeVP, FilterMode: CswEnumNbtFilterMode.Equals, Value: CswEnumNbtContainerLocationTypeOptions.ReconcileScans.ToString());
            CswNbtViewProperty ScanDateVP = ContainerLocationsView.AddViewProperty(ContainerLocationVR, ScanDateOCP);

            if (CswConvert.ToDateTime(Request.StartDate) > CswConvert.ToDateTime(Request.EndDate))
            {
                Request.StartDate = Request.EndDate;
            }
            ContainerLocationsView.AddViewPropertyFilter(ScanDateVP, FilterMode: CswEnumNbtFilterMode.GreaterThanOrEquals, Value: Request.StartDate);
            ContainerLocationsView.AddViewPropertyFilter(ScanDateVP, FilterMode: CswEnumNbtFilterMode.LessThanOrEquals, Value: Request.EndDate);
            ContainerLocationsView.setSortProperty(ScanDateVP, CswEnumNbtViewPropertySortMethod.Descending);
            //Filter to Containers not matching current location scope
            CswNbtViewRelationship ContainerVR = ContainerLocationsView.AddViewRelationship(ContainerLocationVR, CswEnumNbtViewPropOwnerType.First, ContainerOCP, false);
            CswNbtViewProperty     CLocVP      = ContainerLocationsView.AddViewProperty(ContainerVR, CLocationOCP);

            ContainerLocationsView.AddViewPropertyFilter(CLocVP, CswEnumNbtSubFieldName.NodeID, CswEnumNbtFilterMode.In, LocIds.ToString());

            return(ContainerLocationsView);
        }
Esempio n. 19
0
        /// <summary>
        /// Removes all rows flagged isdemo=1
        /// </summary>
        public void RemoveDemoData()
        {
            if ("1" == _CswNbtResources.ConfigVbls.getConfigVariableValue("is_demo"))
            {
                String                  AllDemoTablesSQL = " select distinct tablename from data_dictionary where columnname='isdemo' and tablename <> 'nodes' and tablename <> 'statistics' order by tablename ";
                CswArbitrarySelect      AllDemoTables    = _CswNbtResources.makeCswArbitrarySelect("Fetch Tables With Demo Data", AllDemoTablesSQL);
                DataTable               DemosDataTable   = AllDemoTables.getTable();
                CswCommaDelimitedString TablesToPrune    = new CswCommaDelimitedString();

                for (Int32 i = 0; i < DemosDataTable.Rows.Count; i++)
                {
                    TablesToPrune.Add(DemosDataTable.Rows[i]["tablename"].ToString());
                }
                TablesToPrune.Sort();

                //As of 01H-17, executing this in alphabetical order (minus nodes/statistics) will work
                foreach (String TableName in TablesToPrune)
                {
                    String NukeDemoDataSQL = "delete from " + TableName + " where isdemo = '" + CswConvert.ToDbVal(true) + "'";
                    try
                    {
                        _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql(NukeDemoDataSQL);
                        _CswNbtSchemaModTrnsctn.commitTransaction();
                    }
                    catch (Exception ex)
                    {
                        throw new CswDniException(CswEnumErrorType.Error, "Before records from the " + TableName + " table can be deleted, child records must be deleted first.", "Oracle threw an " + ex + " exception.");
                    }
                }

                // We just happen to know that these are the only 2 tables which have constraints and need to be dealt with separately
                try
                {
                    _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql("delete from nodes where isdemo= '" + CswConvert.ToDbVal(true) + "'");
                    _CswNbtSchemaModTrnsctn.commitTransaction();
                    _CswNbtSchemaModTrnsctn.execArbitraryPlatformNeutralSql("delete from statistics where isdemo= '" + CswConvert.ToDbVal(true) + "'");
                    _CswNbtSchemaModTrnsctn.commitTransaction();
                }
                catch (Exception ex)
                {
                    throw new CswDniException(CswEnumErrorType.Error, "Before records from the nodes/statistics table(s) can be deleted, child records must be deleted first.", "Oracle threw an " + ex + " exception.");
                }

                _CswNbtResources.ConfigVbls.setConfigVariableValue("is_demo", "0");
            }//if( "1" == _CswNbtResources.ConfigVbls.getConfigVariableValue( "is_demo" ) )
        }
Esempio n. 20
0
        public override void update()
        {
            //Rename sched rule
            CswTableUpdate schedRulesTU = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("RenameFingerprintRule", "scheduledrules");
            DataTable      schedRules   = schedRulesTU.getTable("where rulename = 'MolFingerprints'");

            if (schedRules.Rows.Count > 0)
            {
                schedRules.Rows[0]["rulename"] = CswEnumNbtScheduleRuleNames.MolData.ToString();
            }
            schedRulesTU.update(schedRules);

            //Get all Mol NTP ids
            CswCommaDelimitedString molNTPs = new CswCommaDelimitedString();

            foreach (CswNbtMetaDataNodeTypeProp molNTP in _CswNbtSchemaModTrnsctn.MetaData.getNodeTypeProps(CswEnumNbtFieldType.MOL))
            {
                molNTPs.Add(molNTP.PropId.ToString());
            }

            CswTableUpdate molDataUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("moldataUpdate_52735", "mol_data");
            DataTable      molDataTbl    = molDataUpdate.getEmptyTable();

            CswTableUpdate molDataPropsTblUpdate = _CswNbtSchemaModTrnsctn.makeCswTableUpdate("molselect_52735", "jct_nodes_props");
            DataTable      propsWithMols         = molDataPropsTblUpdate.getTable("where nodetypepropid in (" + molNTPs.ToString() + ") and clobdata is not null");

            foreach (DataRow molPropRow in propsWithMols.Rows)
            {
                string molString     = molPropRow["clobdata"].ToString();
                int    jctnodepropid = CswConvert.ToInt32(molPropRow["jctnodepropid"]);

                DataRow newMolDataTblRow = molDataTbl.NewRow();
                newMolDataTblRow["jctnodepropid"] = jctnodepropid;
                newMolDataTblRow["originalmol"]   = Encoding.UTF8.GetBytes(molString);
                newMolDataTblRow["contenttype"]   = ".mol";
                newMolDataTblRow["nodeid"]        = molPropRow["nodeid"];
                molDataTbl.Rows.Add(newMolDataTblRow);

                molPropRow["clobdata"] = string.Empty;
                molPropRow["field1"]   = "1";
            }

            molDataUpdate.update(molDataTbl);
            molDataPropsTblUpdate.update(propsWithMols);
        }
Esempio n. 21
0
        }//afterWriteNode()

        public override void beforeDeleteNode(bool DeleteAllRequiredRelatedNodes = false)
        {
            // case 22486 - Don't allow deleting targets of required relationships
            CswTableSelect          JctSelect    = _CswNbtResources.makeCswTableSelect("defaultBeforeDeleteNode_jnp_select", "jct_nodes_props");
            string                  WhereClause  = " where nodetypepropid in (select nodetypepropid from nodetype_props where isrequired = '1') and field1_fk = " + _CswNbtNode.NodeId.PrimaryKey.ToString();
            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);
                        }
                    }
                }
                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);
                }
            }
        } // beforeDeleteNode()
        public override void ReadJSON( JObject JObject, Dictionary<Int32, Int32> NodeMap, Dictionary<Int32, Int32> NodeTypeMap )
        {
            CswCommaDelimitedString NewSelectedViewIds = new CswCommaDelimitedString();

            CswCheckBoxArrayOptions CBAOptions = new CswCheckBoxArrayOptions();
            if( null != JObject[ElemName_Options] )
            {
                CBAOptions.ReadJson( (JObject) JObject[ElemName_Options] );
            }
            foreach( CswCheckBoxArrayOptions.Option Option in CBAOptions.Options )
            {
                if( Option.Values.Count > 0 && true == Option.Values[0] )
                {
                    NewSelectedViewIds.Add( Option.Key );
                }
            }
            SelectedViewIds = NewSelectedViewIds;
            RefreshViewName();
        } // ReadJSON()
        /// <summary>
        /// Assumes the _MasterSchemaResources is initialized
        /// </summary>
        /// <returns></returns>
        private string _getMasterSessionIdsWhere()
        {
            string         ret                       = "";
            bool           first                     = true;
            CswTableSelect SessionListIdsTS          = _MasterSchemaResources.makeCswTableSelect("get_all_session_ids", "sessionlist");
            DataTable      RemainingSessionListIdsDT = SessionListIdsTS.getTable(new CswCommaDelimitedString {
                "sessionid"
            });
            CswCommaDelimitedString SessionListIds = new CswCommaDelimitedString(0, "'");

            foreach (DataRow Row in RemainingSessionListIdsDT.Rows)
            {
                if (SessionListIds.Count == 999)  //can't have more than 1000 literals in an "in" clause"
                {
                    if (first)
                    {
                        ret   = " where sessionid not in (" + SessionListIds.ToString() + ") ";
                        first = false;
                    }
                    else
                    {
                        ret += " and sessionid not in (" + SessionListIds.ToString() + ") ";
                    }
                    SessionListIds.Clear();
                }
                SessionListIds.Add(Row["sessionid"].ToString());
            }

            if (SessionListIds.Count > 0) //if we never reached the max in the latest iteration
            {
                if (first)                //if we never reached the max period
                {
                    ret = " where sessionid not in (" + SessionListIds.ToString() + ") ";
                }
                else //if we never reached the max on any iteration other than the first
                {
                    ret += " and sessionid not in (" + SessionListIds.ToString() + ") ";
                }
            }

            return(ret);
        }
Esempio n. 24
0
            public InspectionState(CswNbtObjClassInspectionDesign Design)
            {
                _Design             = Design;
                UnAnsweredQuestions = new CswCommaDelimitedString();

                if (null != _Design && null != _Design.Node)
                {
                    CswNbtPropEnmrtrFiltered QuestionsFlt = _Design.Node.Properties[(CswEnumNbtFieldType)CswEnumNbtFieldType.Question];
                    foreach (CswNbtNodePropWrapper PropWrapper in QuestionsFlt)
                    {
                        _Questions.Add(PropWrapper);
                    }
                    foreach (CswNbtNodePropQuestion Question in _Questions)
                    {
                        if (string.IsNullOrEmpty(Question.Answer.Trim()))
                        {
                            UnAnsweredQuestions.Add(Question.Question);
                        }
                    }
                }
            }
        private CswCommaDelimitedString _getMaterialPKsForEP(CswPrimaryKey EPId)
        {
            CswCommaDelimitedString       EPMaterialPks = new CswCommaDelimitedString();
            CswNbtMetaDataObjectClass     ManufacturerEquivalentPartOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ManufacturerEquivalentPartClass);
            CswNbtMetaDataObjectClassProp EPOCP           = ManufacturerEquivalentPartOC.getObjectClassProp(CswNbtObjClassManufacturerEquivalentPart.PropertyName.EnterprisePart);
            CswNbtMetaDataObjectClassProp ManufacturerOCP = ManufacturerEquivalentPartOC.getObjectClassProp(CswNbtObjClassManufacturerEquivalentPart.PropertyName.Manufacturer);
            CswNbtMetaDataObjectClass     ManufacturerOC  = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ManufacturerClass);
            CswNbtMetaDataObjectClassProp MaterialOCP     = ManufacturerOC.getObjectClassProp(CswNbtObjClassManufacturer.PropertyName.Material);

            CswNbtView EPMatsView = new CswNbtView(_CswNbtResources);

            EPMatsView.ViewName = "Materials under " + EPId;
            CswNbtViewRelationship MEPVR = EPMatsView.AddViewRelationship(ManufacturerEquivalentPartOC, false);

            EPMatsView.AddViewPropertyAndFilter(MEPVR, EPOCP, SubFieldName: CswEnumNbtSubFieldName.NodeID, Value: EPId.PrimaryKey.ToString());
            CswNbtViewRelationship ManufacturerVR = EPMatsView.AddViewRelationship(MEPVR, CswEnumNbtViewPropOwnerType.First, ManufacturerOCP, false);
            CswNbtViewRelationship MatVR          = EPMatsView.AddViewRelationship(ManufacturerVR, CswEnumNbtViewPropOwnerType.First, MaterialOCP, false);

            ICswNbtTree EPMatsTree = _CswNbtResources.Trees.getTreeFromView(EPMatsView, false, true, true);

            for (int i = 0; i < EPMatsTree.getChildNodeCount(); i++)
            {
                EPMatsTree.goToNthChild(i);   //EP's MEPs
                if (EPMatsTree.getChildNodeCount() > 0)
                {
                    EPMatsTree.goToNthChild(0);   //MEP's Manufacturer
                    if (EPMatsTree.getChildNodeCount() > 0)
                    {
                        EPMatsTree.goToNthChild(0);   //Manufacturer's Material
                        EPMaterialPks.Add(EPMatsTree.getNodeIdForCurrentPosition().PrimaryKey.ToString());
                        EPMatsTree.goToParentNode();
                    }
                    EPMatsTree.goToParentNode();
                }
                EPMatsTree.goToParentNode();
            }

            return(EPMaterialPks);
        }
Esempio n. 26
0
        private CswCommaDelimitedString _getNonFingerPrintedMols(CswNbtResources CswNbtResources)
        {
            CswCommaDelimitedString nonFingerprintedMols = new CswCommaDelimitedString();

            string             sql       = @"select jnp.nodeid from nodetype_props ntp
                                    join jct_nodes_props jnp on ntp.nodetypepropid = jnp.nodetypepropid 
                                        where ntp.fieldtypeid = (select fieldtypeid from field_types ft where ft.fieldtype = 'MOL')
                                            and jnp.clobdata is not null 
                                            and not exists (select nodeid from mol_keys where nodeid = jnp.nodeid)";
            CswArbitrarySelect arbSelect = CswNbtResources.makeCswArbitrarySelect("getNonFingerprintedMols", sql);

            int       lowerBound    = 0;
            int       upperBound    = 500;
            DataTable jctnodesprops = arbSelect.getTable(lowerBound, upperBound, false, false);   //only get up to 500 records to do in a day

            foreach (DataRow row in jctnodesprops.Rows)
            {
                nonFingerprintedMols.Add(row["nodeid"].ToString());
            }

            return(nonFingerprintedMols);
        }
        /// <summary>
        /// The actual update call
        /// </summary>
        public override void update()
        {
            string ExceptionText = string.Empty;
            if( _CswNbtSchemaModTrnsctn.IsDbLinkConnectionHealthy( CswScheduleLogicNbtCAFImport.CAFDbLink, ref ExceptionText ) )
            {

                CswArbitrarySelect ArbTableSelect = _CswNbtSchemaModTrnsctn.makeCswArbitrarySelect( "nbtimportqueue_table_check", "select table_name from user_tables@" + CswScheduleLogicNbtCAFImport.CAFDbLink + " where lower(table_name)='nbtimportqueue'" );
                DataTable CafTable = ArbTableSelect.getTable();
                if( CafTable.Rows.Count == 0 )
                {
                    throw new CswDniException( "The nbtimportqueue table is missing." );
                }
                else
                {
                    CswArbitrarySelect ArbColumnSelect = _CswNbtSchemaModTrnsctn.makeCswArbitrarySelect( "nbtimportqueue_column_check", "select lower(column_name) col from user_tab_columns@" + CswScheduleLogicNbtCAFImport.CAFDbLink + " where lower(table_name)='nbtimportqueue'" );
                    DataTable CafColumns = ArbColumnSelect.getTable();

                    CswCommaDelimitedString ActualColumns = new CswCommaDelimitedString();
                    foreach( DataRow Row in CafColumns.Rows )
                    {
                        string ColumnName = CswConvert.ToString( Row["col"] );
                        ActualColumns.Add( ColumnName );
                    }

                    CswCommaDelimitedString FailedOnColumns = new CswCommaDelimitedString();
                    CswCommaDelimitedString ExpectedColumns = new CswCommaDelimitedString() { "nbtimportqueueid", "state", "itempk", "priority", "errorlog", "sheetname" };
                    foreach( string ExpectedColumn in ExpectedColumns.Where( ExpectedColumn => false == ActualColumns.Contains( ExpectedColumn ) ) )
                    {
                        FailedOnColumns.Add( ExpectedColumn );
                    }

                    if( FailedOnColumns.Count > 0 )
                    {
                        throw new CswDniException( "The nbtimportqueue is expected to contain these columns {" + ExpectedColumns.ToString() + "}, but the following columns were missing {" + FailedOnColumns.ToString() + "}." );
                    }

                }
            }
        }
Esempio n. 28
0
        public CswNbtWebServiceMainMenu(CswNbtResources CswNbtResources, string LimitMenuTo = null)
        {
            _CswNbtResources = CswNbtResources;
            if (false == string.IsNullOrEmpty(LimitMenuTo))
            {
                CswCommaDelimitedString MenuItemsToKeep = new CswCommaDelimitedString();

                CswCommaDelimitedString MenuItemsToFind = new CswCommaDelimitedString();
                MenuItemsToFind.FromString(LimitMenuTo);
                if (MenuItemsToFind.Count > 0)
                {
                    foreach (string Item in MenuItemsToFind)
                    {
                        if (_MenuItems.Contains(Item))
                        {
                            MenuItemsToKeep.Add(Item);
                        }
                    }
                    _MenuItems = MenuItemsToKeep;
                }
            }
        }
Esempio n. 29
0
        } //ctor Vp

        private void setObjectClassPropListOptions(CswNbtMetaDataObjectClassProp ObjectClassProp)
        {
            if (ObjectClassProp.ListOptions != string.Empty)
            {
                ListOptions.FromString(ObjectClassProp.ListOptions);
            }
            else
            {
                // Get all options from all nodetypes
                foreach (CswNbtMetaDataNodeTypeProp VPNodeTypeProp in ObjectClassProp.getNodeTypeProps())
                {
                    CswCommaDelimitedString NTPListOptions = new CswCommaDelimitedString();
                    //NTPListOptions.FromString( VPNodeTypeProp.ListOptions );
                    if (VPNodeTypeProp.DesignNode.AttributeProperty.ContainsKey(CswEnumNbtPropertyAttributeName.Options))
                    {
                        NTPListOptions.FromString(VPNodeTypeProp.DesignNode.AttributeProperty[CswEnumNbtPropertyAttributeName.Options].AsText.Text);
                    }
                    foreach (string Option in NTPListOptions)
                    {
                        ListOptions.Add(Option, false, true);
                    }
                }
            }
        } // setObjectClassPropListOptions()
        public override void update()
        {
            CswNbtMetaDataObjectClass ChemicalOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.ChemicalClass );
            CswNbtMetaDataObjectClassProp ViewSDSOCP = ChemicalOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.ViewSDS );
            CswNbtMetaDataObjectClassProp RequestOCP = ChemicalOC.getObjectClassProp( CswNbtObjClassChemical.PropertyName.Request );

            CswCommaDelimitedString ViewSDSNTPIds = new CswCommaDelimitedString();
            CswCommaDelimitedString RequestNTPIds = new CswCommaDelimitedString();

            foreach( CswNbtMetaDataNodeTypeProp ViewSDSNTP in ViewSDSOCP.getNodeTypeProps() )
            {
                ViewSDSNTPIds.Add( ViewSDSNTP.PropId.ToString() );
            }

            foreach( CswNbtMetaDataNodeTypeProp RequestNTP in RequestOCP.getNodeTypeProps() )
            {
                RequestNTPIds.Add( RequestNTP.PropId.ToString() );
            }

            string sql = @"select j.nodeid, j.nodetypepropid, count(nodeid) as cnt from jct_nodes_props j
                            where j.nodetypepropid in (" + ViewSDSNTPIds.ToString() + ") or j.nodetypepropid in (" + RequestNTPIds.ToString() + ") " +
                         @"group by j.nodeid, j.nodetypepropid
                            having count(nodeid) > 1";
            CswArbitrarySelect arbSel = _CswNbtSchemaModTrnsctn.makeCswArbitrarySelect( "GetDupRowsNodeIds", sql );
            CswCommaDelimitedString NodeIds = new CswCommaDelimitedString();
            DataTable dupTbl = arbSel.getTable();
            foreach( DataRow row in dupTbl.Rows )
            {
                NodeIds.Add( row["nodeid"].ToString() );
            }

            _deleteDuplicateRows( NodeIds, ViewSDSNTPIds );
            _deleteDuplicateRows( NodeIds, RequestNTPIds );


        } // update()