コード例 #1
0
    /// <summary>
    /// Generate XML attribute text
    /// </summary>
    /// <param name="grantLicenseMode"></param>
    /// <returns></returns>
    public static string GenerateGrantLicenseModeAttributeText(GrantLicenseMode grantLicenseMode)
    {
        switch (grantLicenseMode)
        {
        case GrantLicenseMode.Ignore:
            return(GrantLicenseMode_Ignore);

        case GrantLicenseMode.None:
            return(GrantLicenseMode_None);

        case GrantLicenseMode.OnLogin:
            return(GrantLicenseMode_OnLogin);

        default:
            IwsDiagnostics.Assert(false, "920-618: Internal error. Unknown Grant License Mode");
            throw new Exception("920-618: Internal error. Unknown Grant License Mode");
        }
    }
コード例 #2
0
    /// <summary>
    /// Parse the grant license values
    /// </summary>
    /// <param name="xmlNode"></param>
    /// <param name="groupName"></param>
    /// <param name="grantLicenseMode"></param>
    /// <param name="grantLicenseRole"></param>
    public static void ReadGrantLicenseXmlAttributes(XmlNode xmlNode, string groupName, out GrantLicenseMode grantLicenseMode, out string grantLicenseRole)
    {
        //Parse the grant license mode
        grantLicenseMode = ParseGrantLicenseMode(
            XmlHelper.SafeParseXmlAttribute(xmlNode, XmlAttribute_GrantLicenseMode, ""));

        //Store the target role
        grantLicenseRole =
            XmlHelper.SafeParseXmlAttribute(xmlNode, XmlAttribute_GrantLicenseMinimumSiteRole, null);

        //=======================================================================
        //Sanity check
        //=======================================================================
        if (grantLicenseMode == GrantLicenseMode.OnLogin)
        {
            if (string.IsNullOrWhiteSpace(grantLicenseRole))
            {
                throw new Exception("920-1010: grantLicenseMinimumSiteRole cannot be blank for group: " + groupName);
            }

            var sanityParseRole = SiteUser.ParseUserRole(grantLicenseRole);
            if (sanityParseRole == SiteUserRole.Unknown)
            {
                throw new Exception("920-1007: Unknown grant license role found for group: " + groupName + "/" + grantLicenseRole);
            }
        }
    }