//──────────────────────────────────────── public void Translate( Configurationtree_Node cur_Cf, //コントロール Expression_Node_String ec_Cur, //「E■form-component」 MemoryApplication memoryApplication, Log_TextIndented_ConfigurationtreeToExpression pg_ParsingLog, Log_Reports log_Reports ) { List <Configurationtree_Node> cfList_Data = cur_Cf.GetChildrenByNodename(NamesNode.S_DATA, false, log_Reports); foreach (Configurationtree_Node cf_Data in cfList_Data) { string sAccess; cf_Data.Dictionary_Attribute.TryGetValue(PmNames.S_ACCESS, out sAccess, false, log_Reports); List <string> sList_Access = new CsvTo_ListImpl().Read(sAccess); if (sList_Access.Contains(ValuesAttr.S_FROM)) { // <data>要素(access="from")を S→E。 ConfigurationtreeToExpression_F12_ to = new ConfigurationtreeToExpression_F12_DataImpl_(); to.Translate( cf_Data, ec_Cur, memoryApplication, pg_ParsingLog, log_Reports ); } // fromとtoは、両方持つこともある。 if (sList_Access.Contains(ValuesAttr.S_TO)) { // <data>(access="to")要素要素を S→E。 ConfigurationtreeToExpression_F12_ to = new ConfigurationtreeToExpression_F12_DataImpl_(); to.Translate( cf_Data, ec_Cur, memoryApplication, pg_ParsingLog, log_Reports ); } } // // <view>要素を S→E。 List <Configurationtree_Node> sList_View = cur_Cf.GetChildrenByNodename(NamesNode.S_VIEW, false, log_Reports); if (1 < sList_View.Count) { // <view>要素は1個だけあるという前提。 throw new Exception("<[" + NamesNode.S_VIEW + "]>要素が2個以上あるのはエラー。"); } else if (0 < sList_View.Count) { Configurationtree_Node cf_View = sList_View[0]; ConfigurationtreeToExpression_F12_ViewImpl_ to = new ConfigurationtreeToExpression_F12_ViewImpl_(); to.Translate( cf_View, ec_Cur,//.E_View, memoryApplication, pg_ParsingLog, log_Reports ); } else { } }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// 実行。 /// </summary> /// <param name="sender"></param> /// <param name="eventMonitor"></param> /// <param name="log_Reports"></param> public override string Execute5_Main(Log_Reports log_Reports) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); 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 = "「E■[" + sFncName0 + "]アクション」実行(A)"; log_Method.Log_Stopwatch.Begin(); } if (this.EnumEventhandler == EnumEventhandler.O_Lr) { string sName_Usercontrol; if (this.Functionparameterset.Sender is Customcontrol) { Customcontrol ccFc = (Customcontrol)this.Functionparameterset.Sender; sName_Usercontrol = ccFc.ControlCommon.Expression_Name_Control.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); log_Reports.Comment_EventCreationMe += "/追記:[" + sName_Usercontrol + "]コントロールが、[" + sFncName0 + "]アクションを実行。"; } else { sName_Usercontrol = "(▲不明101!)"; log_Reports.Comment_EventCreationMe += "/追記:[" + sFncName0 + "]アクションを実行。"; } // // // // List <Usercontrol> ucFcList; if (log_Reports.Successful) { // 正常時 // テーブルデータをコントロールにセットします。 // // 指定のコントロール(無指定の場合、自コントロール)を // まず取得。 // Expression_Node_String ec_ArgListboxName; this.TrySelectAttribute(out ec_ArgListboxName, Expression_Node_Function20Impl.PM_NAME_CONTROL_LISTBOX, EnumHitcount.One_Or_Zero, log_Reports); ucFcList = this.Owner_MemoryApplication.MemoryForms.GetUsercontrolsByName( ec_ArgListboxName, true, log_Reports); } else { ucFcList = new List <Usercontrol>(); } // リストボックスにテーブルのデータソースを関連付けます。 if (log_Reports.Successful) { // 正常時 // リストボックス コントロール。 Usercontrol fcUc = ucFcList[0]; Expression_Node_String ec_TableName = null; string sTableName; this.TrySelectAttribute(out sTableName, Expression_Node_Function20Impl.PM_NAME_TABLE, EnumHitcount.One_Or_Zero, log_Reports); if ("" != sTableName)//this.E_SysArgDic.ContainsKey(E_SysFnc20Impl.S_ARG_TABLE_NAME) { //テーブル名を指定(アクション用引数) this.TrySelectAttribute(out ec_TableName, Expression_Node_Function20Impl.PM_NAME_TABLE, EnumHitcount.One_Or_Zero, log_Reports); // #デバッグ if (log_Method.CanWarning()) { log_Method.WriteWarning_ToConsole(" <arg3 tableName=”[" + ec_TableName.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]”>属性でした。"); } } else { // #デバッグ if (log_Method.CanWarning()) { log_Method.WriteWarning_ToConsole(" <arg3 tableName=”☆”>属性が未指定でした。"); } Configuration_Node owner_Configurationtree_Control; { owner_Configurationtree_Control = this.Cur_Configuration.GetParentByNodename( NamesNode.S_CONTROL1, EnumConfiguration.Tree, true, log_Reports); } // // 次を期待。 // <data target=”list-box”> // <arg5 name=”tableName” value=”☆”> // List <Configurationtree_Node> cfList_Data = ((Configurationtree_Node)owner_Configurationtree_Control).GetChildrenByNodename( NamesNode.S_DATA, false, log_Reports); foreach (Configurationtree_Node cf_Data in cfList_Data) { string sAccess; cf_Data.Dictionary_Attribute.TryGetValue(PmNames.S_ACCESS, out sAccess, false, log_Reports); List <string> sList_Access = new CsvTo_ListImpl().Read(sAccess); if (sList_Access.Contains(ValuesAttr.S_FROM)) { // <data access=”from”> string sDataMemory; cf_Data.Dictionary_Attribute.TryGetValue(PmNames.S_MEMORY, out sDataMemory, true, log_Reports); if (!log_Reports.Successful) { goto gt_EndMethod; } if (ValuesAttr.S_RECORDS == sDataMemory) { cf_Data.Dictionary_Attribute.TryGetValue(PmNames.S_NAME_TABLE, out sTableName, true, log_Reports); if (!log_Reports.Successful) { goto gt_EndMethod; } ec_TableName = new Expression_Leaf_StringImpl(sTableName, this, cf_Data); // #デバッグ if (log_Method.CanWarning()) { log_Method.WriteWarning_ToConsole(" <data tableName=”[" + sTableName + "]”>属性でした。"); } } else { //#連続エラー { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, sDataMemory, log_Reports);//属性memoryの値 this.Owner_MemoryApplication.CreateErrorReport("Er:110007;", tmpl, log_Reports); } } } } if (null == ec_TableName) { // エラー処理? if (log_Method.CanError()) { log_Method.WriteError_ToConsole(" 直接指定されなかったので、既に<data>にtableName属性があると期待しましたが、ありませんでした。"); } sTableName = ""; //string sTableName = ""; ec_TableName = new Expression_Leaf_StringImpl(sTableName, this, owner_Configurationtree_Control); // owner_Cf_Fc.S_DataSource } } //↓この中で時間かかってる。 Utility_Listbox.BindTableToDatasource( fcUc,// リストボックス・コントロール ec_TableName, this.Owner_MemoryApplication, log_Reports ); //↑この中で時間かかってる。 } } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(""); }
//──────────────────────────────────────── 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); }