Exemplo n.º 1
0
        //────────────────────────────────────────

        /// <summary>
        /// テーブル読取。
        /// </summary>
        /// <param name="forTable_request"></param>
        /// <param name="forTable_format"></param>
        /// <param name="log_Reports"></param>
        /// <returns></returns>
        private Table_Humaninput ReadTable(
            Request_ReadsTable forSubTable_Request_TblReads,
            Format_Table_Humaninput o_TableFormat_ForSubTable_Puts,
            Log_Reports log_Reports
            )
        {
            Table_Humaninput o_Tbl;

            if (log_Reports.Successful)
            {
                // 正常時

                //
                // テーブル読取り
                CsvTo_Table_HumaninputImpl reader = new CsvTo_Table_HumaninputImpl();

                // テーブル
                o_Tbl = reader.Read(
                    forSubTable_Request_TblReads,
                    o_TableFormat_ForSubTable_Puts,
                    true,
                    log_Reports
                    );
                if (!log_Reports.Successful)
                {
                    // 既エラー。
                    goto gt_EndMethod;
                }

                if (log_Reports.Successful)
                {
                    // 正常時

                    // NOフィールドの値を 0からの連番に振りなおします。
                    o_Tbl.RenumberingNoField();
                }
            }
            else
            {
                o_Tbl = null;
            }

            //
            //
            //
            //
gt_EndMethod:
            return(o_Tbl);
        }
Exemplo n.º 2
0
        //────────────────────────────────────────
        #endregion



        #region アクション
        //────────────────────────────────────────

        public void Perfrom()
        {
            Log_Method  log_Method             = new Log_MethodImpl(0);
            Log_Reports log_Reports_ThisMethod = new Log_ReportsImpl(log_Method);

            log_Method.BeginMethod(Info_PartsnumPut.Name_Library, this, "Perform", log_Reports_ThisMethod);


            this.out_Errormessage     = "";
            this.out_Table_Humaninput = new Table_HumaninputImpl("名無し", null, new Configurationtree_NodeImpl(log_Method.Fullname, null));


            // CSV読取
            string text_Csv;

            try
            {
                text_Csv = System.IO.File.ReadAllText(this.In_Filepathabsolute, Encoding.Default);
            }
            catch (Exception e)
            {
                // エラー
                this.out_Errormessage = e.Message;
                goto gt_EndMethod;
            }

            Request_ReadsTable      request = new Request_ReadsTableImpl();
            Format_Table_Humaninput format  = new Format_Table_HumaninputImpl();

            CsvTo_Table_HumaninputImpl trans = new CsvTo_Table_HumaninputImpl();

            this.out_Table_Humaninput = trans.Read(
                text_Csv,
                request,
                format,
                log_Reports_ThisMethod
                );

            goto gt_EndMethod;
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports_ThisMethod);
            return;
        }
Exemplo n.º 3
0
        //────────────────────────────────────────

        private Table_Humaninput Read_AaFilesCsv(Log_Reports log_Reports)
        {
            //「Aa_Files.csv」を読み取る要求を作成します。
            Request_ReadsTable      forAafilescsv_Request = this.CreateReadRequest_AaFilesCsv(log_Reports);
            Format_Table_Humaninput forAafilescsv_Format  = this.ReadIndexFormat();

            //
            // 「Aa_Files.csv」読取り
            CsvTo_Table_HumaninputImpl reader = new CsvTo_Table_HumaninputImpl();
            Table_Humaninput           xenonTable_Aafilescsv;

            if (log_Reports.Successful)
            {
                // 正常時

                xenonTable_Aafilescsv = reader.Read(
                    forAafilescsv_Request,
                    forAafilescsv_Format,
                    true,
                    log_Reports
                    );
                if (!log_Reports.Successful)
                {
                    // 既エラー。
                    goto gt_EndMethod;
                }
            }
            else
            {
                xenonTable_Aafilescsv = null;
            }

            //
            //
            //
            //
gt_EndMethod:
            return(xenonTable_Aafilescsv);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 大雑把にfunctionを一覧。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            Log_ReportsImpl.BDebugmode_Static = true;
            Log_Reports log_Reports;
            //(2)メソッド開始
            Log_Method log_Method = new Log_MethodImpl();

            // デバッグモード静的設定の後で。
            log_Method.BeginMethod(Info_Actorslist.Name_Library, this, "button2_Click", out log_Reports);


            Exception error_Exception;


            //コンフィグファイル
            ConfigxmlImpl configxml = new ConfigxmlImpl();

            configxml.Read(log_Reports);



            //CSV→テーブル
            Table_Humaninput tableH;

            if (log_Reports.Successful)
            {
                if (!File.Exists(configxml.FilepathExportLualist))
                {
                    goto gt_Error_File1;
                }

                string csvtext = File.ReadAllText(configxml.FilepathExportLualist);
                CsvTo_Table_HumaninputImpl trans = new CsvTo_Table_HumaninputImpl();
                tableH = trans.Read(
                    csvtext,
                    new Request_ReadsTableImpl(),
                    new Format_Table_HumaninputImpl(),
                    //true,
                    log_Reports
                    );
            }
            else
            {
                tableH = null;
            }



            //各.luaファイル
            List <string> listFile     = new List <string>();
            List <string> listRow      = new List <string>();
            List <string> listFunction = new List <string>();

            if (log_Reports.Successful)
            {
                Regex regex2 = new Regex(@"^\s*function\s+(.*)$", RegexOptions.Compiled);
                tableH.ForEach_Datapart(
                    (Record_Humaninput recordH, ref bool isBreak2, Log_Reports log_Reports2) =>
                {
                    string filepathRelational = recordH.TextAt("FILE");
                    string filepath           = Path.Combine(configxml.FolderpathProject, filepathRelational);
                    //ystem.Console.WriteLine("filepath=[" + filepath + "]");

                    string luatext = File.ReadAllText(filepath, Encoding.GetEncoding("Shift-JIS"));
                    string[] lines = luatext.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                    int row = 1;    //行番号
                    foreach (string line in lines)
                    {
                        Match m2 = regex2.Match(line);
                        if (m2.Success)
                        {
                            listFile.Add(filepathRelational);
                            listRow.Add(row.ToString());
                            listFunction.Add(line);
                            //System.Console.WriteLine("ファイル=[" + filepathRelational + "] [" + row + "]行 関数line=[" + line + "]");
                        }
                        else
                        {
                        }

                        row++;
                    }
                }, log_Reports);
            }



            //配列(空回し);buffer
            Dictionary <string, string> dictionary1 = new Dictionary <string, string>();// 関数名の問題文字列:["シーン","クラスネーム"]

            if (log_Reports.Successful)
            {
                Regex regex4 = new Regex(@"^\s*function\s+(.*?)(_OnClose|_OnVanish)\s*\(.*$", RegexOptions.Compiled);


                //「_OnClose」ならシーン、
                //「_OnVanish」ならクラスネームに確定します。

                for (int i = 0; i < listFunction.Count; i++)
                {
                    string function = listFunction[i];

                    Match m4 = regex4.Match(function);
                    if (m4.Success)
                    {
                        if ("_OnClose" == m4.Groups[2].Value)
                        {
                            //シーン
                            dictionary1.Add(m4.Groups[1].Value, "シーン");
                        }
                        else if ("_OnVanish" == m4.Groups[2].Value)
                        {
                            //クラスネーム
                            dictionary1.Add(m4.Groups[1].Value, "クラスネーム");
                        }
                        else
                        {
                        }
                    }
                }
            }



            //配列→CSV
            if (log_Reports.Successful)
            {
                Regex regex3 = new Regex(@"^\s*function\s+(.*?)(?:_OnStart|_OnStep|_OnClose|_OnVanish|_OnDraw)\s*\(.*$", RegexOptions.Compiled);
                Regex regex4 = new Regex(@"^\s*function\s+(?:OnLoad|OnVanish)\s*\(.*$", RegexOptions.Compiled);
                Regex regex5 = new Regex(@"^\s*function\s+(.*?)_init\s*\(.*$", RegexOptions.Compiled);
                Regex regex6 = new Regex(@"^\s*function\s+(.*?)Thread\s*\(.*$", RegexOptions.Compiled);
                Regex regex7 = new Regex(@"^\s*function\s+thread_(.*?)\s*\(.*$", RegexOptions.Compiled);

                CsvLineParserImpl parser = new CsvLineParserImpl();

                StringBuilder sb = new StringBuilder();
                sb.Append("NO,FILE,ROW,INITIALIZER,SCENE,THREAD,CLASS_NAME,FUNCTION,END");//,EOL
                sb.Append(Environment.NewLine);
                sb.Append("int,string,int,string,string,string,string,string,");
                sb.Append(Environment.NewLine);
                sb.Append("-1,ファイルパス,行番号,suica32用ローダースレッド・ハンドラ?,シーン,スレッド?,クラス名,関数シグネチャー,");
                sb.Append(Environment.NewLine);
                int row = 0;
                for (int i = 0; i < listFunction.Count; i++)
                {
                    string file      = listFile[i];
                    string numberRow = listRow[i];
                    string function  = listFunction[i];

                    string initializer = "";
                    string scene       = "";
                    string thread      = "";
                    string classname   = "";

                    Match m3 = regex3.Match(function);
                    if (m3.Success)
                    {
                        string functionname2 = m3.Groups[1].Value;

                        if (dictionary1.ContainsKey(functionname2))
                        {
                            switch (dictionary1[functionname2])
                            {
                            case "シーン":
                                scene = functionname2;
                                break;

                            case "クラスネーム":
                                classname = functionname2;
                                break;

                            default:
                                break;
                            }
                        }

                        goto gt_Csv;
                    }

                    Match m4 = regex4.Match(function);
                    if (m4.Success)
                    {
                        scene = Path.GetFileNameWithoutExtension(file);
                        goto gt_Csv;
                    }

                    Match m5 = regex5.Match(function);
                    if (m5.Success)
                    {
                        initializer = m5.Groups[1].Value;
                        goto gt_Csv;
                    }

                    Match m6 = regex6.Match(function);
                    if (m6.Success)
                    {
                        thread = m6.Groups[1].Value;
                        goto gt_Csv;
                    }

                    Match m7 = regex7.Match(function);
                    if (m7.Success)
                    {
                        thread = m7.Groups[1].Value;
                        goto gt_Csv;
                    }

gt_Csv:
                    sb.Append(row);
                    sb.Append(",");
                    sb.Append(file);
                    sb.Append(",");
                    sb.Append(numberRow);
                    sb.Append(",");
                    sb.Append(initializer);
                    sb.Append(",");
                    sb.Append(scene);
                    sb.Append(",");
                    sb.Append(thread);
                    sb.Append(",");
                    sb.Append(classname);
                    sb.Append(",");
                    sb.Append(parser.EscapeCell(function));
                    sb.Append(",");
                    sb.Append(Environment.NewLine);
                    //ystem.Console.WriteLine("row=[" + row + "] file=[" + file + "] numberRow=[" + numberRow + "] initializer=[" + initializer + "] scene=[" + scene + "] thread=[" + thread + "] classname=[" + classname + "] classname=[" + classname + "] function=[" + parser.EscapeCell(function) + "]");
                    row++;
                }

                sb.Append("EOF,,,,,,,,");
                sb.Append(Environment.NewLine);

                string csvfile = Path.Combine(Application.StartupPath, configxml.FilepathExportFunctionlist);
                System.Console.WriteLine("csvfile=[" + csvfile + "]");
                File.WriteAllText(csvfile, sb.ToString(), Encoding.UTF8);
            }



            goto gt_EndMethod;
            #region 異常系
            //────────────────────────────────────────
gt_Error_File1:
            if (log_Reports.CanCreateReport)
            {
                Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error);
                r.SetTitle("▲エラー13007!", log_Method);

                Log_TextIndented s = new Log_TextIndentedImpl();
                s.Append("ファイルが足りません。");
                s.Append(Environment.NewLine);
                s.Append("readme.txtを読んで、手順を踏んでください。");
                s.Append(Environment.NewLine);
                s.Append("  .lua一覧CSVファイル=[");
                s.Append(configxml.FilepathExportLualist);
                s.Append("]");

                r.Message = s.ToString();
                log_Reports.EndCreateReport();
            }
            goto gt_EndMethod;
            //────────────────────────────────────────
            #endregion

gt_EndMethod:
            log_Method.EndMethod(log_Reports);
            log_Reports.EndLogging(log_Method);
        }
Exemplo n.º 5
0
        //────────────────────────────────────────

        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;
        }
Exemplo n.º 6
0
        //────────────────────────────────────────
        #endregion



        #region アクション
        //────────────────────────────────────────

        public void TryGetTable_Variables(
            out Table_Humaninput out_xenonTable_Variables,
            String filepath_Startup,
            Log_Reports log_Reports
            )
        {
            Log_Method log_Method = new Log_MethodImpl(0, Log_ReportsImpl.BDebugmode_Static);

            log_Method.BeginMethod(Info_MiddleImpl.Name_Library, this, "TryGetTable_Variables", log_Reports);

            out_xenonTable_Variables = null;

            //『Sp:Variables;』で指定されているテーブル
            XenonName xenonName_Variable = new XenonNameImpl(NamesVar.S_SP_VARIABLES, new Configurationtree_NodeImpl("!ハードコーディング_MoNorenImpl#LoadVariables", null));

            //
            // 「変数設定ファイル」のファイルパス。
            //
            log_Reports.Log_Callstack.Push(log_Method, "①");
            Expression_Node_Filepath ec_Fpath_Variables = this.Owner_MemoryApplication.MemoryVariables.GetExpressionfilepathByVariablename(
                new Expression_Leaf_StringImpl(xenonName_Variable.SValue, null, xenonName_Variable.Cur_Configuration),
                false,//必須ではありません。未該当であればヌルを返します。
                log_Reports
                );

            log_Reports.Log_Callstack.Pop(log_Method, "①");

            if (log_Reports.Successful)
            {
                if (null == ec_Fpath_Variables)
                {
                    //
                    // "Sp:Variables;" が未指定の場合、何もしません。
                    //
                    goto gt_EndMethod;
                }
            }

            //指定されていた場合。
            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     = NamesVar.S_ST_VARIABLES2;
                request_tblReads.Expression_Filepath = ec_Fpath_Variables;

                out_xenonTable_Variables = reader.Read(
                    request_tblReads,
                    tblFormat_puts,
                    true,
                    log_Reports
                    );
            }

            goto gt_EndMethod;
            //
gt_EndMethod:
            log_Method.EndMethod(log_Reports);
        }
Exemplo n.º 7
0
        //────────────────────────────────────────

        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);
        }
Exemplo n.º 8
0
        //────────────────────────────────────────

        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);
        }