예제 #1
0
        public IList <string> QualityCheck(UserProperties userAttr)
        {
            IList <string> checkMessage = new List <string>();

            if (userAttr == null)
            {
                return(checkMessage);
            }


            foreach (CheckAttribute checkAttr in QualityCheckAttributes)
            {
                bool found = false;

                string[] userValue = userAttr.GetPropValue(checkAttr.Name);
                if (userAttr != null)
                {
                    foreach (AttributeValue chkVal in checkAttr.CheckAttributeValues)
                    {
                        if (found)
                        {
                            break;
                        }
                        found = Utils.MatchValueInArray(chkVal.Value, userValue);
                    }
                }
                if (!found)
                {
                    checkMessage.Add("[" + checkAttr.Name + "] = " + (userValue != null ? string.Join(";", userValue) : "null"));
                }
            }
            return(checkMessage);
        }
예제 #2
0
        public string GetTransitionByUserAttributes(UserProperties userAttrFrom, UserProperties userAttrTo)
        {
            string matchMessage = "";

            if (this.Type != AdHintType.Terminate_Create || userAttrFrom == null || userAttrTo == null)
            {
                return(""); // Transition rules defined only for Terminate_Create
            }
            foreach (TransitionAttribute hintAttr in TransitionAttributes)
            {
                string matchedAttrValueFrom, matchedAttrValueTo;
                var    userValueFrom = userAttrFrom.GetPropValue(hintAttr.Name);
                var    userValueTo   = userAttrTo.GetPropValue(hintAttr.Name);

                var anyFrom = hintAttr.TransitionAttributeValuesFrom.AnyValue ?? false;
                var anyTo   = hintAttr.TransitionAttributeValuesTo.AnyValue ?? false;

                if (!Utils.CheckEquals(userValueFrom, userValueTo))
                {
                    if (anyFrom)
                    {
                        matchedAttrValueFrom = (userValueFrom == null || userValueFrom.Length == 0 || string.IsNullOrEmpty(userValueFrom[0]) ? "NULL" : userValueFrom[0]) + "(*)"; // if AnyValueAttribute set and value has changed
                    }
                    else
                    {
                        matchedAttrValueFrom = ADHintsConfigurationSection.GetFirstMatchedAttribute(userValueFrom, hintAttr.Name, hintAttr.TransitionAttributeValuesFrom);
                    }

                    if (string.IsNullOrEmpty(matchedAttrValueFrom))
                    {
                        return(null); // values not found. No transition
                    }
                    if (anyTo)
                    {
                        matchedAttrValueTo = (userValueTo == null || userValueTo.Length == 0 || string.IsNullOrEmpty(userValueTo[0]) ? "NULL" : userValueTo[0]) + "(*)"; // if AnyValueAttribute set and value has changed
                    }
                    else
                    {
                        matchedAttrValueTo = ADHintsConfigurationSection.GetFirstMatchedAttribute(userValueTo, hintAttr.Name, hintAttr.TransitionAttributeValuesTo);
                    }

                    if (string.IsNullOrEmpty(matchedAttrValueTo))
                    {
                        return(null); // values not found. No transition
                    }
                    matchMessage += "[" + hintAttr.Name + "]='" + matchedAttrValueFrom + "' -> '" + matchedAttrValueTo + "';";
                }
                else
                {
                    return(null); // values not changed
                }
            }

            return(matchMessage);
        }
예제 #3
0
        public static ADHintElement GetOUByAttributes(UserProperties userPropsNew, UserProperties userPropsOld, out string transResult)
        {
            // ConfigurationManager.RefreshSection("ADHints");
            var hitsElements = (ADHintsConfigurationSection)ConfigurationManager.GetSection("ADHintSettings");

            transResult = string.Empty;

            foreach (ADHintElement hint in hitsElements.ADHints)
            {
                bool hintMatched = true;
                foreach (HintAttribute hintAttr in hint.ADHintAttributes)
                {
                    string[] userAttrValue = userPropsNew.GetPropValue(hintAttr.Name);
                    if ( //userAttrValue == null
                        string.IsNullOrEmpty(GetFirstMatchedAttribute(userAttrValue, hintAttr.Name, hintAttr.HintAttributeValues)))
                    {
                        hintMatched = false; // if any hintvalue is not matched
                        break;               // Then Hint is not matched
                    }
                }
                if (hintMatched) // all attributes are found and equal
                {
                    if (hint.Type == ADHintElement.AdHintType.Terminate_Create)
                    {
                        transResult = hint.GetTransitionByUserAttributes(userPropsOld, userPropsNew);
                        if (!string.IsNullOrEmpty(transResult))
                        {
                            return(hint);
                        }
                    }
                    else
                    {
                        return(hint);
                    }
                }
            } // foreach ADHints
            return(null);
        }