//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── public void CreateErrorReport( string errorSymbol, Builder_TexttemplateP1p texttemplateBuilder_ParameterSetted, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "CreateErrorReport", log_Reports); // int errorNumber; { string tempErrorSymbol = errorSymbol; if (tempErrorSymbol.StartsWith("Er:")) { tempErrorSymbol = tempErrorSymbol.Substring(3); if (tempErrorSymbol.EndsWith(";")) { tempErrorSymbol = tempErrorSymbol.Substring(0, tempErrorSymbol.Length - 1); if (int.TryParse(tempErrorSymbol, out errorNumber)) { } else { goto gt_Error_Symbol; } } else { goto gt_Error_Symbol; } } else { goto gt_Error_Symbol; } } if (log_Reports.CanCreateReport) { string strTypedata = ValuesTypeData.S_TABLE_ERRORMESSAGES; Configurationtree_Node cur_Ct = new Configurationtree_NodeImpl(log_Method.Fullname, null); List <Table_Humaninput> tables = this.MemoryTables.GetTable_HumaninputByTypedata( new Expression_Leaf_StringImpl(strTypedata, null, cur_Ct), true, log_Reports); bool hit = false; foreach (Table_Humaninput table in tables) { foreach (DataRow dataRow in table.DataTable.Rows) { Int_HumaninputImpl xenonValue_Int = (Int_HumaninputImpl)dataRow["ID"]; int valueInt; xenonValue_Int.TryGet(out valueInt); if (valueInt == errorNumber) { //ヒット hit = true; Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("Er:" + errorNumber + ";", log_Method); String_HumaninputImpl xenonValue_String = (String_HumaninputImpl)dataRow["MESSAGE"]; string valueStr; xenonValue_String.TryGet(out valueStr); texttemplateBuilder_ParameterSetted.Text = valueStr; r.Message = texttemplateBuilder_ParameterSetted.Compile(log_Reports).Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); //log_Method.WriteDebug_ToConsole(texttemplateBuilder_ParameterSetted.Compile(log_Reports).Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports)); goto gt_EndLoop1; } } } gt_EndLoop1: if (!hit) { //エラーメッセージの登録がない。 Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("Er:0;", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("エラーメッセージテーブルに、エラーメッセージの登録がありませんでした。\n%1%=[%2%]\nテーブル数=[%3%]"); Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(s.ToString()); tmpl.SetParameter(1, NamesFld.S_TYPE_DATA, log_Reports); tmpl.SetParameter(2, strTypedata, log_Reports); tmpl.SetParameter(3, tables.Count.ToString(), log_Reports); r.Message = tmpl.Compile(log_Reports).Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); } log_Reports.EndCreateReport(); } goto gt_EndMethod; // #region 異常系 //──────────────────────────────────────── gt_Error_Symbol: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー204!", log_Method); StringBuilder s = new StringBuilder(); s.Append("エラーシンボルがおかしい。[" + errorSymbol + "]。プログラムのミス?"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── private void ReadKeyconfig(Gamepadmainloop mainloop, int nPlayerPrm, Memory_GameController gc) { Log_Method pg_Method = new Log_MethodImpl(0); Log_Reports log_Reports_ThisMethod = new Log_ReportsImpl(pg_Method); pg_Method.BeginMethod(Info_Operating.Name_Library, this, "ReadKeyConfig", log_Reports_ThisMethod); // テーブルを、上から下に読んでいく。 // 列の並び順は NO ID Expl PLAYER BEFORE AFTER if (null != this.Table_Humaninput_Keyconfig)//テーブルの読取が成功していること。 { DataTable dataTable = this.Table_Humaninput_Keyconfig.DataTable; foreach (DataRow dataRow in dataTable.Rows) { int nPlayer; Int_HumaninputImpl.TryParse( dataRow.ItemArray[3], out nPlayer, EnumOperationIfErrorvalue.Spaces_To_Alt_Value, 0, log_Reports_ThisMethod ); if (nPlayerPrm == nPlayer) { string sBefore; string sAfter; String_HumaninputImpl.TryParse( dataRow.ItemArray[4], out sBefore, "", "", pg_Method, log_Reports_ThisMethod ); String_HumaninputImpl.TryParse( dataRow.ItemArray[5], out sAfter, "", "", pg_Method, log_Reports_ThisMethod ); EnumGamepadkeyIx o_Before; EnumGamepadkeyBit o_After; switch (sBefore) { case "Up": o_Before = EnumGamepadkeyIx.Up; break; case "Right": o_Before = EnumGamepadkeyIx.Right; break; case "Down": o_Before = EnumGamepadkeyIx.Down; break; case "Left": o_Before = EnumGamepadkeyIx.Left; break; case "1": o_Before = EnumGamepadkeyIx.B0; break; case "2": o_Before = EnumGamepadkeyIx.B1; break; case "3": o_Before = EnumGamepadkeyIx.B2; break; case "4": o_Before = EnumGamepadkeyIx.B3; break; case "5": o_Before = EnumGamepadkeyIx.B4; break; case "6": o_Before = EnumGamepadkeyIx.B5; break; case "7": o_Before = EnumGamepadkeyIx.B6; break; case "8": o_Before = EnumGamepadkeyIx.B7; break; default: o_Before = EnumGamepadkeyIx.Up; break; } switch (sAfter) { case "Up": o_After = EnumGamepadkeyBit.Up; break; case "Right": o_After = EnumGamepadkeyBit.Right; break; case "Down": o_After = EnumGamepadkeyBit.Down; break; case "Left": o_After = EnumGamepadkeyBit.Left; break; case "A": o_After = EnumGamepadkeyBit.A; break; case "B": o_After = EnumGamepadkeyBit.B; break; case "X": o_After = EnumGamepadkeyBit.X; break; case "Y": o_After = EnumGamepadkeyBit.Y; break; case "L": o_After = EnumGamepadkeyBit.L; break; case "R": o_After = EnumGamepadkeyBit.R; break; case "Select": o_After = EnumGamepadkeyBit.Select; break; case "Start": o_After = EnumGamepadkeyBit.Start; break; default: o_After = EnumGamepadkeyBit.Up; break; } gc.KeyCnf.KeyconfigArray[(int)o_Before] = o_After; } } } // // pg_Method.EndMethod(log_Reports_ThisMethod); log_Reports_ThisMethod.EndLogging(pg_Method); }
//──────────────────────────────────────── protected void Execute6_Sub( Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(1, 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(); } // // 変数は、登録されている名前の変数は存在し、登録されていない名前の変数は(自動作成されたもの以外は)存在しない。 // // 元となるテーブルを見ながら、変数オブジェクトの内容を調べていく。 // // Configurationtree_Node cur_Cf = new Configurationtree_NodeImpl(log_Method.Fullname, null); // 変数ログを吐く。 { StringBuilder sb = new StringBuilder(); //1行目 sb.Append(NamesFld.S_NO); sb.Append(","); sb.Append(NamesFld.S_ID); sb.Append(","); sb.Append(NamesFld.S_EXPL); sb.Append(","); sb.Append(NamesFld.S_NAME); sb.Append(","); sb.Append(NamesFld.S_FOLDER); sb.Append(","); sb.Append(NamesFld.S_VALUE); sb.Append(","); sb.Append(NamesFld.S_END); sb.Append(Environment.NewLine); //2行目 sb.Append(NamesTypedb.S_INT); //NO sb.Append(","); sb.Append(NamesTypedb.S_INT); //ID sb.Append(","); sb.Append(NamesTypedb.S_STRING); //Expl sb.Append(","); sb.Append(NamesTypedb.S_STRING); //NAME sb.Append(","); sb.Append(NamesTypedb.S_STRING); //FOLDER sb.Append(","); sb.Append(NamesTypedb.S_STRING); //VALUE sb.Append(","); sb.Append(NamesFld.S_END); //END sb.Append(Environment.NewLine); //3行目 sb.Append("-1,"); //NO sb.Append("使わない,"); //ID sb.Append("解説,"); //Expl sb.Append("変数名,"); //NAME sb.Append("(ファイルパス変数のみ指定有効)フォルダーパス,"); //FOLDER sb.Append("初期値,"); //VALUE sb.Append(NamesFld.S_END); //END sb.Append(Environment.NewLine); int nAuto = 0; this.Owner_MemoryApplication.MemoryVariables.EachVariable(delegate(string sKey, Expression_Node_String ec_String, ref bool bBreak) { if (log_Method.CanDebug(1)) { log_Method.WriteDebug_ToConsole("[" + sKey + "]=[" + ec_String.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]"); } sb.Append(nAuto);//NO sb.Append(","); //ID 使わない sb.Append(","); //Expl 消えてしまう sb.Append(","); sb.Append(sKey);//NAME sb.Append(","); //FOLDER TODO:逆算が必要 sb.Append(","); sb.Append(ec_String.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports)); //VALUE sb.Append(","); sb.Append(NamesFld.S_END); //END sb.Append(Environment.NewLine); nAuto++; }); if (log_Method.CanDebug(1)) { log_Method.WriteDebug_ToConsole(sb.ToString()); } //ログ出力 { Expression_Node_Filepath ec_Fpath_Logs = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename(new Expression_Leaf_StringImpl(NamesVar.S_SP_LOGS, null, cur_Cf), true, log_Reports); string sFpatha_LogVariables = ec_Fpath_Logs.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + System.IO.Path.DirectorySeparatorChar + NamesFile.S_LOG_VARIABLES; if (log_Reports.Successful) { CsvWriterImpl writer = new CsvWriterImpl(); writer.Write( sb.ToString(), sFpatha_LogVariables, true ); } } } //変数CSVを吐き出したい。(登録されている順序を保って) { // 変数ファイルの読取り Table_Humaninput o_Table_Variables; this.Owner_MemoryApplication.MemoryVariables.TryGetTable_Variables( out o_Table_Variables, Application.StartupPath, log_Reports ); if (null != o_Table_Variables) { StringBuilder sb = new StringBuilder(); //1行目 sb.Append(NamesFld.S_NO); sb.Append(","); sb.Append(NamesFld.S_ID); sb.Append(","); sb.Append(NamesFld.S_EXPL); sb.Append(","); sb.Append(NamesFld.S_NAME); sb.Append(","); sb.Append(NamesFld.S_FOLDER); sb.Append(","); sb.Append(NamesFld.S_VALUE); sb.Append(","); sb.Append(NamesFld.S_END); sb.Append(Environment.NewLine); //2行目 sb.Append(NamesTypedb.S_INT); //NO sb.Append(","); sb.Append(NamesTypedb.S_INT); //ID sb.Append(","); sb.Append(NamesTypedb.S_STRING); //Expl sb.Append(","); sb.Append(NamesTypedb.S_STRING); //NAME sb.Append(","); sb.Append(NamesTypedb.S_STRING); //FOLDER sb.Append(","); sb.Append(NamesTypedb.S_STRING); //VALUE sb.Append(","); sb.Append(NamesFld.S_END); //END sb.Append(Environment.NewLine); //3行目 sb.Append("-1,"); //NO sb.Append("使わない,"); //ID sb.Append("解説,"); //Expl sb.Append("変数名,"); //NAME sb.Append("(ファイルパス変数のみ指定有効)フォルダーパス,"); //FOLDER sb.Append("初期値,"); //VALUE sb.Append(NamesFld.S_END); //END sb.Append(Environment.NewLine); int nAuto = 0; foreach (DataRow row in o_Table_Variables.DataTable.Rows) { if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_NO)) { int nValue; Int_HumaninputImpl.TryParse(row[NamesFld.S_NO], out nValue, EnumOperationIfErrorvalue.Spaces_To_Alt_Value, 0, log_Reports); sb.Append(nValue); sb.Append(","); } // IDは空欄が正しいが、int型なので空欄にできないので 0 を入れる。 if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_ID)) { int nValue; Int_HumaninputImpl.TryParse(row[NamesFld.S_ID], out nValue, EnumOperationIfErrorvalue.Spaces_To_Alt_Value, 0, log_Reports); sb.Append(nValue); sb.Append(","); } if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_EXPL)) { string sValue; String_HumaninputImpl.TryParse(row[NamesFld.S_EXPL], out sValue, "", "", log_Method, log_Reports); sb.Append(sValue); sb.Append(","); } string sName_Var = ""; if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_NAME)) { string sValue; String_HumaninputImpl.TryParse(row[NamesFld.S_NAME], out sValue, "", "", log_Method, log_Reports); sb.Append(sValue); sb.Append(","); sName_Var = sValue; } // 現在の変数の内容 string sValue_Var = this.Owner_MemoryApplication.MemoryVariables.GetStringByVariablename(new Expression_Leaf_StringImpl(sName_Var, null, cur_Cf), true, log_Reports); //現在の変数の内容を検索 if (NamesVar.Test_Filepath(sName_Var)) { Expression_Node_Filepath ec_Fpath = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename(new Expression_Leaf_StringImpl(sName_Var, null, cur_Cf), true, log_Reports); // 絶対パスとは限らない。フォルダーを指していることもある。 string sFpath = ec_Fpath.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); //フォルダー列値を取得。 string sNamevar_Folder_Src; if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_FOLDER)) { String_HumaninputImpl.TryParse(row[NamesFld.S_FOLDER], out sNamevar_Folder_Src, "", "", log_Method, log_Reports); //フォルダーパス Expression_Node_Filepath ec_Folder = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename(new Expression_Leaf_StringImpl(sNamevar_Folder_Src, null, cur_Cf), false, log_Reports); if (null != ec_Folder) { // FOLDER列に入力があれば。 string sFpath_Folder = ec_Folder.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); if (sValue_Var.StartsWith(sFpath_Folder)) { // FOLDER列値をそのままキープ。 sb.Append(sNamevar_Folder_Src); // 値のフォルダー部分を削る。 sValue_Var = sValue_Var.Substring(sFpath_Folder.Length); // 先頭が ディレクトリー区切り文字なら削る。 if (sValue_Var.StartsWith(System.IO.Path.DirectorySeparatorChar.ToString())) { sValue_Var = sValue_Var.Substring(System.IO.Path.DirectorySeparatorChar.ToString().Length); } } else { // FOLDER列値はそのまま使えない。 } } sb.Append(","); } if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_VALUE)) { //string sValue; //String_HumaninputImpl.TryParse(row[NamesFld.S_VALUE], out sValue, "", "", log_Method, log_Reports); //sb.Append(sValue); //sb.Append(","); // 現在の変数の値(の削った残り)を入れる。 sb.Append(sValue_Var); sb.Append(","); } } else// if (NamesVar.Test_String(sName_Var)) { // FOLDER列値は無し。 sb.Append(","); if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_VALUE)) { // 現在の変数の値を入れる。 sb.Append(sValue_Var); sb.Append(","); } } sb.Append(NamesFld.S_END); sb.Append(Environment.NewLine); nAuto++; } //ファイル書出し { Expression_Node_Filepath ec_Fpath_Logs = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename(new Expression_Leaf_StringImpl(NamesVar.S_SP_LOGS, null, cur_Cf), true, log_Reports); string sFpatha_LogVariables = ec_Fpath_Logs.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + System.IO.Path.DirectorySeparatorChar + NamesFile.S_SAVE_VARIABLES; if (log_Reports.Successful) { CsvWriterImpl writer = new CsvWriterImpl(); writer.Write( sb.ToString(), sFpatha_LogVariables, true ); } } } } // // メッセージボックスの表示。 { StringBuilder sb = new StringBuilder(); sb.Append(this.GetType().Name); sb.Append("#Execute6_Sub:"); sb.Append(Environment.NewLine); string sArgMessage; this.TrySelectAttribute(out sArgMessage, Expression_Node_Function45Impl.PM_MESSAGE, EnumHitcount.One_Or_Zero, log_Reports); sb.Append(sArgMessage); MessageBox.Show(sb.ToString(), "変数をCSVファイルに書き出したい。"); } log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// ユーザー定義プログラムの実行。 /// </summary> /// <param name="hits"></param> /// <param name="log_Reports"></param> /// <returns></returns> public override string Execute4_OnExpressionString( EnumHitcount hits, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_Expr.Name_Library, this, "Execute4_OnExpressionString", log_Reports); // // Expression_Node_String err_Ev11; bool bAllFldsIsEmpty = true; Expression_Node_String ec_RecordSetLoadFrom;//ソース情報利用 bool bHit = this.TrySelectAttribute(out ec_RecordSetLoadFrom, NamesNode.S_RECORD_SET_LOAD_FROM, EnumHitcount.One, log_Reports); // // 一時記憶に記憶されているレコードセットのコピー内容。 RecordSet recordSet; if (log_Reports.Successful) { string sRecordSetLoadFrom = ec_RecordSetLoadFrom.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); // #デバッグ中 System.Console.WriteLine(Info_Expr.Name_Library + ":" + this.GetType().Name + "#E_Execute: ★★ record-set-load-from=[" + sRecordSetLoadFrom + "]"); recordSet = this.Owner_MemoryApplication.MemoryRecordset.RecordsetStorage.Get(ec_RecordSetLoadFrom, this.Owner_MemoryApplication, log_Reports); } else { recordSet = null; } Value_Humaninput err_OValue; string err_SFldName; Exception err_Excp; string err_SCsv; List <string> err_SList; if (log_Reports.Successful) { // // 子<f-●●>要素を実行し、文字列連結。 // 「SK10,LV10,OP10,COND10,COND10x,COND10y,COND10z,PRI10,RATE10,PER10」といった文字列が取得できることを期待。 StringBuilder sb_Csv = new StringBuilder(); { List <Expression_Node_String> ecList_Child = this.List_Expression_Child.SelectList( EnumHitcount.Unconstraint, log_Reports ); foreach (Expression_Node_String ec_11 in ecList_Child) { if (ec_11 is Expressionv_Elem99) { Expressionv_Elem99 ev_elem = (Expressionv_Elem99)ec_11; ev_elem.SetDataRow(this.DataRow); sb_Csv.Append(ev_elem.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports)); } else if (ec_11 is Expression_Node_StringImpl) { sb_Csv.Append(ec_11.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports)); } else { err_Ev11 = ec_11; bAllFldsIsEmpty = false; goto gt_Error_UndefinedElementClass; } } } // // コンマ区切り文字列を、リスト化。 List <string> sList; { CsvTo_ListImpl csvTo = new CsvTo_ListImpl(); sList = csvTo.Read(sb_Csv.ToString()); } // // 全部真なら真、1つでも偽なら偽。 foreach (string sFldName in sList) { // bug: argumentException Value_Humaninput oValue; try { // レコードセットの1件目だけをとりあえず確認。TODO: oValue = recordSet.List_Field[0][sFldName.ToUpper()]; //oValue = (OValue)dataRow[fldName]; } catch (KeyNotFoundException ex) { err_Excp = ex; err_SFldName = sFldName; err_SCsv = sb_Csv.ToString(); err_SList = sList; goto gt_Error_UndefinedFld; } // #デバッグ中 System.Console.WriteLine(Info_Expr.Name_Library + ":" + this.GetType().Name + "#E_Execute: oValue.Text=[" + oValue.Text + "]"); if (oValue is Int_HumaninputImpl) { Int_HumaninputImpl oInt = (Int_HumaninputImpl)oValue; if ("" != oInt.Text) { bAllFldsIsEmpty = false; } } else if (oValue is String_HumaninputImpl) { String_HumaninputImpl oString = (String_HumaninputImpl)oValue; if ("" != oString.Text) { bAllFldsIsEmpty = false; } } else if (oValue is Bool_HumaninputImpl) { Bool_HumaninputImpl oBool = (Bool_HumaninputImpl)oValue; if ("" != oBool.Text) { bAllFldsIsEmpty = false; } // // TODO: false/trueタイプ、0/1タイプにも対応したい。 // } else { // // エラー。 err_OValue = oValue; goto gt_Error_UndefinedType; } } } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_UndefinedType: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, err_OValue.GetType().Name, log_Reports); //値の型名 tmpl.SetParameter(2, Log_RecordReportsImpl.ToText_Configuration(this.Cur_Configuration), log_Reports); //設定位置パンくずリスト this.Owner_MemoryApplication.CreateErrorReport("Er:6032;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_UndefinedElementClass: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, err_Ev11.GetType().Name, log_Reports); //クラス名 tmpl.SetParameter(2, Log_RecordReportsImpl.ToText_Configuration(this.Cur_Configuration), log_Reports); //設定位置パンくずリスト this.Owner_MemoryApplication.CreateErrorReport("Er:6033;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_UndefinedFld: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, err_SFldName.ToUpper(), log_Reports); //フィールド名大文字化 tmpl.SetParameter(2, err_SCsv, log_Reports); //指定されたフィールド名の文字列 StringBuilder s1 = new StringBuilder(); foreach (string str in err_SList) { s1.Append("["); s1.Append(str); s1.Append("]"); s1.Append(Environment.NewLine); } tmpl.SetParameter(3, s1.ToString(), log_Reports);//指定されたフィールド名の文字列 StringBuilder s2 = new StringBuilder(); // あるフィールド名の一覧 foreach (DataColumn dataColumn in this.DataRow.Table.Columns) { s2.Append("["); s2.Append(dataColumn.ColumnName); s2.Append("]"); s2.Append(Environment.NewLine); } tmpl.SetParameter(4, s1.ToString(), log_Reports); //指定されたフィールド名の文字列 tmpl.SetParameter(5, Log_RecordReportsImpl.ToText_Configuration(this.Cur_Configuration), log_Reports); //設定位置パンくずリスト tmpl.SetParameter(6, Log_RecordReportsImpl.ToText_Exception(err_Excp), log_Reports); //例外メッセージ this.Owner_MemoryApplication.CreateErrorReport("Er:6034;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(bAllFldsIsEmpty.ToString()); }
//──────────────────────────────────────── public void XTo( out KeyconfigImpl out_Keycnf, Log_Reports log_Reports ) { Log_Method pg_Method = new Log_MethodImpl(0); Log_Reports log_Reports_Load = new Log_ReportsImpl(pg_Method); pg_Method.BeginMethod(Info_Operating.Name_Library, this, "XToO", log_Reports_Load); // // out_Keycnf = new KeyconfigImpl(); CsvTo_Table_HumaninputImpl csvTo = new CsvTo_Table_HumaninputImpl(); Request_ReadsTable oRequest_TableReads = new Request_ReadsTableImpl(); { Configurationtree_NodeImpl cf_ConfigStack = new Configurationtree_NodeImpl(Info_Operating.Name_Library + ":" + this.GetType().Name + "#<init>:", null); Configurationtree_NodeFilepath cf_Fpath = new Configurationtree_NodeFilepathImpl("ファイルパス出典未指定L03_1", cf_ConfigStack); cf_Fpath.InitPath( "Editor-config/GAME_PAD/Key-config.csv", log_Reports ); Expression_Node_Filepath ec_Fpath = new Expression_Node_FilepathImpl(cf_Fpath); oRequest_TableReads.Expression_Filepath = ec_Fpath; if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } } Format_Table_Humaninput o_TableFormat = new Format_Table_HumaninputImpl(); out_Keycnf.O_Table_Keycnf = csvTo.Read( oRequest_TableReads, o_TableFormat, true, log_Reports ); if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } // // テーブルを上から1行ずつ読んでいきます。 // foreach (DataRow dataRow in out_Keycnf.O_Table_Keycnf.DataTable.Rows) { //NO ID Expl PLAYER BEFORE AFTER // プレイヤー番号 int nPlayer; { Int_HumaninputImpl o_Player = (Int_HumaninputImpl)dataRow["PLAYER"]; if (Int_HumaninputImpl.TryParse( o_Player, out nPlayer, EnumOperationIfErrorvalue.Error, 0, log_Reports )) { } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } } // BEFORE EnumGamepadkeyIx enumGmkeyArray; { string sBefore; string sDebug1 = ""; string sDebug2 = ""; String_HumaninputImpl o_Before = (String_HumaninputImpl)dataRow["BEFORE"]; if (String_HumaninputImpl.TryParse( o_Before, out sBefore, sDebug1, sDebug2, pg_Method, log_Reports )) { } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } switch (sBefore) { case "Up": enumGmkeyArray = EnumGamepadkeyIx.Up; break; case "Right": enumGmkeyArray = EnumGamepadkeyIx.Right; break; case "Down": enumGmkeyArray = EnumGamepadkeyIx.Down; break; case "Left": enumGmkeyArray = EnumGamepadkeyIx.Left; break; case "0": enumGmkeyArray = EnumGamepadkeyIx.B0; break; case "1": enumGmkeyArray = EnumGamepadkeyIx.B1; break; case "2": enumGmkeyArray = EnumGamepadkeyIx.B2; break; case "3": enumGmkeyArray = EnumGamepadkeyIx.B3; break; case "4": enumGmkeyArray = EnumGamepadkeyIx.B4; break; case "5": enumGmkeyArray = EnumGamepadkeyIx.B5; break; case "6": enumGmkeyArray = EnumGamepadkeyIx.B6; break; case "7": enumGmkeyArray = EnumGamepadkeyIx.B7; break; default: // エラー enumGmkeyArray = EnumGamepadkeyIx.B0; break; } } // AFTER EnumGamepadkeyBit gmkeyPushEnum; { string sAfter; string sDebug1 = ""; string sDebug2 = ""; String_HumaninputImpl o_Before = (String_HumaninputImpl)dataRow["AFTER"]; if (String_HumaninputImpl.TryParse( o_Before, out sAfter, sDebug1, sDebug2, pg_Method, log_Reports )) { } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } switch (sAfter) { case "Up": gmkeyPushEnum = EnumGamepadkeyBit.Up; break; case "Right": gmkeyPushEnum = EnumGamepadkeyBit.Right; break; case "Down": gmkeyPushEnum = EnumGamepadkeyBit.Down; break; case "Left": gmkeyPushEnum = EnumGamepadkeyBit.Left; break; case "A": gmkeyPushEnum = EnumGamepadkeyBit.A; break; case "B": gmkeyPushEnum = EnumGamepadkeyBit.B; break; case "X": gmkeyPushEnum = EnumGamepadkeyBit.X; break; case "Y": gmkeyPushEnum = EnumGamepadkeyBit.Y; break; case "L": gmkeyPushEnum = EnumGamepadkeyBit.L; break; case "R": gmkeyPushEnum = EnumGamepadkeyBit.R; break; case "Select": gmkeyPushEnum = EnumGamepadkeyBit.Select; break; case "Start": gmkeyPushEnum = EnumGamepadkeyBit.Start; break; default: // エラー gmkeyPushEnum = EnumGamepadkeyBit.A; break; } } // // 記憶 // KeyconfigPadImpl keycnfPad; if (out_Keycnf.Dic_KeyCnf.ContainsKey(nPlayer)) { keycnfPad = out_Keycnf.Dic_KeyCnf[nPlayer]; } else { keycnfPad = new KeyconfigPadImpl(); } keycnfPad.KeyconfigArray[(int)enumGmkeyArray] = gmkeyPushEnum; out_Keycnf.Dic_KeyCnf[nPlayer] = keycnfPad; } goto gt_EndMethod; // // gt_EndMethod: pg_Method.EndMethod(log_Reports_Load); log_Reports_Load.EndLogging(pg_Method); return; }
//──────────────────────────────────────── protected void Execute6_Sub( Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(1, 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(); } // // 変数は、登録されている名前の変数は存在し、登録されていない名前の変数は(自動作成されたもの以外は)存在しない。 // // 元となるテーブルを見ながら、変数オブジェクトの内容を調べていく。 // // Configurationtree_Node cur_Cf = new Configurationtree_NodeImpl(log_Method.Fullname, null); // 変数ログを吐く。 { StringBuilder sb = new StringBuilder(); //1行目 sb.Append(NamesFld.S_NO); //NO sb.Append(","); sb.Append(NamesFld.S_ID); //ID sb.Append(","); sb.Append(NamesFld.S_TREE); //TREE sb.Append(","); sb.Append(NamesFld.S_EXPL); //Expl sb.Append(","); sb.Append(NamesFld.S_FILE); //FILE sb.Append(","); sb.Append(NamesFld.S_NAME); //NAME sb.Append(","); sb.Append(NamesFld.S_TYPE); //TYPE sb.Append(","); sb.Append(NamesFld.S_TEXT); //TEXT sb.Append(","); sb.Append(NamesFld.S_FONT_SIZE_PT); //FONT_SIZE_PT sb.Append(","); sb.Append(NamesFld.S_X_LT); //X_LT sb.Append(","); sb.Append(NamesFld.S_Y_LT); //Y_LT sb.Append(","); sb.Append(NamesFld.S_WIDTH); //WIDTH sb.Append(","); sb.Append(NamesFld.S_HEIGHT); //HEIGHT sb.Append(","); sb.Append(NamesFld.S_ENABLED); //ENABLED sb.Append(","); sb.Append(NamesFld.S_VISIBLE); //VISIBLE sb.Append(","); sb.Append(NamesFld.S_READ_ONLY); //READ_ONLY sb.Append(","); sb.Append(NamesFld.S_WORD_WRAP); //WORD_WRAP sb.Append(","); sb.Append(NamesFld.S_NEW_LINE); //NEW_LINE sb.Append(","); sb.Append(NamesFld.S_SCROLL_BARS); //SCROLL_BARS sb.Append(","); sb.Append(NamesFld.S_CHK_VALUE_TYPE); //CHK_VALUE_TYPE sb.Append(","); sb.Append(NamesFld.S_PIC_ZOOM); //PIC_ZOOM sb.Append(","); sb.Append(NamesFld.S_TAB_INDEX); //TAB_INDEX sb.Append(","); sb.Append(NamesFld.S_BACK_COLOR); //BACK_COLOR sb.Append(","); //ここまで基本テーブル。 sb.Append(NamesFld.S_ITEM_HEIGHT_PX); //ITEM_HEIGHT_PX sb.Append(","); sb.Append(NamesFld.S_ITEM_DISPLAY_FORMAT); //ITEM_DISPLAY_FORMAT sb.Append(","); sb.Append(NamesFld.S_LIST_VALUE_FIELD); //LIST_VALUE_FIELD sb.Append(","); sb.Append(NamesFld.S_END); sb.Append(Environment.NewLine); //2行目 sb.Append(NamesTypedb.S_INT); //NO sb.Append(","); sb.Append(NamesTypedb.S_INT); //ID sb.Append(","); sb.Append(NamesTypedb.S_INT); //TREE sb.Append(","); sb.Append(NamesTypedb.S_STRING); //Expl sb.Append(","); sb.Append(NamesTypedb.S_STRING); //FILE sb.Append(","); sb.Append(NamesTypedb.S_STRING); //NAME sb.Append(","); sb.Append(NamesTypedb.S_STRING); //TYPE sb.Append(","); sb.Append(NamesTypedb.S_STRING); //TEXT sb.Append(","); sb.Append(NamesTypedb.S_STRING); //FONT_SIZE_PT sb.Append(","); sb.Append(NamesTypedb.S_INT); //X_LT sb.Append(","); sb.Append(NamesTypedb.S_INT); //Y_LT sb.Append(","); sb.Append(NamesTypedb.S_INT); //WIDTH sb.Append(","); sb.Append(NamesTypedb.S_INT); //HEIGHT sb.Append(","); sb.Append(NamesTypedb.S_BOOL); //ENABLED sb.Append(","); sb.Append(NamesTypedb.S_BOOL); //VISIBLE sb.Append(","); sb.Append(NamesTypedb.S_BOOL); //READ_ONLY sb.Append(","); sb.Append(NamesTypedb.S_BOOL); //WORD_WRAP sb.Append(","); sb.Append(NamesTypedb.S_STRING); //NEW_LINE sb.Append(","); sb.Append(NamesTypedb.S_STRING); //SCROLL_BARS sb.Append(","); sb.Append(NamesTypedb.S_STRING); //CHK_VALUE_TYPE sb.Append(","); sb.Append(NamesTypedb.S_INT); //PIC_ZOOM sb.Append(","); sb.Append(NamesTypedb.S_INT); //TAB_INDEX sb.Append(","); sb.Append(NamesTypedb.S_STRING); //BACK_COLOR sb.Append(","); //ここまで基本テーブル。 sb.Append(NamesTypedb.S_INT); //ITEM_HEIGHT_PX sb.Append(","); sb.Append(NamesTypedb.S_STRING); //ITEM_DISPLAY_FORMAT sb.Append(","); sb.Append(NamesTypedb.S_STRING); //LIST_VALUE_FIELD sb.Append(","); sb.Append(NamesFld.S_END); sb.Append(Environment.NewLine); //3行目 sb.Append("-1,"); //NO sb.Append("使わない,"); //ID sb.Append("ネスト関係,"); //TREE sb.Append("解説,"); //Expl sb.Append("コントロール設定ファイルパス,"); //FILE sb.Append("コントロール固有名,"); //NAME sb.Append("コントロールの型,"); //TYPE sb.Append("初期値,"); //TEXT sb.Append("フォントサイズ(pt),"); //FONT_SIZE_PT sb.Append("左上角の座標X,"); //X_LT sb.Append("左上角の座標Y,"); //Y_LT sb.Append("横幅ピクセル,"); //WIDTH sb.Append("縦幅ピクセル,"); //HEIGHT sb.Append("活性化,"); //ENABLED sb.Append("可視,"); //VISIBLE sb.Append("テキストボックス等を読み取り専用にするなら真。,"); //READ_ONLY sb.Append("テキストエリアで行を自動的に折り返すなら真。,"); //WORD_WRAP sb.Append("(テキストエリア)改行記号。,"); //NEW_LINE sb.Append("テキストエリア等で利用。None,Horizontal,Vertical,Bothの4つ。使わないなら空欄。,"); //SCROLL_BARS sb.Append("チェックボックスの値の型。(空欄:false,true。ZERO_ONE:0,1),"); //CHK_VALUE_TYPE sb.Append("(未実装)画像の倍角サイズ。2000で2倍。,"); //PIC_ZOOM sb.Append("タブ・インデックス,"); //TAB_INDEX sb.Append("背景色,"); //BACK_COLOR //ここまで基本テーブル。 sb.Append("リストボックスの項目の高さ(ピクセル),"); //ITEM_HEIGHT_PX sb.Append("リストボックスの各項目の表示書式,"); //ITEM_DISPLAY_FORMAT sb.Append("(開発中)リストボックスの値が入っている、レコードのフィールド名。,"); //LIST_VALUE_FIELD sb.Append(NamesFld.S_END); sb.Append(Environment.NewLine); int nAuto = 0; this.Owner_MemoryApplication.MemoryForms.ForEach_Children(delegate(string sKey, Usercontrol uct_Child, ref bool bRemove, ref bool bBreak) { //uct_Child.ControlCommon.Configurationtree_Control.Dictionary_Attribute. sb.Append(nAuto);//NO sb.Append(","); //ID は使わない。 sb.Append(","); sb.Append(NamesFld.S_TREE); //TREE sb.Append(","); sb.Append(NamesFld.S_EXPL); //Expl sb.Append(","); sb.Append(NamesFld.S_FILE); //FILE sb.Append(","); sb.Append(uct_Child.ControlCommon.Configurationtree_Control.Name); //NAME sb.Append(","); sb.Append(NamesFld.S_TYPE); //TYPE sb.Append(","); sb.Append(uct_Child.UsercontrolText); //TEXT sb.Append(","); sb.Append(uct_Child.UsercontrolFontsizept); //FONT_SIZE_PT sb.Append(","); sb.Append(uct_Child.UsercontrolXlt); //X_LT sb.Append(","); sb.Append(uct_Child.UsercontrolYlt); //Y_LT sb.Append(","); sb.Append(uct_Child.UsercontrolWidth); //WIDTH sb.Append(","); sb.Append(uct_Child.UsercontrolHeight); //HEIGHT sb.Append(","); if (uct_Child.UsercontrolEnabled) { sb.Append(uct_Child.UsercontrolEnabled);//ENABLED } sb.Append(","); if (uct_Child.UsercontrolVisible) { sb.Append(uct_Child.UsercontrolVisible);//VISIBLE } sb.Append(","); if (uct_Child.UsercontrolReadonly) { sb.Append(uct_Child.UsercontrolReadonly);//READ_ONLY } sb.Append(","); if (uct_Child.UsercontrolWordwrap) { sb.Append(uct_Child.UsercontrolWordwrap);//WORD_WRAP } sb.Append(","); sb.Append(uct_Child.UsercontrolNewline);//NEW_LINE sb.Append(","); switch (uct_Child.UsercontrolScrollbars) { case ScrollBars.Both: sb.Append(ValuesAttr.S_BOTH); break; case ScrollBars.Horizontal: sb.Append(ValuesAttr.S_HORIZONTAL); break; case ScrollBars.Vertical: sb.Append(ValuesAttr.S_VERTICAL); break; default: //TODO:「無視」と、「無し」は、分けたい。 //sb.Append(ValuesAttr.S_NONE); break; } sb.Append(","); sb.Append(uct_Child.UsercontrolChkvaluetype); //CHK_VALUE_TYPE sb.Append(","); sb.Append(uct_Child.UsercontrolPiczoom); //PIC_ZOOM sb.Append(","); sb.Append(uct_Child.UsercontrolTabindex); //TAB_INDEX sb.Append(","); sb.Append(uct_Child.UsercontrolBackcolor); //BACK_COLOR sb.Append(","); //ここまで基本テーブル。 sb.Append(uct_Child.UsercontrolItemheightpx); //ITEM_HEIGHT_PX sb.Append(","); sb.Append(uct_Child.UsercontrolItemdisplayformat); //ITEM_DISPLAY_FORMAT sb.Append(","); sb.Append(uct_Child.UsercontrolListvaluefield /*"NO"*/); //TODO:LIST_VALUE_FIELD sb.Append(","); sb.Append(NamesFld.S_END); sb.Append(Environment.NewLine); nAuto++; }); if (log_Method.CanDebug(1)) { log_Method.WriteDebug_ToConsole(sb.ToString()); } //ログ出力 { Expression_Node_Filepath ec_Fpath_Logs = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename(new Expression_Leaf_StringImpl(NamesVar.S_SP_LOGS, null, cur_Cf), true, log_Reports); string sFpatha_LogVariables = ec_Fpath_Logs.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + System.IO.Path.DirectorySeparatorChar + NamesFile.S_LOG_FORM; if (log_Reports.Successful) { CsvWriterImpl writer = new CsvWriterImpl(); writer.Write( sb.ToString(), sFpatha_LogVariables, true ); } } } //変数CSVを吐き出したい。(登録されている順序を保って) { // 変数ファイルの読取り Table_Humaninput o_Table_Variables; this.Owner_MemoryApplication.MemoryVariables.TryGetTable_Variables( out o_Table_Variables, Application.StartupPath, log_Reports ); if (null != o_Table_Variables) { StringBuilder sb = new StringBuilder(); //1行目 sb.Append(NamesFld.S_NO); //NO sb.Append(","); sb.Append(NamesFld.S_ID); //ID sb.Append(","); sb.Append(NamesFld.S_TREE); //TREE sb.Append(","); sb.Append(NamesFld.S_EXPL); //Expl sb.Append(","); sb.Append(NamesFld.S_NAME); sb.Append(","); sb.Append(NamesFld.S_FOLDER); sb.Append(","); sb.Append(NamesFld.S_VALUE); sb.Append(","); sb.Append(NamesFld.S_END); sb.Append(Environment.NewLine); //2行目 sb.Append(NamesTypedb.S_INT); //NO sb.Append(","); sb.Append(NamesTypedb.S_INT); //ID sb.Append(","); sb.Append(NamesTypedb.S_STRING); //Expl sb.Append(","); sb.Append(NamesTypedb.S_STRING); //NAME sb.Append(","); sb.Append(NamesTypedb.S_STRING); //FOLDER sb.Append(","); sb.Append(NamesTypedb.S_STRING); //VALUE sb.Append(","); sb.Append(NamesFld.S_END); //END sb.Append(Environment.NewLine); //3行目 sb.Append("-1,"); //NO sb.Append("使わない,"); //ID sb.Append("解説,"); //Expl sb.Append("変数名,"); //NAME sb.Append("(ファイルパス変数のみ指定有効)フォルダーパス,"); //FOLDER sb.Append("初期値,"); //VALUE sb.Append(NamesFld.S_END); //END sb.Append(Environment.NewLine); int nAuto = 0; foreach (DataRow row in o_Table_Variables.DataTable.Rows) { if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_NO)) { int nValue; Int_HumaninputImpl.TryParse(row[NamesFld.S_NO], out nValue, EnumOperationIfErrorvalue.Spaces_To_Alt_Value, 0, log_Reports); sb.Append(nValue); sb.Append(","); } // IDは空欄が正しいが、int型なので空欄にできないので 0 を入れる。 if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_ID)) { int nValue; Int_HumaninputImpl.TryParse(row[NamesFld.S_ID], out nValue, EnumOperationIfErrorvalue.Spaces_To_Alt_Value, 0, log_Reports); sb.Append(nValue); sb.Append(","); } if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_EXPL)) { string sValue; String_HumaninputImpl.TryParse(row[NamesFld.S_EXPL], out sValue, "", "", log_Method, log_Reports); sb.Append(sValue); sb.Append(","); } string sName_Var = ""; if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_NAME)) { string sValue; String_HumaninputImpl.TryParse(row[NamesFld.S_NAME], out sValue, "", "", log_Method, log_Reports); sb.Append(sValue); sb.Append(","); sName_Var = sValue; } // 現在の変数の内容 string sValue_Var = this.Owner_MemoryApplication.MemoryVariables.GetStringByVariablename(new Expression_Leaf_StringImpl(sName_Var, null, cur_Cf), true, log_Reports); //現在の変数の内容を検索 if (NamesVar.Test_Filepath(sName_Var)) { Expression_Node_Filepath ec_Fpath = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename(new Expression_Leaf_StringImpl(sName_Var, null, cur_Cf), true, log_Reports); // 絶対パスとは限らない。フォルダーを指していることもある。 string sFpath = ec_Fpath.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); //フォルダー列値を取得。 string sNamevar_Folder_Src; if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_FOLDER)) { String_HumaninputImpl.TryParse(row[NamesFld.S_FOLDER], out sNamevar_Folder_Src, "", "", log_Method, log_Reports); //フォルダーパス Expression_Node_Filepath ec_Folder = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename(new Expression_Leaf_StringImpl(sNamevar_Folder_Src, null, cur_Cf), false, log_Reports); if (null != ec_Folder) { // FOLDER列に入力があれば。 string sFpath_Folder = ec_Folder.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); if (sValue_Var.StartsWith(sFpath_Folder)) { // FOLDER列値をそのままキープ。 sb.Append(sNamevar_Folder_Src); // 値のフォルダー部分を削る。 sValue_Var = sValue_Var.Substring(sFpath_Folder.Length); // 先頭が ディレクトリー区切り文字なら削る。 if (sValue_Var.StartsWith(System.IO.Path.DirectorySeparatorChar.ToString())) { sValue_Var = sValue_Var.Substring(System.IO.Path.DirectorySeparatorChar.ToString().Length); } } else { // FOLDER列値はそのまま使えない。 } } sb.Append(","); } if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_VALUE)) { //string sValue; //String_HumaninputImpl.TryParse(row[NamesFld.S_VALUE], out sValue, "", "", log_Method, log_Reports); //sb.Append(sValue); //sb.Append(","); // 現在の変数の値(の削った残り)を入れる。 sb.Append(sValue_Var); sb.Append(","); } } else// if (NamesVar.Test_String(sName_Var)) { // FOLDER列値は無し。 sb.Append(","); if (o_Table_Variables.DataTable.Columns.Contains(NamesFld.S_VALUE)) { // 現在の変数の値を入れる。 sb.Append(sValue_Var); sb.Append(","); } } sb.Append(NamesFld.S_END); sb.Append(Environment.NewLine); nAuto++; } //ファイル書出し { Expression_Node_Filepath ec_Fpath_Logs = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename(new Expression_Leaf_StringImpl(NamesVar.S_SP_LOGS, null, cur_Cf), true, log_Reports); string sFpatha_LogVariables = ec_Fpath_Logs.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + System.IO.Path.DirectorySeparatorChar + NamesFile.S_SAVE_FORM; if (log_Reports.Successful) { CsvWriterImpl writer = new CsvWriterImpl(); writer.Write( sb.ToString(), sFpatha_LogVariables, true ); } } } } // // メッセージボックスの表示。 { StringBuilder sb = new StringBuilder(); sb.Append(this.GetType().Name); sb.Append("#Execute6_Sub:"); sb.Append(Environment.NewLine); string sArgMessage; this.TrySelectAttribute(out sArgMessage, Expression_Node_Function46Impl.PM_MESSAGE, EnumHitcount.One_Or_Zero, log_Reports); sb.Append(sArgMessage); MessageBox.Show(sb.ToString(), "変数をCSVファイルに書き出したい。"); } log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── /// <summary> /// 一覧系のテーブルの行を読み取り、テーブルを読み取る要求を作成します。 /// </summary> /// <param name="dataRow"></param> /// <param name="o_IndexTable"></param> /// <param name="log_Reports"></param> /// <returns></returns> private Request_ReadsTable CreateReadRequest( DataRow dataRow, Table_Humaninput o_Table_Aafiles, Log_Reports log_Reports ) { // // // //()メソッド開始 // // // Log_Method log_Method = new Log_MethodImpl(1); log_Method.BeginMethod(Info_Functions.Name_Library, this, "CreateReadRequest", log_Reports); // // Request_ReadsTable forTable_request = new Request_ReadsTableImpl(); // // 「インデックス_テーブル」の絶対ファイルパス Expression_Node_Filepath ec_Fpath_Aafilescsv = o_Table_Aafiles.Expression_Filepath_ConfigStack; string sFpatha_Aafilescsv = ec_Fpath_Aafilescsv.Execute4_OnExpressionString( EnumHitcount.Unconstraint, log_Reports); //if (log_Method.CanDebug(1)) //{ // log_Method.WriteDebug_ToConsole("「Aa_Files.csv」のファイルパス=[" + sFpatha_Aafilescsv + "]"); //} if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } // // テーブル名 { string sName_Field = NamesFld.S_NAME; string sTableName; if (String_HumaninputImpl.TryParse( dataRow[sName_Field], out sTableName, o_Table_Aafiles.Name, sName_Field, log_Method, log_Reports)) { } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } forTable_request.Name_PutToTable = sTableName; } // // フォーム名 { string sName_Field = NamesFld.S_NAME_FORM; string sTableUnit; if (dataRow.Table.Columns.Contains(sName_Field)) { bool bBool = String_HumaninputImpl.TryParse( dataRow[sName_Field], out sTableUnit, o_Table_Aafiles.Name, sName_Field, log_Method, log_Reports); if (bBool) { } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } } else { sTableUnit = ""; } forTable_request.Tableunit = sTableUnit; } // // データ・タイプです。 { string sName_Field = NamesFld.S_TYPE_DATA; string sValue; if (dataRow.Table.Columns.Contains(sName_Field)) { if (String_HumaninputImpl.TryParse( dataRow[sName_Field], out sValue, o_Table_Aafiles.Name, sName_Field, log_Method, log_Reports)) { } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } } else { sValue = ""; } forTable_request.Typedata = sValue; } // // テーブルのファイルパス // Expression_Node_Filepath ec_Fpath; { this.Read_Folder_File( out ec_Fpath, forTable_request.Name_PutToTable, sFpatha_Aafilescsv, dataRow, o_Table_Aafiles, log_Reports ); if (log_Reports.Successful) { forTable_request.Expression_Filepath = ec_Fpath; } } // // ファイルパスを変数にセット // { string sName_Field = NamesFld.S_SET_VAR_PATH; string sNamevar; if (dataRow.Table.Columns.Contains(sName_Field)) { if (String_HumaninputImpl.TryParse( dataRow[sName_Field], out sNamevar, o_Table_Aafiles.Name, sName_Field, log_Method, log_Reports)) { } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } } else { sNamevar = ""; } if ("" != sNamevar && null != ec_Fpath) { // 指定があれば、ファイルパスを変数にセット。 this.Owner_MemoryApplication.MemoryVariables.SetFilepathValue( sNamevar, ec_Fpath, false, log_Reports); } } // // 「日別バックアップ」するなら真。 // { string sName_Field = NamesFld.S_DATE_BACKUP; bool bDateBackup; if (dataRow.Table.Columns.Contains(sName_Field)) { bool bParsedSuccessful = Bool_HumaninputImpl.TryParse( dataRow[sName_Field], out bDateBackup, EnumOperationIfErrorvalue.Spaces_To_Alt_Value, false, log_Reports ); if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } if (bParsedSuccessful) { } } else { bDateBackup = false; } forTable_request.IsDatebackupActivated = bDateBackup; } // // 用途。/「」指定なし。/「WriteOnly」データの読取を行わない。ログ出力先を登録しているだけなど。 // { string sName_Field = NamesFld.S_USE; string sField; if (dataRow.Table.Columns.Contains(sName_Field)) { bool bParsedSuccessful = String_HumaninputImpl.TryParse( dataRow[sName_Field], out sField, o_Table_Aafiles.Name, sName_Field, log_Method, log_Reports ); if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } if (bParsedSuccessful) { } } else { sField = "";//指定なし。 } forTable_request.Use = sField; } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(forTable_request); }
//──────────────────────────────────────── /// <summary> /// Aa_Files.xmlの「FOLDER」「FILE」列を読取ります。 /// </summary> /// <param name="ec_Fpath"></param> /// <param name="sTableNameToPuts"></param> /// <param name="sFpatha_Aafiles"></param> /// <param name="dataRow"></param> /// <param name="o_IndexTable"></param> /// <param name="log_Reports"></param> private void Read_Folder_File( out Expression_Node_Filepath ec_Fpath, string sTableNameToPuts, string sFpatha_Aafiles, DataRow dataRow, Table_Humaninput o_IndexTable, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Functions.Name_Library, this, "Read_Folder_File", log_Reports); string sFpath; //バックアップ用に使い回す文字列。 ec_Fpath = null; //セットパス用に使い回す。 { // // フォルダー変数の指定の有無 // string sNamevarFolder; { string sFieldName2 = NamesFld.S_FOLDER; if (String_HumaninputImpl.TryParse( dataRow[sFieldName2], out sNamevarFolder, o_IndexTable.Name, sFieldName2, log_Method, log_Reports)) { // 正常、スルー。 } else { sNamevarFolder = ""; } } // テーブルのファイルのパスを取得 string sName_Field = NamesFld.S_FILE; if (String_HumaninputImpl.TryParse( dataRow[sName_Field], out sFpath, o_IndexTable.Name, sName_Field, log_Method, log_Reports)) { if ("" != sNamevarFolder.Trim()) { // FOLDER列に、変数名が指定されているとき。 Expression_Node_String ec_Namevar_Folder = new Expression_Leaf_StringImpl(sNamevarFolder.Trim(), null, new Configurationtree_NodeImpl(o_IndexTable.Name, null));//todo: log_Reports.Log_Callstack.Push(log_Method, "③"); Expression_Node_Filepath ec_Fopath = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename( ec_Namevar_Folder, true, log_Reports); log_Reports.Log_Callstack.Pop(log_Method, "③"); if (null == ec_Fopath) { goto gt_Error_NullFolder; } //if (log_Method.CanDebug(1)) //{ // log_Method.WriteDebug_ToConsole(".csvのFOLDER列に[" + sNamevarFolder + "]と指定されていました。"); //} log_Reports.Log_Callstack.Push(log_Method, "⑧"); //bug:フォルダーパスだと Execute4_OnExpressionString は空白を返す?? string sFopath2 = ec_Fopath.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); if ("" == sFopath2) { //bug:フォルダーパスだと Execute4_OnExpressionString は空白を返すようなので、入力値をそのまま返すことにした。 sFopath2 = ec_Fopath.Humaninput.Trim(); } log_Reports.Log_Callstack.Pop(log_Method, "⑧"); //if (log_Method.CanDebug(1)) //{ // log_Method.WriteDebug_ToConsole("[" + sNamevarFolder + "]変数の内容は["+sFopath2+"]"); // //this.Owner_MemoryApplication.MemoryVariables.WriteDebug_ToConsole(); //} // 「フォルダー」 + 「¥」 + 「相対パス」 sFpath = sFopath2 + System.IO.Path.DirectorySeparatorChar + sFpath; } } // // ファイルパス // Configurationtree_NodeFilepath cf_Fpath1; { StringBuilder s = new StringBuilder(); s.Append("L11_1["); s.Append(NamesFile.S_AA_FILES_CSV); s.Append("ファイルの"); s.Append(sTableNameToPuts); s.Append("指定="); s.Append(sFpath); s.Append("]"); cf_Fpath1 = new Configurationtree_NodeFilepathImpl(s.ToString(), null); //cf_Fpath = new Configurationtree_NodeFilepathImpl("ファイルパス出典未指定L11_1", new Configurationtree_NodeImpl(s.ToString(), null)); } cf_Fpath1.InitPath(sFpath, log_Reports); if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } ec_Fpath = new Expression_Node_FilepathImpl(cf_Fpath1); } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_NullFolder: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, Log_RecordReportsImpl.ToText_Configuration(this.Cur_Configuration), log_Reports);//設定位置パンくずリスト this.Owner_MemoryApplication.CreateErrorReport("Er:110009;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── /// <summary> /// /// </summary> /// <param name="dataRow"></param> /// <param name="forIndexTable_csvAbsFilePath"></param> /// <param name="log_Reports"></param> /// <returns></returns> private MemoryCodefileinfo Read_RequestPart_Script( DataRow dataRow, string sFpatha_Aafilescsv, Table_Humaninput o_Table_Aafiles, Log_Reports log_Reports ) { // // // //()メソッド開始 // // // Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_Functions.Name_Library, this, "Read_RequestPart_Script", log_Reports); // // 「各テーブル」の引数 MemoryCodefileinfo result = new MemoryCodefileinfoImpl(); // // 呼出名。 // { string sName; bool bParsedSuccessful = String_HumaninputImpl.TryParse( dataRow[NamesFld.S_NAME], out sName, sFpatha_Aafilescsv, NamesFld.S_NAME, log_Method, log_Reports ); if (bParsedSuccessful) { result.Name = sName; } } // // タイプデータ。 // { string sTypedata; bool bParsedSuccessful = String_HumaninputImpl.TryParse( dataRow[NamesFld.S_TYPE_DATA], out sTypedata, sFpatha_Aafilescsv, NamesFld.S_NAME, log_Method, log_Reports ); if (bParsedSuccessful) { result.Typedata = sTypedata; } } // // フォルダーと、ファイルパス。 // Expression_Node_Filepath ec_Fpath; { this.Read_Folder_File( out ec_Fpath, result.Name, sFpatha_Aafilescsv, dataRow, o_Table_Aafiles, log_Reports ); result.Expression_Filepath = ec_Fpath; } goto gt_EndMethod; // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(result); }
//──────────────────────────────────────── /// <summary> /// 「変数設定ファイル」のテーブルを読み取り、変数を登録します。 /// </summary> /// <param oVariableName="varOTable"></param> /// <param oVariableName="log_Reports"></param> public void Load( Table_Humaninput o_Table_Var, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(1, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "Load", log_Reports); // if (log_Method.CanDebug(1)) { log_Method.WriteDebug_ToConsole("「変数登録ファイル」を Load します。"); } // // // // if (null == o_Table_Var) { goto gt_Error_NullTable; } if (null != this.parent_Variablesconfig_Configurationtree) { goto gt_Error_DoubleLoad; } string err_SFolder; string err_SName; if (log_Reports.Successful) { this.parent_Variablesconfig_Configurationtree = new Configurationtree_NodeImpl(NamesNode.S_VARIABLE_CONFIG, o_Table_Var.Expression_Filepath_ConfigStack.Cur_Configuration); if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } foreach (DataRow dataRow in o_Table_Var.DataTable.Rows) { string sStringValue;// = ""; // ソース情報として使うだけ。 Configurationtree_Node cf_VarRecord1 = new Configurationtree_NodeImpl(NamesNode.S_VARIABLE_RECORD, parent_Variablesconfig_Configurationtree); // 注意: dataRow[]の連想配列は大文字・小文字を区別しないのが欠点。 //NAME列 { string sFldName = NamesFld.S_NAME;//フィールド名。 if (o_Table_Var.ContainsField(sFldName, true, log_Reports)) { if (String_HumaninputImpl.TryParse( dataRow[sFldName], out sStringValue, o_Table_Var.Name, sFldName, log_Method, log_Reports)) { } else { sStringValue = ""; } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } cf_VarRecord1.Dictionary_Attribute.Set(PmNames.S_NAME.Name_Pm, sStringValue, log_Reports); } } // FOLDER列 (オプション) { string sFldName = NamesFld.S_FOLDER; if (o_Table_Var.ContainsField(sFldName, false, log_Reports)) { if (String_HumaninputImpl.TryParse( dataRow[sFldName], out sStringValue, o_Table_Var.Name, sFldName, log_Method, log_Reports)) { } else { sStringValue = ""; } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } //if (log_Method.CanDebug(1)) //{ // log_Method.WriteDebug_ToConsole("「変数登録ファイル」FOLDER列=[" + sStringValue + "]"); //} cf_VarRecord1.Dictionary_Attribute.Set(PmNames.S_FOLDER.Name_Pm, sStringValue, log_Reports); } else { //なければ無視。 } } // VALUE列 { string sFldName = NamesFld.S_VALUE;//フィールド名。 if (o_Table_Var.ContainsField(sFldName, true, log_Reports)) { if (String_HumaninputImpl.TryParse( dataRow[sFldName], out sStringValue, o_Table_Var.Name, sFldName, log_Method, log_Reports)) { } else { sStringValue = ""; } if (!log_Reports.Successful) { // エラー goto gt_EndMethod; } cf_VarRecord1.Dictionary_Attribute.Set(PmNames.S_VALUE.Name_Pm, sStringValue, log_Reports); } } // // 変数を登録。 // if (log_Reports.Successful) { //NAME列 string sName; cf_VarRecord1.Dictionary_Attribute.TryGetValue(PmNames.S_NAME, out sName, true, log_Reports); //FOLDER列 (オプション) string sFolder; bool bExistsFolder = cf_VarRecord1.Dictionary_Attribute.TryGetValue(PmNames.S_FOLDER, out sFolder, false, log_Reports); string sValue; cf_VarRecord1.Dictionary_Attribute.TryGetValue(PmNames.S_VALUE, out sValue, false, //空文字列でも可。 log_Reports); if (NamesVar.Test_Filepath(sName)) { //ファイルパス変数の場合。 Configurationtree_NodeFilepath cf_Fpath = new Configurationtree_NodeFilepathImpl("変数[" + sName + "]", this.parent_Variablesconfig_Configurationtree); cf_Fpath.InitPath( sValue, log_Reports ); if ("" != sFolder) { //if (log_Method.CanDebug(1)) //{ // log_Method.WriteDebug_ToConsole("「変数登録ファイル」FOLDER列指定あり=[" + sFolder + "]"); //} Expression_Node_String ec_Namevar_Folder = new Expression_Leaf_StringImpl(sFolder, null, this.parent_Variablesconfig_Configurationtree); Expression_Node_Filepath ec_Fopath_Folder = this.GetExpressionfilepathByVariablename( ec_Namevar_Folder, true, log_Reports ); cf_Fpath.SetDirectory_Base(ec_Fopath_Folder.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports)); } //else //{ // if (log_Method.CanDebug(1)) // { // log_Method.WriteDebug_ToConsole("「変数登録ファイル」FOLDER列指定なし"); // } //} Expression_Node_Filepath ec_Fpath = new Expression_Node_FilepathImpl(cf_Fpath); this.PutFilepath( sName, ec_Fpath, true, log_Reports ); //if (log_Method.CanDebug(1)) //{ // log_Method.WriteDebug_ToConsole("「変数登録ファイル」ファイルパス変数=[" + sName + "] 値=[" + ec_Fpath.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]"); //} } else { //ファイルパス以外の変数の場合。 //if (log_Method.CanDebug(1)) //{ // log_Method.WriteDebug_ToConsole("「変数登録ファイル」ファイルパス以外の変数=[" + sName + "]"); //} if (bExistsFolder && "" != sFolder) { //ファイルパス変数以外の変数で、FOLDER列値を指定しているのはエラーです。 //※FOLDER列が存在する場合だけエラーチェックします。FOLDER列値がない場合は、sFolderには"null"が入っているので無視します。 err_SName = sName; err_SFolder = sFolder; goto gt_Error_InputFolder; } this.PutString( sName, sValue, log_Reports ); } } } } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_InputFolder: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("Er:402;", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("["); s.Append(err_SName); s.Append("]変数に、"); s.Append(PmNames.S_FOLDER.Name_Attribute); s.Append("列値を指定しているのはエラーです。"); s.Newline(); s.Append(PmNames.S_FOLDER.Name_Attribute); s.Append("列値は、ファイルパス変数にしか書いてはいけません。"); s.Newline(); s.Append("ファイルパス変数は、「"); s.Append(NamesVar.S_SP_); s.Append("」、「"); s.Append(NamesVar.S_UP_); s.Append("」で始まる名前の変数です。"); s.Newline(); s.Newline(); s.AppendI(1, PmNames.S_FOLDER.Name_Attribute); if (null == err_SFolder) { s.Append("=ヌル。"); } else { s.Append("=["); s.Append(err_SFolder); s.Append("]"); } s.Newline(); s.Newline(); // ヒント r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_NullTable: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー918!", log_Method); StringBuilder t = new StringBuilder(); t.Append("指定されたテーブルは、ヌルでした。"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); // ヒント r.Message = t.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_DoubleLoad: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー919!", log_Method); StringBuilder t = new StringBuilder(); t.Append("既に「変数設定ファイル」はロードされているのに、"); t.Append(Environment.NewLine); t.Append("また 「変数設定ファイル」をロードしようとしました。"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); // ヒント r.Message = t.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // 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 error_Filepath_Source; int error_RowNumber; Table_Humaninput error_Table_Humaninput; 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(); } Expression_Node_Filepath pm_FileImportListfile_Expr; this.TrySelectAttribute_ExpressionFilepath(out pm_FileImportListfile_Expr, Expression_Node_Function48Impl.PM_FILE_IMPORT_LISTFILE, EnumHitcount.One, log_Reports); Expression_Node_String pm_FieldsourceImportlistfile_Expr; this.TrySelectAttribute(out pm_FieldsourceImportlistfile_Expr, Expression_Node_Function48Impl.PM_FIELDSOURCE_IMPORTLISTFILE, EnumHitcount.One, log_Reports); Expression_Node_String pm_FielddestinationImportlistfile_Expr; this.TrySelectAttribute(out pm_FielddestinationImportlistfile_Expr, Expression_Node_Function48Impl.PM_FIELDDESTINATION_IMPORTLISTFILE, EnumHitcount.One, log_Reports); Expression_Node_String pm_EncodingFileimport_Expr; this.TrySelectAttribute(out pm_EncodingFileimport_Expr, Expression_Node_Function48Impl.PM_ENCODING_FILEIMPORT, EnumHitcount.One, log_Reports); Expression_Node_String pm_EncodingFileexport_Expr; this.TrySelectAttribute(out pm_EncodingFileexport_Expr, Expression_Node_Function48Impl.PM_ENCODING_FILEEXPORT, EnumHitcount.One, log_Reports); // // メッセージボックスの表示。 { StringBuilder sb = new StringBuilder(); sb.Append(log_Method.Fullname); sb.Append(":"); sb.Append(Environment.NewLine); sb.Append( "\n" + "file-listfile = " + pm_FileImportListfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "\n\n" + "fieldsource-importlistfile = " + pm_FieldsourceImportlistfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "\n\n" + "fielddestination-importlistfile = " + pm_FielddestinationImportlistfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "\n\n" + "encoding-fileimport=[" + pm_EncodingFileimport_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "encoding-fileexport=[" + pm_EncodingFileexport_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports) + "]\n\n" + "" ); MessageBox.Show(sb.ToString(), "デバッグ表示"); } // CSVファイル読取り Table_Humaninput tableH; if (log_Reports.Successful) { // // CSVソースファイル読取 // CsvTo_Table_HumaninputImpl reader = new CsvTo_Table_HumaninputImpl(); Request_ReadsTable request_tblReads = new Request_ReadsTableImpl(); Format_Table_Humaninput tblFormat_puts = new Format_Table_HumaninputImpl(); request_tblReads.Name_PutToTable = log_Method.Fullname;//暫定 request_tblReads.Expression_Filepath = pm_FileImportListfile_Expr; tableH = reader.Read( request_tblReads, tblFormat_puts, true, log_Reports ); } else { tableH = null; } if (log_Reports.Successful) { int rowNumber = 1; foreach (DataRow row in tableH.DataTable.Rows) { //記述されているファイルパス string filepath_Source_Cur; string filepath_Destination_Cur; if (log_Reports.Successful) { //"FILE" string field1 = pm_FieldsourceImportlistfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); //"FILE2" string field2 = pm_FielddestinationImportlistfile_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); String_HumaninputImpl.TryParse(row[field1], out filepath_Source_Cur, "", "", log_Method, log_Reports); String_HumaninputImpl.TryParse(row[field2], out filepath_Destination_Cur, "", "", log_Method, log_Reports); //if (log_Method.CanDebug(9)) //{ //log_Method.WriteDebug_ToConsole("コピーしたいfilepath:①[" + filepath_Source_Cur + "]→②[" + filepath_Destination_Cur + "]"); //} } else { filepath_Source_Cur = ""; filepath_Destination_Cur = ""; } // // ファイルのコピー(上書き) // if ("" != filepath_Source_Cur && "" != filepath_Destination_Cur) { //フォルダーのコピー方法は別。 if (System.IO.Directory.Exists(filepath_Source_Cur)) { //フォルダー //コピー先のディレクトリがないときは作る if (!System.IO.Directory.Exists(filepath_Destination_Cur)) { System.IO.Directory.CreateDirectory(filepath_Destination_Cur); //属性もコピー System.IO.File.SetAttributes(filepath_Destination_Cur, System.IO.File.GetAttributes(filepath_Source_Cur)); } } else if (System.IO.File.Exists(filepath_Source_Cur)) { //ファイル //コピー先フォルダが存在しない場合、フォルダを作成 string nameFolderDestination = System.IO.Path.GetDirectoryName(filepath_Destination_Cur); if (!System.IO.Directory.Exists(nameFolderDestination)) { // フォルダ作成 System.IO.Directory.CreateDirectory(nameFolderDestination); //TODO:作成したフォルダに、フォルダの属性を複写 //System.IO.File.SetAttributes(nameFolderDestination, System.IO.File.GetAttributes(Source_Folder_Name)); } //第一引数で示されたファイルを、第二引数で示されたファイル位置にコピー。 //第3項にtrueを指定することにより、上書きを許可 System.IO.File.Copy(filepath_Source_Cur, filepath_Destination_Cur, true); //エンコーディングを変換する { Encoding encodingSrc; { string nameEncodingSrc = pm_EncodingFileimport_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); if ("" != nameEncodingSrc) { encodingSrc = Encoding.GetEncoding(nameEncodingSrc); } else { encodingSrc = null; } } Encoding encodingDst; { string nameEncodingDst = pm_EncodingFileexport_Expr.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); if ("" != nameEncodingDst) { encodingDst = Encoding.GetEncoding(nameEncodingDst); } else { encodingDst = Global.ENCODING_CSV; } } if (null != encodingSrc && (encodingSrc != encodingDst)) { //エンコーディング変換を行う。 log_Method.WriteDebug_ToConsole("エンコーディング変換[" + encodingSrc.EncodingName + "]→[" + encodingDst.EncodingName + "]"); string textAll = System.IO.File.ReadAllText(filepath_Source_Cur); byte[] temp1 = encodingSrc.GetBytes(textAll); byte[] temp2 = System.Text.Encoding.Convert(encodingSrc, encodingDst, temp1); textAll = encodingDst.GetString(temp2); System.IO.File.WriteAllText(filepath_Destination_Cur, textAll); } } } else { //エラー // error_Filepath_Source = filepath_Source_Cur; error_RowNumber = rowNumber; error_Table_Humaninput = tableH; goto gt_Error_NoFilesystementry; } } if (!log_Reports.Successful) { //エラー break; } rowNumber++; } } goto gt_EndMethod; // #region 異常系 //──────────────────────────────────────── gt_Error_NoFilesystementry: { Builder_TexttemplateP1p tmpl = new Builder_TexttemplateP1pImpl(); tmpl.SetParameter(1, error_Filepath_Source, log_Reports); //ファイルパス tmpl.SetParameter(2, error_RowNumber.ToString(), log_Reports); //エラーのあった行 tmpl.SetParameter(3, Log_RecordReportsImpl.ToText_Configuration(error_Table_Humaninput), log_Reports); //設定位置パンくずリスト this.Owner_MemoryApplication.CreateErrorReport("Er:110030;", tmpl, log_Reports); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // 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); }
//──────────────────────────────────────── /// <summary> /// 選択されているセルに、指定の値を上書きします。 /// </summary> /// <param nFcName="outputValueStr"></param> /// <param nFcName="row"></param> /// <param nFcName="selFldDefinition">選択フィールド</param> /// <param nFcName="log_Reports"></param> public void ToMemory_ToSelectedField( string sValue_Output, Expression_Node_String ec_Fcell, DataRow row, Fielddefinition selFldDefinition,//選択したフィールド定義 Log_Reports log_Reports ) { //essageBox.Show("アップデートデータ【開始】 outputValueStr=[" + outputValueStr + "]\n", "(FormsImpl)" + this.GetType().NFcName ); //.WriteLine(this.GetType().NFcName + "#: 【開始】データのアップデートを始める。"); Log_Method pg_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); pg_Method.BeginMethod(Info_Controls.Name_Library, this, "ToM_ToSelectedField", log_Reports); // // string sName_SelectedFld; { bool bHit = ec_Fcell.TrySelectAttribute( out sName_SelectedFld, PmNames.S_SELECT.Name_Pm, EnumHitcount.One, log_Reports ); } string sConfigStack_StringOfCell = sName_SelectedFld; switch (selFldDefinition.Type_Field) { case EnumTypeFielddefinition.String: { // 空欄も自動処理 String_HumaninputImpl cellData = new String_HumaninputImpl(sConfigStack_StringOfCell); cellData.Text = sValue_Output; row[sName_SelectedFld] = cellData; } break; case EnumTypeFielddefinition.Int: { // 空欄も自動処理 Int_HumaninputImpl cellData = new Int_HumaninputImpl(sConfigStack_StringOfCell); cellData.Text = sValue_Output; row[sName_SelectedFld] = cellData; } break; case EnumTypeFielddefinition.Bool: { // 空欄も自動処理 Bool_HumaninputImpl cellData = new Bool_HumaninputImpl(sConfigStack_StringOfCell); cellData.Text = sValue_Output; row[sName_SelectedFld] = cellData; } break; default: { if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー398!", pg_Method); StringBuilder t = new StringBuilder(); t.Append("予期しない、フィールドの型です。"); t.Append(Environment.NewLine); t.Append("selFldDefinition.Type=["); t.Append(selFldDefinition.ToString_Type()); t.Append("]"); t.Append(Environment.NewLine); t.Append(Environment.NewLine); // ヒント t.Append(r.Message_Configuration( ec_Fcell.Cur_Configuration)); r.Message = t.ToString(); log_Reports.EndCreateReport(); } } break; } // pg_Method.EndMethod(log_Reports); }