Exemple #1
0
        internal OverWriteSetting Initialize()
        {
            string _Path = PGTSetting.Default.SettingFilePath + "\\" + PGTSetting.Default.SettingFileName;

            OverWriteSetting curentSettig = null;

            try
            {
                _iLog.Info("PGTSetting.config'S PATH=" + _Path);
                curentSettig = (OverWriteSetting)XmlStrreamer.Import(_Path, typeof(OverWriteSetting));
                _iLog.Info("LodingPropaties=\n" + getPropertiesFormat(curentSettig, 1));
            }
            catch (Exception ex)
            {
                _iLog.Error("error", ex);
                throw ex;
            }

            return(curentSettig);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            bool l4nSetingLoadSucess = _iLog.Logger.Repository.Configured;

            if (!l4nSetingLoadSucess)
            {
                var errorIventMsg = "log4net.xml load Error:Repository.Configured=" + l4nSetingLoadSucess.ToString();

                EventLog.WriteEntry("TESTPG", errorIventMsg, EventLogEntryType.Error, 9999);

                throw new Exception();
            }


            curentSettig = new SettingReader();

            clogFilePathUpdate(); // CallLogの出力先をPGTSetting.configから取得した出力先に変更する

            _cLog.Info("*** TEST AP START ***");

            // _cLog.Debug("TEST MSG Debug");
            // _cLog.Info("TEST MSG Info");


            SocketRequest sr = new SocketRequest();

            sr.KyokuNo     = "03";
            sr.LineNo      = "10";
            sr.MonitorReq  = "1";
            sr.RecFileName = "test_test.wav";
            sr.ServerID    = "10";
            sr.StnNo       = "1";
            sr.TelNo       = "0312345678";

            string tmpStreem = XmlStrreamer.TransPortString(sr);    // クラステキスト化

            // 整形
            tmpStreem = tmpStreem.Replace("\r\n", "");
            tmpStreem = tmpStreem.Replace("  ", ""); // 簡易版 汎用性?
            string headClass = " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"";

            tmpStreem = tmpStreem.Replace(headClass, "");
            string headXML = "<?xml version=\"1.0\" encoding=\"utf-16\"?>";

            tmpStreem = tmpStreem.Replace(headXML, "");
            _cLog.Info("SocketRequest.toString=" + tmpStreem);


            // 接続文字列を生成する
            // string connectionString = ConfigurationManager.ConnectionStrings["SQLCON"].ConnectionString;

            // SqlConnection の新しいインスタンスを生成する (接続文字列を指定)
            try
            {
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(curentSettig.setting.ConnectionStr);

                builder.ConnectRetryCount        = 3;
                builder.ConnectRetryInterval     = 5;
                builder.LoadBalanceTimeout       = 43200;
                builder.MultipleActiveResultSets = true;

                dbConnection = new SqlConnection(builder.ConnectionString);
            }
            catch (Exception ex)
            {
                _iLog.Error("error", ex);
            }

            // データベース接続を開く
            try
            {
                dbConnection.Open();
            }
            catch (Exception ex)
            {
                _iLog.Error("error", ex);
            }


            try
            {
//              string sql1 = @"SELECT WATCH_FLG FROM T_SYSTEM WITH(XLOCK,ROWLOCK,NOWAIT)";
                string sql1 = @"SELECT WATCH_FLG FROM T_SYSTEM WITH(XLOCK,ROWLOCK)";

                dbCommand             = dbConnection.CreateCommand();    // コマンドオブジェクト作成
                dbTransaction         = dbConnection.BeginTransaction(); // トランザクションオブジェクト作成
                dbCommand.Transaction = dbTransaction;                   // コマンドにトランザクションを関連付ける

                dbCommand.CommandText = sql1;

                SqlDataReader sdr = dbCommand.ExecuteReader();

                _cLog.Info("T_SYSTEM'S Has RowS=" + sdr.HasRows.ToString());


                int rowCount = 0;

                while (sdr.Read())
                {
                    rowCount++;
                    _cLog.Info("T_SYSTEM'S WATCH_FLG=" + sdr["WATCH_FLG"].ToString());
                }

                if (rowCount != 1)
                {
                    _cLog.Info("T_SYSTEM'S FOUND COUNT OVVER COUNt=" + rowCount.ToString());
                }
                sdr.Close();

                dbTransaction.Commit();
            }
            catch (Exception ex)
            {
                _iLog.Error("error", ex);
                dbTransaction.Rollback();
            }
            finally
            {
            }


            string CSTMR_TEL_NO = "12345678";

            try
            {
                string sql2 = @"SELECT DEST_TEL_NO, PLAY_FLG FROM T_CALLINFO WITH(XLOCK,ROWLOCK) WHERE DEST_TEL_NO = @P_CSTMR_TEL_NO AND PLAY_FLG = '0';";
                string sql3 = @"UPDATE T_CALLINFO SET PLAY_FLG = '1' WHERE DEST_TEL_NO = @P_CSTMR_TEL_NO AND PLAY_FLG = '0';";

                dbCommand             = dbConnection.CreateCommand();    // コマンドオブジェクト作成
                dbTransaction         = dbConnection.BeginTransaction(); // トランザクションオブジェクト作成
                dbCommand.Transaction = dbTransaction;                   // コマンドにトランザクションを関連付ける

                dbCommand.CommandText = sql2;
                dbCommand.Parameters.AddWithValue("@P_CSTMR_TEL_NO", CSTMR_TEL_NO);

                SqlDataReader sdr = dbCommand.ExecuteReader();

                _cLog.Info("T_CALLINFO'S Has RowS=" + sdr.HasRows.ToString());


                int rowCount = 0;

                while (sdr.Read())
                {
                    rowCount++;
                    _cLog.Info("T_CALLINFO'S DEST_TEL_NO=" + sdr["DEST_TEL_NO"].ToString()
                               + "PLAY_FLG=" + sdr["PLAY_FLG"].ToString());
                }

                if (rowCount != 1)
                {
                    _cLog.Info("T_CALLINFO'S FOUND COUNT OVVER COUNT=" + rowCount.ToString());
                }

                sdr.Close();
                dbCommand.CommandText = sql3;

                int resultCount = dbCommand.ExecuteNonQuery();


                dbTransaction.Commit();

                _cLog.Info("T_CALLINFO'S UPDATE COUNT=" + resultCount.ToString());
            }
            catch (Exception ex)
            {
                _iLog.Error("error", ex);
                dbTransaction.Rollback();
            }
            finally
            {
                dbConnection.Close();
                dbConnection.Dispose();
            }

            // データベース接続を閉じる (正しくは オブジェクトの破棄を保証する を参照)

            _cLog.Info("*** TEST AP END ***");
        }