Exemple #1
0
        /// <summary>
        /// Get all device info from DB
        /// </summary>
        /// <returns>List of device</returns>
        public static List <Device> LoadAllDevices()
        {
            List <Device> devices = new List <Device>();
            DataTable     dt      = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.DeviceQuery("Q", "", "", "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id   = dr["deviceId"].ToString();
                    string Name = dr["deviceName"].ToString();
                    string ip   = dr["deviceIP"].ToString();

                    Device device = new Device(Id, Name, ip);
                    devices.Add(device);
                }
                return(devices);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Get device by device id from DB
        /// </summary>
        /// <param name="deviceId">Id of device need get</param>
        /// <returns>One device object</returns>
        public static Device LoadDeviceById(string deviceId)
        {
            Device    device = new Device();
            DataTable dt     = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.DeviceQuery("Q", deviceId, "", "");
                dt = ds.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    string Id   = dr["deviceId"].ToString();
                    string Name = dr["deviceName"].ToString();
                    string ip   = dr["deviceIP"].ToString();

                    device = new Device(Id, Name, ip);
                }
                return(device);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #3
0
        /// <summary>
        /// Auto generate device id base on max device id on DB
        /// </summary>
        /// <returns>Device ID: DExxxxxxxx </returns>
        public static string GenId()
        {
            string    id = "";
            DataTable dt = null;

            try
            {
                ServiceReference1.WSACUSoapClient client = new ServiceReference1.WSACUSoapClient();
                DataSet ds = client.DeviceQuery("S", "", "", "");
                dt = ds.Tables[0];
                id = dt.Rows[0][0].ToString();
                return(id);
            }
            catch (Exception ex)
            {
                return(id);
            }
        }