//────────────────────────────────────────
        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);
        }
Пример #2
0
        //────────────────────────────────────────
        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);
        }
        //────────────────────────────────────────
        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);
        }
Пример #4
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;
        }
Пример #5
0
        //────────────────────────────────────────
        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;
        }
        //────────────────────────────────────────
        private Format_Table_Humaninput ReadIndexFormat()
        {
            //
            // テーブル読取り引数。
            Format_Table_Humaninput forIndexTable_format = new Format_Table_HumaninputImpl();

            //
            // 「int型ばかりで型が省略されているテーブル」ではない。
            forIndexTable_format.IsAllintfieldsActivated = false;

            //
            // 行の末尾をカンマで終わらない。
            forIndexTable_format.IsCommaending = false;

            return forIndexTable_format;
        }
        //────────────────────────────────────────
        /// <summary>
        /// 
        /// </summary>
        /// <param name="datarow"></param>
        /// <param name="forIndexTable_csvAbsFilePath"></param>
        /// <param name="log_Reports"></param>
        /// <returns></returns>
        private Format_Table_Humaninput Read_RequestPart_Table(
            DataRow datarow,
            string filepath_ForAafilescsv,
            Log_Reports log_Reports
            )
        {
            //
            // 「各テーブル」の引数
            Format_Table_Humaninput forTable_format = new Format_Table_HumaninputImpl();

            //
            // 縦、横がひっくり返っているかどうか。
            //
            {
                bool isRowColRev;

                bool isSuccessful_Parsed = Bool_HumaninputImpl.TryParse(
                    datarow[NamesFld.S_ROW_COL_REV],
                    out isRowColRev,
                    EnumOperationIfErrorvalue.Spaces_To_Alt_Value,
                    false,
                    log_Reports
                    );
                if (!log_Reports.Successful)
                {
                    // エラー
                    goto gt_EndMethod;
                }

                if (isSuccessful_Parsed)
                {

                }
                forTable_format.IsRowcolumnreverse = isRowColRev;
            }

            //
            // 型定義のレコード(intやboolやstringが書いてあるところ)がなく、
            // 全フィールドがint型のテーブルかどうか。
            //
            {
                bool isAllIntFields;

                bool isSuccessful_Parsed = Bool_HumaninputImpl.TryParse(
                    datarow[NamesFld.S_ALL_INT_FIELDS],
                    out isAllIntFields,
                    EnumOperationIfErrorvalue.Spaces_To_Alt_Value,
                    false,
                    log_Reports
                    );
                if (!log_Reports.Successful)
                {
                    // エラー
                    goto gt_EndMethod;
                }

                if (isSuccessful_Parsed)
                {

                }
                forTable_format.IsAllintfieldsActivated = isAllIntFields;
            }

            //
            // 行の末尾を「,」で終える場合、真。
            //
            {
                string name_Field = NamesFld.S_COMMA_ENDING;
                bool isCommaEnding;
                if (datarow.Table.Columns.Contains(name_Field))
                {
                    bool isSuccessful_Parsed = Bool_HumaninputImpl.TryParse(
                        datarow[name_Field],
                        out isCommaEnding,
                        EnumOperationIfErrorvalue.Spaces_To_Alt_Value,
                        false,
                        log_Reports
                        );
                    if (!log_Reports.Successful)
                    {
                        // エラー
                        goto gt_EndMethod;
                    }

                    if (isSuccessful_Parsed)
                    {

                    }
                }
                else
                {
                    isCommaEnding = false;
                }

                forTable_format.IsCommaending = isCommaEnding;
            }

            //
            //
            //
            //
            gt_EndMethod:
            return forTable_format;
        }