示例#1
0
        /// <summary>
        /// is client entitled to  feature. Entitlements work two ways - eaither by Default On or by Default Off.
        /// If default is on, then A feature is turned off by having the client name in the list for this "feature/NotEntiled" app parm 
        /// in the shared table or having this feature appear in the client's AppParm "Setup/feature_NotEntitled" (which is created by SetupClient)
        /// if the default is off, the a client has a feature truned on by having the client name in the app parm "feature/Entiled" in the
        /// shared table or the or having this feature appear in the client's AppParm "Setup/feature_Entitled"
        /// Most features in the system are by default entitled
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public static bool Entitled(string feature, GenericClient c, EntitlementType EntType)
        {
            string cname = c.Name.ToLower();

            string ParmName;
            bool ParmAction;

            Dictionary<string, bool> ents = __EntsByFeatureUser[feature];
            if (ents == null) {
                if (EntType == EntitlementType.DefaultPositive) {
                    ParmName = "ClientsNotEntitled";
                    ParmAction = false;
                } else {
                    ParmName = "ClientsEntitled";
                    ParmAction = true;
                }

                ents = new Dictionary<string, bool>();
                __EntsByFeatureUser[feature] = ents;

                //this parm that should only exist on shared level
                string str = ApplicationParameters.GetParm(feature, ParmName);
                if (str != null) {
                    str = str.ToLower();
                    string[] parts = str.Split(",".ToCharArray());
                    foreach (string name in parts) {
                        ents[name] = ParmAction;
                    }
                }
            }

            //a null indicates we still have not checked the Setup paramaters on the client level
            object o = ents[cname];
            if (o != null)
                return (bool)o;

            if (EntType == EntitlementType.DefaultPositive) {
                ParmName = "_NotEntitled";
                ParmAction = false;
            } else {
                ParmName = "_Entitled";
                ParmAction = true;
            }

            //now check client setup paramaters
            string str2 = ApplicationParameters.GetParm("Setup", feature + ParmName);
            if (str2 != null)
                ents[cname] = ParmAction;
            else
                ents[cname] = !ParmAction;

            return (bool)ents[cname];
        }
示例#2
0
        public static void CacheCB(DataTable dt)
        {
            mClientCache.Clear();

            foreach (DataRow r in dt.Rows) {
                GenericClient c = new GenericClient();
                c.Load(r);
                mClientCache.Add(c);
            }
        }