Example #1
0
        /// <summary>
        /// 获得代理信息对象
        /// </summary>
        /// <returns></returns>
        private static WebProxy GetProxy(string ip = "", string port = "")
        {
            ip   = string.IsNullOrEmpty(ip) ? ServiceIniUpgradeHelper.ReadProxyIp() : ip;
            port = string.IsNullOrEmpty(port) ? ServiceIniUpgradeHelper.ReadProxyPort() : port;
            if (string.IsNullOrEmpty(ip) || string.IsNullOrEmpty(port))
            {
                return(null);
            }

            var proxy = new WebProxy
            {
                Address = new Uri($"http://{ip}:{port}")
            };

            //if (!string.IsNullOrEmpty(_proxyConfig.UserName))
            //    proxy.Credentials = new NetworkCredential(_proxyConfig.UserName, _proxyConfig.Password);

            return(proxy);
        }
        /// <summary>
        /// 获得需要更新得模块信息
        /// </summary>
        /// <returns></returns>
        public static List <UpgradeModel> GetUpgradeModule()
        {
            var resp = new List <UpgradeModel>();

            try
            {
                var list = ServiceIniUpgradeHelper.ReadModuleList();
                list?.ForEach(item =>
                {
                    var response           = new UpgradeModel();
                    response.Url           = ServiceIniUpgradeHelper.ReadModuleUrl(item);
                    response.FileName      = ServiceIniUpgradeHelper.ReadModuleFileName(item);
                    response.Description   = ServiceIniUpgradeHelper.ReadModuleDescription(item);
                    response.IsMainProcess = ServiceIniUpgradeHelper.ReadModuleIsMainProcess(item);
                    resp.Add(response);
                });
            }
            catch (Exception ex)
            {
                TextHelper.Error("GetUpgradeModule 异常", ex);
            }
            return(resp);
        }