StateTrans.cs 3.07 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using VRH.Log4Pro.MultiLanguageManager;
using Vrh.iScheduler;

namespace Vrh.Web.iScheduler
{
    /// <summary>
    /// Az állapotok fordítását és egyéb használatos
    /// segédeszközöket tartalmazó osztály.
    /// </summary>
    public class StateTrans
    {
        #region Properties

        /// <summary>
        /// Aktív állapot nevének fordítása.
        /// </summary>
        public string Active { get; private set; }

        /// <summary>
        /// Aktív állapot nevének fordítása.
        /// </summary>
        public string Success { get; private set; }

        /// <summary>
        /// Aktív állapot nevének fordítása.
        /// </summary>
        public string Failed { get; private set; }

        /// <summary>
        /// A lefordított elemekből összeállított lista a megjelenítéshez.
        /// </summary>
        public List<SelectListItem> SelectList { get; private set; }

        /// <summary>
        /// A lefordított elemekből összeállított lista a szűréshez.
        /// </summary>
        public List<SelectListItem> FilterList { get; private set; }
        #endregion Properties

        #region Constructor
        /// <summary>
        /// Egy példány előállítása.
        /// </summary>
        /// <param name="lcid">A környezetben érvényes nyelvi kód.</param>
        public StateTrans(string lcid)
        {
            Active = MultiLanguageManager.GetTranslation(typeof(SchedulerWordCodes.iScheduler.Manager.State.Active), lcid);
            Success = MultiLanguageManager.GetTranslation(typeof(SchedulerWordCodes.iScheduler.Manager.State.Success), lcid);
            Failed = MultiLanguageManager.GetTranslation(typeof(SchedulerWordCodes.iScheduler.Manager.State.Failed), lcid);
            this.SelectList = new List<SelectListItem>
            {
                new SelectListItem { Value = ((int)ScheduleStates.Active).ToString(), Text = this.Active },
                new SelectListItem { Value = ((int)ScheduleStates.Failed).ToString(), Text = this.Failed },
                new SelectListItem { Value = ((int)ScheduleStates.Success).ToString(), Text = this.Success },
            };
            this.FilterList = new List<SelectListItem> { new SelectListItem { Value = "", Text = "" } };
            this.FilterList.AddRange(this.SelectList);
        }
        #endregion Constructor

        /// <summary>
        /// A lefordított állapotnév visszaadása.
        /// </summary>
        /// <param name="ss"></param>
        /// <returns></returns>
        public string GetName(ScheduleStates ss)
        {
            switch (ss)
            {
                case ScheduleStates.Active:
                    return this.Active;
                case ScheduleStates.Success:
                    return this.Success;
                case ScheduleStates.Failed:
                    return this.Failed;
                default:
                    return "";
            }
        }
    }
}