Пример #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public CswNbtActionCollection(CswNbtResources Resources, bool ExcludeDisabledActions)
        {
            _CswNbtResources = Resources;

            _ActionSL   = new SortedList();
            _ActionHash = new Hashtable();

            // Actions
            DataTable ActionsTable = null;

            if (ExcludeDisabledActions)
            {
                CswStaticSelect ActionsSelect = _CswNbtResources.makeCswStaticSelect("CswNbtActionCollection.ActionsSelect", "getActiveActions");
                ActionsTable = ActionsSelect.getTable();
            }
            else
            {
                CswTableSelect ActionsSelect = _CswNbtResources.makeCswTableSelect("CswNbtActionCollection.AllActionsSelect", "actions");
                ActionsTable = ActionsSelect.getTable();
            }

            foreach (DataRow ActionRow in ActionsTable.Rows)
            {
                try
                {
                    CswEnumNbtActionName CurrentActionName = CswNbtAction.ActionNameStringToEnum(ActionRow["actionname"].ToString());
                    if (CurrentActionName != CswResources.UnknownEnum)
                    {
                        Int32        ActionId = CswConvert.ToInt32(ActionRow["actionid"]);
                        CswNbtAction Action   = new CswNbtAction(_CswNbtResources,
                                                                 ActionId,
                                                                 ActionRow["url"].ToString(),
                                                                 CurrentActionName,
                                                                 CswConvert.ToBoolean(ActionRow["showinlist"]),
                                                                 ActionRow["category"].ToString(),
                                                                 CswConvert.ToString(ActionRow["iconfilename"]));
                        string ActionNameAsString = CswNbtAction.ActionNameEnumToString(CurrentActionName);
                        if (false == _ActionSL.ContainsKey(ActionNameAsString))
                        {
                            _ActionSL.Add(ActionNameAsString, Action);
                        }
                        if (false == _ActionHash.ContainsKey(ActionId))
                        {
                            _ActionHash.Add(ActionId, Action);
                        }
                    }
                }
                catch (Exception ex)
                {
                    // Log the error but keep going
                    _CswNbtResources.logError(new CswDniException(CswEnumErrorType.Error, "System Error", "Encountered an invalid Action: " + ActionRow["actionname"] + " (" + ActionRow["actionid"] + ")", ex));
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Find an action by ActionName
 /// </summary>
 /// <param name="ActionName">CswNbtActionName value for action</param>
 public CswNbtAction this[CswEnumNbtActionName ActionName]
 {
     get { return((CswNbtAction)_ActionSL[CswNbtAction.ActionNameEnumToString(ActionName)]); }
 }