//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── public void Read(Log_Reports log_Reports) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Actorslist.Name_Library, this, "button1_Click", log_Reports); Exception error_Exception; string error_Attribute; string error_Value; string filepathConfig = Path.Combine(Application.StartupPath, "Config.xml"); { XmlDocument doc = new XmlDocument(); try { doc.Load(filepathConfig); XmlElement root = doc.DocumentElement; foreach (XmlNode child in root.ChildNodes) { if (child is XmlElement) { XmlElement elm = (XmlElement)child; if ("input" == elm.Name) { if ("FolderProject" == elm.GetAttribute("name")) { string value = elm.GetAttribute("value"); this.FolderpathProject = value; if (!Directory.Exists(value)) { error_Attribute = "FolderProject"; error_Value = value; goto gt_Error_Folder1; } } else if ("FileExportLualist" == elm.GetAttribute("name")) { string value = elm.GetAttribute("value"); this.FilepathExportLualist = value; //if (!Directory.Exists(value)) //{ // error_Attribute = "FileExportLualist"; // error_Value = value; // goto gt_Error_File1; //} } else if ("FileExportFunctionlist" == elm.GetAttribute("name")) { string value = elm.GetAttribute("value"); this.FilepathExportFunctionlist = value; //if (!Directory.Exists(value)) //{ // error_Attribute = "FilepathExportFunctionlist"; // error_Value = value; // goto gt_Error_File1; //} } } else { } } } } catch (Exception ex) { error_Exception = ex; goto gt_Error_Config; } } System.Console.WriteLine("filepathExportLualist=[" + filepathExportLualist + "]"); goto gt_EndMethod; #region 異常系 //──────────────────────────────────────── gt_Error_Config: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー13002!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("Config.xmlにエラー?"); s.Newline(); s.Append(r.Message_SException(error_Exception)); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_Folder1: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー13005!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("存在するフォルダーを指定してください。"); s.Append(Environment.NewLine); s.Append(" " + error_Attribute + "=["); s.Append(this.FolderpathProject); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── //gt_Error_File1: // if (log_Reports.CanCreateReport) // { // Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); // r.SetTitle("▲エラー13006!", log_Method); // Log_TextIndented s = new Log_TextIndentedImpl(); // s.Append("存在するファイルを指定してください。"); // s.Append(Environment.NewLine); // s.Append(" " + error_Attribute + "=["); // s.Append(this.FolderpathProject); // s.Append("]"); // r.Message = s.ToString(); // log_Reports.EndCreateReport(); // } // goto gt_EndMethod; //──────────────────────────────────────── #endregion gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── /// <summary> /// 指定のフィールド名だけに絞り込んだサブテーブルを作って返します。 /// </summary> /// <param name="sFieldNameList"></param> /// <returns></returns> public static Table_Humaninput CreateSubTableBySelect( string name_NewTable, List <string> list_Src_SNewFieldName, Expr_Filepath expr_Fpath_NewTable, EnumLogic enumWhereLogic, List <Recordcondition> list_Reccond, Table_Humaninput src_XenonTable, Log_Reports log_Reports) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, "Util_Table", "CreateSubTableBySelect", log_Reports); // // // // Table_Humaninput tableH_New = new Table_HumaninputImpl( name_NewTable, expr_Fpath_NewTable, expr_Fpath_NewTable.Conf); RecordFielddef recordFielddefinigion_New; List <List <string> > sFieldListList; Utility_Table.SelectFieldListList( out sFieldListList, out recordFielddefinigion_New, enumWhereLogic, list_Src_SNewFieldName, list_Reccond, src_XenonTable, log_Reports ); // // 新しいテーブルを作成します。(列定義の追加) // tableH_New.CreateTable(recordFielddefinigion_New, log_Reports); if (tableH_New.DataTable.Columns.Count < 1) { // エラー。 goto gt_Error_ZeroField; } else if (tableH_New.RecordFielddef.Count < 1) { // エラー。 goto gt_Error_ZeroFieldDef; } // 不要なレコードを除去して絞り込んだ後で、 // レコード追加。 { tableH_New.AddRecordList(sFieldListList, recordFielddefinigion_New, log_Reports); } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_ZeroField: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー471!", log_Method); Log_TextIndented t = new Log_TextIndentedImpl(); t.Append(" フィールドが0件のテーブルを作ることはできません。newFldDefList=["); t.Append(recordFielddefinigion_New.Count); t.Append("]"); t.Newline(); t.Newline(); // ヒント r.Message = t.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_ZeroFieldDef: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー472!", log_Method); Log_TextIndented t = new Log_TextIndentedImpl(); t.Append(" フィールド定義が0件のテーブルを作ることはできません。o_NewTable.FieldDefinitions.Count=["); t.Append(tableH_New.RecordFielddef.Count); t.Append("]"); t.Newline(); t.Newline(); // ヒント r.Message = t.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(tableH_New); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// 『レイアウト設定ファイル』をもとに、 /// コントロール(UserControl)を作成します。 /// /// 作成できなかった、または作成しなかった場合はヌル。 /// /// プロパティーの設定は、この時点では、名前だけ行います。 /// </summary> /// <param name="fo_Record"></param> /// <param name="bRequired">未定義の設定があったときに、エラーにするなら真。</param> /// <param name="pg_Logging"></param> public Usercontrol Create( RecordUserformconfig fo_Record, bool bRequired_NotUse,// TODO:必ず真でいいのでは? MemoryApplication owner_MemoryApplication, Log_Reports pg_Logging ) { Log_Method pg_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static); pg_Method.BeginMethod(Info_LayoutImpl.Name_Library, this, "Create", pg_Logging); // // string sName_Control; fo_Record.TryGetString(out sName_Control, NamesFld.S_NAME, true, "", owner_MemoryApplication, pg_Logging); // // コントロール名 レコード→Ec Expression_Node_StringImpl ec_Name_Control = new Expression_Node_StringImpl(null, fo_Record.Parent_TableUserformconfig.Cur_Configurationtree); ec_Name_Control.AppendTextNode( sName_Control, fo_Record.Parent_TableUserformconfig.Cur_Configurationtree, pg_Logging ); Usercontrol ucontrol = null; string sType_Control; fo_Record.TryGetString(out sType_Control, NamesFld.S_TYPE, true, "", owner_MemoryApplication, pg_Logging); if (null == sType_Control) { goto gt_Error_Type; } else if (!this.Dictionary_UsercontrolCreator.ContainsKey(sType_Control))//TODO:設定ミス時への対応。フィールド名がヌル? { goto gt_Error_FName; } UsercontrolCreator2 uctCreator = this.Dictionary_UsercontrolCreator[sType_Control]; ucontrol = uctCreator.Perform(ec_Name_Control, owner_MemoryApplication); if (null != ucontrol) { // ヌル オブジェクトを設定。 ucontrol.ControlCommon.Expression_Control = new Expression_ControlImpl( null, new Configurationtree_NodeImpl(NamesNode.S_HARDCODING_CONTROL, null), ucontrol, owner_MemoryApplication ); ucontrol.ControlCommon.Owner_MemoryApplication = owner_MemoryApplication; } else { goto gt_Error_NullUsercontrol; } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_NullUsercontrol: if (pg_Logging.CanCreateReport) { Log_RecordReports r = pg_Logging.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー356!", pg_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("ucontrolがヌルでした。"); s.Newline(); s.Newline(); // ヒント s.Append(r.Message_Configuration(fo_Record.Parent_TableUserformconfig.Cur_Configurationtree)); r.Message = s.ToString(); pg_Logging.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_Type: if (pg_Logging.CanCreateReport) { Log_RecordReports r = pg_Logging.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー355!", pg_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("コントロールの型が指定されていません。"); s.Newline(); s.Newline(); s.Append(" 『レイアウト設定』をもとに、コントロールを作成しているときに、"); s.Newline(); s.Append(" エラーが発生しました。"); s.Newline(); // ヒント s.Append(r.Message_Configuration(fo_Record.Parent_TableUserformconfig.Cur_Configurationtree)); r.Message = s.ToString(); pg_Logging.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_FName: // テーブルタイプが「Form」で、"TREE" フィールドがないとき。 // (Form_lstタイプには、TREEフィールドは要らない) if (pg_Logging.CanCreateReport) { Log_RecordReports r = pg_Logging.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー354!", pg_Method); Log_TextIndented t = new Log_TextIndentedImpl(); t.Append(" 『レイアウト設定』をもとに、コントロールを作成しているときに、"); t.Newline(); t.Append(" エラーが発生しました。"); t.Newline(); t.Newline(); t.Append(" 指定の型=["); t.Append(sType_Control); t.Append("]は未定義のコントロールの型です。"); // ヒント t.Append(r.Message_Configuration(fo_Record.Parent_TableUserformconfig.Cur_Configurationtree)); r.Message = t.ToString(); pg_Logging.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: pg_Method.EndMethod(pg_Logging); return(ucontrol); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// CSVを読取り、テーブルにして返します。 /// /// /// SRS仕様の実装状況 /// ここでは、先頭行を[0]行目と数えるものとします。 /// (1)CSVの[0]行目は列名です。 /// (2)CSVの[1]行目は型名です。 /// (3)CSVの[2]行目はコメントです。 /// /// (4)データ・テーブル部で、0列目に「EOF」と入っていれば終了。大文字・小文字は区別せず。 /// それ以降に、コメントのようなデータが入力されていることがあるが、フィールドの型に一致しないことがあるので無視。 /// TODO: EOF以降の行も、コメントとして残したい。 /// /// (5)列名に ”END”(半角) がある場合、その手前までの列が有効データです。 /// ”END”以降の列は無視します。 /// TODO: ”END”以降の行も、コメントとして残したい。 /// /// (6)int型として指定されているフィールドのデータ・テーブル部に空欄があった場合、DBNull(データベース用のヌル)とします。 /// </summary> /// <param name="csvText"></param> /// <returns>列名情報も含むテーブル。列の型は文字列型とします。</returns> public Table_Humaninput Read( string string_Csv, Request_ReadsTable forTable_request, Format_Table_Humaninput forTable_puts, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, this, "Read(1)", log_Reports); Table_Humaninput xenonTable = new Table_HumaninputImpl( forTable_request.Name_PutToTable, forTable_request.Expression_Filepath, forTable_request.Expression_Filepath.Cur_Configuration); xenonTable.Tableunit = forTable_request.Tableunit; xenonTable.Typedata = forTable_request.Typedata; xenonTable.IsDatebackupActivated = forTable_request.IsDatebackupActivated; xenonTable.Format_Table_Humaninput = forTable_puts; Exception err_Excp; int error_Count_Index; string[] error_Fields_Cur; // // 型定義部 // // (※NO,ID,EXPL,NAME など、フィールドの定義を持つテーブル) // RecordFielddefinition recordFielddefinition = new RecordFielddefinitionImpl(); // // データ・テーブル部 // List <List <string> > dataTableRows = new List <List <string> >(); // CSVテキストを読み込み、型とデータのバッファーを作成します。 System.IO.StringReader reader = new System.IO.StringReader(string_Csv); CsvLineParserImpl csvParser = new CsvLineParserImpl(); // CSVを解析して、テーブル形式で格納。 { // データとして認識する列の総数です。 int nDataColumnsCount = 0; int nRowIndex = 0; string[] fields_Cur; while (-1 < reader.Peek()) { string line = reader.ReadLine(); fields_Cur = csvParser.UnescapeLineToFieldList(line, this.charSeparator).ToArray(); if (0 == nRowIndex) { // 0行目 // 列名の行とします。 for (int nColumnIx = 0; nColumnIx < fields_Cur.Length; nColumnIx++) { string sColumnName = fields_Cur[nColumnIx]; // 列名を読み込みました。 // トリム&大文字 string sCellValueTU = sColumnName.Trim().ToUpper(); if (ToCsv_Table_Humaninput_RowColRegularImpl.S_END == sCellValueTU) { // 列名に ”END” がある場合、その手前までの列が有効データです。 // ”END” 以降の列は無視します。 goto field_name_reading_end; } // テーブルのフィールドを追加します。型の既定値は文字列型とします。 FielddefinitionImpl fieldDef = new FielddefinitionImpl(sColumnName, EnumTypeFielddefinition.String); recordFielddefinition.Add(fieldDef); nDataColumnsCount++; } // 0行目は、テーブルのデータとしては持ちません。 } else if (1 == nRowIndex) { // 1行目 // フィールド型名の行。 for (int nColumnIx = 0; nColumnIx < nDataColumnsCount; nColumnIx++) { string name_FieldType_Lower; try { name_FieldType_Lower = fields_Cur[nColumnIx].ToLower(); } catch (IndexOutOfRangeException e) { err_Excp = e; goto gt_Error_FdIndexOutOfRangeException; } // 列の型名を読み込みました。 // テーブルのフィールドを追加します。型の既定値は文字列型とします。 // TODO int型とboolean型にも対応したい。 if (FielddefinitionImpl.S_STRING.Equals(name_FieldType_Lower)) { recordFielddefinition.ValueAt(nColumnIx).Type_Field = EnumTypeFielddefinition.String; } else if (FielddefinitionImpl.S_INT.Equals(name_FieldType_Lower)) { recordFielddefinition.ValueAt(nColumnIx).Type_Field = EnumTypeFielddefinition.Int; } else if (FielddefinitionImpl.S_BOOL.Equals(name_FieldType_Lower)) { // 2009-11-11修正:SRS仕様では「bool」が正しい。「boolean」は間違い。 recordFielddefinition.ValueAt(nColumnIx).Type_Field = EnumTypeFielddefinition.Bool; } else { // 型が未定義の列は、文字列型として読み取ります。 // TODO:警告を出すか? recordFielddefinition.ValueAt(nColumnIx).Type_Field = EnumTypeFielddefinition.String; } } // 1行目は、テーブルのデータとしては持ちません。 } else if (2 == nRowIndex) { // 2行目 // フィールドのコメントの行。 // TODO: フィールドのコメントの行は省略されることがある。 for (int column = 0; column < nDataColumnsCount; column++) { if (fields_Cur.Length <= column) { error_Fields_Cur = fields_Cur; //error_Count_Columns = fields_Cur.Length; error_Count_Index = column; goto gt_Error_CommentFieldCount; } string comment_Field = fields_Cur[column];//todo:bug:境界線エラーをキャッチしてない。 recordFielddefinition.ValueAt(column).Comment = comment_Field; } // 2行目は、テーブルのデータとしては持ちません。 } else { // 3行目以降のループ。 List <string> sList_Column = new List <string>(); // データ・テーブル部で、0列目に「EOF」と入っていれば終了。大文字・小文字は区別せず。 if (fields_Cur.Length < 1) { // 空行は無視。 goto end_recordAdd; } //ystem.Console.WriteLine(InfxenonTable.LibraryName + ":" + this.GetType().Name + "#UnescapeToList: sFields[0]=[" + sFields[0] + "] sLine=[" + sLine + "]"); string sCellValueTrimUpper = fields_Cur[0].Trim().ToUpper(); if (ToCsv_Table_Humaninput_RowColRegularImpl.S_EOF == sCellValueTrimUpper) { goto reading_end; } int nColumnCount; if (fields_Cur.Length < nDataColumnsCount) { // 「実際にデータとして存在する列数」 nColumnCount = fields_Cur.Length; } else { // 「データとして存在する筈の列数」(これ以降の列は無視) nColumnCount = nDataColumnsCount; } for (int nColumnIx = 0; nColumnIx < nColumnCount; nColumnIx++) { string sValue; sValue = fields_Cur[nColumnIx]; if (recordFielddefinition.Count <= nColumnIx) { // 0行目で数えた列数より多い場合。 // テーブルのフィールドを追加します。型は文字列型とします。名前は空文字列です。 recordFielddefinition.Add(new FielddefinitionImpl("", EnumTypeFielddefinition.String)); } sList_Column.Add(sValue); } dataTableRows.Add(sList_Column); end_recordAdd: ; } field_name_reading_end: //essageBox.Show("ttbwIndex=[" + ttbwIndex + "]行目ループ終わり", "TableCsvLibデバッグ"); nRowIndex++; } } reading_end: // ストリームを閉じます。 reader.Close(); //essageBox.Show("CSV読取終わり1 rows.Count=[" + rows.Count + "]", "TableCsvLibデバッグ"); // テーブルのフィールド定義。 xenonTable.CreateTable(recordFielddefinition, log_Reports); if (log_Reports.Successful) { // データ本体のセット。 xenonTable.AddRecordList(dataTableRows, recordFielddefinition, log_Reports); } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_CommentFieldCount: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー1356!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("「フィールド・コメント」行のフィールド数が合いませんでした。"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("index=["); s.Append(error_Count_Index); s.Append("]"); s.Append(Environment.NewLine); s.Append("列数=["); s.Append(error_Fields_Cur.Length); s.Append("]"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("──────────fields ここから"); s.Append(Environment.NewLine); foreach (string field in error_Fields_Cur) { s.Append("field=["); s.Append(field); s.Append("]"); s.Append(Environment.NewLine); } s.Append("──────────fields ここまで"); s.Append(Environment.NewLine); // // ヒント s.Append(Log_RecordReportsImpl.ToText_Configuration(xenonTable)); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_FdIndexOutOfRangeException: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー132!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Newline(); s.Append("フィールド定義の数が合いませんでした。"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); string sFpatha = forTable_request.Expression_Filepath.Execute4_OnExpressionString( EnumHitcount.Unconstraint, log_Reports); s.Append("ファイルパス=["); s.Append(sFpatha); s.Append("]"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); // // ヒント s.Append(err_Excp.Message); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(xenonTable); }
//──────────────────────────────────────── public void Judge( out bool isJudge, string name_KeyField, string value_Expected, bool isRequired_ExpectedValue, DataRow row, Conf_String parent_Query, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, this, "Judge", log_Reports); // try { object obj = row[name_KeyField]; if (obj is DBNull) { isJudge = false; goto gt_Error_DBNull; } Cell valueH = (Cell)obj; // (5)キーが空欄で、検索ヒット必須でなければ、無視します。【int型フィールドの場合】 if (IntCellImpl.IsSpaces(valueH)) { isJudge = false; goto gt_EndMethod; } // (6)この行の、キー_フィールドの値を取得。 int keyValue; bool bParsedSuccessful = IntCellImpl.TryParse( valueH, out keyValue, EnumOperationIfErrorvalue.Error, null, log_Reports ); if (log_Reports.Successful) { if (!bParsedSuccessful) { isJudge = false; if (log_Reports.CanCreateReport) { Log_RecordReports d_Report = log_Reports.BeginCreateReport(EnumReport.Error); d_Report.SetTitle("▲エラー698!", log_Method); d_Report.Message = "int型パース失敗。"; log_Reports.EndCreateReport(); } goto gt_EndMethod; } } // (7)キー値をint型に変換します。 int expectedValue; if (log_Reports.Successful) { bool bParseSuccessful2 = int.TryParse(value_Expected, out expectedValue); if (!bParseSuccessful2) { isJudge = false; if (isRequired_ExpectedValue) { goto gt_Error_Parse; } goto gt_EndMethod; } } else { expectedValue = 0; } if (log_Reports.Successful) { // (8)該当行をレコードセットに追加。 if (keyValue == expectedValue) { // // 該当行なら。 isJudge = true; } else { isJudge = false; } } else { isJudge = false; } } catch (RowNotInTableException) { // (9)指定行がなかった場合は、スルー。 isJudge = false; // // 指定の行は、テーブルの中にありませんでした。 // 再描画と、行の削除が被ったのかもしれません。 // いわゆる「処理中」です。 // //.WriteLine(this.GetType().Name+"#GetValueStringList: ["+refTable.Name+"]テーブルには、["+ttbwIndex+"]行が存在しませんでした。もしかすると、削除されたのかもしれません。エラー:"+e.Message); } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_DBNull: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー244!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("検索キーに指定した["); s.Append(name_KeyField); s.Append("]というフィールドは無いです。"); s.Newline(); // ヒント parent_Query.ToText_Locationbreadcrumbs(s); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_Parse: // 空値ではダメという設定の場合。 if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー287!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.AppendI(0, "<Select_KeyIntImplクラス>"); s.Newline(); s.AppendI(1, "これはint型値のプログラムです。他の型のプログラムを使ってください。"); s.Newline(); s.AppendI(1, "・ヒント:変数が見つからなかった場合もここに来ます。例えば、変数名「$aaa」を書こうとして、「aaa」と書いていませんか?"); s.Newline(); s.AppendI(1, "・ヒント:数値が大きすぎた場合もここに来ます。"); s.Newline(); s.AppendI(1, "sExpectedValue=["); s.Append(value_Expected); s.Append("]"); s.Newline(); s.Newline(); // // ヒント parent_Query.ToText_Locationbreadcrumbs(s); s.AppendI(0, "</Select_KeyIntImplクラス>"); s.Newline(); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); }
//──────────────────────────────────────── /// <summary> /// <f-set-var>要素の名前を指定して、値を取り出します。(ファイル・パスとします) /// 該当がなければヌルを返します。 /// </summary> /// <param name="projectName"></param> /// <param name="bRequired">該当がない場合にエラー扱いにするなら真</param> /// <returns></returns> public Expression_Node_Filepath GetFilepathByFsetvarname( string sNamevar_Expected, MemoryVariables moVariables, bool bRequired, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(1, Log_ReportsImpl.BDebugmode_Static); log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "GetFilepathByFsetvarname", log_Reports); // // Expression_Node_Filepath ec_Fpath = null; //各<f-set-var> this.Dictionary_Fsetvar_Configurationtree.List_Child.ForEach(delegate(Configurationtree_Node s_Fsetvar, ref bool bBreak) { //name-var属性 string sNamevar_Cur; s_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_NAME_VAR, out sNamevar_Cur, true, log_Reports); if (sNamevar_Cur == sNamevar_Expected) { string sFolder; s_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_FOLDER, out sFolder, false, log_Reports); string sValue; s_Fsetvar.Dictionary_Attribute.TryGetValue(PmNames.S_VALUE, out sValue, true, log_Reports); { Configurationtree_NodeFilepath cf_Fpath = new Configurationtree_NodeFilepathImpl("『エディター設定ファイル』の[" + sNamevar_Expected + "]要素_L09Mid_2[" + sValue + "]", this.Parent); cf_Fpath.InitPath( sValue, log_Reports ); if ("" != sFolder) { //フォルダーパス変数名の指定有り Expression_Node_String ec_Namevar_Folder = new Expression_Leaf_StringImpl(sFolder, null, cf_Fpath); log_Reports.Log_Callstack.Push(log_Method, "②"); Expression_Node_Filepath ec_Fpath_Folder = moVariables.GetExpressionfilepathByVariablename(ec_Namevar_Folder, true, log_Reports); log_Reports.Log_Callstack.Pop(log_Method, "②"); if (log_Reports.Successful) { string sDirectory = ec_Fpath_Folder.Execute4_OnExpressionString(EnumHitcount.Unconstraint, log_Reports); if (log_Method.CanDebug(1)) { log_Method.WriteDebug_ToConsole("folder=[" + sFolder + "] directory=[" + sDirectory + "]"); } cf_Fpath.SetDirectory_Base( sDirectory ); } } if (!log_Reports.Successful) { // 既エラー。 bBreak = true; goto gt_EndMethod2; } ec_Fpath = new Expression_Node_FilepathImpl(cf_Fpath); } } goto gt_EndMethod2; // // gt_EndMethod2: ; }); if (null == ec_Fpath) { if (bRequired) { // エラーとして扱います。 goto gt_Error_NotFoundFsetvar; } } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_NotFoundFsetvar: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("Er:003;", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("次の要素は必要でしたが、記述されていませんでした。<" + NamesNode.S_EDITOR + ">要素の中に。"); s.Newline(); s.Newline(); s.Append("<" + NamesNode.S_F_SET_VAR + " name=\"" + sNamevar_Expected + "\" >"); s.Newline(); s.Newline(); s.Append("もしかして?"); s.Newline(); s.Append(" ・『設定ファイル』に、必要な内容が書けていない?"); s.Newline(); s.Append(" ・設定ファイル情報:"); s.Append(r.Message_Configuration(this.Parent)); s.Newline(); s.Newline(); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(ec_Fpath); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// パーサーのハブ。 /// /// </summary> /// <param name="request_ReadsTable">テーブルに付けたい名前や、ファイルパスの要求。</param> /// <param name="tableFormat_puts">テーブルの行列が逆になっているなどの、設定。</param> /// <param name="isRequired">テーブルが無かった場合、エラーとするなら真。</param> /// <param name="out_sErrorMsg"></param> /// <returns></returns> public Table_Humaninput Read( Request_ReadsTable request_ReadsTable, Format_Table tableFormat_puts, bool isRequired, Encoding encodingCsv, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(); log_Method.BeginMethod(Info_Table.Name_Library, this, "Read", log_Reports); // 読み取ったテーブル Table_Humaninput xTable; //絶対ファイルパス string csvAbs = request_ReadsTable.Expression_Filepath.Lv4Execute_OnImplement( EnumHitcount.Unconstraint, log_Reports); if (!log_Reports.Successful) { // 既エラー。 xTable = null; goto gt_EndMethod; } // CSVテキスト string contents; Exception error_Excp; if (CsvTo_TableImpl.S_WRITE_ONLY != request_ReadsTable.Use) { // 書き出し専用でなければ。 // ファイル読取を実行します。 try { if (!System.IO.File.Exists(csvAbs)) { // ファイルが存在しない場合。 xTable = null; goto gt_Error_NotExistsFile; } // TODO:IOException 別スレッドで開いているときなど。 contents = System.IO.File.ReadAllText(csvAbs, encodingCsv); //log_Method.WriteDebug_ToConsole(string_Csv); } catch (System.IO.IOException e) { // エラー処理。 xTable = null; contents = ""; error_Excp = e; goto gt_Error_FileOpen; } catch (Exception e) { // エラー処理。 xTable = null; contents = ""; error_Excp = e; goto gt_Error_Exception; } } else { contents = ""; } xTable = this.Read( contents, request_ReadsTable, tableFormat_puts, log_Reports ); if (!log_Reports.Successful) { // 既エラー。 goto gt_EndMethod; } // NOフィールドの値を 0からの連番に振りなおします。 xTable.RenumberingNoField(); if (isRequired && null == xTable) { goto gt_Error_NullTable; } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_FileOpen: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("Er:201;", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("ファイルの読取りに失敗しました。"); s.Newline(); s.Newline(); s.Append(" ファイル=["); s.Append(csvAbs); s.Append("]"); s.Newline(); s.Newline(); s.Append("もしかして?"); s.Newline(); s.Append(" ・ファイルの有無、ファイル名、ファイル パスを確認してください。"); s.Newline(); s.Append(" ・別アプリケーションで ファイルを開いていれば、閉じてください。"); s.Newline(); s.Newline(); // // ヒント request_ReadsTable.Expression_Filepath.Conf.ToText_Locationbreadcrumbs(s); s.Append(error_Excp.Message); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_NotExistsFile: if (log_Reports.CanCreateReport) { if ("" == request_ReadsTable.Expression_Filepath.Directory_Base) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("Er:202;", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("指定されたファイルはありませんでした。CSVファイルを読み込もうとしたとき。"); s.Newline(); s.Newline(); s.AppendI(1, "指定されたファイルパス=["); s.Append(csvAbs); s.Append("]"); s.Newline(); { s.AppendI(1, "ベース・ディレクトリは指定されていません。"); s.Newline(); s.AppendI(2, "もし相対パスが指定されていた場合、実行した.exeファイルからの相対パスとします。"); s.Newline(); s.Newline(); } s.Append(" ヒント:ファイルの有無、ファイル名、ファイル パスを確認してください。"); s.Newline(); // ヒント s.Append(r.Message_Conf( request_ReadsTable.Expression_Filepath.Conf)); r.Message = s.ToString(); } else { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー235!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("指定されたファイルはありませんでした。CSVファイルを読み込もうとしたとき。"); s.Newline(); s.Newline(); s.AppendI(1, "指定されたファイルパス=["); s.Append(csvAbs); s.Append("]"); s.Newline(); { s.AppendI(1, "指定されたベース・ディレクトリ=["); s.Append(request_ReadsTable.Expression_Filepath.Directory_Base); s.Append("]"); s.Newline(); s.Newline(); } s.Append(" ヒント:ファイルの有無、ファイル名、ファイル パスを確認してください。"); s.Newline(); // ヒント s.Append(r.Message_Conf( request_ReadsTable.Expression_Filepath.Conf)); r.Message = s.ToString(); } log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_Exception: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー104!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("▲エラー4030!(" + Info_Table.Name_Library + ")"); s.Newline(); s.Append("CSV読み取り中にエラーが発生しました。"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("指定CSVファイル=["); s.Append(csvAbs); s.Append("]"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); // // ヒント request_ReadsTable.Expression_Filepath.Conf.ToText_Locationbreadcrumbs(s); s.Append("エラーの種類:"); s.Append(error_Excp.GetType().Name); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("エラーメッセージ:"); s.Append(error_Excp.Message); 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("▲エラー105!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("▲エラー131!"); s.Newline(); s.Append("["); s.Append(request_ReadsTable.Name_PutToTable); s.Append("]テーブルがありませんでした。"); 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); return(xTable); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── public string ToCsvText( Table_Humaninput tableH, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Table.Name_Library, this, "ToCsvText", log_Reports); Log_TextIndented result = new Log_TextIndentedImpl(); RecordFielddefinition error_RecordFielddefinition; Exception err_Excep; int error_IndexColumn; Fielddefinition error_Fielddefinition; object error_Item; if (null == tableH) { // エラー goto gt_Error_NullTable; } CsvLineParserImpl csvParser = new CsvLineParserImpl(); // フィールド名をカンマ区切りで出力します。最後にENDを付加します。 // フィールド定義部 if (tableH.RecordFielddefinition.Count < 1) { //エラー。 error_RecordFielddefinition = tableH.RecordFielddefinition; goto gt_Error_FieldZero; } // フィールド定義部:名前 tableH.RecordFielddefinition.ForEach(delegate(Fielddefinition fielddefinition, ref bool isBreak, Log_Reports log_Reports2) { if (this.ExceptedFields.TryExceptedField(fielddefinition.Name_Trimupper)) { // 出力しないフィールドの場合、無視します。 } else { result.Append(csvParser.EscapeCell(fielddefinition.Name_Humaninput)); result.Append(","); } }, log_Reports); result.Append(ToCsv_Table_Humaninput_RowColRegularImpl.S_END); result.Append(Environment.NewLine);//改行 // フィールド定義部:型 tableH.RecordFielddefinition.ForEach(delegate(Fielddefinition fielddefinition, ref bool isBreak, Log_Reports log_Reports2) { if (this.ExceptedFields.TryExceptedField(fielddefinition.Name_Trimupper)) { // 出力しないフィールドの場合、無視します。 } else { switch (fielddefinition.Type_Field) { case EnumTypeFielddefinition.String: { result.Append(FielddefinitionImpl.S_STRING); } break; case EnumTypeFielddefinition.Int: { result.Append(FielddefinitionImpl.S_INT); } break; case EnumTypeFielddefinition.Bool: { result.Append(FielddefinitionImpl.S_BOOL); } break; default: { // TODO エラー対応。 // 未定義の型があった場合、そのまま出力します。 // C#のメッセージになるかと思います。 result.Append(fielddefinition.ToString_Type()); } break; } result.Append(","); } }, log_Reports); result.Append(ToCsv_Table_Humaninput_RowColRegularImpl.S_END); result.Append(Environment.NewLine);//改行 // フィールド定義部:コメント tableH.RecordFielddefinition.ForEach(delegate(Fielddefinition fielddefinition, ref bool isBreak, Log_Reports log_Reports2) { if (this.ExceptedFields.TryExceptedField(fielddefinition.Name_Trimupper)) { // 出力しないフィールドの場合、無視します。 } else { result.Append(csvParser.EscapeCell(fielddefinition.Comment)); result.Append(","); } }, log_Reports); result.Append(ToCsv_Table_Humaninput_RowColRegularImpl.S_END); result.Append(Environment.NewLine);//改行 // 0行目から数えて3行目以降はデータ・テーブル部。 // データ・テーブル部 DataTable dataTable = tableH.DataTable; // 各行について for (int nRowIndex = 0; nRowIndex < dataTable.Rows.Count; nRowIndex++) { DataRow dataRow = dataTable.Rows[nRowIndex]; // // 各フィールドについて // object[] itemArray = dataRow.ItemArray;// ItemArrayは1回の呼び出しが重い。 for (int indexColumn = 0; indexColumn < itemArray.Length; indexColumn++) { // TODO:範囲 リストサイズが0の時がある←プログラムミス? Fielddefinition fielddefinition; try { fielddefinition = tableH.RecordFielddefinition.ValueAt(indexColumn); } catch (Exception e) { // エラー。 err_Excep = e; error_RecordFielddefinition = tableH.RecordFielddefinition; error_IndexColumn = indexColumn; goto gt_Error_OutOfIndex; } if (this.ExceptedFields.TryExceptedField(fielddefinition.Name_Trimupper)) { // 出力しないフィールドの場合、無視します。 } else { string value_Cell; object item = itemArray[indexColumn]; if (item is Value_Humaninput) { value_Cell = ((Value_Humaninput)item).Text; } else if (item is string) { //フィールド定義部など。 value_Cell = (string)item; } else if (item is DBNull) { //空欄。 value_Cell = ""; } else { // エラー error_Item = item; error_Fielddefinition = fielddefinition; goto gt_Error_UndefinedFieldType; } result.Append(csvParser.EscapeCell(value_Cell)); result.Append(this.charSeparator); } } result.Append(ToCsv_Table_Humaninput_RowColRegularImpl.S_END); result.Append(Environment.NewLine);//改行 } result.Append(ToCsv_Table_Humaninput_RowColRegularImpl.S_EOF); // 最後に一応、改行を付けておきます。 result.Append(Environment.NewLine);//改行 goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_FieldZero: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー854!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("(プログラム内部エラー)テーブルの列定義が0件です。 error_RecordFielddefinition.Count["); s.Append(error_RecordFielddefinition.Count); s.Append("] テーブル名=["); s.Append(tableH.Name); s.Append("]"); s.Newline(); // ヒント r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_OutOfIndex: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー853!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("(プログラム内部エラー)err_NColIndex=["); s.Append(error_IndexColumn); s.Append("] error_RecordFielddefinition.Count["); s.Append(error_RecordFielddefinition.Count); s.Append("]"); s.Newline(); // ヒント s.Append(r.Message_SException(err_Excep)); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_UndefinedFieldType: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー855!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("(プログラム内部エラー)CSVを出力しようとしたとき、未定義のフィールド型=["); s.Append(error_Fielddefinition.ToString_Type()); s.Append("]がありました。"); s.Newline(); s.Append("型名=["); s.Append(error_Item.GetType().Name); s.Append("]"); s.Newline(); s.Append("型は["); s.Append(typeof(String_HumaninputImpl)); s.Append("],["); s.Append(typeof(Int_HumaninputImpl)); s.Append("],["); s.Append(typeof(Bool_HumaninputImpl)); s.Append("]が使えます。"); 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("▲エラー852!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("(プログラム内部エラー)tableがヌルでした。"); s.Newline(); // ヒント r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: log_Method.EndMethod(log_Reports); return(result.ToString()); }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── public static bool TryParse( object value, out Cell value_Out, bool isRequired, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Table.Name_Library, "Utility_HumaninputValue", "TryParse", log_Reports); bool bResult; if (value is Cell) { value_Out = (Cell)value; bResult = true; } else { value_Out = null; bResult = false; if (isRequired) { goto gt_Error_AnotherType; } goto gt_EndMethod; } goto gt_EndMethod; // #region 異常系 //──────────────────────────────────────── gt_Error_AnotherType: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー201!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("string,int,boolセルデータクラス以外のオブジェクトが指定されました。"); s.Newline(); s.Append("指定された値のクラス=["); s.Append(value.GetType().Name); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // gt_EndMethod: log_Method.EndMethod(log_Reports); return(bResult); }
//──────────────────────────────────────── public static Cell NewInstance( object value, bool isRequired, string conf_Node, Log_Reports log_Reports ) { Log_Method log_Method = new Log_MethodImpl(0); log_Method.BeginMethod(Info_Table.Name_Library, "Utility_HumaninputValue", "NewInstance", log_Reports); Cell result; if (value is StringCellImpl) { result = new StringCellImpl(conf_Node); } else if (value is IntCellImpl) { result = new IntCellImpl(conf_Node); } else if (value is BoolCellImpl) { result = new BoolCellImpl(conf_Node); } else { result = null; if (isRequired) { //エラー goto gt_Error_AnotherType; } } goto gt_EndMethod; // #region 異常系 //──────────────────────────────────────── gt_Error_AnotherType: if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー292!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("▲エラー201!(" + Info_Table.Name_Library + ")"); s.Newline(); s.Append("string,int,boolセルデータクラス以外のオブジェクトが指定されました。"); s.Newline(); s.Append("指定された値のクラス=["); s.Append(value.GetType().Name); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── #endregion // gt_EndMethod: log_Method.EndMethod(log_Reports); return(result); }
//──────────────────────────────────────── 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); }