Exemple #1
0
        /// <summary>業務処理を実装</summary>
        /// <param name="muParameter">汎用引数クラス</param>
        private void UOC_Select(MuParameterValue muParameter)
        {
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            this.ReturnValue = muReturn;

            // ↓業務処理-----------------------------------------------------
            DataTable dt      = null;
            Shipper   shipper = null;

            switch ((muParameter.ActionType.Split('%'))[1])
            {
            case "common":     // 共通Daoを使用する。

                // 共通Daoを生成
                CmnDao cmnDao = new CmnDao(this.GetDam());

                switch ((muParameter.ActionType.Split('%'))[2])
                {
                case "static":
                    // 静的SQLを指定
                    cmnDao.SQLFileName = "ShipperSelect.sql";
                    break;

                case "dynamic":
                    // 動的SQLを指定
                    cmnDao.SQLFileName = "ShipperSelect.xml";
                    break;
                }

                // パラメタ ライズド クエリのパラメタに対して、動的に値を設定する。
                cmnDao.SetParameter("P1", muParameter.Bean.ToString());

                // 戻り値 dt
                dt = new DataTable("rtn");

                // 共通Daoを実行
                cmnDao.ExecSelectFill_DT(dt);

                // 戻り値を設定
                shipper             = new Shipper();
                shipper.ShipperID   = (int)muParameter.Bean;
                shipper.CompanyName = (string)dt.Rows[0].ItemArray.GetValue(1);
                shipper.Phone       = (string)dt.Rows[0].ItemArray.GetValue(2);
                muReturn.Bean       = shipper;

                break;

            case "generate":     // 自動生成Daoを使用する。

                // 自動生成Daoを生成
                DaoShippers genDao = new DaoShippers(this.GetDam());

                // パラメタに対して、動的に値を設定する。
                genDao.PK_ShipperID = muParameter.Bean.ToString();

                // 戻り値 dt
                dt = new DataTable("rtn");

                // 自動生成Daoを実行
                genDao.S2_Select(dt);

                // 戻り値を設定
                shipper             = new Shipper();
                shipper.ShipperID   = (int)muParameter.Bean;
                shipper.CompanyName = (string)dt.Rows[0].ItemArray.GetValue(1);
                shipper.Phone       = (string)dt.Rows[0].ItemArray.GetValue(2);
                muReturn.Bean       = shipper;

                break;

            default:     // 個別Daoを使用する。
                string companyName;
                string phone;

                LayerD_mu myDao = new LayerD_mu(this.GetDam());
                myDao.Select(muParameter.ActionType,
                             muParameter.Bean.ToString(),
                             out companyName, out phone);

                // 戻り値を設定
                shipper             = new Shipper();
                shipper.ShipperID   = (int)muParameter.Bean;
                shipper.CompanyName = companyName;
                shipper.Phone       = phone;
                muReturn.Bean       = shipper;

                break;
            }

            // ↑業務処理-----------------------------------------------------

            // ロールバックのテスト
            this.TestRollback(muParameter);
        }
Exemple #2
0
        /// <summary>業務処理を実装</summary>
        /// <param name="muParameter">汎用引数クラス</param>
        private void UOC_Select(MuParameterValue muParameter)
        {
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            muReturn.Bean    = new Informations("");
            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            string shipperID = ((Informations)muParameter.Bean).Str;

            // ↓業務処理-----------------------------------------------------
            DataTable dt = null;
            Dictionary <string, string> dic = null;

            switch ((muParameter.ActionType.Split('%'))[1])
            {
            case "common":     // 共通Daoを使用する。

                // 共通Daoを生成
                CmnDao cmnDao = new CmnDao(this.GetDam());

                switch ((muParameter.ActionType.Split('%'))[2])
                {
                case "static":
                    // 静的SQLを指定
                    cmnDao.SQLFileName = "ShipperSelect.sql";
                    break;

                case "dynamic":
                    // 動的SQLを指定
                    cmnDao.SQLFileName = "ShipperSelect.xml";
                    break;
                }

                // パラメタ ライズド クエリのパラメタに対して、動的に値を設定する。
                cmnDao.SetParameter("P1", shipperID);

                // 戻り値 dt
                dt = new DataTable("rtn");

                // 共通Daoを実行
                cmnDao.ExecSelectFill_DT(dt);

                // 戻り値を設定
                dic = new Dictionary <string, string>();
                dic["ShipperID"]   = dt.Rows[0].ItemArray.GetValue(0).ToString();
                dic["CompanyName"] = (string)dt.Rows[0].ItemArray.GetValue(1);
                dic["Phone"]       = (string)dt.Rows[0].ItemArray.GetValue(2);
                muReturn.Bean      = new Informations(dic);

                break;

            case "generate":     // 自動生成Daoを使用する。

                // 自動生成Daoを生成
                DaoShippers genDao = new DaoShippers(this.GetDam());

                // パラメタに対して、動的に値を設定する。
                genDao.PK_ShipperID = shipperID;

                // 戻り値 dt
                dt = new DataTable("rtn");

                // 自動生成Daoを実行
                genDao.S2_Select(dt);

                // 戻り値を設定
                dic = new Dictionary <string, string>();
                dic["ShipperID"]   = dt.Rows[0].ItemArray.GetValue(0).ToString();
                dic["CompanyName"] = (string)dt.Rows[0].ItemArray.GetValue(1);
                dic["Phone"]       = (string)dt.Rows[0].ItemArray.GetValue(2);
                muReturn.Bean      = new Informations(dic);

                break;

            default:     // 個別Daoを使用する。
                string companyName;
                string phone;

                // 個別Daoを実行
                LayerD_mu myDao = new LayerD_mu(this.GetDam());
                myDao.Select(muParameter.ActionType, shipperID,
                             out companyName, out phone);

                // 戻り値を設定
                dic = new Dictionary <string, string>();
                dic["CompanyName"] = companyName;
                dic["Phone"]       = phone;
                muReturn.Bean      = new Informations(dic);

                break;
            }

            // ↑業務処理-----------------------------------------------------

            // ロールバックのテスト
            this.TestRollback(muParameter);
        }
Exemple #3
0
        /// <summary>業務処理を実装</summary>
        /// <param name="muParameter">汎用引数クラス</param>
        private void UOC_Select(MuParameterValue muParameter)
        {
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            //DTTables dtts_in = Marshalling.StringToDTTables(muParameter.Value);
            //DTTable dtt_in = dtts_in[0];
            //DTRow dtrow_in = dtt_in.Rows[0];

            DTTables dtts_out  = null;
            DTTable  dtt_out   = null;
            DTRow    dtrow_out = null;

            // ↓業務処理-----------------------------------------------------
            DataTable dt = null;

            switch ((muParameter.ActionType.Split('%'))[1])
            {
            case "common":     // 共通Daoを使用する。

                // 共通Daoを生成
                CmnDao cmnDao = new CmnDao(this.GetDam());

                switch ((muParameter.ActionType.Split('%'))[2])
                {
                case "static":
                    // 静的SQLを指定
                    cmnDao.SQLFileName = "ShipperSelect.sql";
                    break;

                case "dynamic":
                    // 動的SQLを指定
                    cmnDao.SQLFileName = "ShipperSelect.xml";
                    break;
                }

                // パラメタ ライズド クエリのパラメタに対して、動的に値を設定する。
                cmnDao.SetParameter("P1", muParameter.Value);

                // 戻り値 dt
                dt = new DataTable("rtn");

                // 共通Daoを実行
                cmnDao.ExecSelectFill_DT(dt);

                // キャストの対策コードを挿入
                dtt_out = new DTTable("ret");
                dtt_out.Cols.Add(new DTColumn("ShipperID", DTType.Int32));
                dtt_out.Cols.Add(new DTColumn("CompanyName", DTType.String));
                dtt_out.Cols.Add(new DTColumn("Phone", DTType.String));
                dtrow_out = dtt_out.Rows.AddNew();

                // ・SQLの場合、ShipperIDのintがInt32型にマップされる。
                // ・ODPの場合、ShipperIDのNUMBERがInt64型にマップされる。
                // ・DB2の場合、ShipperIDのDECIMALがxxx型にマップされる。
                if (dt.Rows[0].ItemArray.GetValue(0).GetType().ToString() == "System.Int32")
                {
                    // Int32なのでキャスト
                    dtrow_out["ShipperID"] = (int)dt.Rows[0].ItemArray.GetValue(0);
                }
                else
                {
                    // それ以外の場合、一度、文字列に変換してInt32.Parseする。
                    dtrow_out["ShipperID"] = int.Parse(dt.Rows[0].ItemArray.GetValue(0).ToString());
                }

                dtrow_out["CompanyName"] = (string)dt.Rows[0].ItemArray.GetValue(1);
                dtrow_out["Phone"]       = (string)dt.Rows[0].ItemArray.GetValue(2);

                // 戻り値をマーシャリングして設定
                dtts_out = new DTTables();
                dtts_out.Add(dtt_out);
                muReturn.Value = DTTables.DTTablesToString(dtts_out);

                break;

            case "generate":     // 自動生成Daoを使用する。

                // 自動生成Daoを生成
                DaoShippers genDao = new DaoShippers(this.GetDam());

                // パラメタに対して、動的に値を設定する。
                genDao.PK_ShipperID = muParameter.Value;

                // 戻り値 dt
                dt = new DataTable("rtn");

                // 自動生成Daoを実行
                genDao.S2_Select(dt);

                // キャストの対策コードを挿入
                dtt_out = new DTTable("ret");
                dtt_out.Cols.Add(new DTColumn("ShipperID", DTType.Int32));
                dtt_out.Cols.Add(new DTColumn("CompanyName", DTType.String));
                dtt_out.Cols.Add(new DTColumn("Phone", DTType.String));
                dtrow_out = dtt_out.Rows.AddNew();

                // ・SQLの場合、ShipperIDのintがInt32型にマップされる。
                // ・ODPの場合、ShipperIDのNUMBERがInt64型にマップされる。
                // ・DB2の場合、ShipperIDのDECIMALがxxx型にマップされる。
                if (dt.Rows[0].ItemArray.GetValue(0).GetType().ToString() == "System.Int32")
                {
                    // Int32なのでキャスト
                    dtrow_out["ShipperID"] = (int)dt.Rows[0].ItemArray.GetValue(0);
                }
                else
                {
                    // それ以外の場合、一度、文字列に変換してInt32.Parseする。
                    dtrow_out["ShipperID"] = int.Parse(dt.Rows[0].ItemArray.GetValue(0).ToString());
                }

                dtrow_out["CompanyName"] = (string)dt.Rows[0].ItemArray.GetValue(1);
                dtrow_out["Phone"]       = (string)dt.Rows[0].ItemArray.GetValue(2);

                // 戻り値をマーシャリングして設定
                dtts_out = new DTTables();
                dtts_out.Add(dtt_out);
                muReturn.Value = DTTables.DTTablesToString(dtts_out);

                break;

            default:     // 個別Daoを使用する。

                // 個別Daoを実行
                string companyName;
                string phone;

                LayerD_mu myDao = new LayerD_mu(this.GetDam());
                myDao.Select(muParameter.ActionType, muParameter.Value,
                             out companyName, out phone);

                // 戻り値をマーシャリングして設定
                dtt_out = new DTTable("ret");
                dtt_out.Cols.Add(new DTColumn("ShipperID", DTType.Int32));
                dtt_out.Cols.Add(new DTColumn("CompanyName", DTType.String));
                dtt_out.Cols.Add(new DTColumn("Phone", DTType.String));
                dtrow_out = dtt_out.Rows.AddNew();

                dtrow_out["ShipperID"]   = int.Parse(muParameter.Value);
                dtrow_out["CompanyName"] = companyName;
                dtrow_out["Phone"]       = phone;

                dtts_out = new DTTables();
                dtts_out.Add(dtt_out);
                muReturn.Value = DTTables.DTTablesToString(dtts_out);

                break;
            }

            // ↑業務処理-----------------------------------------------------

            // ロールバックのテスト
            this.TestRollback(muParameter);
        }