예제 #1
0
 /// <summary>
 /// DLLをインターネットよりダウンロード
 /// </summary>
 /// <param name="iDllType">DllType</param>
 /// <returns>成功した場合True</returns>
 private bool DownloadDll(DllType iDllType)
 {
     try
     {
         DllTypeInfo dll = settings.DllTypeInfoList[iDllType];
         if (!dll.Enable || dll.DownloadUrl.Length == 0 || dll.Filename.Length == 0)
         {
             return(false);
         }
         // DLL保存ディレクトリ作成
         string path = GetSourcePath();
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         // ダウンロード
         string downloadFilename = Path.Combine(GetSourcePath(), Constants.FilenameTemp);
         if (File.Exists(downloadFilename))
         {
             File.Delete(downloadFilename);
         }
         using (WebClient wc = new WebClient())
         {
             if (settings.Proxy.Enable)
             {
                 string proxy = string.Format("http://{0}:{1}", settings.Proxy.Server, settings.Proxy.Port);
                 wc.Proxy = new WebProxy(proxy);
             }
             wc.Encoding = Encoding.UTF8;
             wc.DownloadFile(dll.DownloadUrl, downloadFilename);
         }
         // ファイル移動
         string destFilename = Path.Combine(GetSourcePath(), dll.Filename);
         if (File.Exists(destFilename))
         {
             File.Delete(destFilename);
         }
         File.Move(downloadFilename, destFilename);
         // バージョン取得
         RefreshDllVersion();
         return(true);
     }
     catch (Exception e)
     {
         string msg = string.Format(Resources.MsgVersionUpFor, iDllType, e.Message);
         throw new Exception(msg, e);
     }
 }
예제 #2
0
        /// <summary>
        /// DLL配布ページから、バージョンアップが必要か判定
        /// </summary>
        /// <param name="iDllType">DLL種別</param>
        /// <param name="oXPathData">判定用文字列</param>
        /// <returns>バージョンアップが必要な場合True</returns>
        private bool MasterVersionCheck(DllType iDllType, out string oXPathData)
        {
            try
            {
                oXPathData = string.Empty;
                DllTypeInfo dll = settings.DllTypeInfoList[iDllType];
                if (!dll.Enable || dll.XPath.Length == 0 || dll.CheckUrl.Length == 0)
                {
                    return(false);
                }

                using (WebClient wc = new WebClient())
                {
                    if (settings.Proxy.Enable)
                    {
                        string proxy = string.Format("http://{0}:{1}", settings.Proxy.Server, settings.Proxy.Port);
                        wc.Proxy = new WebProxy(proxy);
                    }
                    wc.Encoding = Encoding.UTF8;
                    string html = wc.DownloadString(dll.CheckUrl);

                    HtmlDocument htmlDoc = new HtmlDocument();
                    htmlDoc.LoadHtml(html);
                    HtmlNodeCollection nodes = htmlDoc.DocumentNode.SelectNodes(dll.XPath);
                    if (nodes != null && nodes.Count == 1)
                    {
                        string val = nodes[0].InnerText.Replace("\r", "").Replace("\n", "").Trim();
                        if (dll.XPathData != val)
                        {
                            oXPathData = val;
                            return(true);
                        }
                    }
                    else
                    {
                        throw new Exception(Resources.MsgXPathNotExist);
                    }
                }
                return(false);
            }
            catch (Exception e)
            {
                string msg = string.Format(Resources.MsgCheckingFor, iDllType, e.Message);
                throw new Exception(msg, e);
            }
        }
예제 #3
0
        /// <summary>
        /// 設定読み込み
        /// </summary>
        public void Load()
        {
            // Globals
            this.CheckNewDllOnStartup = ini.GetBool(IniSectionGlobals, IniKeyCheckNewDllOnStartup, IniDefaultCheckNewDllOnStartup);
            this.FindDllOnStartup     = ini.GetBool(IniSectionGlobals, IniKeyFindDllOnStartup, IniDefaultFindDllOnStartup);
            // TargetPath
            this.TargetPathList = new ObservableCollection <PathInfo>();
            for (int i = 0; i < 100; i++)
            {
                string   key       = string.Format(IniKeyTargetPath + "{0:00}", i);
                string   iniString = ini.GetString(IniSectionGlobals, key, IniDefaultTargetPath);
                string[] value     = iniString.Split(',');
                if (value.Length == 2)
                {
                    if (value[1].Length > 0)
                    {
                        this.TargetPathList.Add(new PathInfo(
                                                    (value[0] == "1"),
                                                    value[1],
                                                    true,
                                                    true
                                                    ));
                    }
                }
            }
            if (this.TargetPathList.Count == 0)
            {
                this.TargetPathList.Add(new PathInfo(true, string.Empty, true, true));
            }
            // IgnorePath
            this.IgnorePathList = new ObservableCollection <PathInfo>();
            for (int i = 0; i < 100; i++)
            {
                string   key       = string.Format(IniKeyIgnorePath + "{0:00}", i);
                string   iniString = ini.GetString(IniSectionGlobals, key, IniDefaultIgnorePath);
                string[] value     = iniString.Split(',');
                if (value.Length == 4)
                {
                    if (value[1].Length > 0)
                    {
                        this.IgnorePathList.Add(new PathInfo(
                                                    (value[0] == "1"),
                                                    value[1],
                                                    (value[2] == "1"),
                                                    (value[3] == "1")
                                                    ));
                    }
                }
            }
            if (this.IgnorePathList.Count == 0)
            {
                this.IgnorePathList.Add(new PathInfo(true, string.Empty, true, true));
            }

            // Proxy
            this.Proxy = new Proxy()
            {
                Enable = ini.GetBool(IniSectionProxy, IniKeyProxyEnable, IniDefaultProxyEnable),
                Server = ini.GetString(IniSectionProxy, IniKeyProxyServer, IniDefaultProxyServer),
                Port   = ini.GetInt(IniSectionProxy, IniKeyProxyPort, IniDefaultProxyPort)
            };

            // DLL EliteAPI
            this.EliteAPI = new DllTypeInfo()
            {
                DllType     = DllType.EliteAPI,
                Enable      = ini.GetBool(IniSectionEliteAPI, IniKeyEnable, IniDefaultEnableEliteAPI),
                Filename    = Constants.FilenameEliteAPI,
                CheckUrl    = ini.GetString(IniSectionEliteAPI, IniKeyCheckUrl, IniDefaultCheckUrlEliteAPI),
                XPath       = ini.GetString(IniSectionEliteAPI, IniKeyXPath, IniDefaultXPathEliteAPI),
                XPathData   = ini.GetString(IniSectionEliteAPI, IniKeyXPathLastestData, IniDefaultXPathDataEliteAPI),
                DownloadUrl = ini.GetString(IniSectionEliteAPI, IniKeyDownloadUrl, IniDefaultDownloadUrlEliteAPI)
            };
            this.DllTypeInfoList.Add(DllType.EliteAPI, this.EliteAPI);
            // DLL EliteMMOAPI
            this.EliteMMOAPI = new DllTypeInfo()
            {
                DllType     = DllType.EliteMMOAPI,
                Enable      = ini.GetBool(IniSectionEliteMMOAPI, IniKeyEnable, IniDefaultEnableEliteMMOAPI),
                Filename    = Constants.FilenameEliteMMOAPI,
                CheckUrl    = ini.GetString(IniSectionEliteMMOAPI, IniKeyCheckUrl, IniDefaultCheckUrlEliteMMOAPI),
                XPath       = ini.GetString(IniSectionEliteMMOAPI, IniKeyXPath, IniDefaultXPathEliteMMOAPI),
                XPathData   = ini.GetString(IniSectionEliteMMOAPI, IniKeyXPathLastestData, IniDefaultXPathDataEliteMMOAPI),
                DownloadUrl = ini.GetString(IniSectionEliteMMOAPI, IniKeyDownloadUrl, IniDefaultDownloadUrlEliteMMOAPI)
            };
            this.DllTypeInfoList.Add(DllType.EliteMMOAPI, this.EliteMMOAPI);
        }