Beispiel #1
0
        /// <summary>
        /// SQL3LogNumberFld()
        /// </summary>
        /// <param name="sqlvar"></param>
        public static void SQL3LogNumberFld(Sql3SqlVar sqlvar)
        {
            short shortVal = 0;
            long  longVal  = 0;
            int   printFieldLen;
            float floatVal = 0.0F;

            switch (sqlvar.SqlType)
            {
            case Sql3Type.SQL3TYPE_I2:
            case Sql3Type.SQL3TYPE_I4:
            case Sql3Type.SQL3TYPE_R4:
            case Sql3Type.SQL3TYPE_R8:
                if (sqlvar.SqlLen == 2)
                {
                    shortVal = short.Parse(sqlvar.SqlData.ToString());
                    Logger.Instance.WriteToLog(string.Format("SQL3LogNumberFld(): sqlvar.SqlData = {0}", shortVal), true);
                }
                else if (sqlvar.SqlLen == 4)
                {
                    if (sqlvar.typeAffinity == TypeAffinity.TYPE_AFFINITY_REAL)
                    {
                        floatVal = float.Parse(sqlvar.SqlData.ToString());
                        Logger.Instance.WriteToLog(string.Format("SQL3LogNumberFld():sqlvar.SqlData = {0}", floatVal), true);
                    }
                    else
                    {
                        longVal = long.Parse(sqlvar.SqlData.ToString());
                        Logger.Instance.WriteToLog(string.Format("SQL3LogNumberFld():sqlvar.SqlData = {0}", longVal), true);
                    }
                }
                else
                {
                    Logger.Instance.WriteToLog(string.Format("SQL3LogNumberFld(): sqlvar.SqlData = {0}", sqlvar.SqlData), true);
                }
                break;

            default:
                if (sqlvar.SqlLen <= 40)
                {
                    printFieldLen = (int)sqlvar.SqlLen;
                    Logger.Instance.WriteToLog(string.Format("SQL3LogNumberFld(): sqlvar.SqlData = {0}", sqlvar.SqlData), true);
                }
                else
                {
                    Logger.Instance.WriteToLog("SQL3LogNumberFld(): sqlvar->sqllen bigger than 40, db_crsr->buf is not printed", true);
                }
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// SQL3LogSqldataOutput()
        /// </summary>
        /// <param name="sqlvar"></param>
        public static void SQL3LogSqldataOutput(Sql3SqlVar sqlVar)
        {
            int fldLen;

            if (sqlVar.NullIndicator == 1)
            {
                Logger.Instance.WriteToLog("\n\tRESULT: NULL", true);
            }
            else
            {
                switch (sqlVar.SqlType)
                {
                case Sql3Type.SQL3TYPE_STR:
                case Sql3Type.SQL3TYPE_DATE:
                    if (sqlVar.SqlLen < 40)
                    {
                        fldLen = sqlVar.SqlLen;
                        Logger.Instance.WriteToLog(string.Format("\n\tRESULT: {0}", sqlVar.SqlData), true);
                    }
                    else
                    {
                        Logger.Instance.WriteToLog(string.Format("\n\tRESULT TRUNCATED TO 40: {0}", sqlVar.SqlData), true);
                    }
                    break;

                case Sql3Type.SQL3TYPE_WSTR:
                case Sql3Type.SQL3TYPE_BSTR:
                    if (sqlVar.SqlLen < 40)
                    {
                        fldLen = (sqlVar.SqlLen / 2) - 1;
                        Logger.Instance.WriteToLog(string.Format("\n\tRESULT: {0}", sqlVar.SqlData), true);
                    }
                    else
                    {
                        Logger.Instance.WriteToLog(string.Format("\n\tRESULT TRUNCATED TO 40: {0}", sqlVar.SqlData), true);
                    }
                    break;

                case Sql3Type.SQL3TYPE_UI1:
                case Sql3Type.SQL3TYPE_I2:
                case Sql3Type.SQL3TYPE_I4:
                    switch (sqlVar.SqlLen)
                    {
                    case 1:
                        Logger.Instance.WriteToLog(string.Format(" \n\tRESULT: {0}", sqlVar.SqlData), true);
                        break;

                    case 2:
                        Logger.Instance.WriteToLog(string.Format(" \n\tRESULT: {0}", short.Parse(sqlVar.SqlData.ToString())), true);
                        break;

                    case 4:
                        Logger.Instance.WriteToLog(string.Format(" \n\tRESULT: {0}", long.Parse(sqlVar.SqlData.ToString())), true);
                        break;
                    }
                    break;

                case Sql3Type.SQL3TYPE_R4:
                case Sql3Type.SQL3TYPE_R8:
                    switch (sqlVar.SqlLen)
                    {
                    case 4:
                        Logger.Instance.WriteToLog(string.Format(" \n\tRESULT: {0}", float.Parse(sqlVar.SqlData.ToString())), true);
                        break;

                    case 8:
                        Logger.Instance.WriteToLog(string.Format(" \n\tRESULT: {0}", double.Parse(sqlVar.SqlData.ToString())), true);
                        break;
                    }
                    break;

                case Sql3Type.SQL3TYPE_BYTES:
                    Logger.Instance.WriteToLog(string.Format(" \n\tRESULT: {0}", sqlVar.SqlData), true);
                    break;

                case Sql3Type.SQL3TYPE_BOOL:
                    Logger.Instance.WriteToLog(string.Format(" \n\tRESULT: {0}", sqlVar.SqlData.ToString()), true);
                    break;
                }
            }
        }