using Microsoft.Extensions.Options;
using XF.Domain.Dependency;

namespace DataSharing
{
    /// <summary>
    /// 获取系统配置
    /// </summary>
    public class ChannelConfigurationManager : IChannelConfigurationManager, IScopeDependency
    {
        private readonly IOptionsSnapshot<ChannelConfiguration> _channelOption;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="channelOption"></param>
        public ChannelConfigurationManager(IOptionsSnapshot<ChannelConfiguration> channelOption)
        {
            _channelOption = channelOption;
        }

        /// <summary>
        /// 获取服务名称
        /// </summary>
        /// <returns></returns>
        public string GetConfigurationProcessingServices()
        {
            return _channelOption.Value.ProcessingServices;
        }

        /// <summary>
        /// 获取是否开启推送
        /// </summary>
        /// <returns></returns>
        public bool GetConfigurationIsOpenPush()
        {
            return _channelOption.Value.IsOpenPush;
        }

        /// <summary>
        /// 业务系统附件上传配置
        /// </summary>
        /// <returns></returns>
        public ConfigurationBusinessFile GetConfigurationBusinessFile()
        {
            return _channelOption.Value.BusinessFile;
        }

        /// <summary>
        /// 写入工单数据
        /// </summary>
        /// <returns></returns>
        public ConfigurationHotlineClient GetConfigurationHotlineClient()
        {
            return _channelOption.Value.HotlineClient;
        }

        /// <summary>
        /// 省12345配置
        /// </summary>
        /// <returns></returns>
        public ConfigurationProvince GetConfigurationProvince()
        {
            return _channelOption.Value.Province;
        }
    }



    /// <summary>
    /// 获取地市系统配置
    /// </summary>
    public interface ISharingConfigurationManager
    {
        /// <summary>
        /// 判断是否是指定市州
        /// </summary>
        /// <param name="cityCode"></param>
        /// <returns></returns>
        bool IsCity(string cityCode);

        /// <summary>
        /// 获取市州编码
        /// </summary>
        /// <returns></returns>
        string GetCityCode();

        /// <summary>
        /// 获取市州名称
        /// </summary>
        /// <returns></returns>
        string GetCityName();

        /// <summary>
        /// 获取热线名称
        /// </summary>
        /// <returns></returns>
        string GetHotlineName();

        /// <summary>
        ///获取省12345平台部门Code
        /// </summary>
        /// <returns></returns>
        string GetProvinceOrgCode();

        /// <summary>
        /// 获取省12345交办部门Code
        /// </summary>
        /// <returns></returns>
        string GetProvinceAssignmentOrgCode();

        /// <summary>
        ///获取 110部门Code
        /// </summary>
        /// <returns></returns>
        string GetPoliceOrgCode();

        /// <summary>
        /// 获取宜宾配置
        /// </summary>
        /// <returns></returns>
        CityYiBinConfig GetYiBinConfig();

        /// <summary>
        /// 获取自贡配置
        /// </summary>
        /// <returns></returns>
        CityZiGongConfig GetZiGongConfig();

        /// <summary>
        /// 获取泸州配置
        /// </summary>
        /// <returns></returns>
        CityLuZhouConfig GetLuZhouConfig();
    }

    /// <summary>
    /// 获取地市系统配置
    /// </summary>
    public class SharingConfigurationManager : ISharingConfigurationManager, IScopeDependency
    {
        private readonly IOptionsSnapshot<SharingConfiguration> _sharingOption;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sharingOption"></param>
        public SharingConfigurationManager(IOptionsSnapshot<SharingConfiguration> sharingOption)
        {
            _sharingOption = sharingOption;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="cityCode"></param>
        /// <returns></returns>
        public bool IsCity(string cityCode) =>
            _sharingOption.Value.CityCode.Equals(cityCode, StringComparison.OrdinalIgnoreCase);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string GetCityCode() => _sharingOption.Value.CityCode;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string GetCityName() => _sharingOption.Value.CityName;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string GetHotlineName() => _sharingOption.Value.HotlineName;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string GetProvinceOrgCode() => _sharingOption.Value.ProvinceOrgCode;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string GetProvinceAssignmentOrgCode() => _sharingOption.Value.ProvinceAssignmentOrgCode;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string GetPoliceOrgCode() => _sharingOption.Value.PoliceOrgCode;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CityYiBinConfig GetYiBinConfig() => _sharingOption.Value.CityYiBin;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CityZiGongConfig GetZiGongConfig() => _sharingOption.Value.CityZiGong;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public CityLuZhouConfig GetLuZhouConfig() => _sharingOption.Value.CityLuZhou;
    }
}
