Ejemplo n.º 1
0
        public static DeviceRec CreateDeviceRec(GCDevice device)
        {
            if (device == null)
            {
                return(null);
            }
            DeviceRec rec = new DeviceRec();

            rec.ID          = device.DeviceID;
            rec.Folder      = device.FolderPath;
            rec.IndexFile   = DeviceDirManager.IndexFileName;
            rec.Name        = device.Directory.Header.Name;
            rec.Type        = ((int)device.Directory.Header.Type).ToString();
            rec.Description = device.Directory.Header.Description;

            switch (device.Directory.Header.Direction)
            {
            case DirectionType.INBOUND:
                rec.Direction = "I";
                break;

            case DirectionType.OUTBOUND:
                rec.Direction = "O";
                break;

            case DirectionType.BIDIRECTIONAL:
                rec.Direction = "B";
                break;
            }

            return(rec);
        }
Ejemplo n.º 2
0
        public bool DeleteDevice(int deviceID)
        {
            DeviceRec rec = new DeviceRec();

            rec.ID = deviceID;
            return(Delete(rec));
        }
Ejemplo n.º 3
0
        public bool UpdateDevice(GCDevice device)
        {
            DeviceRec rec = DataHelper.CreateDeviceRec(device);

            if (rec == null)
            {
                return(false);
            }
            return(Update(rec));
        }
Ejemplo n.º 4
0
        public GCDevice GetDeviceByID(int deviceID)
        {
            string sql = "SELECT * FROM " + TableName + " WHERE DEVICE_ID=" + deviceID.ToString();

            DObjectCollection dlist = Select(sql);

            if (dlist == null || dlist.Count < 1)
            {
                return(null);
            }

            DeviceRec rec = dlist[0] as DeviceRec;

            return(new GCDeviceAgent(rec));
        }
Ejemplo n.º 5
0
        public bool HasSameDevice(GCDevice device)
        {
            DeviceRec rec = DataHelper.CreateDeviceRec(device);

            if (rec == null)
            {
                return(true);
            }

            string sql = "SELECT * FROM " + TableName + " WHERE DEVICE_DIRECT='" + rec.Direction + "' AND DEVICE_TYPE='" + rec.Type + "' AND DEVICE_NAME='" + rec.Name + "'";

            DObjectCollection dlist = Select(sql);

            if (dlist == null)
            {
                return(true);                   //db query failed.
            }
            if (dlist.Count > 0)
            {
                return(true);
            }

            return(false);
        }