Example #1
0
        public static byte[] CheckSumHEXString(string stringReadFrom)
        {
            string[] arrayBarcode = stringReadFrom.Split(new Char[] { (char)44 });
            byte []  result       = new byte[0];
            for (int i = 0; i < arrayBarcode.Length; i++)
            {
                result = i == 0? GlobalStaticFunction.StringToByteArrayFastest(arrayBarcode[i]): GlobalStaticFunction.XORBytes(result, GlobalStaticFunction.StringToByteArrayFastest(arrayBarcode[i]));
            }

            return(result);
        }
Example #2
0
        public static void WriteToStream(NetworkStream networkStream, string stringToWrite)
        {
            try
            {
                stringToWrite = stringToWrite.Replace("/", "");
                stringToWrite = stringToWrite.Replace(",", "");
                if (networkStream.CanWrite)
                {
                    //Byte[] arrayBytesWriteTo = Encoding.ASCII.GetBytes(stringToWrite); /MAY IN DOMINO: COMMAND LA ASCII, NEN SU DUNG CAU LENH NAY
                    byte[] arrayBytesWriteTo = GlobalStaticFunction.HexStringToByteArray(stringToWrite); //MAY IN IMAJE: COMMAND LA HEX, NEN SU DUNG CAU LENH NAY

                    if (networkStream != null)
                    {
                        networkStream.Write(arrayBytesWriteTo, 0, arrayBytesWriteTo.Length);
                    }
                }
                else
                {
                    throw new System.InvalidOperationException("NMVN: Network stream cannot be written");
                }
            }
            catch (Exception exception)
            { throw exception; }
        }
Example #3
0
 public static int DateToContinuosMonth()
 {
     return(GlobalStaticFunction.DateToContinuosMonth(DateTime.Now));
 }