public static void GetFilterOpts(ICswResources CswResources, CswNbtExplorerReturn Return, string Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            CswCommaDelimitedString ValsCDS = new CswCommaDelimitedString();

            Return.Data.FilterVal = CswNbtArborGraph._setDefaultFilterVal(NbtResources);
            ValsCDS.FromString(Return.Data.FilterVal);

            foreach (CswNbtMetaDataNodeType NodeType in NbtResources.MetaData.getNodeTypes())
            {
                Return.Data.Opts.Add(new ArborFilterOpt()
                {
                    selected = ValsCDS.Contains("NT_" + NodeType.NodeTypeId),
                    text     = NodeType.NodeTypeName,
                    value    = "NT_" + NodeType.NodeTypeId.ToString()
                });
            }

            foreach (CswNbtMetaDataObjectClass ObjClass in NbtResources.MetaData.getObjectClasses())
            {
                Return.Data.Opts.Add(new ArborFilterOpt()
                {
                    selected = ValsCDS.Contains("OC_" + ObjClass.ObjectClassId.ToString()),
                    text     = ObjClass.ObjectClassName,
                    value    = "OC_" + ObjClass.ObjectClassId.ToString()
                });
            }
        }
        private static void _recurseForRelatingNodes(CswNbtResources NbtResources, CswNbtExplorerReturn Return, CswNbtNode Node, int Level, string OwnerIdStr)
        {
            CswNbtMetaDataNodeType TargetNodeType = Node.getNodeType();

            foreach (CswNbtMetaDataNodeTypeProp RelNTP in TargetNodeType.getNodeTypeProps(CswEnumNbtFieldType.Relationship))    //TODO: Locations are just like relationships, we should be able to handle them
            {
                CswNbtNodePropRelationship RelProp = Node.Properties[RelNTP];
                string Icon = _getIconFromRelationshipProp(NbtResources, RelNTP);
                if (CswTools.IsPrimaryKey(RelProp.RelatedNodeId))
                {
                    CswNbtNode             TargetNode = NbtResources.Nodes[RelProp.RelatedNodeId];
                    CswNbtMetaDataNodeType TargetNT   = TargetNode.getNodeType();

                    if (FilterVal.Contains("NT_" + TargetNode.NodeTypeId) || FilterVal.Contains("OC_" + TargetNode.getObjectClassId()))
                    {
                        string targetIdStr = OwnerIdStr + "_" + RelProp.RelatedNodeId.ToString();
                        _addToGraph(Return, RelProp.PropName + ": " + RelProp.CachedNodeName, Node.NodeId.ToString(), RelProp.RelatedNodeId.ToString(), Icon, Level, "Instance", RelProp.RelatedNodeId.ToString(), TargetNT.NodeTypeName, RelNTP.PropId);

                        if (Level + 1 <= MAX_DEPTH)
                        {
                            _recurseForRelatedNTs(NbtResources, Return, TargetNode.NodeTypeId, 1, RelProp.RelatedNodeId.ToString());
                        }

                        if (Level + 1 <= MAX_DEPTH)
                        {
                            _recurseForRelatingNodes(NbtResources, Return, TargetNode, Level + 1, targetIdStr);
                        }
                    }
                }
            }
        }
Esempio n. 3
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()
Esempio n. 4
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);
            }
        }
        /// <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()
        public override void update()
        {
            CswNbtMetaDataNodeType LabSafetyCheckListNt = _CswNbtSchemaModTrnsctn.MetaData.getNodeType( "Lab Safety Checklist" );
            if(null != LabSafetyCheckListNt)
            {
                CswNbtMetaDataNodeType LabSafetyLatest = LabSafetyCheckListNt.getNodeTypeLatestVersion();
                foreach ( CswNbtMetaDataNodeTypeProp NodeTypeProp in LabSafetyLatest.getNodeTypeProps() )
                {
                    if(NodeTypeProp.getFieldTypeValue() == CswNbtMetaDataFieldType.NbtFieldType.Question)
                    {
                        CswCommaDelimitedString AllowedAnswers = new CswCommaDelimitedString();
                        AllowedAnswers.FromString(NodeTypeProp.ListOptions);
                        if( AllowedAnswers.Contains( "Yes", false ) )
                        {
                            NodeTypeProp.Extended = "Yes";
                        }
                    }
                }
            }

        }//Update()
 /// <summary>
 /// Check to see if a value is present
 /// </summary>
 public bool CheckValue(string ValueToCheck)
 {
     return(Value.Contains(ValueToCheck));
 }
Esempio n. 8
0
        public override void update()
        {

            #region Create Signal Word Nodes

            Dictionary<string, string> DangerDictionary = new Dictionary<string, string>()
                {
                    {"Bulgarian", "опасност"},
                    {"Spanish", "peligro"},
                    {"Chinese", "危险"},
                    {"Czech", "nebezpečí"},
                    {"Danish", "Danger"},
                    {"German", "Danger"},
                    {"Estonian", "oht"},
                    {"Greek", "κίνδυνος"},
                    {"English", "Danger"},
                    {"French", "danger"},
                    {"Irish", "Danger"},
                    {"Italian", "pericolo"},
                    {"Latvian", "briesmas"},
                    {"Lithuanian", "pavojus"},
                    {"Hungarian", "veszély"},
                    {"Maltese", "periklu"},
                    {"Dutch", "gevaar"},
                    {"Polish", "niebezpieczeństwo"},
                    {"Portuguese", "perigo"},
                    {"Romanian", "pericol"},
                    {"Slovac", "nebezpečenstvo"},
                    {"Slovenian", "nevarnost"},
                    {"Finnish", "vaara"},
                    {"Swedish", "fara"},
                };

            Dictionary<string, string> WarningDictionary = new Dictionary<string, string>()
                {
                    {"Bulgarian", "Предупреждение"},
                    {"Spanish", "Advertencia"},
                    {"Chinese", "警告"},
                    {"Czech", "Upozornění"},
                    {"Danish", "advarsel"},
                    {"German", "Warnung"},
                    {"Estonian", "Hoiatus"},
                    {"Greek", "προειδοποίηση"},
                    {"English", "Warning"},
                    {"French", "avertissement"},
                    {"Irish", "rabhadh"},
                    {"Italian", "Attenzione"},
                    {"Latvian", "brīdinājums"},
                    {"Lithuanian", "Įspėjimas"},
                    {"Hungarian", "Warning"},
                    {"Maltese", "twissija"},
                    {"Dutch", "waarschuwing"},
                    {"Polish", "Ostrzeżenie"},
                    {"Portuguese", "aviso"},
                    {"Romanian", "Atenție"},
                    {"Slovac", "Upozornenie"},
                    {"Slovenian", "Opozorilo"},
                    {"Finnish", "Varoitus"},
                    {"Swedish", "Varning"},
                };


            CswNbtMetaDataObjectClass GHSOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.GHSClass );
            CswNbtMetaDataObjectClass GHSSignalWordOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.GHSSignalWordClass );
            CswNbtMetaDataNodeType SignalWordNodeType = GHSSignalWordOC.getNodeTypes().FirstOrDefault();
            if( null == SignalWordNodeType )
            {
                SignalWordNodeType = _CswNbtSchemaModTrnsctn.MetaData.makeNewNodeType( GHSSignalWordOC.ObjectClassId, "GHS Signal Word", "System" );
                SignalWordNodeType.setNameTemplateText( CswNbtMetaData.MakeTemplateEntry( CswNbtObjClassGHSSignalWord.PropertyName.Code ) );

                CswNbtView SignalWordRelationshipPropView = _CswNbtSchemaModTrnsctn.makeSafeView( "GHS Signal Word Relationship Prop View", CswEnumNbtViewVisibility.Hidden );
                SignalWordRelationshipPropView.AddViewRelationship( GHSSignalWordOC, false );
                SignalWordRelationshipPropView.save();

                CswNbtMetaDataNodeTypeProp EnglishNTP = SignalWordNodeType.getNodeTypePropByObjectClassProp( CswNbtObjClassGHSSignalWord.PropertyName.English );
                EnglishNTP.updateLayout( CswEnumNbtLayoutType.Add, true );

                foreach( CswNbtMetaDataNodeTypeProp SignalWordNTP in GHSOC.getObjectClassProp( CswNbtObjClassGHS.PropertyName.SignalWord ).getNodeTypeProps() )
                {
                    SignalWordNTP.ViewId = SignalWordRelationshipPropView.ViewId;
                }

            }
            CswNbtNode DangerNode = _createSignalWord( SignalWordNodeType, DangerDictionary );
            CswNbtNode WarningNode = _createSignalWord( SignalWordNodeType, WarningDictionary );

            #endregion

            #region Update Existing GHS nodes

            CswCommaDelimitedString NodeIds = new CswCommaDelimitedString();
            foreach( KeyValuePair<CswPrimaryKey, string> Pair in GHSOC.getNodeIdAndNames( false, true, false, true ) )
            {
                NodeIds.Add( Pair.Key.PrimaryKey.ToString() );
            }

            _updateGHSNodes( "Danger", DangerNode, NodeIds, GHSOC );
            _updateGHSNodes( "Warning", WarningNode, NodeIds, GHSOC );

            #endregion

            #region Add New Language Opts to User

            CswNbtMetaDataObjectClass UserOC = _CswNbtSchemaModTrnsctn.MetaData.getObjectClass( CswEnumNbtObjectClass.UserClass );
            CswNbtMetaDataObjectClassProp LanguageProp = UserOC.getObjectClassProp( CswNbtObjClassUser.PropertyName.Language );

            CswCommaDelimitedString ListOpts = new CswCommaDelimitedString() { LanguageProp.ListOptions };

            foreach( string Language in CswNbtObjClassGHS.LanguageCodeMap.Keys )
            {
                if( false == ListOpts.Contains( Language ) )
                {
                    ListOpts.Add( Language.ToLower() );
                }
            }

            _CswNbtSchemaModTrnsctn.MetaData.UpdateObjectClassProp( LanguageProp, CswEnumNbtObjectClassPropAttributes.listoptions, ListOpts.ToString() );

            #endregion

        } // update()
        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();
        }
Esempio n. 10
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;
                }
            }
        }
        public static void getTimelines(ICswResources CswResources, CswNbtSchedServiceTimeLineReturn Return, CswNbtSchedServiceTimeLineRequest Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            DateTime StartDate = new DateTime();
            int      counter   = 0;

            CswColorGenerator ColorGenerator = new CswColorGenerator();

            int SeriesNo = 30;

            Dictionary <string, Series> TimeLineData = new Dictionary <string, Series>();
            HashSet <string>            seen         = new HashSet <string>();

            string LogFileLocation = NbtResources.SetupVbls[CswEnumSetupVariableNames.LogFileLocation];

            _getLogFiles(NbtResources, Return, LogFileLocation);   //Order the log files by last modified date

            //Case 30403 - if the current user is not ChemSW_Admin, scope timeline to the users schema
            if (NbtResources.CurrentNbtUser.Username != CswAuthenticator.ChemSWAdminUsername)
            {
                Request.FilterSchemaTo = NbtResources.AccessId;
            }

            if (Return.Data.FilterData.LogFiles.Count > 0)
            {
                //If no log file is selected, default to the last log file modified
                string       selectedFile = String.IsNullOrEmpty(Request.SelectedLogFile) ? Return.Data.FilterData.LogFiles[0] : Request.SelectedLogFile;
                StreamReader file         = new StreamReader(LogFileLocation + @"\" + selectedFile);
                string       line;
                while ((line = file.ReadLine()) != null)
                {
                    line = line.Replace("\"", "");
                    string[] splitLine = line.Split(',');
                    string   MsgType   = splitLine[0];

                    if ((MsgType.Equals("PerOp") || MsgType.Equals("Error")))
                    {
                        string Schema        = splitLine[1];
                        string StartTime     = splitLine[20];
                        string OpName        = splitLine[23].Split(':')[0]; //this is something like "GenNode: Execution" and all we want is "GenNode"
                        double ExecutionTime = CswConvert.ToDouble(splitLine[28]);
                        string ErrMsg        = splitLine[9];

                        if (MsgType.Equals("Error"))
                        {
                            OpName        = "Error";
                            ExecutionTime = double.MinValue;
                        }
                        string LegendName = Schema + " " + OpName;

                        _populateFilterData(NbtResources, Return, OpName, Schema, seen);

                        DateTime thisStartDate = CswConvert.ToDateTime(StartTime);

                        DateTime FilterDateStart = CswConvert.ToDateTime(Request.FilterStartTimeTo);
                        DateTime FilterDateEnd   = CswConvert.ToDateTime(Request.FilterEndTimeTo);
                        CswCommaDelimitedString FilterSchemas = new CswCommaDelimitedString();
                        FilterSchemas.FromString(Request.FilterSchemaTo);
                        CswCommaDelimitedString FilterOps = new CswCommaDelimitedString();
                        FilterOps.FromString(Request.FilterOpTo);

                        if (((thisStartDate >= FilterDateStart && thisStartDate <= FilterDateEnd) || (DateTime.MinValue == FilterDateStart && DateTime.MinValue == FilterDateEnd)) &&
                            (FilterSchemas.Contains(Schema) || String.IsNullOrEmpty(Request.FilterSchemaTo)) &&
                            (FilterOps.Contains(OpName) || String.IsNullOrEmpty(Request.FilterOpTo)))
                        {
                            if (FilterSchemas.IsEmpty || FilterOps.IsEmpty)  //If no schema filter is set we want to generate a timeline of each schema + all the rules that ran
                            {
                                if (FilterOps.IsEmpty)
                                {
                                    if (MsgType.Equals("Error"))
                                    {
                                        //If we're mashing all schema errors together, we do not show what the msg or schema was was since there are probably many, just that an error occured.
                                        LegendName = "Error";
                                        OpName     = "";
                                        ErrMsg     = "";
                                        Schema     = "";
                                    }
                                    else
                                    {
                                        //If we're mashing all schema together, we don't care what op ran since there are many, just show that this schema was running something
                                        LegendName = Schema;
                                        OpName     = "";
                                    }
                                }
                                else
                                {
                                    //If no schema is selected, but there are Op filters, we mash the Ops on each Schema together
                                    LegendName = OpName;
                                    Schema     = "";
                                }
                            }

                            if (0 == counter)
                            {
                                StartDate = CswConvert.ToDateTime(StartTime);
                            }
                            counter++;

                            double DataStartS = (thisStartDate - StartDate).TotalMilliseconds / 1000;
                            double DataEndS   = double.MinValue;
                            if (MsgType.Equals("PerOp"))
                            {
                                DataEndS = DataStartS + ExecutionTime / 1000;
                            }

                            Series ThisSeries;
                            if (TimeLineData.ContainsKey(LegendName))
                            {
                                ThisSeries = TimeLineData[LegendName];
                            }
                            else
                            {
                                ThisSeries = new Series()
                                {
                                    label      = LegendName,
                                    SchemaName = Schema,
                                    OpName     = OpName,
                                    SeriesNo   = SeriesNo,
                                    ErrorMsg   = ErrMsg
                                };
                                TimeLineData.Add(LegendName, ThisSeries);
                                SeriesNo += 90;
                            }
                            _processData(ThisSeries, DataStartS, DataEndS, ExecutionTime, thisStartDate.ToString(), ColorGenerator);
                        }
                    } //if( splitLine.Length >= 28 && splitLine[0].Equals( "PerOp" ) )
                }     // while( ( line = file.ReadLine() ) != null && counter <= maxLines )

                foreach (Series series in TimeLineData.Values)
                {
                    Return.Data.Series.Add(series);
                }
            }
        }//getTimelines()
Esempio n. 12
0
        protected override void beforeWriteNodeLogic( bool Creating, bool OverrideUniqueValidation )
        {
            // The user cannot change his or her own Administrator privileges.
            if( Administrator.wasAnySubFieldModified() &&
                Administrator.Checked != CswConvert.ToTristate( Administrator.GetOriginalPropRowValue() ) &&
                _CswNbtResources.CurrentUser.RoleId == _CswNbtNode.NodeId )
            {
                _CswNbtNode.Properties.clearModifiedFlag();  // prevents multiple error messages from appearing if we attempt to write() again
                throw new CswDniException( CswEnumErrorType.Warning, "You may not change your own administrator status", "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to edit the Administrator property of their own Role" );
            }

            // case 22512
            // also case 22557 - use the original name, not the new one
            CswNbtNodePropWrapper NamePropWrapper = Node.Properties[PropertyName.Name];
            if( NamePropWrapper.GetOriginalPropRowValue( _CswNbtResources.MetaData.getFieldTypeRule( NamePropWrapper.getFieldTypeValue() ).SubFields.Default.Column ) == ChemSWAdminRoleName &&
                _CswNbtResources.CurrentNbtUser.Username != CswNbtObjClassUser.ChemSWAdminUsername &&
                false == ( _CswNbtResources.CurrentNbtUser is CswNbtSystemUser ) )
            {
                throw new CswDniException( CswEnumErrorType.Warning, "The " + ChemSWAdminRoleName + " role cannot be edited", "Current user (" + _CswNbtResources.CurrentUser.Username + ") attempted to edit the '" + ChemSWAdminRoleName + "' role." );
            }

            if( NodeTypePermissions.wasAnySubFieldModified( false ) )
            {
                // case 25444 - was it *really* modified?
                CswNbtNodePropWrapper NodeTypePermissionsPropWrapper = Node.Properties[PropertyName.NodeTypePermissions];

                string NodeTypePermissionsOriginalValueStr = NodeTypePermissionsPropWrapper.GetOriginalPropRowValue( CswEnumNbtPropColumn.ClobData );
                CswCommaDelimitedString NodeTypePermissionsOriginalValue = new CswCommaDelimitedString();
                NodeTypePermissionsOriginalValue.FromString( NodeTypePermissionsOriginalValueStr );

                if( NodeTypePermissions.Value != NodeTypePermissionsOriginalValue )
                {
                    // Prevent granting permission to Design nodetypes without Design Action permission
                    if( NodeTypePermissions.Gestalt.Contains( "Design" ) &&   // shortcut
                        false == _CswNbtResources.Permit.can( CswEnumNbtActionName.Design, this ) )
                    {
                        throw new CswDniException( CswEnumErrorType.Warning, "You may not grant access to Design NodeTypes without the Design Action Permission",
                                                   "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to grant access to Design NodeTypes on role: " + _CswNbtNode.NodeName );
                    }
                }
            }

            // case 22437
            if( ActionPermissions.wasAnySubFieldModified() )
            {
                // case 25444 - was it *really* modified?
                CswNbtNodePropWrapper ActionPermissionsPropWrapper = Node.Properties[PropertyName.ActionPermissions];
                string ActionPermissionsOriginalValueStr = ActionPermissionsPropWrapper.GetOriginalPropRowValue( ( (CswNbtFieldTypeRuleMultiList) _CswNbtResources.MetaData.getFieldTypeRule( ActionPermissionsPropWrapper.getFieldTypeValue() ) ).ValueSubField.Column );
                CswCommaDelimitedString ActionPermissionsOriginalValue = new CswCommaDelimitedString();
                ActionPermissionsOriginalValue.FromString( ActionPermissionsOriginalValueStr );

                if( ActionPermissions.Value != ActionPermissionsOriginalValue )
                {
                    // You can never grant your own action permissions
                    if( _CswNbtResources.CurrentUser.RoleId == _CswNbtNode.NodeId && this.Name.Text != ChemSWAdminRoleName )
                    {
                        // case 26346 - we might be trimming invalid actions out automatically, 
                        // so just throw if an action permissions is being ADDED, not removed
                        bool ActionAdded = false;
                        foreach( string ActionStr in ActionPermissions.Value )
                        {
                            if( false == ActionPermissionsOriginalValue.Contains( ActionStr ) )
                            {
                                ActionAdded = true;
                            }
                        }

                        if( ActionAdded )
                        {
                            throw new CswDniException( CswEnumErrorType.Warning, "You may not grant access to actions for which you have no permissions",
                                "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to edit their own action permissions on role: " + _CswNbtNode.NodeName );
                        }
                    }
                    // You can only grant action permissions on other roles to which you have access
                    foreach( CswNbtAction Action in _CswNbtResources.Actions )
                    {
                        if( true == _CswNbtResources.Permit.can( Action, this ) ) // permission is being granted
                        {
                            if( ( Action.Name == CswEnumNbtActionName.Design ||
                                  Action.Name == CswEnumNbtActionName.Create_Inspection || //Case 24288
                                  Action.Name == CswEnumNbtActionName.View_Scheduled_Rules ) && //Case 28564
                                _CswNbtResources.CurrentNbtUser.Rolename != ChemSWAdminRoleName &&  //Case 28433: chemsw_admin can grant Design to anyone.
                                false == _CswNbtResources.IsSystemUser )
                            {
                                // case 23677
                                throw new CswDniException( CswEnumErrorType.Warning, "You may not grant access to " + Action.DisplayName + " to this role",
                                    "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to grant access to action " + Action.DisplayName + " to role " + _CswNbtNode.NodeName );
                            }
                            //Case 29338 - If the Role has no Material NT create permissions, remove the Create Material action permission
                            if( Action.Name == CswEnumNbtActionName.Create_Material )
                            {
                                CswNbtMetaDataPropertySet MaterialPS = _CswNbtResources.MetaData.getPropertySet( CswEnumNbtPropertySetName.MaterialSet );

                                bool HasOneMaterialCreate = false;
                                foreach( CswNbtMetaDataObjectClass MaterialOc in MaterialPS.getObjectClasses() )
                                {
                                    foreach( CswNbtMetaDataNodeType MaterialNt in MaterialOc.getNodeTypes() )
                                    {
                                        string NodeTypePermission = MakeNodeTypePermissionValue(
                                            MaterialNt.FirstVersionNodeTypeId,
                                            CswEnumNbtNodeTypePermission.Create );

                                        HasOneMaterialCreate = HasOneMaterialCreate ||
                                                               NodeTypePermissions.CheckValue( NodeTypePermission );
                                    }
                                }
                                if( false == HasOneMaterialCreate )
                                {
                                    ActionPermissions.RemoveValue( MakeActionPermissionValue( Action ) );
                                }
                            }
                            if( false == _CswNbtResources.Permit.can( Action, _CswNbtResources.CurrentNbtUser ) )
                            {
                                throw new CswDniException( CswEnumErrorType.Warning, "You may not grant access to actions for which you have no permissions",
                                    "User (" + _CswNbtResources.CurrentUser.Username + ") attempted to grant access to action " + Action.DisplayName + " to role " + _CswNbtNode.NodeName );
                            }
                        } // if( true == _CswNbtResources.Permit.can( Action, this ) )
                    } // foreach( string ActionNameString in ActionPermissions.YValues )
                } // if( ActionPermissions.Value != ActionPermissionsOriginalValue )
            } // if( ActionPermissions.getAnySubFieldModified() )
        }//beforeWriteNode()
Esempio n. 13
0
        public HMISData getHMISData(HMISData.HMISDataRequest Request)
        {
            HMISData      Data          = new HMISData();
            CswPrimaryKey ControlZoneId = null;

            if (false == string.IsNullOrEmpty(Request.ControlZoneId))
            {
                ControlZoneId = CswConvert.ToPrimaryKey(Request.ControlZoneId);
            }
            else if (false == string.IsNullOrEmpty(Request.ControlZone))
            {
                if (CswTools.IsInteger(Request.ControlZone))
                {
                    ControlZoneId = new CswPrimaryKey("nodes", CswConvert.ToInt32(Request.ControlZone));
                }
                else
                {
                    CswNbtView  ControlZoneView = getControlZonesView(Request.ControlZone);
                    ICswNbtTree ControlZoneTree = _CswNbtResources.Trees.getTreeFromView(ControlZoneView, RequireViewPermissions: false, IncludeSystemNodes: true, IncludeHiddenNodes: true);
                    if (ControlZoneTree.getChildNodeCount() > 0)
                    {
                        ControlZoneTree.goToNthChild(0);
                        ControlZoneId = ControlZoneTree.getNodeIdForCurrentPosition();
                    }
                }
            }

            if (CswTools.IsPrimaryKey(ControlZoneId))
            {
                Data.ControlZone = _CswNbtResources.Nodes.getNodeName(ControlZoneId);

                string HMISSql = @"with loc as (select n.nodeid
                                                  from nodes n
                                                  join nodetypes t on t.nodetypeid = n.nodetypeid
                                                  join object_class oc on t.objectclassid = oc.objectclassid
                                                  join (select j.nodeid, j.field1_fk 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Control Zone'
                                                       ) cz on (cz.nodeid = n.nodeid)
                                                 where oc.objectclass = 'LocationClass'
                                                   and cz.field1_fk = " + ControlZoneId.PrimaryKey + @"
                                               ),
                                        mat as (select n.nodeid, n.nodename materialname, hc.clobdata hazardclasses, sf.gestaltsearch specialflags, ps.field1 physstate
                                                  from nodes n
                                                  join nodetypes t on t.nodetypeid = n.nodetypeid
                                                  join object_class oc on t.objectclassid = oc.objectclassid
                                                  join (select j.nodeid, j.clobdata
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Hazard Classes'
                                                       ) hc on (hc.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.gestaltsearch 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Special Flags'
                                                       ) sf on (sf.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.field1
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Physical State'
                                                       ) ps on (ps.nodeid = n.nodeid)
                                                 where oc.objectclass = 'ChemicalClass'
                                                   and (sf.gestaltsearch is null or sf.gestaltsearch not like '%not reportable%')";
                if (string.IsNullOrEmpty(Request.Class))
                {
                    HMISSql += "   and hc.clobdata is not null";
                }
                else
                {
                    HMISSql += "   and hc.clobdata like '%" + Request.Class + @"%'";
                }
                HMISSql += @"                ),
                                       cont as (select SUM(q.field2_numeric) total_qty_kg, 
                                                       SUM(q.field3_numeric) total_qty_lt, 
                                                       ut.field1 usetype, 
                                                       m.field1_fk materialid
                                                  from nodes n
                                                  join nodetypes t on t.nodetypeid = n.nodetypeid
                                                  join object_class oc on t.objectclassid = oc.objectclassid
                                                  join (select j.nodeid, j.field1_fk 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Location'
                                                       ) l on (l.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.field2_numeric, j.field3_numeric 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Quantity'
                                                       ) q on (q.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.field1 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Use Type'
                                                       ) ut on (ut.nodeid = n.nodeid)
                                                  join (select j.nodeid, j.field1_fk 
                                                          from object_class_props ocp  
                                                          join nodetype_props ntp on ocp.objectclasspropid = ntp.objectclasspropid 
                                                          join jct_nodes_props j on ntp.nodetypepropid = j.nodetypepropid
                                                         where ocp.propname = 'Material'
                                                       ) m on (m.nodeid = n.nodeid)
                                                 where oc.objectclass = 'ContainerClass'
                                                   and ut.field1 is not null
                                                   and l.field1_fk in (select nodeid from loc) 
                                                   and (q.field2_numeric > 0 
                                                     or q.field3_numeric > 0)
                                                 group by ut.field1, m.field1_fk
                                               )
                                   select c.*, mat.hazardclasses, mat.specialflags, mat.materialname, mat.physstate
                                     from cont c
                                     join mat on (c.materialid = mat.nodeid)";
                CswArbitrarySelect HMISSelect = _CswNbtResources.makeCswArbitrarySelect("HMIS_Select", HMISSql);
                DataTable          HMISTable  = HMISSelect.getTable();

                if (string.IsNullOrEmpty(Request.Class))
                {
                    // Get totals for all classes
                    _setFireClasses(ControlZoneId, Data);

                    foreach (DataRow row in HMISTable.Rows)
                    {
                        CswCommaDelimitedString HazardClasses = new CswCommaDelimitedString();
                        HazardClasses.FromString(CswConvert.ToString(row["hazardclasses"]));
                        if (HazardClasses.Contains("FL-1A") || HazardClasses.Contains("FL-1B") || HazardClasses.Contains("FL-1C"))
                        {
                            HazardClasses.Add("FL-Comb");
                        }
                        foreach (String HazardClass in HazardClasses)
                        {
                            HMISData.HMISMaterial HMISMaterial = Data.Materials.FirstOrDefault(EmptyHazardClass => EmptyHazardClass.HazardClass == HazardClass);
                            if (null != HMISMaterial)  //This would only be null if the Material's HazardClass options don't match the Default FireClass nodes
                            {
                                _addQuantityDataToHMISMaterial(HMISMaterial,
                                                               CswConvert.ToString(row["usetype"]),
                                                               CswConvert.ToDouble(row["total_qty_kg"]),
                                                               CswConvert.ToDouble(row["total_qty_lt"]),
                                                               CswConvert.ToString(row["physstate"]),
                                                               new CswPrimaryKey("nodes", CswConvert.ToInt32(row["materialid"])));
                            }
                        }
                    } // foreach( DataRow row in HMISTable )
                }     // if( string.IsNullOrEmpty( Request.Class ) )
                else
                {
                    // Get material information for one class
                    foreach (DataRow row in HMISTable.Rows)
                    {
                        HMISData.HMISMaterial NewMaterial = new HMISData.HMISMaterial
                        {
                            Material    = CswConvert.ToString(row["materialname"]),
                            NodeId      = CswConvert.ToInt32(row["materialid"]),
                            HazardClass = Request.Class
                        };
                        _addQuantityDataToHMISMaterial(NewMaterial,
                                                       CswConvert.ToString(row["usetype"]),
                                                       CswConvert.ToDouble(row["total_qty_kg"]),
                                                       CswConvert.ToDouble(row["total_qty_lt"]),
                                                       CswConvert.ToString(row["physstate"]),
                                                       new CswPrimaryKey("nodes", CswConvert.ToInt32(row["materialid"])));
                        Data.Materials.Add(NewMaterial);
                    }
                } // if-else( string.IsNullOrEmpty( Request.Class ) )
            }     // if( CswTools.IsPrimaryKey( ControlZoneId ) )
            return(Data);
        }
        /// <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. 15
0
        private CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspectionDesign _addNodeTypeInspectionDesignToResponse(CswNbtNode InspectionNode)
        {
            CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspectionDesign Ret = null;
            if (false == InspectionDesignTypeIds.Contains(InspectionNode.NodeTypeId))
            {
                CswNbtMetaDataNodeType NewInspectionNodeType = InspectionNode.getNodeType();
                InspectionDesignTypeIds.Add(NewInspectionNodeType.NodeTypeId);
                Ret = new CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspectionDesign
                {
                    DesignId = NewInspectionNodeType.NodeTypeId,
                    Name     = NewInspectionNodeType.NodeTypeName
                };

                foreach (CswNbtMetaDataNodeTypeTab NodeTypeTab in from CswNbtMetaDataNodeTypeTab _NodeTypeTab
                         in NewInspectionNodeType.getVisibleNodeTypeTabs()
                         orderby _NodeTypeTab.TabOrder
                         select _NodeTypeTab)
                {
                    bool canPropOnAnyOtherTab = (false == _CswNbtResources.Permit.canTab(CswEnumNbtNodeTypePermission.Edit, NewInspectionNodeType, NodeTypeTab: NodeTypeTab));
                    var  ResponseSection      = new CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspectionDesign.Section
                    {
                        Name      = NodeTypeTab.TabName,
                        Order     = NodeTypeTab.TabOrder,
                        SectionId = NodeTypeTab.TabId,
                        ReadOnly  = ((false == _CswNbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Edit, NewInspectionNodeType)) && (false == _CswNbtResources.Permit.canTab(CswEnumNbtNodeTypePermission.Edit, NewInspectionNodeType, NodeTypeTab: NodeTypeTab)))
                    };

                    IEnumerable <CswNbtMetaDataNodeTypeProp> NodeTypeProps = NodeTypeTab.getNodeTypePropsByDisplayOrder();
                    //Debug.Assert( NodeTypeProps != null, "NodeTypeProps != null" );

                    IEnumerable <CswNbtMetaDataNodeTypeProp> TypeProps = NodeTypeProps as CswNbtMetaDataNodeTypeProp[] ?? NodeTypeProps.ToArray();
                    foreach (CswNbtMetaDataNodeTypeProp NodeTypeProp in from CswNbtMetaDataNodeTypeProp _NodeTypeProp
                             in TypeProps
                             where _NodeTypeProp.getFieldTypeValue() != CswEnumNbtFieldType.Question &&
                             _propIsSupportedInMobile(_NodeTypeProp.getFieldTypeValue())
                             select _NodeTypeProp)
                    {
                        ResponseSection.Properties.Add(new CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspectionDesign.SectionProperty
                        {
                            HelpText   = NodeTypeProp.HelpText,
                            Type       = NodeTypeProp.getFieldTypeValue().ToString(),
                            QuestionId = NodeTypeProp.PropId,
                            Text       = NodeTypeProp.PropName,
                            Choices    = null,
                            ReadOnly   = canPropOnAnyOtherTab
                        });
                    }

                    foreach (CswNbtMetaDataNodeTypeProp NodeTypeProp in from CswNbtMetaDataNodeTypeProp _NodeTypeProp
                             in TypeProps
                             orderby _NodeTypeProp.QuestionNo
                             where _NodeTypeProp.getFieldTypeValue() == CswEnumNbtFieldType.Question &&
                             false == _NodeTypeProp.ReadOnly &&
                             _CswNbtResources.Permit.isPropWritable(CswEnumNbtNodeTypePermission.Edit, _NodeTypeProp, null)
                             select _NodeTypeProp)
                    {
                        string PreferredAnswer = string.Empty;
                        CswCommaDelimitedString PossibleAnswers  = new CswCommaDelimitedString();
                        CswCommaDelimitedString CompliantAnswers = new CswCommaDelimitedString();
                        if (null != NodeTypeProp.DesignNode)
                        {
                            PreferredAnswer = NodeTypeProp.DesignNode.getAttributeValueByName(CswNbtFieldTypeRuleQuestion.AttributeName.PreferredAnswer);
                            PossibleAnswers.FromString(NodeTypeProp.DesignNode.getAttributeValueByName(CswNbtFieldTypeRuleQuestion.AttributeName.PossibleAnswers));
                            CompliantAnswers.FromString(NodeTypeProp.DesignNode.getAttributeValueByName(CswNbtFieldTypeRuleQuestion.AttributeName.CompliantAnswers));
                        }

                        var ResponseProperty = new CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspectionDesign.SectionProperty
                        {
                            HelpText   = NodeTypeProp.HelpText,
                            Type       = CswEnumNbtFieldType.Question,
                            QuestionId = NodeTypeProp.PropId,
                            //PreferredAnswer = NodeTypeProp.Extended,
                            PreferredAnswer = PreferredAnswer,
                            Text            = "Question " + NodeTypeProp.QuestionNo + ": " + NodeTypeProp.PropName,
                            ReadOnly        = false
                        };

                        //CswCommaDelimitedString PossibleAnswers = new CswCommaDelimitedString();
                        //PossibleAnswers.FromString( NodeTypeProp.ListOptions );
                        //CswCommaDelimitedString CompliantAnswers = new CswCommaDelimitedString();
                        //CompliantAnswers.FromString( NodeTypeProp.ValueOptions );
                        foreach (string Answer in PossibleAnswers)
                        {
                            ResponseProperty.Choices.Add(new CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspectionDesign.AnswerChoice
                            {
                                Text        = Answer,
                                IsCompliant = CompliantAnswers.Contains(Answer, false)
                            });
                        }
                        ResponseSection.Properties.Add(ResponseProperty);
                    }

                    if (ResponseSection.Properties.Count > 0)
                    {
                        Ret.Sections.Add(ResponseSection);
                    }
                }
            }
            return(Ret);
        }
        /// <summary>
        /// True if user is subscribed
        /// </summary>
        private bool _IsSubscribed(Int32 UserId)
        {
            bool ret = Int32.MinValue != UserId && SelectedUserIds.Contains(UserId.ToString());

            return(ret);
        }
 /// <summary>
 /// True if the SelectedViewIds contains the given ViewId
 /// </summary>
 public bool ContainsViewId( CswNbtViewId ViewIdToFind )
 {
     return SelectedViewIds.Contains( ViewIdToFind.get().ToString() );
 }
        //_getConfigVars

        /// <summary>
        /// powers the webservice, which handles incoming updated config vars from server
        /// </summary>
        /// <param name="NbtResources">NbtResources object</param>
        /// <param name="varsFromServer">Encapsulates a collection of config vars form server</param>
        /// <returns></returns>
        private static CswNbtDataContractConfigurationUpdateSuccessResponse _updateConfigVars(CswNbtResources NbtResources,
                                                                                              CswNbtDataContractConfigurationVariableResponseContainer varsFromServer)
        {
            CswNbtDataContractConfigurationUpdateSuccessResponse ret = new CswNbtDataContractConfigurationUpdateSuccessResponse();
            Dictionary <string, string> updatedConfigVarsFromClient  = new Dictionary <string, string>();

            //add all the config vars into the dictionary
            //keyed by name. If the incoming array contains
            //more than one change to the same config var,
            //the last change 'wins'.
            foreach (CswNbtDataContractConfigurationVariableResponse thisResponse in varsFromServer.responseArray)
            {
                if (updatedConfigVarsFromClient.ContainsKey(thisResponse.VariableName))
                {
                    updatedConfigVarsFromClient[thisResponse.VariableName] = thisResponse.VariableValue;
                }
                else
                {
                    updatedConfigVarsFromClient.Add(thisResponse.VariableName, thisResponse.VariableValue);
                }
            }

            CswTableUpdate CVTableUpdate = NbtResources.makeCswTableUpdate("update config vars", "configuration_variables");
            DataTable      CVDataTable   = CVTableUpdate.getTable();

            foreach (DataRow thisRow in CVDataTable.Rows)
            {
                string configVarName = thisRow[COL_VARIABLENAME].ToString();

                if (updatedConfigVarsFromClient.ContainsKey(configVarName))
                {
                    string updatedConfigVarValue = updatedConfigVarsFromClient[configVarName];
                    string currentConfigVarValue = thisRow[COL_VARIABLEVALUE].ToString();

                    //make sure config var has been altered
                    if (updatedConfigVarValue != currentConfigVarValue)
                    {
                        string configVarDataType = thisRow[COL_DATATYPE].ToString();

                        //now do type specific validation
                        switch (configVarDataType)
                        {
                        case DATATYPE_INT:
                            int configValueAsInt = CswConvert.ToInt32(updatedConfigVarValue);
                            int configMinValue   = CswConvert.ToInt32(thisRow[COL_CONSTRAINT]);
                            //throw exception if the value is > minvalue
                            if (configValueAsInt <= configMinValue)
                            {
                                throw new CswDniException(CswEnumErrorType.Warning,
                                                          "The value of " + configVarName + " must be greater than "
                                                          + configMinValue,
                                                          "Config varible of INT datatype must be < " + configMinValue);
                            }
                            else
                            {
                                thisRow[COL_VARIABLEVALUE] = updatedConfigVarValue;
                            }
                            break;

                        case DATATYPE_LIST:
                            CswCommaDelimitedString listOptions = new CswCommaDelimitedString(thisRow[COL_CONSTRAINT].ToString());
                            if (false == listOptions.Contains(updatedConfigVarValue))
                            {
                                string listOptionsString = listOptions.ToString();
                                throw new CswDniException(CswEnumErrorType.Warning,
                                                          configVarName + " must be set to one of these options: "
                                                          + listOptionsString,
                                                          "Config variable " + configVarName + " cannot be set to " + currentConfigVarValue +
                                                          " since it is not one of the predefined options " + listOptionsString);
                            }
                            else
                            {
                                thisRow[COL_VARIABLEVALUE] = updatedConfigVarValue;
                            }
                            break;

                        case DATATYPE_BOOL:
                            if (false == (updatedConfigVarValue == "0" ||
                                          updatedConfigVarValue == "1"))
                            {
                                throw new CswDniException(CswEnumErrorType.Warning,
                                                          configVarName + " must be set to 0 or 1",
                                                          configVarName + " is of type BOOL, therefore it must be set to 0 or 1");
                            }
                            else
                            {
                                thisRow[COL_VARIABLEVALUE] = updatedConfigVarValue;
                            }
                            break;

                        //for string type there is no config var specific validation
                        default:
                            thisRow[COL_VARIABLEVALUE] = updatedConfigVarValue;
                            break;
                        } //switch by ConfigVarDatatype
                    }     // if config var has been updated
                }         //if this config var was returned from client
            }             //for each dataRow

            //commit changes
            CVTableUpdate.update(CVDataTable);

            //if any errors are encountered, the exception will throw an error message
            //so there is no execution path where we return false
            ret.success = true;
            return(ret);
        }