Example #1
0
        public void OnCurrentWorkUnitPropertyChange(CswNbtNodeProp Prop, bool Creating)
        {
            CswPrimaryKey UsersCurrentWorkUnitId = CurrentWorkUnitId;

            //Case 30817
            //if( null != UsersWorkUnitId )
            if (false == CswTools.IsPrimaryKey(UsersCurrentWorkUnitId))
            {
                UsersCurrentWorkUnitId = GetFirstAvailableWorkUnitNodeId();
            }

            if (false == AvailableWorkUnits.CheckValue(UsersCurrentWorkUnitId.ToString()))
            {
                if (false == _CswNbtResources.CurrentNbtUser is CswNbtSystemUser &&
                    _CswNbtResources.CurrentNbtUser.Username != ChemSWAdminUsername)
                {
                    throw new CswDniException(CswEnumErrorType.Warning,
                                              CurrentWorkUnitProperty.CachedNodeName +
                                              " is not an available Work Unit for user " + Username,
                                              _CswNbtResources.CurrentNbtUser.Username + " attempted to assign User: "******" to Work Unit: " + UsersCurrentWorkUnitId +
                                              " when Users available Work Units are: " + AvailableWorkUnits.Value);
                }
                // We add the work unit to the list and then check it!
                AvailableWorkUnits.AddValue(UsersCurrentWorkUnitId.ToString());
                CurrentWorkUnitProperty.RelatedNodeId = UsersCurrentWorkUnitId;
                CurrentWorkUnitProperty.SyncGestalt();

                _updateAvailableWorkUnits();
            }
        }
Example #2
0
        private void _updateAvailableWorkUnits()
        {
            //Case 30817 (Case 30843: moved to here from onBeforeCreate)
            if (CswTools.IsPrimaryKey(CurrentWorkUnitId) &&
                false == AvailableWorkUnits.CheckValue(CurrentWorkUnitId.ToString()))
            {
                AvailableWorkUnits.AddValue(CurrentWorkUnitId.ToString());
                CurrentWorkUnitProperty.RelatedNodeId = CurrentWorkUnitId;
                CurrentWorkUnitProperty.SyncGestalt();
            }

            CswNbtView View = _CswNbtResources.ViewSelect.restoreView(CurrentWorkUnitProperty.NodeTypeProp.ViewId);

            View.Clear();
            View.SetVisibility(CswEnumNbtViewVisibility.Property, null, null);

            CswNbtMetaDataObjectClass WorkUnitOC     = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.WorkUnitClass);
            CswNbtViewRelationship    WorkUnitParent = View.AddViewRelationship(WorkUnitOC, false);

            foreach (string WorkUnitNodeId in AvailableWorkUnits.Value)
            {
                CswPrimaryKey pk = CswConvert.ToPrimaryKey(WorkUnitNodeId);
                WorkUnitParent.NodeIdsToFilterIn.Add(pk);
            }

            CurrentWorkUnitProperty.OverrideView(View);
        }
Example #3
0
        protected override void beforeWriteNodeLogic(bool Creating, bool OverrideUniqueValidation)
        {
            if (_unableToWriteNodeInvalidUserName())
            {
                throw new CswDniException(CswEnumErrorType.Warning, "Usernames may only contains letters, numbers, underscores, periods and dashes.",
                                          "Username contains invalid characters: " + this.Username);
            }

            if (UsernameProperty.Text != string.Empty)                     // case 25616
            {
                UsernameProperty.setReadOnly(value: true, SaveToDb: true); // BZ 5906
            }

            // case 22512
            if (Username == ChemSWAdminUsername &&
                _CswNbtResources.CurrentNbtUser != null &&
                _CswNbtResources.CurrentNbtUser.Username != ChemSWAdminUsername &&
                false == (_CswNbtResources.CurrentNbtUser is CswNbtSystemUser))
            {
                throw new CswDniException(CswEnumErrorType.Warning, "The '" + ChemSWAdminUsername + "' user cannot be edited",
                                          "Current user (" + _CswNbtResources.CurrentUser.Username +
                                          ") attempted to edit the '" + ChemSWAdminUsername + "' user account.");
            }

            if (AvailableWorkUnits.Value.Count == 0 && null != CurrentWorkUnitProperty.RelatedNodeId)
            {
                AvailableWorkUnits.AddValue(CurrentWorkUnitProperty.RelatedNodeId.ToString());
            }
        }