//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// アクション実行。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public override string Execute5_Main(Log_Reports log_Reports) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Functions.Name_Library, this, "Execute5_Main", log_Reports); string sFncName0; this.TrySelectAttribute(out sFncName0, PmNames.S_NAME.Name_Pm, EnumHitcount.One_Or_Zero, log_Reports); if (log_Reports.CanStopwatch) { log_Method.Log_Stopwatch.Message = "Nアクション[" + sFncName0 + "]実行"; log_Method.Log_Stopwatch.Begin(); } // // if (this.EnumEventhandler == EnumEventhandler.O_Ea) { if (this.Functionparameterset.Sender is Customcontrol) { Customcontrol fcCc = (Customcontrol)this.Functionparameterset.Sender; string fcNameStr = fcCc.ControlCommon.Expression_Name_Control.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); log_Reports.Comment_EventCreationMe += "/追記:[" + fcNameStr + "]コントロールが、[" + sFncName0 + "]アクションを実行。"; } else { log_Reports.Comment_EventCreationMe += "/追記:[" + sFncName0 + "]アクションを実行。"; } // テーブル Table_Humaninput o_Table_Src; { Expression_Node_String ec_ArgTableName; this.TrySelectAttribute(out ec_ArgTableName, Expression_Node_Function05Impl.PM_NAME_TABLE_SOURCE, EnumHitcount.One_Or_Zero, log_Reports); o_Table_Src = this.Owner_MemoryApplication.MemoryTables.GetTable_HumaninputByName( ec_ArgTableName, true, log_Reports ); } // // 書き出すテキスト // string sCsvText; { ToCsv_Table_Humaninput_Impl toCsv = new ToCsv_Table_Humaninput_Impl(); // // 出力しないフィールド名(英字は、大文字にして入れること) // toCsv.ExceptedFields.List_SExceptedFields_Starts_Upper.Add("Expl".ToUpper()); // // 一時的にプロパティー変更 // bool bOldRowColRev = o_Table_Src.Format_Table_Humaninput.IsRowcolumnreverse; o_Table_Src.Format_Table_Humaninput.IsRowcolumnreverse = false;//行と列を、ひっくり返さずに書きだす。 sCsvText = toCsv.ToCsvText(o_Table_Src, log_Reports); if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } // // 元に戻す。 // o_Table_Src.Format_Table_Humaninput.IsRowcolumnreverse = bOldRowColRev; } // // 書き出し先のテーブル // Table_Humaninput o_Table_Dst; if (log_Reports.Successful) { Expression_Node_String ec_ArgTableName; this.TrySelectAttribute(out ec_ArgTableName, Expression_Node_Function05Impl.PM_NAME_TABLE_DESTINATION, EnumHitcount.One_Or_Zero, log_Reports); o_Table_Dst = this.Owner_MemoryApplication.MemoryTables.GetTable_HumaninputByName( ec_ArgTableName, true, log_Reports ); } else { o_Table_Dst = null; } // // 書き出し先ファイルへのパス // string sFpatha_Dst;//絶対ファイルパス if (log_Reports.Successful) { sFpatha_Dst = o_Table_Dst.Expression_Filepath_ConfigStack.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); } else { sFpatha_Dst = null; } // // ファイルの書き出し // if (log_Reports.Successful) { // 正常時 CsvWriterImpl writer = new CsvWriterImpl(); writer.Write(sCsvText, sFpatha_Dst, true); } } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(""); }
//──────────────────────────────────────── private void Execute6_Sub(Log_Reports log_Reports) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Functions.Name_Library, this, "Execute6_Sub", log_Reports); string sFlowSkip; this.TrySelectAttribute(out sFlowSkip, Expression_Node_Function04Impl.PM_FLOWSKIP, EnumHitcount.One_Or_Zero, log_Reports); if ("" != sFlowSkip.Trim()) { // 処理をスキップします。 goto gt_EndMethod; } // // // // テーブル名 // // // List <string> sList_TableName = new List <string>(); { string sTableNames; this.TrySelectAttribute(out sTableNames, Expression_Node_Function04Impl.PM_NAME_TABLE, EnumHitcount.One_Or_Zero, log_Reports); CsvTo_DataTableImpl reader = new CsvTo_DataTableImpl(); DataTable tblNamesTable = reader.Read( sTableNames ); foreach (DataRow row in tblNamesTable.Rows) { foreach (string column in row.ItemArray) { sList_TableName.Add(column); } } } foreach (string sTableName in sList_TableName) { Table_Humaninput o_Table; if (log_Reports.Successful) { Expression_Node_String ec_ArgTableName; this.TrySelectAttribute(out ec_ArgTableName, Expression_Node_Function04Impl.PM_NAME_TABLE, EnumHitcount.One_Or_Zero, log_Reports); Expression_Node_StringImpl ec_TableName = new Expression_Node_StringImpl(this, ec_ArgTableName.Cur_Configuration); ec_TableName.AppendTextNode( sTableName, this.Cur_Configuration, log_Reports ); // テーブル o_Table = this.Owner_MemoryApplication.MemoryTables.GetTable_HumaninputByName( ec_TableName, true, log_Reports ); } else { o_Table = null; } string sCsvText; if (log_Reports.Successful) { ToCsv_Table_Humaninput_Impl textizer = new ToCsv_Table_Humaninput_Impl(); sCsvText = textizer.ToCsvText(o_Table, log_Reports); if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } } else { sCsvText = null; } string sFpatha;//絶対ファイルパス if (log_Reports.Successful) { // 正常時 //essageBox.Show("テーブルのtext=[" + csvText + "]", "デバッグ"); // TODO ファイルパスの妥当性判定も欲しい sFpatha = o_Table.Expression_Filepath_ConfigStack.Execute4_OnExpressionString( EnumHitcount.Unconstraint, log_Reports); if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } } else { sFpatha = ""; } if (log_Reports.Successful) { bool bPopup; string sPopup; this.TrySelectAttribute(out sPopup, Expression_Node_Function04Impl.PM_POPUP, EnumHitcount.One_Or_Zero, log_Reports); if ("block" == sPopup.Trim()) { log_Method.WriteInfo_ToConsole("sPopup=[" + sPopup + "] ポップアップしません。"); bPopup = false; } else { bPopup = true; } CsvWriterImpl writer = new CsvWriterImpl(); writer.Write( sCsvText, sFpatha, bPopup); } } gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── protected void Execute6_Sub( Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_Functions.Name_Library, this, "Execute6_Sub", log_Reports); string sName_Fnc; this.TrySelectAttribute(out sName_Fnc, PmNames.S_NAME.Name_Pm, EnumHitcount.One_Or_Zero, log_Reports); if (log_Reports.CanStopwatch) { log_Method.Log_Stopwatch.Message = "Nアクション[" + sName_Fnc + "]実行"; log_Method.Log_Stopwatch.Begin(); } Exception error_Exception; string error_Filepath_Export; Expression_Node_Filepath pm_FileImportListfile_Expr; this.TrySelectAttribute_ExpressionFilepath(out pm_FileImportListfile_Expr, Expression_Node_Function49Impl.PM_FILE_IMPORT_LISTFILE, EnumHitcount.One_Or_Zero, log_Reports); Expression_Node_String pm_FieldImportListfile_Expr; this.TrySelectAttribute(out pm_FieldImportListfile_Expr, Expression_Node_Function49Impl.PM_FIELD_IMPORT_LISTFILE, EnumHitcount.One, log_Reports); Expression_Node_String pm_FilterExtensionImport_Expr; this.TrySelectAttribute(out pm_FilterExtensionImport_Expr, Expression_Node_Function49Impl.PM_FILTER_EXTENSION_IMPORT, EnumHitcount.One, log_Reports); Expression_Node_Filepath pm_FileExportListfile_Expr; this.TrySelectAttribute_ExpressionFilepath(out pm_FileExportListfile_Expr, Expression_Node_Function49Impl.PM_FILE_EXPORT_LISTFILE, EnumHitcount.One_Or_Zero, log_Reports); Expression_Node_String pm_FieldExportListfile_Expr; this.TrySelectAttribute(out pm_FieldExportListfile_Expr, Expression_Node_Function49Impl.PM_FIELD_EXPORT_LISTFILE, EnumHitcount.One, log_Reports); Expression_Node_String pm_TypefieldExportListfile_Expr; this.TrySelectAttribute(out pm_TypefieldExportListfile_Expr, Expression_Node_Function49Impl.PM_TYPEFIELD_EXPORT_LISTFILE, EnumHitcount.One, log_Reports); Expression_Node_String pm_CommentfieldExportListfile_Expr; this.TrySelectAttribute(out pm_CommentfieldExportListfile_Expr, Expression_Node_Function49Impl.PM_COMMENTFIELD_EXPORT_LISTFILE, EnumHitcount.One, log_Reports); Expression_Node_String pm_RegularexpressionReplacebeforeNamefileexport_Expr; this.TrySelectAttribute(out pm_RegularexpressionReplacebeforeNamefileexport_Expr, Expression_Node_Function49Impl.PM_REGULAREXPRESSION_REPLACEBEFORE_NAMEFILEEXPORT, EnumHitcount.One_Or_Zero, log_Reports); Expression_Node_String pm_RegularexpressionReplaceafterNamefileexport_Expr; this.TrySelectAttribute(out pm_RegularexpressionReplaceafterNamefileexport_Expr, Expression_Node_Function49Impl.PM_REGULAREXPRESSION_REPLACEAFTER_NAMEFILEEXPORT, EnumHitcount.One_Or_Zero, log_Reports); Expression_Node_Filepath pm_FolderSource_Expr; this.TrySelectAttribute_ExpressionFilepath(out pm_FolderSource_Expr, Expression_Node_Function49Impl.PM_FOLDER_SOURCE, EnumHitcount.One_Or_Zero, log_Reports); Expression_Node_Filepath pm_FolderDestination_Expr; this.TrySelectAttribute_ExpressionFilepath(out pm_FolderDestination_Expr, Expression_Node_Function49Impl.PM_FOLDER_DESTINATION, EnumHitcount.One_Or_Zero, log_Reports); //ポップアップ指定 string pm_Popup; this.TrySelectAttribute(out pm_Popup, Expression_Node_Function49Impl.PM_POPUP, EnumHitcount.One_Or_Zero, log_Reports); pm_Popup = pm_Popup.Trim(); // メッセージボックスの表示。 { Log_TextIndented str_Messagebox = new Log_TextIndentedImpl(); str_Messagebox.Append(log_Method.Fullname); str_Messagebox.Append(":"); str_Messagebox.Append(Environment.NewLine); this.Dictionary_Expression_Attribute.ToText_Debug(str_Messagebox, log_Reports); str_Messagebox.Append( "file-import-listfile=[" + pm_FileImportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "field-import-listfile=[" + pm_FieldImportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "filter-extension-import=[" + pm_FilterExtensionImport_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "file-export-listfile=[" + pm_FileExportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "field-export-listfile=[" + pm_FieldExportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "typefield-export-listfile=[" + pm_TypefieldExportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "commentfield-export-listfile=[" + pm_CommentfieldExportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "regularexpression-replacebefore-namefileexport=[" + pm_RegularexpressionReplacebeforeNamefileexport_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "regularexpression-replaceafter-namefileexport=[" + pm_RegularexpressionReplaceafterNamefileexport_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "folder-source=[" + pm_FolderSource_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "folder-destination=[" + pm_FolderDestination_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "pm_Popup=[" + pm_Popup + "]\n\n" ); MessageBox.Show(str_Messagebox.ToString(), "デバッグ表示"); } //書出し先ファイルパス。 string filepath_Export = ""; try { filepath_Export = pm_FileExportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); if ("" == filepath_Export) { //エラー error_Exception = null; error_Filepath_Export = filepath_Export; goto gt_Error_FilepathExport; } } catch (Exception ex) { //エラー error_Exception = ex; error_Filepath_Export = filepath_Export; goto gt_Error_FilepathExport; } // 「ファイル・リスト」CSVファイル読取り Table_Humaninput tableH; if (log_Reports.Successful) { CsvTo_Table_HumaninputImpl reader = new CsvTo_Table_HumaninputImpl(); Request_ReadsTable request_Reads = new Request_ReadsTableImpl(); Format_Table_Humaninput tblFormat_puts = new Format_Table_HumaninputImpl(); request_Reads.Name_PutToTable = log_Method.Fullname;//暫定 request_Reads.Expression_Filepath = pm_FileImportListfile_Expr; tableH = reader.Read( request_Reads, tblFormat_puts, true, log_Reports ); } else { tableH = null; } // CSVに列追加。 string name_FieldNew; int index_FieldNew; if (log_Reports.Successful) { name_FieldNew = pm_FieldExportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); string name_Typefield = pm_TypefieldExportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); Fielddefinition fielddefinition_New = new FielddefinitionImpl(name_FieldNew, FielddefinitionImpl.TypefieldFromString(name_Typefield, true, log_Reports)); fielddefinition_New.Comment = pm_CommentfieldExportListfile_Expr.Execute4_OnExpressionString(Syntax.EnumHitcount.Unconstraint, log_Reports); tableH.AddField(fielddefinition_New, true, log_Reports); index_FieldNew = tableH.RecordFielddefinition.ColumnIndexOf_Trimupper(name_FieldNew); } else { index_FieldNew = -1; } string regularexpression_Replacebefore_Namefileexport = pm_RegularexpressionReplacebeforeNamefileexport_Expr.Execute4_OnExpressionString(Syntax.EnumHitcount.Unconstraint, log_Reports); string regularexpression_Replaceafter_Namefileexport = pm_RegularexpressionReplaceafterNamefileexport_Expr.Execute4_OnExpressionString(Syntax.EnumHitcount.Unconstraint, log_Reports); string name_FieldSource = pm_FieldImportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports);// "FILE" if (log_Reports.Successful) { // // CSVソースファイル読取 // int rowNumber = 1; tableH.ForEach_Datapart(delegate(Record_Humaninput recordH, ref bool isBreak2, Log_Reports log_Reports2) { //記述されているファイルパス string filepath_Source_Cur; if (log_Reports.Successful) { String_HumaninputImpl.TryParse( recordH.ValueAt(name_FieldSource), out filepath_Source_Cur, "", "", log_Method, log_Reports); } else { filepath_Source_Cur = ""; } if ("" == filepath_Source_Cur) { //空欄なら無視。 goto gt_EndInnermethod; } Configurationtree_NodeFilepath filepathCur_Conf; if (log_Reports.Successful) { filepathCur_Conf = new Configurationtree_NodeFilepathImpl(log_Method.Fullname, null); filepathCur_Conf.InitPath(filepath_Source_Cur, log_Reports); } else { filepathCur_Conf = null; } Expression_Node_Filepath filepathCur_Expr; if (log_Reports.Successful) { filepathCur_Expr = new Expression_Node_FilepathImpl(filepathCur_Conf); } else { filepathCur_Expr = null; } //頭をカットする Expression_Node_Filepath fileDestination_Expr; if (log_Reports.Successful) { string filepath_Destination_New1; filepathCur_Expr.TryCutFolderpath(out filepath_Destination_New1, pm_FolderSource_Expr, true, log_Reports); //転送先パスの作成 Configurationtree_NodeFilepath fileDestination_Conf = new Configurationtree_NodeFilepathImpl(log_Method.Fullname, null); fileDestination_Conf.InitPath(pm_FolderDestination_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports), filepath_Destination_New1, log_Reports); fileDestination_Expr = new Expression_Node_FilepathImpl(fileDestination_Conf); } else { fileDestination_Expr = null; } if (!log_Reports.Successful) { //エラー isBreak2 = true; goto gt_EndInnermethod; } // //ソース側の拡張子を確認したい。 // string extension; string filterExtension = pm_FilterExtensionImport_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); List <string> list_FilterExtension = new CsvTo_ListImpl().Read(filterExtension); fileDestination_Expr.TryGetExtension(out extension, log_Reports); //log_Method.WriteDebug_ToConsole("拡張子=[" + extension + "](要素数=" + list_FilterExtension.Count + ") フィルター=[" + filterExtension + "] 含まれる?=[" + list_FilterExtension.Contains(extension) + "]"); if (list_FilterExtension.Contains(extension)) { //フィルターに含まれる //出力側のファイルパス Value_Humaninput valueH_New = new String_HumaninputImpl(log_Method.Fullname); valueH_New.Text = fileDestination_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); //ファイル名を正規表現で置換をするか否か if ("" != regularexpression_Replacebefore_Namefileexport) { Match m1 = Regex.Match(valueH_New.Text, regularexpression_Replacebefore_Namefileexport); if (m1.Success) { //ファイルパスを正規表現で置換します。 valueH_New.Text = System.Text.RegularExpressions.Regex.Replace( valueH_New.Text, regularexpression_Replacebefore_Namefileexport, regularexpression_Replaceafter_Namefileexport ); } else { //【2012-10-24 追加】 //置換が指定されているのに置換ができなかった場合は、空文字列に変換します。 valueH_New.Text = ""; } } // // レコードの追加列に値セット。 // recordH.SetValueAt(index_FieldNew, valueH_New, log_Reports); } else { } // gt_EndInnermethod: rowNumber++; }, log_Reports); } //自動連番を振ります。 if (log_Reports.Successful) { tableH.RenumberingNoField(); } //CSVファイルの書出し if (log_Reports.Successful) { string text_Csv = new ToCsv_Table_Humaninput_Impl().ToCsvText(tableH, log_Reports); try { System.IO.File.WriteAllText( filepath_Export, text_Csv, Global.ENCODING_CSV ); if (pm_Popup != S_BLOCK) { Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("ファイルに書き込みました。"); s.Newline(); s.Append("["); s.Append(filepath_Export); s.Append("]"); s.Newline(); s.Newline(); MessageBox.Show(s.ToString(), "▲実行結果!(L02)"); } } catch (Exception ex) { //エラー error_Exception = ex; error_Filepath_Export = filepath_Export; goto gt_Error_Exception; } } goto gt_EndMethod; // #region 異常系 //──────────────────────────────────────── gt_Error_FilepathExport: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Exception(error_Exception), log_Reports); //例外メッセージ tmpl.SetParameter(2, error_Filepath_Export, log_Reports); //出力先ファイルパス this.Owner_MemoryApplication.CreateErrorReport("Er:110031;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_Exception: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Exception(error_Exception), log_Reports); //例外メッセージ tmpl.SetParameter(2, error_Filepath_Export, log_Reports); //出力先ファイルパス this.Owner_MemoryApplication.CreateErrorReport("Er:110032;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // gt_EndMethod: log_Method.EndMethod(log_Reports); }