예제 #1
0
        public static int BL_Write(string strModule, string strMethod, int intType, string strDetails, string strUser)
        {
            if (strDetails != "")
            {
                string strErrorType;

                switch (intType)
                {
                case 0:
                    strErrorType = "Error";
                    break;

                case 1:
                    strErrorType = "Worning";
                    break;

                case 2:
                    strErrorType = "Success";
                    break;

                default:
                    strErrorType = "Error";
                    break;
                }

                string strPlantCode = string.Empty;

                if (strUser.Trim() == null)
                {
                    strPlantCode = "'-'";
                }
                else
                {
                    strPlantCode = "(SELECT TOP(1) PLANT FROM TBLUSER WHERE UID = '" + strUser.Trim() + "')";
                }

                SqlDataLayer objSql   = new SqlDataLayer();
                string       strQuery = string.Empty;
                try
                {
                    if (strDetails.Contains("This SqlTransaction has completed") == false)
                    {
                        strQuery = "INSERT INTO TBLEVENTS (MODULE, METHOD, TYPE, DETAILS, CRDATE, CRUSER, PLANT, PROGRAM) VALUES (" +
                                   "'" + strModule.Trim() + "', '" + strMethod.Trim() + "', " +
                                   "'" + strErrorType.Trim() + "', '" + strDetails.Replace("System.Exception:", "").Trim() + "', GETDATE(), '" + strUser.Trim() + "'," + strPlantCode + ", 'RF SERVER')";
                        return(objSql.ExecuteNonQuery(SqlDataLayer.strLocal, strQuery));
                    }
                }
                catch //(Exception ex)
                {
                    //throw new Exception(ex.ToString());
                }
                finally
                {
                    strQuery = string.Empty;
                    objSql   = null;
                }
            }
            return(1);
        }