using System.Collections.Generic;
using MegaRobo.Entities;
using MegaRobo.C00225155.Entities;
using MegaRobo.Entities.ViewTT;
using MegaRobo.C00225155.Entities.Enums;
using System.Threading;
using System.Diagnostics;
using System.Threading.Tasks;
using Common;

namespace MegaRobo.C00225155.AppServer;

public class AppConfigService
{
    public AppConfigService()
    {
        ReadConfig();
    }
    public ProjectInfo ProjectInfo { get; set; }
    public IList<Setting> SettingList { get; set; }
    //public IList<WebApiUrl> WebApiUrlList { get; set; }
    
    public readonly string ApiName = "C00225155";

    public readonly string globalOrderId = "0";

    public List<string> BlockKeywords { get; set; } = new List<string>();

    /// <summary>
    /// 配置站、检测站公用的访问数据库的锁
    /// </summary>
    public readonly SemaphoreSlim databaseSemaphoreSlim = new SemaphoreSlim(1, 1);

    ///// <summary>
    ///// 工站属性列表
    ///// </summary>
    //public List<StationProperty> StationPropList = new List<StationProperty>();

    public IDictionary<ViewNames, AuthLevel> ViewNameAuthLevelsDic = new Dictionary<ViewNames, AuthLevel>();

    private void ReadConfig()
    {
        ViewNameAuthLevelsDic.Clear();
        ViewNameAuthLevelsDic.Add(ViewNames.HomeView, AuthLevel.None);
        ViewNameAuthLevelsDic.Add(ViewNames.SettingView, AuthLevel.Operator);
        ViewNameAuthLevelsDic.Add(ViewNames.CommunicationDebugView, AuthLevel.None);
        ViewNameAuthLevelsDic.Add(ViewNames.FlowConfigView, AuthLevel.None);
        ViewNameAuthLevelsDic.Add(ViewNames.AdditivePipetteConfigView, AuthLevel.None);
        ViewNameAuthLevelsDic.Add(ViewNames.LoggerView, AuthLevel.None);
        ViewNameAuthLevelsDic.Add(ViewNames.UserView, AuthLevel.Instructor);
    }
}