Esempio n. 1
0
 private void send(ParamCode code, byte[] buffer)
 {
     if (Adapter != null && Adapter.IsConnected)
     {
         Adapter.Send((int)code, buffer);
     }
 }
Esempio n. 2
0
        public DBColumn GetColumn()
        {
            int      index  = ParamCode.IndexOf(' ');
            string   code   = ParamCode.Substring(0, index < 0 ? ParamCode.Length : index);
            DBColumn column = DBService.Schems.ParseColumn(code, Table.Schema);

            return(column);
        }
Esempio n. 3
0
        public DBForeignKey GetReference()
        {
            int    index = ParamCode.IndexOf(' ');
            string code  = ParamCode.Substring(0, index < 0 ? ParamCode.Length : index);

            DBColumn column = DBService.Schems.ParseColumn(code, Table.Schema);

            //var result = new DBConstraintForeign() { Table = column.Table, Column = column, Value = column.Reference };
            //if (index >= 0) result.Value = ParamCode.Substring(index + 1);
            return(column?.GetForeign());
        }
Esempio n. 4
0
        /// <summary>
        /// 获取参数
        /// </summary>
        /// <param name="devHandle">设备句柄</param>
        /// <param name="code">参数代码(见附录说明)</param>
        /// <param name="paramValue">参数值</param>
        /// <returns></returns>
        public static ErrorCode GetParameters(IntPtr devHandle, ParamCode code, byte[] paramValue)
        {
            if (IntPtr.Zero == devHandle)
            {
                return(ErrorCode.InvalidHandle);
            }
            int    size   = paramValue.Length;
            IntPtr intPtr = Marshal.AllocHGlobal(size);
            int    num    = ZkfpPlus.ZKFPM_GetParameters(devHandle, (int)code, intPtr, ref size);

            if (num == (int)ErrorCode.OK)
            {
                Marshal.Copy(intPtr, paramValue, 0, size);
            }
            Marshal.FreeHGlobal(intPtr);
            return((ErrorCode)num);
        }
Esempio n. 5
0
        /// <summary>
        /// 设置参数
        /// </summary>
        /// <param name="devHandle">设备句柄</param>
        /// <param name="code">参数代码(见附录说明)</param>
        /// <param name="pramValue">参数值</param>
        /// <returns></returns>
        public static ErrorCode SetParameters(IntPtr devHandle, ParamCode code, byte[] pramValue)
        {
            if (devHandle == IntPtr.Zero)
            {
                return(ErrorCode.InvalidHandle);
            }
            if (pramValue == null)
            {
                return(ErrorCode.InvalidParam);
            }

            IntPtr intPtr = Marshal.AllocHGlobal(pramValue.Length);

            Marshal.Copy(pramValue, 0, intPtr, pramValue.Length);
            int result = ZkfpPlus.ZKFPM_SetParameters(devHandle, (int)code, intPtr, pramValue.Length);

            Marshal.FreeHGlobal(intPtr);
            return((ErrorCode)result);
        }
Esempio n. 6
0
        private void onReceiveCompleted(object sender, ReceiveEventArgs args)
        {
            try
            {
                if (args.ByteLength > 0)
                {
                    using (MemoryStream ms = new MemoryStream(args.ReceivedBytes))
                    {
                        ParamCode code   = (ParamCode)PacketBase.ReadInt(ms);
                        byte[]    buffer = null;
                        switch (code)
                        {
                        case ParamCode.VideoInfosTimePeriods:
                            updateVideoInfosTimePeriods(VideoDataInfoParam.Decode(ms));
                            break;

                        case ParamCode.DownloadBegin:
                            beginDownload(DownloadInfoParam.Decode(ms));
                            break;

                        case ParamCode.DownloadToLocal:
                            downloadToLocal(PacketBase.ReadString(ms));
                            break;

                        case ParamCode.VideoPacket:
                            getVideoStreamsPacket(VideoDataParam.Decode(ms));
                            break;

                        case ParamCode.ProbeTime:
                            setProbeTime(PacketBase.ReadTime(ms));
                            break;

                        case ParamCode.DownloadInfosAll:
                            feedbackDownloadInfosToClient();
                            break;

                        case ParamCode.DownloadControl:
                            var controlCode = (DownloadControlCode)PacketBase.ReadInt(ms);
                            onDownloadControl(controlCode, ms);
                            break;

                        case ParamCode.LocalDownloadPath:
                            onLocalDownloadPath(PacketBase.ReadString(ms));
                            break;

                        case ParamCode.LocalDownloadBegin:
                            onLocalDownloadStart(LocalDownloadInfoPacket.Decode(ms));
                            break;
                        }
                        if (buffer != null)
                        {
                            send((ParamCode)code, buffer);
                        }
                    }
                }
            }
            catch (IOException ex)
            {
                sendMessage(MessageType.Warn, ex.Message, null);
            }
            catch (Exception ex)
            {
                sendMessage(MessageType.Error, ex.Message, null);
                Console.WriteLine(ex.ToString());
            }
        }
 void write(FileStream fs, ParamCode code, byte[] buffer)
 {
     PacketBase.WriteBytes(fs, buffer.Length + 4);
     PacketBase.WriteBytes(fs, (int)code);
     PacketBase.WriteBytes(fs, buffer);
 }