Пример #1
0
 public int compareColumn(ColumnInformation x, ColumnInformation y)
 {
     if (x.getId() < y.getId())
     {
         return(-1);
     }
     else
     {
         return(0);
     }
 }
Пример #2
0
        public String convertValue(byte[] data, ColumnInformation colInfo)
        {
            int colType   = (int)colInfo.getColType();
            int maxLength = colInfo.getMaxLength();

            if (colInfo.getName().Contains("Time"))
            {
                long timeValue = (long)BitConverter.ToUInt64(data, 0);
                if (timeValue == 0)
                {
                    return("0");
                }
                DateTime datetime = DateTime.FromBinary(timeValue);
                datetime = datetime.AddYears(1600);
                datetime = datetime.AddHours(Int32.Parse(UTCAddHour));
                datetime = datetime.AddMinutes(Int32.Parse(UTCAddMinute));
                return(datetime.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            if (colType == 1) //bool
            {
                return("NULL");
            }
            else if (colType == 1) //bool
            {
                return(data[0] == 1 ? "TRUE" : "FALSE");
            }
            else if (colType == 2) //byte
            {
                return(data[0].ToString());
            }
            else if (colType == 3) //short
            {
                return(BitConverter.ToInt16(data, 0).ToString());
            }
            else if (colType == 4) //integer
            {
                return(BitConverter.ToInt32(data, 0).ToString());
            }
            else if (colType == 5) //binary
            {
                double temp = (double)BitConverter.ToInt64(data, 0) / 1E4;
                return(temp.ToString());
            }
            else if (colType == 6) //float
            {
                return(BitConverter.ToSingle(data, 0).ToString());
            }
            else if (colType == 7) //double
            {
                return(BitConverter.ToDouble(data, 0).ToString());
            }
            else if (colType == 8) //dateTime
            {
                long     longVar     = BitConverter.ToInt64(data, 0);
                DateTime dateTimeVar = new DateTime(1980, 1, 1).AddMilliseconds(longVar);
                dateTimeVar.AddHours((Double)Int32.Parse(UTCAddHour));
                dateTimeVar.AddMinutes((Double)Int32.Parse(UTCAddMinute));
                return(dateTimeVar.ToString());
            }
            else if (colType == 9) //binary
            {
                string hex = BitConverter.ToString(data);
                return(hex.Replace("-", ""));
            }
            else if (colType == 10) //text
            {
                if (maxLength == 255)
                {
                    return(Encoding.UTF8.GetString(data));
                }
                else
                {
                    return(Encoding.Unicode.GetString(data));
                }
            }
            else if (colType == 11) //binary
            {
                string hex = BitConverter.ToString(data);
                return(hex.Replace("-", ""));
            }
            else if (colType == 12) //text
            {
                return(Encoding.Unicode.GetString(data));
            }
            else if (colType == 13) //integer
            {
                return(BitConverter.ToInt32(data, 0).ToString());
            }
            else if (colType == 14) //unsigned integer
            {
                return(BitConverter.ToUInt32(data, 0).ToString());
            }
            else if (colType == 15) //unsigned long long
            {
                return(BitConverter.ToUInt64(data, 0).ToString());
            }
            else if (colType == 16) //text
            {
                return(Encoding.UTF8.GetString(data));
            }
            else if (colType == 17) //unsigned short
            {
                return(BitConverter.ToInt16(data, 0).ToString());
            }
            else
            {
                return("UNKNOWN");
            }
        }