Exemplo n.º 1
0
        public PermissionEnum Permissions = PermissionEnum.None; // set of assigned permissions

/// <summary>
/// Get the external group or user name corresponding to an internal name
/// </summary>
/// <returns></returns>

        public string GetExternalName()
        {
            string name = AssignedTo;

            if (IsGroup)
            {
                UserGroup g = UserGroups.LookupInternalName(name);
                if (g != null)
                {
                    name = g.ExternalName;
                }
            }

            else             // user name
            {
                DictionaryMx userDict = DictionaryMx.Get("UserName");
                if (userDict != null && userDict.LookupDefinition(name) != null)
                {
                    string   userInfoString = userDict.LookupDefinition(name);
                    UserInfo ui             = UserInfo.Deserialize(userInfoString);
                    name = ui.FullNameReversed;
                }
            }

            return(name);
        }
Exemplo n.º 2
0
/// <summary>
/// Get a list of all of the words in a dictionary
/// </summary>
/// <param name="dictName"></param>
/// <returns></returns>

        public static List <string> GetWords(
            string dictName,
            bool removeDuplicates)
        {
            DictionaryMx dict = DictionaryMx.Get(dictName);

            if (dict == null)
            {
                return(null);
            }
            if (!removeDuplicates)
            {
                return(dict.Words);
            }

            List <string>    words = new List <string>();
            HashSet <string> set   = new HashSet <string>();

            foreach (string word in dict.Words)
            {
                if (set.Contains(word.ToLower()))
                {
                    continue;
                }

                words.Add(word);
                set.Add(word.ToLower());
            }

            return(words);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Lookup the definition for a word
        /// </summary>
        /// <param name="dictName"></param>
        /// <param name="word"></param>
        /// <returns></returns>

        public static string LookupDefinition(
            string dictName,
            string word)
        {
            DictionaryMx d = DictionaryMx.Get(dictName);

            if (d == null)
            {
                return(null);
            }
            return(d.LookupDefinition(word));
        }
Exemplo n.º 4
0
/// <summary>
/// Deserialize dictionary
/// </summary>
/// <param name="serializedVersion"></param>
/// <param name="dex"></param>

        public static void Deserialize(string serializedVersion, DictionaryMx dex)
        {
            dex.Initialize();
            DictionaryMx dex2 = Deserialize(serializedVersion);

            foreach (string word in dex2.Words)
            {
                dex.Add(word, dex2.LookupDefinition(word));
            }

            return;
        }
Exemplo n.º 5
0
/// <summary>
/// Get dictionary associated with a set of root tables
/// </summary>
/// <param name="dictName"></param>
///
        public static DictionaryMx GetDictionary(string dictName)
        {
            if (TableList == null)
            {
                Build();
            }

            bool allRoots   = Lex.Eq(dictName, "Root_Tables");
            bool structs    = Lex.Eq(dictName, "StructureDatabases");
            bool cartridge  = Lex.Eq(dictName, "CartridgeDatabases");
            bool smallWorld = Lex.Eq(dictName, "SmallWorldDatabases");

            DictionaryMx dex = new DictionaryMx();

            dex.Name = dictName;

            foreach (RootTable rt in TableList)
            {
                bool   add  = false;
                string word = rt.Label;
                string def  = rt.MetaTableName;

                if (Lex.Eq(rt.Label, "SmallWorld"))
                {
                    continue;                                                 // ignore this
                }
                if (structs)
                {
                    add = rt.IsStructureTable;
                }

                else if (cartridge)
                {
                    add = rt.CartridgeSearchable;
                }

                else if (smallWorld)
                {
                    add = Lex.IsDefined(rt.SmallWorldDbName);                     // exclude the "SmallWorld" umbrella DB
                }
                else
                {
                    add = true;                  // if dict not one of the definede subsets then include all
                }
                if (add)
                {
                    dex.Add(rt.Label, rt.MetaTableName);
                }
            }

            return(dex);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Get a dictionary
 /// </summary>
 /// <param name="dictName"></param>
 /// <returns></returns>
 ///
 public static DictionaryMx Get(         // lookup or read dictionary and return
     string dictName)
 {
     try
     {
         DictionaryMx d = DictionaryMx.GetWithException(dictName);
         return(d);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 7
0
/// <summary>
/// Deserialize dictionary
/// </summary>
/// <param name="serializedVersion"></param>
/// <returns></returns>

        public static DictionaryMx Deserialize(string serializedVersion)
        {
            DictionaryMx dex = new DictionaryMx();

            dex.Initialize();
            string[] sa = serializedVersion.Split('\t');
            dex.Name = sa[0];
            dex.Sql  = sa[1];

            for (int i = 2; i + 1 < sa.Length; i += 2)
            {
                dex.Add(sa[i], sa[i + 1]);
            }

            return(dex);
        }
Exemplo n.º 8
0
/// <summary>
/// Get a dictionary
/// </summary>
/// <param name="dictName"></param>
/// <returns></returns>

        public static DictionaryMx GetWithException(         // lookup or read dictionary and return
            string dictName)
        {
            string sql, tok;

            //if (Lex.Eq(dictName, "DIT_PERSON")) dictName = dictName; // debug

            if (dictName == null || dictName == "")
            {
                throw new Exception("Dictionary name not defined");
            }

            if (RootTable.IsDatabaseListDictionaryName(dictName))
            {             // dict of root tables move to factory after Mobius 2.4 is deactivated
                return(RootTable.GetDictionary(dictName));
            }

            dictName = dictName.ToLower();
            DictionaryMx dict = Dictionaries[dictName];

            if (dict == null)
            {
                throw new Exception("Dictionary not defined: " + dictName);
            }

            if (dict.Words == null)
            {
                if (DictionaryFactory == null)
                {
                    throw new Exception("DictionaryFactory not defined");
                }
                int t0 = TimeOfDay.Milliseconds();
                DictionaryFactory.GetDefinitions(dict);
                t0 = TimeOfDay.Milliseconds() - t0;
                //DebugLog.Message("DictionaryMx.Get " + dictName + ", time: " + t0);
            }

            return(dict);
        }