コード例 #1
0
ファイル: DTOPage.xaml.cs プロジェクト: ukayare/OpenTouryo
        /// <summary>ListViewの初期化</summary>
        async private void InitListView()
        {
            // テーブル@汎用DTOにデータを詰めてバインディングさせる。

            // 引数1:コンテキスト
            string Context = "User1";

            // 引数2:共通部
            MuServiceReference.ArrayOfString param
                = new MuServiceReference.ArrayOfString();

            // 共通部を生成
            param.Add(this.Name);               // 画面名
            param.Add("Page_Loaded");           // ボタン名
            param.Add("InitDataGrid");          // メソッド名
            param.Add("ActionType");            // アクションタイプ

            // 引数3:汎用DTOデータ部

            // 空のDTTables
            DTTables dtts = new DTTables();

            dtts.Add(this.Dtt);

            // 汎用サービスI/FのWebサービスは通常のWeb参照を用いる。
            MuServiceReference.ServiceForMuSoapClient client = new MuServiceReference.ServiceForMuSoapClient();

            // 非同期呼出しを行う
            MuServiceReference.CallResponse response = await client.CallAsync(Context, "muWebService", param, DTTables.DTTablesToString(dtts));

            // データバインド(ToDataSourceでは、削除行を除いたリストを返す)
            this.Dtt = DTTables.StringToDTTables(response.Body.returnValue)[0];
            this.ListView1.ItemsSource = this.Dtt.Rows.ToDataSource();
        }
コード例 #2
0
        /// <summary>
        /// GetProductData method for fetching product table data.
        /// </summary>
        /// <returns>Message</returns>
        public Message GetProductData()
        {
            HttpContext.Current.Session["DAP"]  = "SQL";
            HttpContext.Current.Session["DBMS"] = DbEnum.DBMSType.SQLServer;

            NameValueCollection queryStrings = HttpContext.Current.Request.QueryString;

            HttpContext.Current.Session["SortExpression"] = queryStrings["sidx"];
            HttpContext.Current.Session["SortDirection"]  = queryStrings["sord"];
            string currentPage = queryStrings["page"];
            string rows        = queryStrings["rows"];
            int    startIndex  = (int.Parse(currentPage) - 1) * int.Parse(rows);
            int    maximumRows = int.Parse(rows);

            ProductsTableAdapter productTableAdapter = new ProductsTableAdapter();
            DataTable            productTableData    = productTableAdapter.SelectMethod(startIndex, maximumRows);
            int totalCount = productTableAdapter.SelectCountMethod();

            // Calling SavejqGridJson
            DTTable dtTable      = new DTTable("Product");
            object  jqGridObject = dtTable.SavejqGridJson(productTableData, totalCount, currentPage, rows);

            // Converts Product table into JSon strig
            string jsonData = JsonConvert.SerializeObject(jqGridObject);

            // Converts JSON data to Message format.
            WebOperationContext.Current.OutgoingResponse.Headers.Add("X-Content-Type-Options", "nosniff");

            // returns JSON string in Message format
            return(WebOperationContext.Current.CreateTextResponse(jsonData, "application/json; charset=utf-8", Encoding.UTF8));
        }
コード例 #3
0
ファイル: DTOPage.xaml.cs プロジェクト: ukayare/OpenTouryo
        /// <summary>
        /// Webサービスに汎用DTOデータを渡し
        /// Webサービス内で1行、行を追加する。
        /// </summary>
        async private void btnAddRow_CallWebService_Click(object sender, RoutedEventArgs e)
        {
            // 引数1:コンテキスト
            string Context = "User1";

            // 引数2:共通部
            MuServiceReference.ArrayOfString param
                = new MuServiceReference.ArrayOfString();

            // 共通部を生成
            param.Add(this.Name);               // 画面名
            param.Add(((Button)sender).Name);   // ボタン名
            param.Add("AddRow");                // メソッド名
            param.Add("ActionType");            // アクションタイプ

            // 引数3:汎用DTOデータ部

            // 空のDTTables
            DTTables dtts = new DTTables();

            dtts.Add(this.Dtt);

            // 汎用サービスI/FのWebサービスは通常のWeb参照を用いる。
            MuServiceReference.ServiceForMuSoapClient client
                = new MuServiceReference.ServiceForMuSoapClient();

            // 非同期呼出しを行う
            MuServiceReference.CallResponse response = await client.CallAsync(Context, "muWebService", param, DTTables.DTTablesToString(dtts));

            // データバインド(ToDataSourceでは、削除行を除いたリストを返す)
            this.Dtt = DTTables.StringToDTTables(response.Body.returnValue)[0];
            this.ListView1.ItemsSource = this.Dtt.Rows.ToDataSource();
        }
コード例 #4
0
        /// <summary>Silverlight&汎用DTOのテスト(行追加)</summary>
        /// <param name="muParameter">引数クラス</param>
        protected void UOC_AddRow(MuParameterValue muParameter)
        {
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            this.ReturnValue = muReturn;

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

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

            // 1行追加
            dtrow_in               = dtt_in.Rows.AddNew();
            dtrow_in["boolVal"]    = true;
            dtrow_in["charVal"]    = 'z';
            dtrow_in["dateVal"]    = new DateTime(1946, 12, 11, 10, 20, 30, 444);
            dtrow_in["decimalVal"] = 99999;
            dtrow_in["doubleVal"]  = 9.99D;
            dtrow_in["shortVal"]   = 900;
            dtrow_in["intVal"]     = 9000000;
            dtrow_in["longVal"]    = 9000000000000;
            dtrow_in["singleVal"]  = 9.9f;
            dtrow_in["stringVal"]  = "test" + dtt_in.Rows.Count.ToString();

            // 戻り値をマーシャリングして設定
            ((MuReturnValue)this.ReturnValue).Value = DTTables.DTTablesToString(dtts_in);
        }
コード例 #5
0
        /// <summary>更新処理</summary>
        async private void button8_Click(object sender, RoutedEventArgs e)
        {
            // 引数1:コンテキスト
            string context = "User1";

            // 引数2:共通部
            MuServiceReference.ArrayOfString param
                = new MuServiceReference.ArrayOfString();

            // 共通部を生成
            string actionType =
                ((ComboBoxItem)this.ddlDap.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode1.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode2.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlExRollback.SelectedItem).Value;

            param.Add(this.Name);               // 画面名
            param.Add(((Button)sender).Name);   // ボタン名
            param.Add("Update");                // メソッド名
            param.Add(actionType);              // アクションタイプ

            // 引数3:汎用DTOデータ部

            // 引数のDTTables
            DTTables dtts  = new DTTables();
            DTTable  dtt   = new DTTable("param");
            DTRow    dtrow = null;

            dtt.Cols.Add(new DTColumn("ShipperID", DTType.String));
            dtt.Cols.Add(new DTColumn("CompanyName", DTType.String));
            dtt.Cols.Add(new DTColumn("Phone", DTType.String));
            dtrow = dtt.Rows.AddNew();
            dtrow["ShipperID"]   = this.textBox1.Text;
            dtrow["CompanyName"] = this.textBox2.Text;
            dtrow["Phone"]       = this.textBox3.Text;
            dtts.Add(dtt);

            // SOAP汎用Webメソッドは通常のWeb参照を用いる。
            MuServiceReference.ServiceForMuSoapClient client = new MuServiceReference.ServiceForMuSoapClient();

            // 非同期呼出しを行う
            MuServiceReference.CallResponse response = await client.CallAsync(context, "muWebService", param, DTTables.DTTablesToString(dtts));

            if (response.Body.CallResult != "")
            {
                // 例外発生時
                WSErrorInfo   wse    = new WSErrorInfo(response.Body.CallResult);
                MessageDialog dialog = new MessageDialog("以下のエラーが発生しました\r\nメッセージ : " + response.Body.CallResult + " , " + response.Body.returnValue + " , " + wse.MessageID + " , " + wse.Message + " , " + wse.Information);
                await dialog.ShowAsync();
            }
            else
            {
                // 結果(正常系)
                this.labelMessage.Text = response.Body.returnValue + "件更新";
            }
        }
コード例 #6
0
        /// <summary>一覧取得(動的sql)</summary>
        async private void button5_Click(object sender, RoutedEventArgs e)
        {
            // 引数1:コンテキスト
            string context = "User1";

            // 引数2:共通部
            MuServiceReference.ArrayOfString param
                = new MuServiceReference.ArrayOfString();

            // 共通部を生成
            string actionType =
                ((ComboBoxItem)this.ddlDap.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode1.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode2.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlExRollback.SelectedItem).Value;

            param.Add(this.Name);               // 画面名
            param.Add(((Button)sender).Name);   // ボタン名
            param.Add("SelectAll_DSQL");        // メソッド名
            param.Add(actionType);              // アクションタイプ

            // 引数3:汎用DTOデータ部

            // 引数のDTTables
            DTTables dtts  = new DTTables();
            DTTable  dtt   = new DTTable("param");
            DTRow    dtrow = null;

            dtt.Cols.Add(new DTColumn("OrderColumn", DTType.String));
            dtt.Cols.Add(new DTColumn("OrderSequence", DTType.String));
            dtrow = dtt.Rows.AddNew();
            dtrow["OrderColumn"]   = ((ComboBoxItem)this.ddlOrderColumn.SelectedItem).Value;
            dtrow["OrderSequence"] = ((ComboBoxItem)this.ddlOrderSequence.SelectedItem).Value;
            dtts.Add(dtt);

            // SOAP汎用Webメソッドは通常のWeb参照を用いる。
            MuServiceReference.ServiceForMuSoapClient client = new MuServiceReference.ServiceForMuSoapClient();

            // 非同期呼出しを行う
            MuServiceReference.CallResponse response = await client.CallAsync(context, "muWebService", param, DTTables.DTTablesToString(dtts));

            if (response.Body.CallResult != "")
            {
                // 例外発生時
                WSErrorInfo   wse    = new WSErrorInfo(response.Body.CallResult);
                MessageDialog dialog = new MessageDialog("以下のエラーが発生しました\r\nメッセージ : " + response.Body.CallResult + " , " + response.Body.returnValue + " , " + wse.MessageID + " , " + wse.Message + " , " + wse.Information);
                await dialog.ShowAsync();
            }
            else
            {
                // 結果(正常系)
                // データバインド(ToDataSourceでは、削除行を除いたリストを返す)
                this.ListView1.ItemsSource = DTTables.StringToDTTables(response.Body.returnValue)[0].Rows.ToDataSource();
            }
        }
コード例 #7
0
        /// <summary>更新処理</summary>
        private void button8_Click(object sender, RoutedEventArgs e)
        {
            // 引数1:コンテキスト
            string context = "User1";

            // 引数2:共通部
            MuServiceReference.ArrayOfString param
                = new MuServiceReference.ArrayOfString();

            // 共通部を生成
            string actionType =
                ((ComboBoxItem)this.ddlDap.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode1.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlMode2.SelectedItem).Value + "%"
                + ((ComboBoxItem)this.ddlExRollback.SelectedItem).Value;

            param.Add(this.Name);               // 画面名
            param.Add(((Button)sender).Name);   // ボタン名
            param.Add("Update");                // メソッド名
            param.Add(actionType);              // アクションタイプ

            // 引数3:汎用DTOデータ部

            // 引数のDTTables
            DTTables dtts  = new DTTables();
            DTTable  dtt   = new DTTable("param");
            DTRow    dtrow = null;

            dtt.Cols.Add(new DTColumn("ShipperID", DTType.String));
            dtt.Cols.Add(new DTColumn("CompanyName", DTType.String));
            dtt.Cols.Add(new DTColumn("Phone", DTType.String));
            dtrow = dtt.Rows.AddNew();
            dtrow["ShipperID"]   = this.textBox1.Text;
            dtrow["CompanyName"] = this.textBox2.Text;
            dtrow["Phone"]       = this.textBox3.Text;
            dtts.Add(dtt);

            // SOAP汎用Webメソッドは通常のWeb参照を用いる。
            MuServiceReference.ServiceForMuSoapClient client
                = new MuServiceReference.ServiceForMuSoapClient();

            // 呼び出しが完了した場合のイベントハンドラを設定する。
            client.CallCompleted += new EventHandler <MuServiceReference.CallCompletedEventArgs>(client_Update_CallCompleted);
            // 非同期呼出しを行う(Silverlightは非同期呼び出しのみサポートする)。
            client.CallAsync(context, "muWebService", param, DTTables.DTTablesToString(dtts));
        }
コード例 #8
0
        /// <summary>業務処理を実装</summary>
        /// <param name="muParameter">汎用引数クラス</param>
        private void UOC_メソッド名(MuParameterValue muParameter)
        { //メソッド引数にBaseParameterValueの派生の型を定義可能。
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            DTTables dtts_in  = DTTables.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;

            // ↓業務処理-----------------------------------------------------

            // 個別Dao
            LayerD myDao = new LayerD(this.GetDam());
            //myDao.xxxx(muParameter.ActionType, dtts, muReturn);

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

            cmnDao.ExecSelectScalar();

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

            muReturn.Value = DTTables.DTTablesToString(dtts_out);

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

            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            DTTables dtts_in  = DTTables.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;

            // ↓業務処理-----------------------------------------------------

            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 = "ShipperUpdate.sql";
                    break;

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

                // パラメタ ライズド クエリのパラメタに対して、動的に値を設定する。
                cmnDao.SetParameter("P1", dtrow_in["ShipperID"]);
                cmnDao.SetParameter("P2", dtrow_in["CompanyName"]);
                cmnDao.SetParameter("P3", dtrow_in["Phone"]);

                // 共通Daoを実行
                // 戻り値を設定
                muReturn.Value = cmnDao.ExecInsUpDel_NonQuery().ToString();

                break;

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

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

                // パラメタに対して、動的に値を設定する。
                genDao.PK_ShipperID           = dtrow_in["ShipperID"];
                genDao.Set_CompanyName_forUPD = dtrow_in["CompanyName"];
                genDao.Set_Phone_forUPD       = dtrow_in["Phone"];

                // 自動生成Daoを実行
                // 戻り値を設定
                muReturn.Value = genDao.S3_Update().ToString();

                break;

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

                // 個別Daoを実行
                // 戻り値を設定
                LayerD myDao = new LayerD(this.GetDam());
                myDao.Update(muParameter.ActionType,
                             (string)dtrow_in["ShipperID"],
                             (string)dtrow_in["CompanyName"],
                             (string)dtrow_in["Phone"],
                             out muReturn.Value);

                break;
            }

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

            // ロールバックのテスト
            this.TestRollback(muParameter);
        }
コード例 #10
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 myDao = new LayerD(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);
        }
コード例 #11
0
        /// <summary>業務処理を実装</summary>
        /// <param name="muParameter">汎用引数クラス</param>
        private void UOC_SelectAll_DSQL(MuParameterValue muParameter)
        {
            // 戻り値クラスを生成して、事前に戻り地に設定しておく。
            MuReturnValue muReturn = new MuReturnValue();

            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            DTTables dtts_in  = DTTables.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 = "ShipperSelectOrder.sql";
                    break;

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

                // ユーザ定義パラメタに対して、動的に値を設定する。
                string orderColumn   = "";
                string orderSequence = "";

                if (dtrow_in["OrderColumn"].ToString() == "c1")
                {
                    orderColumn = "ShipperID";
                }
                else if (dtrow_in["OrderColumn"].ToString() == "c2")
                {
                    orderColumn = "CompanyName";
                }
                else if (dtrow_in["OrderColumn"].ToString() == "c3")
                {
                    orderColumn = "Phone";
                }
                else
                {
                }

                if (dtrow_in["OrderSequence"].ToString() == "A")
                {
                    orderSequence = "ASC";
                }
                else if (dtrow_in["OrderSequence"].ToString() == "D")
                {
                    orderSequence = "DESC";
                }
                else
                {
                }

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

                // ユーザ入力は指定しない。
                // ※ 動的SQLのVALタグは、前後の空白をつめることが有るので、
                //    必要であれば、前後の空白を明示的に指定する必要がある。
                cmnDao.SetUserParameter("COLUMN", " " + orderColumn + " ");
                cmnDao.SetUserParameter("SEQUENCE", " " + orderSequence + " ");

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

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

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

                break;

            //case "generate": // 自動生成Daoを使用する。
            //    // 当該SQLなし
            //    break;

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

                // 個別Daoを実行
                LayerD myDao = new LayerD(this.GetDam());
                myDao.SelectAll_DSQL(
                    muParameter.ActionType,
                    dtrow_in["OrderColumn"].ToString(),
                    dtrow_in["OrderSequence"].ToString(), out dt);

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

                break;
            }

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

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

            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            DTTables dtts_in = DTTables.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.SQLText = "SELECT * FROM Shippers";
                    break;

                case "dynamic":
                    // 動的SQLを指定
                    cmnDao.SQLText = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><ROOT>SELECT * FROM Shippers</ROOT>";
                    break;
                }

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

                // 3列生成
                dt.Columns.Add("ShipperID", System.Type.GetType("System.String"));
                dt.Columns.Add("CompanyName", System.Type.GetType("System.String"));
                dt.Columns.Add("Phone", System.Type.GetType("System.String"));

                // 共通Daoを実行
                IDataReader idr = cmnDao.ExecSelect_DR();

                while (idr.Read())
                {
                    // DRから読む
                    object[] objArray = new object[3];
                    idr.GetValues(objArray);

                    // DTに設定する。
                    DataRow dr = dt.NewRow();
                    dr.ItemArray = objArray;
                    dt.Rows.Add(dr);
                }

                // 終了したらクローズ
                idr.Close();

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

                break;

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

                // DRのI/Fなし

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

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

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

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

                break;

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

                // 個別Daoを実行
                LayerD myDao = new LayerD(this.GetDam());
                myDao.SelectAll_DR(muParameter.ActionType, out dt);

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

                break;
            }

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

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

            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            DTTables dtts_in = DTTables.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;

            // ↓業務処理-----------------------------------------------------
            DataSet ds = 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.SQLText = "SELECT * FROM Shippers";
                    break;

                case "dynamic":
                    // 動的SQLを指定
                    cmnDao.SQLText = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><ROOT>SELECT * FROM Shippers</ROOT>";
                    break;
                }

                // 戻り値 ds
                ds = new DataSet();

                // 共通Daoを実行
                cmnDao.ExecSelectFill_DS(ds);

                // 戻り値をマーシャリングして設定
                dtts_out = new DTTables();
                dtts_out.Add(DTTable.FromDataTable(ds.Tables[0]));
                muReturn.Value = DTTables.DTTablesToString(dtts_out);

                break;

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

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

                // 戻り値 ds
                ds = new DataSet();
                ds.Tables.Add(new DataTable("rtn"));

                // 自動生成Daoを実行
                genDao.D2_Select(ds.Tables[0]);

                // 戻り値をマーシャリングして設定
                dtts_out = new DTTables();
                dtts_out.Add(DTTable.FromDataTable(ds.Tables[0]));
                muReturn.Value = DTTables.DTTablesToString(dtts_out);

                break;

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

                // 個別Daoを実行
                LayerD myDao = new LayerD(this.GetDam());
                myDao.SelectAll_DS(muParameter.ActionType, out ds);

                // 戻り値をマーシャリングして設定
                dtts_out = new DTTables();
                dtts_out.Add(DTTable.FromDataTable(ds.Tables[0]));
                muReturn.Value = DTTables.DTTablesToString(dtts_out);

                break;
            }

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

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

            this.ReturnValue = muReturn;

            // 引数をアンマーシャル
            DTTables dtts_in = DTTables.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;

            // ↓業務処理-----------------------------------------------------

            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 = "ShipperCount.sql";
                    break;

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

                // 共通Daoを実行
                // 戻り値を設定
                muReturn.Value = cmnDao.ExecSelectScalar().ToString();

                break;

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

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

                // 共通Daoを実行
                // 戻り値を設定
                muReturn.Value = genDao.D5_SelCnt().ToString();

                break;

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

                // 個別Daoを実行
                string ret   = "";
                LayerD myDao = new LayerD(this.GetDam());
                myDao.SelectCount(muParameter.ActionType, out ret);

                // 戻り値を設定
                muReturn.Value = ret;

                break;
            }

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

            // ロールバックのテスト
            this.TestRollback(muParameter);
        }
コード例 #15
0
        /// <summary>Silverlight&汎用DTOのテスト(DataGrid初期化処理)</summary>
        /// <param name="muParameter">引数クラス</param>
        protected void UOC_InitDataGrid(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;

            // テーブル生成@汎用DTO
            dtt_out = new DTTable("test");

            // カラム定義@汎用DTOテーブル
            dtt_out.Cols.Add(new DTColumn("boolVal", DTType.Boolean));
            dtt_out.Cols.Add(new DTColumn("charVal", DTType.Char));
            dtt_out.Cols.Add(new DTColumn("dateVal", DTType.DateTime));
            dtt_out.Cols.Add(new DTColumn("decimalVal", DTType.Decimal));
            dtt_out.Cols.Add(new DTColumn("doubleVal", DTType.Double));
            dtt_out.Cols.Add(new DTColumn("shortVal", DTType.Int16));
            dtt_out.Cols.Add(new DTColumn("intVal", DTType.Int32));
            dtt_out.Cols.Add(new DTColumn("longVal", DTType.Int64));
            dtt_out.Cols.Add(new DTColumn("singleVal", DTType.Single));
            dtt_out.Cols.Add(new DTColumn("stringVal", DTType.String));

            // 行追加@汎用DTOテーブル

            // 1行目
            dtrow_out               = dtt_out.Rows.AddNew();
            dtrow_out["boolVal"]    = true;
            dtrow_out["charVal"]    = 'a';
            dtrow_out["dateVal"]    = new DateTime(1977, 7, 22, 10, 20, 30, 444);
            dtrow_out["decimalVal"] = 10000;
            dtrow_out["doubleVal"]  = 3.55D;
            dtrow_out["shortVal"]   = 100;
            dtrow_out["intVal"]     = 1000000;
            dtrow_out["longVal"]    = 1000000000000;
            dtrow_out["singleVal"]  = 3.5f;
            dtrow_out["stringVal"]  = "test";

            // 2行目
            dtrow_out               = dtt_out.Rows.AddNew();
            dtrow_out["boolVal"]    = false;
            dtrow_out["charVal"]    = 'b';
            dtrow_out["dateVal"]    = new DateTime(1976, 4, 23, 10, 20, 30, 444);
            dtrow_out["decimalVal"] = 20000;
            dtrow_out["doubleVal"]  = 6.11D;
            dtrow_out["shortVal"]   = 200;
            dtrow_out["intVal"]     = 2000000;
            dtrow_out["longVal"]    = 2000000000000;
            dtrow_out["singleVal"]  = 6.5f;
            dtrow_out["stringVal"]  = "test2";

            // 3行目
            dtrow_out               = dtt_out.Rows.AddNew();
            dtrow_out["boolVal"]    = true;
            dtrow_out["charVal"]    = 'c';
            dtrow_out["dateVal"]    = new DateTime(1975, 1, 1, 10, 20, 30, 444);
            dtrow_out["decimalVal"] = 30000;
            dtrow_out["doubleVal"]  = 8.25D;
            dtrow_out["shortVal"]   = 300;
            dtrow_out["intVal"]     = 3000000;
            dtrow_out["longVal"]    = 3000000000000;
            dtrow_out["singleVal"]  = 7.2f;
            dtrow_out["stringVal"]  = "test3";

            // ここで変更を確定させる
            dtt_out.AcceptChanges();

            // 戻り値をマーシャリングして設定
            dtts_out = new DTTables();
            dtts_out.Add(dtt_out);
            ((MuReturnValue)this.ReturnValue).Value = DTTables.DTTablesToString(dtts_out);
        }
コード例 #16
0
 /// <summary>呼出しの完了後イベント(データグリッドの初期化)</summary>
 void client_InitDataGridCallCompleted(object sender, MuServiceReference.CallCompletedEventArgs e)
 {
     // データバインド(ToDataSourceでは、削除行を除いたリストを返す)
     this.Dtt = DTTables.StringToDTTables(e.returnValue)[0];
     this.dataGrid1.ItemsSource = this.Dtt.Rows.ToDataSource();
 }