List <ThemeData> LoadThemes(string[] data) { var themes = new List <ThemeData>(); foreach (var theme in data) { var split = theme.Split('|'); if (split.Length != 3) { // except continue; } var name = split[0]; var path = split[1]; var guid = split[2]; try { using (var http = new ExWebClient()) { http.Encoding = Encoding.UTF8; var files = new List <FilesData>(); var bytes = http.DownloadData("https://dnf.kxnrl.com/themes/" + path + ".list"); foreach (var result in Encoding.UTF8.GetString(bytes).Split('\n')) { var info = result.Split('|'); if (info.Length != 4) { // except continue; } files.Add(new FilesData(info[0], info[2], info[3], info[1])); } if (files.Count == 0) { // wtf? throw new Exception("NullDataSet"); } themes.Add(new ThemeData(name, guid, path, files)); } } catch (Exception e) { Logger.LogError("LoadTheme [{0}] Exception: {1}{2}", name, e.Message, e.StackTrace); } } return(themes); }
private void btnSearch_Click(object sender, RoutedEventArgs e) { this.tblUpload.Text = ""; _entityUpdate._upload_file_path1 = ""; this.wc = new ExWebClient(); wc.win = this; wc.FileUpLoadFileSet(); this.txtPath.Text = wc.uploadFileName; if (!string.IsNullOrEmpty(this.txtPath.Text)) { Common.gstrProgressDialogTitle = "ファイルアップロード処理中"; dlgProc.Show(); } }
private void btnDownLoad_Click(object sender, RoutedEventArgs e) { Button btn = (Button)sender; string no = btn.Name.Replace("btn", ""); for (int i = 0; i <= _entityList.Count - 1; i++) { if (ExCast.zCLng(no) == _entityList[i]._no) { string[] prm = new string[4]; prm[0] = _entityList[i]._upload_file_name1; prm[1] = _entityList[i]._upload_file_path1; wc = new ExWebClient(); wc.utlParentFKey = null; wc.FileDownLoad(DataReport.geReportKbn.None, CLASS_NM, prm); } } }
public void DownloadData(Action <DownloadDatas> data, Action <bool, string> func = null, Action <bool, double> progressDownload = null) { DownloadDatas dd = new DownloadDatas(); data(dd); int _timeout = (int)TimeSpan.FromSeconds(dd.timeout_seconds).TotalMilliseconds; if (dd.url == null) { throw new ArgumentException("Please set the URL"); } ExWebClient webClient = new ExWebClient(_timeout); try { // mendapatkan nama berdasarkan url string _file_name = dd.url.Split('/').Last(); var _path = dd.folder_directory; string path = ""; if (Device.RuntimePlatform == Device.Android) { path = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/" + _path; } else { path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/" + _path; } if (!Directory.Exists(path)) { // Console.WriteLine("directory tidak ada " + path); Directory.CreateDirectory(path); } double progress = .0; if (progressDownload != null) { webClient.DownloadProgressChanged += (s, e) => { double prog = (double)e.ProgressPercentage; progress = prog / 100; progressDownload(false, progress); }; } webClient.DownloadDataCompleted += (s, e) => { try { var bytes = e.Result; string localFilename = dd.file_name ?? _file_name; string localPath = Path.Combine(path, localFilename); progressDownload?.Invoke(true, .0); try { File.WriteAllBytes(localPath, bytes); //Application.Current.MainPage.DisplayAlert("Info", "Data berhasil di unduh.\n\rFolder penyimpanan : " + _path, "Ok"); } catch (DirectoryNotFoundException dx) { Console.WriteLine("Directory Not found : " + dx.StackTrace); Console.WriteLine("Directory Not found : " + dx.Message); //Application.Current.MainPage.DisplayAlert("Ops", "Terjadi kesalahan : " + dx.Message, "Ok"); } } catch (Exception ex) { Console.WriteLine("Directory Not found : " + ex.StackTrace); Console.WriteLine("Directory Not found : " + ex.Message); func(false, ex.Message); } // IMPORTANT: this is a background thread, so any interaction with // UI controls must be done via the MainThread }; func(true, null); webClient.DownloadDataAsync(new Uri(dd.url)); } catch (Exception ex) { func(false, ex.Message); //Application.Current.MainPage.DisplayAlert("Ops", "Terjadi kersalahan : \n\r" + ex.Message, "Ok"); Console.WriteLine("ERROR:" + ex.StackTrace); Console.WriteLine("ERROR:" + ex.Message); } }
private void PatchForm_Load(object sender, EventArgs e) { Icon = Properties.Resources.icon; Utils.NPKScanner.Scan(); switch (Variables.PatchMode) { case Variables.PatchType.Character: Text = "角色补丁"; PatchTypeName = "Character"; break; case Variables.PatchType.Optimization: Text = "优化补丁"; PatchTypeName = "Optimization"; break; case Variables.PatchType.Miscellaneous: Text = "其他补丁"; PatchTypeName = "Miscellaneous"; break; //case Variables.PatchType.Theme: // Text = "自定义主题"; // PatchTypeName = "Theme"; // break; default: MessageBox.Show("发生未知错误!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); ((MainForm)Owner).Activate(); Close(); Dispose(); return; } new Thread(() => { Invoke(new Action(() => { ActionLabel.Text = "正在连接服务器..."; Application.DoEvents(); })); Thread.Sleep(100); Invoke(new Action(() => { try { using (var http = new ExWebClient()) { http.Encoding = Encoding.UTF8; var data = Encoding.UTF8.GetString(http.DownloadData("https://dnf.kxnrl.com/" + PatchTypeName + ".list")).Split('\n'); if (data.Length == 0) { // null ActionLabel.Text = "补丁列表为空"; throw new Exception("补丁列表为空"); } patches.Clear(); foreach (var patch in data) { var split = patch.Split('|'); if (split.Length != 4) { // ??? continue; } patches.Add(new Patches(split[0], split[1], split[2].ToLowerInvariant(), split[3])); } Progressbar.Value = Progressbar.Maximum; ActionLabel.Text = "初始化完成..."; foreach (var p in patches) { PatchList.Rows.Add(p.pGUID, p.pName, p.pDesc, p.pDone ? "卸载" : "安装"); } } } catch (Exception ex) { MessageBox.Show("初始化补丁列表失败:" + Environment.NewLine + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.LogError("DownloadData [{0}] Exception: {1}", "ThreadInvoker", ex.Message); Invoke(new Action(() => { ((MainForm)Owner).Activate(); Close(); Dispose(); })); } })); }).Start(); }
public override void ReportOut(object entity) { string _msg = ""; ExWebClient wc = null; try { if (entity != null) { EntityReport _entity = (EntityReport)entity; // 失敗 if (_entity._message != "" || _entity._ret == false) { reportView.Close(); if (this.utlParentFKey != null) { this.utlParentFKey.IsEnabled = true; } return; } switch (this.rptKbn) { case DataReport.geReportKbn.OutPut: //ExHyperlinkButton link = new ExHyperlinkButton(_entity._downLoadUrl); //link.ClickMe(); reportView.reportUrl = _entity._downLoadUrl; reportView.reportFileName = _entity._downLoadFileName; reportView.reportFilePath = _entity._downLoadFilePath; reportView.ViewReport(); break; case DataReport.geReportKbn.Download: case DataReport.geReportKbn.Csv: string[] prm = new string[4]; prm[0] = _entity._downLoadFileName; prm[1] = _entity._downLoadFilePath; wc = new ExWebClient(); wc.utlParentFKey = this.utlParentFKey; webService.ProcessingDlgClose(); wc.FileDownLoad(this.rptKbn, pgId, prm); break; } #region 印刷発行済セット switch (pgId) { case DataPgEvidence.PGName.Estimate.EstimatePrint: if (this.updPrintNo != null) { string _no = (string)this.updPrintNo; object[] prm = new object[2]; prm[0] = (int)Common.geUpdateType.Update; prm[1] = _no; webService.objPerent = this; webService.CallWebService(ExWebService.geWebServiceCallKbn.UpdateEstimatePrint, ExWebService.geDialogDisplayFlg.No, ExWebService.geDialogCloseFlg.No, prm); } break; case DataPgEvidence.PGName.Order.OrderPrint: if (this.updPrintNo != null) { string _no = (string)this.updPrintNo; object[] prm = new object[2]; prm[0] = (int)Common.geUpdateType.Update; prm[1] = _no; webService.objPerent = this; webService.CallWebService(ExWebService.geWebServiceCallKbn.UpdateOrderPrint, ExWebService.geDialogDisplayFlg.No, ExWebService.geDialogCloseFlg.No, prm); } break; case DataPgEvidence.PGName.Sales.SalesPrint: if (this.updPrintNo != null) { string _no = (string)this.updPrintNo; object[] prm = new object[2]; prm[0] = (int)Common.geUpdateType.Update; prm[1] = _no; webService.objPerent = this; webService.CallWebService(ExWebService.geWebServiceCallKbn.UpdateSalesPrint, ExWebService.geDialogDisplayFlg.No, ExWebService.geDialogCloseFlg.No, prm); } break; case DataPgEvidence.PGName.Invoice.InvoicePrint: if (this.updPrintNo != null) { ObservableCollection <EntityInvoiceClose> lstPrm = (ObservableCollection <EntityInvoiceClose>) this.updPrintNo; object[] prm = new object[2]; prm[0] = (int)Common.geUpdateType.Update; prm[1] = lstPrm; webService.objPerent = this; webService.CallWebService(ExWebService.geWebServiceCallKbn.UpdateInvoicePrint, ExWebService.geDialogDisplayFlg.No, ExWebService.geDialogCloseFlg.No, prm); } break; case DataPgEvidence.PGName.PurchaseOrder.PurchaseOrderPrint: if (this.updPrintNo != null) { string _no = (string)this.updPrintNo; object[] prm = new object[2]; prm[0] = (int)Common.geUpdateType.Update; prm[1] = _no; webService.objPerent = this; webService.CallWebService(ExWebService.geWebServiceCallKbn.UpdatePurchaseOrderPrint, ExWebService.geDialogDisplayFlg.No, ExWebService.geDialogCloseFlg.No, prm); } break; case DataPgEvidence.PGName.Payment.PaymentPrint: if (this.updPrintNo != null) { ObservableCollection <EntityPaymentClose> lstPrm = (ObservableCollection <EntityPaymentClose>) this.updPrintNo; object[] prm = new object[2]; prm[0] = (int)Common.geUpdateType.Update; prm[1] = lstPrm; webService.objPerent = this; webService.CallWebService(ExWebService.geWebServiceCallKbn.UpdatePaymentPrint, ExWebService.geDialogDisplayFlg.No, ExWebService.geDialogCloseFlg.No, prm); } break; } #endregion } else { // 失敗 switch (this.rptKbn) { case DataReport.geReportKbn.OutPut: _msg = "レポート出力"; break; case DataReport.geReportKbn.Download: _msg = "レポートダウンロード"; break; case DataReport.geReportKbn.Csv: _msg = "CSVダウンロード"; break; } if (_msg != "") { ExMessageBox.Show(_msg + "で予期せぬエラーが発生しました。"); } if (this.utlParentFKey != null) { this.utlParentFKey.IsEnabled = true; } return; } } catch { webService.ProcessingDlgClose(); if (this.utlParentFKey != null) { this.utlParentFKey.IsEnabled = true; } } }
public static void CheckVersion(out Variables.VersionInfo versionInfo) { versionInfo = new Variables.VersionInfo(); var file = Path.Combine(Variables.BaseFolder, "cache", "version.db"); new Thread(PostUserInfo) { IsBackground = true, Priority = ThreadPriority.Lowest }.Start(); try { if (File.Exists(file)) { // deleted File.Delete(file); } using (var http = new ExWebClient()) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; http.Encoding = Encoding.UTF8; http.DownloadFile("https://dnf.kxnrl.com/version.ini", file); versionInfo.Version = GetIniString(file, "Version", "version"); string[] latest = versionInfo.Version.Split('.'); if (latest.Length != 3 || !uint.TryParse(latest[2], out uint latestBuild) || !uint.TryParse(latest[1], out uint latestMinor) || !uint.TryParse(latest[0], out uint latestMajor) ) { throw new Exception("版本号检查错误 -> 本地版本[" + Variables.Version.Version + "] 远程版本[" + versionInfo.Version + "]."); } if (latestMajor > Major || (latestMajor == Major && latestMinor > Minor) || (latestMajor == Major && latestMinor == Minor && latestBuild > Builld)) { versionInfo.Author = GetIniString(file, "Description", "author"); versionInfo.Commit = GetIniString(file, "Version", "commit"); versionInfo.Date = GetIniString(file, "Version", "date"); versionInfo.UpdateURL = GetIniString(file, "Version", "updateUrl"); versionInfo.Description = GetIniString(file, "Description", "description"); versionInfo.Website = GetIniString(file, "Description", "website"); if (MessageBox.Show("发现新版本 [" + versionInfo.Version + "]" + Environment.NewLine + "是否立即更新? ", "发现新版本", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { System.Diagnostics.Process.Start(versionInfo.UpdateURL); Environment.Exit(0); } } } } catch (Exception e) { Logger.LogError("CheckVersionError Exception: {0}", e.Message); Program.CloseTips(); MessageBox.Show("检查新版本失败...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void ThemeForm_Load(object sender, EventArgs e) { Icon = Properties.Resources.icon; Utils.NPKScanner.Scan(); new Thread(() => { Invoke(new Action(() => { ActionLabel.Text = "正在连接服务器..."; Application.DoEvents(); })); Thread.Sleep(100); Invoke(new Action(() => { try { using (var http = new ExWebClient()) { http.Encoding = Encoding.UTF8; var text = Encoding.UTF8.GetString(http.DownloadData("https://dnf.kxnrl.com/" + "Theme.list")).Split('\n'); if (text.Length == 0) { // null ActionLabel.Text = "补丁列表为空"; throw new Exception("补丁列表为空"); } defaultIndex = ThemeSelector.Items.Add(new ThemeData("国服DNF原版界面")); ThemeSelector.SelectedIndex = defaultIndex; currentInstalled = defaultIndex; foreach (var theme in LoadThemes(text)) { var index = ThemeSelector.Items.Add(theme); CheckValidation(theme.tFile, out int installed); if (installed > 0) { // installed currentInstalled = index; ThemeSelector.SelectedIndex = index; } } ThemeSelector.DropDownStyle = ComboBoxStyle.DropDownList; ThemeSelector.Enabled = true; Progressbar.Value = Progressbar.Maximum; ActionLabel.Text = "初始化完成..."; } } catch (Exception ex) { MessageBox.Show("初始化补丁列表失败:" + Environment.NewLine + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Logger.LogError("DownloadData [{0}] Exception: {1} {2} {3}", "ThreadInvoker", ex.Message, Environment.NewLine, ex.StackTrace); Invoke(new Action(() => { ((MainForm)Owner).Activate(); Close(); Dispose(); })); } })); }).Start(); }