/// <summary>更新チェック&インストール</summary> private void btnCheckUpdateAndInstall_Click(object sender, EventArgs e) { // エントリを生成 Entry entry = new Entry(); entry.WWWURL = txtURL.Text; entry.WWWUID = txtUID.Text; entry.WWWPWD = txtPWD.Text; entry.WWWDomain = txtDomain.Text; //--- entry.ProxyURL = txtProxyURL.Text; entry.ProxyUID = txtProxyUID.Text; entry.ProxyPWD = txtProxyPWD.Text; entry.ProxyDomain = txtProxyDomain.Text; // エントリを保存 Program.SaveCurrent(entry); // 履歴をロード this.LoadHistories(); #region 更新処理の実行 // 非同期呼び出し Program.Af = new MyBaseAsyncFunc(this.panel1); // 非同期処理本体デレゲード Program.Af.AsyncFunc = new BaseAsyncFunc.AsyncFuncDelegate(Program.ExecUpdate); // 進捗報告・無名関数デレゲード Program.Af.ChangeProgress = delegate(object param) { this.Status = ((ChangeProgressParameter)param).Status; this.Refresh(); }; // 結果設定・無名関数デレゲード Program.Af.SetResult = delegate(object retVal) { if (retVal is MyException) { // 戻し Program.Recover(); // メッセージ表示時 MyException my_ex = (MyException)retVal; string message = my_ex.Message; // ログ出力用のフィールドがあるか?ないか? if (string.IsNullOrEmpty(my_ex.ToLog)) { Program.OutPutMessage(message, LogLevel.InfoLog); } else { Program.OutPutMessage(message + "\r\n" + my_ex.ToLog, LogLevel.InfoLog); } //MessageBox.Show(message, "メッセージ", MessageBoxButtons.OK, MessageBoxIcon.Information); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call MessageBox.Show(message, ResourceMgr.GetString("M0001"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (retVal is Exception) { // 戻し Program.Recover(); // 例外発生時 string message = ""; Exception ex = (Exception)retVal; //message += "<メッセージ>\r\n"; //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call message += ResourceMgr.GetString("M0002") + "\r\n"; message += ex.Message; message += "\r\n"; message += "\r\n"; //message += "<スタック トレース>\r\n"; //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call message += ResourceMgr.GetString("M0003") + "\r\n"; message += ex.StackTrace; message += "\r\n"; if (ex.InnerException != null) { message += "\r\n"; //message += "<内部例外>\r\n"; //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call message += ResourceMgr.GetString("M0004") + "\r\n"; message += ex.InnerException.ToString(); message += "\r\n"; } Program.OutPutMessage(message, LogLevel.ErrorLog); //CustMsgBox custMsgBox = new CustMsgBox("エラー", message, SystemIcons.Error); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call CustMsgBox custMsgBox = new CustMsgBox(ResourceMgr.GetString("Error0001"), string.Format(message), SystemIcons.Error); custMsgBox.ShowDialog(); } else { // 正常終了 // 履歴を保存 Program.SaveHistories(); // エントリ・履歴の復元する。 this.LoadBins(); } // テンポラリの削除 File.Delete(Program.OrgCurrentDirectory + Program.TempMftFileName); // GCでZIPが解放される可能性 //GC.Collect(); Program.system_gc_collecting(); try { File.Delete(Program.OrgCurrentDirectory + Program.TempZipFileName); } catch (Exception ex) { // 例外を潰してログに出力 //Program.OutPutMessage(Program.TempZipFileName + "削除例外:" + ex.ToString(), LogLevel.ErrorLog); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call Program.OutPutMessage(Program.TempZipFileName + ResourceMgr.GetString("E0002") + ex.ToString(), LogLevel.ErrorLog); } }; // 非同期処理を開始させる。 Program.Af.Parameter = entry; if (Program.Af.Start()) { //this.xxx(string.Format( // "キューイングされました、現在のスレッド数:{0}", // BaseAsyncFunc.ThreadCount.ToString())); } else { //this.xxx(string.Format( // "非同期スレッドが最大数に達しています。:{0}", // BaseAsyncFunc.ThreadCount.ToString())); } #endregion }
/// <summary>解凍処理</summary> private void btnDecomp_Click(object sender, EventArgs e) { try { // チェック処理 this.CheckComp_DeComp(); // 解凍部品 UnZipper uz = new UnZipper(); // 選択基準 string[] exts = null; Zipper.SelectionDelegate scd = null; if (this.txtExt.Enabled) { exts = this.txtExt.Text.Split(','); scd = Program.SelectionCriteriaDlgt2; } // 解凍時、上書き制御 uz.ExtractProgress = Program.MyExtractProgressEventHandler; // 解凍(1)デリゲートでフィルタ uz.ExtractFileFromZip( this.txtFile.Text, this.txtFolder.Text, scd, exts, (ExtractExistingFileAction)this.cmbEEFA.SelectedItem, Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), this.txtPass.Text); //// 解凍(2):selectionCriteriaStringでフィルタ //string selectionCriteriaString = ""; //if (exts != null) //{ // foreach (string ext in exts) // { // if (selectionCriteriaString == "") // { // selectionCriteriaString = "name != *." + ext; // } // else // { // selectionCriteriaString += " and name != *." + ext; // } // } //} //uz.ExtractFileFromZip( // this.txtFile.Text, // this.txtFolder.Text, // selectionCriteriaString, // (ExtractExistingFileAction)this.cmbEEFA.SelectedItem, // Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), // this.txtPass.Text); //MessageBox.Show(uz.StatusMSG, "サマリ", // MessageBoxButtons.OK, MessageBoxIcon.Information); //CustMsgBox custMsgBox = new CustMsgBox("サマリ(解凍)", uz.StatusMSG, SystemIcons.Information); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call CustMsgBox custMsgBox = new CustMsgBox(ResourceMgr.GetString("Error0003"), uz.StatusMSG, SystemIcons.Information); custMsgBox.ShowDialog(); } catch(Exception ex) { //MessageBox.Show(ex.Message, "エラーが発生しました。", MessageBoxButtons.OK, MessageBoxIcon.Error); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call MessageBox.Show(ex.Message, ResourceMgr.GetString("E0001"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary>圧縮処理</summary> private void btnCompress_Click(object sender, EventArgs e) { try { // チェック処理 this.CheckComp_DeComp(); // 圧縮部品 Zipper z = new Zipper(); // 選択基準 string[] exts = null; Zipper.SelectionDelegate scd = null; if (this.txtExt.Enabled) { exts = this.txtExt.Text.Split(','); scd = Program.SelectionCriteriaDlgt1; } // 形式指定 SelfExtractorFlavor? selfEx = null; if (this.cmbFormat.Enabled) { selfEx = (SelfExtractorFlavor)this.cmbFormat.SelectedItem; } // ZIP内パスのルート名 string[] temp = this.txtFile.Text.Split('\\'); // 進捗報告処理 z.SaveProgress = Program.MySaveProgressEventHandler; // ルートのディレクトリを作るか作らないか。 string rootPathInArchive = ""; if (!this.cbxRootDir.Checked) { rootPathInArchive = temp[temp.Length - 1]; } // 圧縮(1)デリゲートでフィルタ z.CreateZipFromFolder( this.txtFile.Text, this.txtFolder.Text, scd, exts, rootPathInArchive, // ここを空文字列にするとルートフォルダ無しになる。 Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), (EncryptionAlgorithm)this.cmbCyp.SelectedItem, this.txtPass.Text, (CompressionLevel)this.cmbCmpLv.SelectedItem, selfEx); //// 圧縮(2):selectionCriteriaStringでフィルタ //string selectionCriteriaString = ""; //if (exts != null) //{ // foreach (string ext in exts) // { // if (selectionCriteriaString == "") // { // selectionCriteriaString = "name != *." + ext; // } // else // { // selectionCriteriaString += " and name != *." + ext; // } // } //} //z.CreateZipFromFolder( // this.txtFile.Text, this.txtFolder.Text, // selectionCriteriaString, // temp[temp.Length - 1], // Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), // (EncryptionAlgorithm)this.cmbCyp.SelectedItem, this.txtPass.Text, // (CompressionLevel)this.cmbCmpLv.SelectedItem, selfEx); //MessageBox.Show(z.StatusMSG,"サマリ", // MessageBoxButtons.OK, MessageBoxIcon.Information); CustMsgBox custMsgBox = new CustMsgBox(ResourceMgr.GetString("Error0002"), z.StatusMSG, SystemIcons.Information); custMsgBox.ShowDialog(); } catch (Exception ex) { //MessageBox.Show(ex.Message, "エラーが発生しました。", MessageBoxButtons.OK, MessageBoxIcon.Error); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call MessageBox.Show(ex.Message, ResourceMgr.GetString("E0001"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary>解凍処理</summary> private void btnDecomp_Click(object sender, EventArgs e) { try { // チェック処理 this.CheckComp_DeComp(); // 解凍部品 UnZipper uz = new UnZipper(); // 選択基準 string[] exts = null; Zipper.SelectionDelegate scd = null; if (this.txtExt.Enabled) { exts = this.txtExt.Text.Split(','); scd = Program.SelectionCriteriaDlgt2; } // 解凍時、上書き制御 uz.ExtractProgress = Program.MyExtractProgressEventHandler; // 解凍(1)デリゲートでフィルタ uz.ExtractFileFromZip( this.txtFile.Text, this.txtFolder.Text, scd, exts, (ExtractExistingFileAction)this.cmbEEFA.SelectedItem, Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), this.txtPass.Text); //// 解凍(2):selectionCriteriaStringでフィルタ //string selectionCriteriaString = ""; //if (exts != null) //{ // foreach (string ext in exts) // { // if (selectionCriteriaString == "") // { // selectionCriteriaString = "name != *." + ext; // } // else // { // selectionCriteriaString += " and name != *." + ext; // } // } //} //uz.ExtractFileFromZip( // this.txtFile.Text, // this.txtFolder.Text, // selectionCriteriaString, // (ExtractExistingFileAction)this.cmbEEFA.SelectedItem, // Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), // this.txtPass.Text); //MessageBox.Show(uz.StatusMSG, "サマリ", // MessageBoxButtons.OK, MessageBoxIcon.Information); //CustMsgBox custMsgBox = new CustMsgBox("サマリ(解凍)", uz.StatusMSG, SystemIcons.Information); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call CustMsgBox custMsgBox = new CustMsgBox(ResourceMgr.GetString("Error0003"), uz.StatusMSG, SystemIcons.Information); custMsgBox.ShowDialog(); } catch (Exception ex) { //MessageBox.Show(ex.Message, "エラーが発生しました。", MessageBoxButtons.OK, MessageBoxIcon.Error); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call MessageBox.Show(ex.Message, ResourceMgr.GetString("E0001"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary>圧縮処理</summary> private void btnCompress_Click(object sender, EventArgs e) { try { // チェック処理 this.CheckComp_DeComp(); // 圧縮部品 Zipper z = new Zipper(); // 選択基準 string[] exts = null; Zipper.SelectionDelegate scd = null; if (this.txtExt.Enabled) { exts = this.txtExt.Text.Split(','); scd = Program.SelectionCriteriaDlgt1; } // 形式指定 SelfExtractorFlavor?selfEx = null; if (this.cmbFormat.Enabled) { selfEx = (SelfExtractorFlavor)this.cmbFormat.SelectedItem; } // ZIP内パスのルート名 string[] temp = this.txtFile.Text.Split('\\'); // 進捗報告処理 z.SaveProgress = Program.MySaveProgressEventHandler; // ルートのディレクトリを作るか作らないか。 string rootPathInArchive = ""; if (!this.cbxRootDir.Checked) { rootPathInArchive = temp[temp.Length - 1]; } // 圧縮(1)デリゲートでフィルタ z.CreateZipFromFolder( this.txtFile.Text, this.txtFolder.Text, scd, exts, rootPathInArchive, // ここを空文字列にするとルートフォルダ無しになる。 Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), (EncryptionAlgorithm)this.cmbCyp.SelectedItem, this.txtPass.Text, (CompressionLevel)this.cmbCmpLv.SelectedItem, selfEx); //// 圧縮(2):selectionCriteriaStringでフィルタ //string selectionCriteriaString = ""; //if (exts != null) //{ // foreach (string ext in exts) // { // if (selectionCriteriaString == "") // { // selectionCriteriaString = "name != *." + ext; // } // else // { // selectionCriteriaString += " and name != *." + ext; // } // } //} //z.CreateZipFromFolder( // this.txtFile.Text, this.txtFolder.Text, // selectionCriteriaString, // temp[temp.Length - 1], // Encoding.GetEncoding((string)this.cmbEnc.SelectedItem), // (EncryptionAlgorithm)this.cmbCyp.SelectedItem, this.txtPass.Text, // (CompressionLevel)this.cmbCmpLv.SelectedItem, selfEx); //MessageBox.Show(z.StatusMSG,"サマリ", // MessageBoxButtons.OK, MessageBoxIcon.Information); CustMsgBox custMsgBox = new CustMsgBox(ResourceMgr.GetString("Error0002"), z.StatusMSG, SystemIcons.Information); custMsgBox.ShowDialog(); } catch (Exception ex) { //MessageBox.Show(ex.Message, "エラーが発生しました。", MessageBoxButtons.OK, MessageBoxIcon.Error); //For internationalization, Replaced all the Japanese language to ResourceMgr.GetString() method call MessageBox.Show(ex.Message, ResourceMgr.GetString("E0001"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }