Пример #1
0
        public static void InsertTxnDataLog_DB(string connectionName, int dbIndex,
                                                                  EnumMsgCategory Category,
                                                                    string Action,
                                                                    string KeyValue1,
                                                                    string KeyValue2,
                                                                    string TxnId,
                                                                    string ErrorCode,
                                                                    string ErrorDescr,
                                                                    EnumMsgState State,
                                                                    string Comment)
        {
            string strSQL = @"if not Exists (select * from TxnDataLog where [Action]=@Action and [KeyValue1]=@KeyValue1 and [TxnId]=@TxnId and [Category]=@Category)
                              BEGIN  
                                    INSERT INTO TxnDataLog ([Category],[Action],[KeyValue1],[KeyValue2],[TxnId],
                                                            [ErrorCode],[ErrorDescr],[State],[Comment],[Cdt])
                                    VALUES (@Category,@Action,@KeyValue1,@KeyValue2,@TxnId,
                                            @ErrorCode,@ErrorDescr,@State,@Comment,GETDATE()) 
                              END";

            SQLHelper.ExecuteNonQuery(SQLHelper.GetDBConnectionString(connectionName, dbIndex),
                                                            System.Data.CommandType.Text,
                                                             strSQL,
                                                             SQLHelper.CreateSqlParameter("@Category", 16, Category.ToString().Trim()),
                                                             SQLHelper.CreateSqlParameter("@Action", 32, Action),
                                                             SQLHelper.CreateSqlParameter("@KeyValue1", 32, KeyValue1),
                                                             SQLHelper.CreateSqlParameter("@KeyValue2", 32, KeyValue2),
                                                             SQLHelper.CreateSqlParameter("@TxnId", 40, TxnId),
                                                             SQLHelper.CreateSqlParameter("@ErrorCode", 32, ErrorCode),
                                                             SQLHelper.CreateSqlParameter("@ErrorDescr", 255, ErrorDescr),
                                                             SQLHelper.CreateSqlParameter("@State", 16, State.ToString().Trim()),
                                                             SQLHelper.CreateSqlParameter("@Comment", 255, Comment));

        }           
Пример #2
0
        public static void InsertCancelBindDNLog(string connectionDB, int dbIndex, 
                                                 string SerialNumber, string Plant, string DN, string Remark1, string Remark2,
                                                 EnumMsgCategory Category, EnumMsgState State, string ErrorDescr, string Editor)
        {
            Remark1 = (Remark1 == null ? "" : Remark1);
            Remark2 = (Remark2 == null ? "" : Remark2);

            string strSQL = @"insert into CancelBindDNLog(Action, SerialNumber, Plant, DN, Remark1, Remark2, State, ErrorDescr, Editor, Cdt)
                              values (@Category, @SerialNumber, @Plant, @DN, @Remark1, @Remark2, @State, @ErrorDescr, @Editor, @Now) ";


            //SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionString_HISTORY(1),
            SQLHelper.ExecuteNonQuery(SQLHelper.GetDBConnectionString(connectionDB, dbIndex),
                                                System.Data.CommandType.Text,
                                                strSQL,
                                                SQLHelper.CreateSqlParameter("@Category", 10, Category.ToString().Trim()),
                                                SQLHelper.CreateSqlParameter("@SerialNumber", 25, SerialNumber),
                                                SQLHelper.CreateSqlParameter("@Plant", 4, Plant),
                                                SQLHelper.CreateSqlParameter("@DN", 10, DN),
                                                SQLHelper.CreateSqlParameter("@Remark1", 25, Remark1),
                                                SQLHelper.CreateSqlParameter("@Remark2", 25, Remark2),
                                                SQLHelper.CreateSqlParameter("@State", 16, State.ToString().Trim()),
                                                SQLHelper.CreateSqlParameter("@ErrorDescr", 255, ErrorDescr),
                                                SQLHelper.CreateSqlParameter("@Editor", 20, Editor),
                                                SQLHelper.CreateSqlParameter("@Now", DateTime.Now));

        }
Пример #3
0
        public static void InsertTxnDataLog( EnumMsgCategory  Category, 
                                                                  string Action, 
                                                                    string KeyValue1, 
                                                                    string KeyValue2, 
                                                                    string TxnId, 
                                                                    string ErrorCode, 
                                                                    string ErrorDescr, 
                                                                    EnumMsgState State, 
                                                                    string Comment)
        {
            string strSQL = @"INSERT INTO TxnDataLog ([Category],[Action],[KeyValue1],[KeyValue2],[TxnId],
                                                                                        [ErrorCode],[ErrorDescr],[State],[Comment],[Cdt])
                                        VALUES (@Category,@Action,@KeyValue1,@KeyValue2,@TxnId,
                                                        @ErrorCode,@ErrorDescr,@State,@Comment,GETDATE()) ";

            SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionString_CFG(),
                                                            System.Data.CommandType.Text,
                                                             strSQL,
                                                             SQLHelper.CreateSqlParameter("@Category", 16, Category.ToString().Trim()),
                                                             SQLHelper.CreateSqlParameter("@Action", 32, Action),
                                                             SQLHelper.CreateSqlParameter("@KeyValue1", 32, KeyValue1),
                                                             SQLHelper.CreateSqlParameter("@KeyValue2", 32, KeyValue2),
                                                             SQLHelper.CreateSqlParameter("@TxnId", 32, TxnId),
                                                             SQLHelper.CreateSqlParameter("@ErrorCode", 32, ErrorCode),
                                                             SQLHelper.CreateSqlParameter("@ErrorDescr", 255, ErrorDescr),
                                                             SQLHelper.CreateSqlParameter("@State", 16, State.ToString().Trim()),
                                                             SQLHelper.CreateSqlParameter("@Comment", 255, Comment));

        }
Пример #4
0
        /// <summary>
        /// カテゴリ名を取得
        /// </summary>
        /// <param name="category">メッセージカテゴリ</param>
        /// <returns>メッセージカテゴリ名</returns>
        public static string GetCategoryName(this EnumMsgCategory category)
        {
            switch (category)
            {
            case EnumMsgCategory.INFO:
                return("INFO");

            case EnumMsgCategory.WARN:
                return("INFO");

            case EnumMsgCategory.ERROR:
                return("ERROR");

            default:
                return("DEBUG");
            }
        }
Пример #5
0
        private void OutputLog(Type source, EnumMsgCategory category, string log)
        {
            var logger = LogManager.GetLogger(source);

            if (category == EnumMsgCategory.ERROR && logger.IsErrorEnabled)
            {
                logger.ErrorFormat("[{0}] {1}", source, log);
            }
            else if (category == EnumMsgCategory.WARN && logger.IsWarnEnabled)
            {
                logger.WarnFormat("[{0}] {1}", source, log);
            }
            else if (category == EnumMsgCategory.INFO && logger.IsInfoEnabled)
            {
                logger.InfoFormat("[{0}] {1}", source, log);
            }
            else if (category == EnumMsgCategory.DEBUG && logger.IsDebugEnabled)
            {
                logger.DebugFormat("[{0}] {1}", source, log);
            }
        }
Пример #6
0
        /// <summary>
        /// ログ出力
        /// </summary>
        /// <param name="source"></param>
        /// <param name="category"></param>
        /// <param name="log"></param>
        private static void OutputLog(Type source, EnumMsgCategory category, string log)
        {
            ILog logger = LogManager.GetLogger(source);

            switch (category)
            {
            case EnumMsgCategory.ERROR:
                logger.Error(log);
                break;

            case EnumMsgCategory.WARN:
                logger.Warn(log);
                break;

            case EnumMsgCategory.INFO:
                logger.Info(log);
                break;

            default:
                logger.Debug(log);
                break;
            }
        }
Пример #7
0
        public static void UpdateSendDataAndInsertLog(EnumMsgCategory Category,
                                                      string action,
                                                      string key1,
                                                      string key2,
                                                      string txnId,
                                                      string errorCode,
                                                      string errorDescr,
                                                      EnumMsgState state,
                                                      DateTime udt)
        {

            string strSQL = @"UPDATE SendData
                              SET State =@State,
                                  Udt =@now,
                                  ErrorCode =@ErrorCode,
                                  ErrorDescr=@ErrorDescr
                              WHERE Action =@Action AND TxnId =@TxnId  
                                        
                            INSERT INTO TxnDataLog(Category, Action, KeyValue1, KeyValue2, TxnId, 
					                               ErrorCode, ErrorDescr, State, Comment, Cdt)
                                            VALUES(@Category, @Action, @KeyValue1, @KeyValue2, @TxnId, 
                                                    @ErrorCode,@ErrorDescr, @State, '', @now)";

            SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionString_CFG(),
                                      System.Data.CommandType.Text,
                                      strSQL,
                                      SQLHelper.CreateSqlParameter("@Action", 32, action),
                                      SQLHelper.CreateSqlParameter("@KeyValue1", 32, key1),
                                      SQLHelper.CreateSqlParameter("@KeyValue2", 32, key2),
                                      SQLHelper.CreateSqlParameter("@TxnId", 32, txnId),
                                      SQLHelper.CreateSqlParameter("@State", 32, state.ToString().Trim()),
                                      SQLHelper.CreateSqlParameter("@now", udt),
                                      SQLHelper.CreateSqlParameter("@Category", 32, Category.ToString().Trim()),
                                      SQLHelper.CreateSqlParameter("@ErrorCode", 32, errorCode),
                                      SQLHelper.CreateSqlParameter("@ErrorDescr", 255, errorDescr));
        }
Пример #8
0
        public static void InsertSendDataAndLog(EnumMsgCategory Category,
                                               string action,
                                               string key1,
                                               string key2,
                                               string txnId,
                                               EnumMsgState state,
                                               DateTime udt)
        {

            string strSQL = @"INSERT INTO SendData(Action, KeyValue1, KeyValue2, TxnId, ErrorCode, 
						                           ErrorDescr, State, ResendCount, Comment, Cdt,Udt)
                                            VALUES(@Action, @KeyValue1, @KeyValue2, @TxnId, '', 
		                                            '', @State, 0, '', @now,@now)
                                
                              INSERT INTO TxnDataLog(Category, Action, KeyValue1, KeyValue2, TxnId, 
					                                 ErrorCode, ErrorDescr, State, Comment, Cdt)
                                              VALUES(@Category, @Action, @KeyValue1, @KeyValue2, @TxnId, 
                                                     '','', @State, '', @now)";

            SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionString_CFG(),
                                      System.Data.CommandType.Text,
                                      strSQL,
                                      SQLHelper.CreateSqlParameter("@Action", 32, action),
                                      SQLHelper.CreateSqlParameter("@KeyValue1", 32, key1),
                                      SQLHelper.CreateSqlParameter("@KeyValue2", 32, key2),
                                      SQLHelper.CreateSqlParameter("@TxnId", 32, txnId),
                                      SQLHelper.CreateSqlParameter("@State", 32, state.ToString().Trim()),
                                      SQLHelper.CreateSqlParameter("@now", udt),
                                      SQLHelper.CreateSqlParameter("@Category", 32, Category.ToString().Trim()));            
        }
Пример #9
0
 /// <summary>
 /// ログ出力(コンソール)
 /// </summary>
 /// <param name="source">ログ出力元の型</param>
 /// <param name="category">ログカテゴリ</param>
 /// <param name="log">ログ出力内容</param>
 private static void OutputLogToConsole(Type source, EnumMsgCategory category, string log)
 {
     Console.WriteLine(string.Format("{0} {1}:[{2}] {3}",
                                     DateTime.Now, source.Name, category.GetCategoryName(), log));
 }