Beispiel #1
0
 public List <Tag> GetByDataBlock(DataBlock db)
 {
     try
     {
         SQLiteCommand sqlCommand = new SQLiteCommand();
         sqlCommand.CommandType = CommandType.Text;
         sqlCommand.CommandText = string.Format("SELECT * FROM {0} WHERE {1} = @{2} AND {3} = @{4} AND {5} = @{6}", "[Tag]", "ChannelId", "ChannelId", "DeviceId", "DeviceId", "DataBlockId", "DataBlockId");
         sqlCommand.Parameters.Add(string.Format("@{0}", "ChannelId"), DbType.Int32).Value   = db.ChannelId;
         sqlCommand.Parameters.Add(string.Format("@{0}", "DeviceId"), DbType.Int32).Value    = db.DeviceId;
         sqlCommand.Parameters.Add(string.Format("@{0}", "DataBlockId"), DbType.Int32).Value = db.DataBlockId;
         string[] array = new string[10]
         {
             "TagId",
             "DataBlockId",
             "DeviceId",
             "ChannelId",
             "TagName",
             "TagPrefix",
             "Address",
             "DataType",
             "Size",
             "Description"
         };
         return(LocalBaseDAO.SelectCollection <Tag>(array, array, sqlCommand));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List <DataBlock> GetByDBNumberInDevice(DataBlock db)
 {
     try
     {
         SQLiteCommand sqlCommand = new SQLiteCommand();
         sqlCommand.CommandType = CommandType.Text;
         sqlCommand.CommandText = string.Format("SELECT * FROM {0} WHERE {1} = @{2} AND {3} = @{4} AND {5} = @{6} AND {7} = @{8}", "[DataBlock]", "ChannelId", "ChannelId", "DeviceId", "DeviceId", "MemoryType", "MemoryType", "DBNumber", "DBNumber");
         sqlCommand.Parameters.Add(string.Format("@{0}", "ChannelId"), DbType.Int32).Value  = db.ChannelId;
         sqlCommand.Parameters.Add(string.Format("@{0}", "DeviceId"), DbType.Int32).Value   = db.DeviceId;
         sqlCommand.Parameters.Add(string.Format("@{0}", "MemoryType"), DbType.Int32).Value = db.MemoryType;
         sqlCommand.Parameters.Add(string.Format("@{0}", "DBNumber"), DbType.Int32).Value   = db.StartAddress;
         string[] array = new string[7]
         {
             "DataBlockId",
             "DeviceId",
             "ChannelId",
             "DataBlockName",
             "MemoryType",
             "DBNumber",
             "Description"
         };
         return(LocalBaseDAO.SelectCollection <DataBlock>(array, array, sqlCommand));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public List <Channel> Select()
 {
     try
     {
         SQLiteCommand sqlCommand = new SQLiteCommand();
         sqlCommand.CommandType = CommandType.Text;
         sqlCommand.CommandText = string.Format("SELECT * FROM {0}", "[Channel]");
         string[] collectionNames = new string[3]
         {
             "ChannelId",
             "ChannelName",
             "Description"
         };
         string[] columnNames = new string[3]
         {
             "ChannelId",
             "ChannelName",
             "Description"
         };
         return(LocalBaseDAO.SelectCollection <Channel>(collectionNames, columnNames, sqlCommand));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public DataBlock GetByName(DataBlock db)
        {
            DataBlock result = null;

            try
            {
                SQLiteCommand sqlCommand = new SQLiteCommand();
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.CommandText = string.Format("SELECT * FROM {0} WHERE {1} = @{2} AND {3} = @{4} AND {5} = @{6}", "[DataBlock]", "ChannelId", "ChannelId", "DeviceId", "DeviceId", "DataBlockName", "DataBlockName");
                sqlCommand.Parameters.Add(string.Format("@{0}", "ChannelId"), DbType.Int32).Value      = db.ChannelId;
                sqlCommand.Parameters.Add(string.Format("@{0}", "DeviceId"), DbType.Int32).Value       = db.DeviceId;
                sqlCommand.Parameters.Add(string.Format("@{0}", "DataBlockName"), DbType.String).Value = db.DataBlockName;
                string[] array = new string[7]
                {
                    "DataBlockId",
                    "DeviceId",
                    "ChannelId",
                    "DataBlockName",
                    "MemoryType",
                    "DBNumber",
                    "Description"
                };
                List <DataBlock> list = LocalBaseDAO.SelectCollection <DataBlock>(array, array, sqlCommand);
                if (list.Count > 0)
                {
                    return(list[0]);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public List <DataBlock> Select()
 {
     try
     {
         SQLiteCommand sqlCommand = new SQLiteCommand();
         sqlCommand.CommandType = CommandType.Text;
         sqlCommand.CommandText = string.Format("SELECT * FROM {0}", "[DataBlock]");
         string[] collectionNames = new string[7]
         {
             "DataBlockId",
             "DeviceId",
             "ChannelId",
             "DataBlockName",
             "MemoryType",
             "DBNumber",
             "Description"
         };
         string[] columnNames = new string[7]
         {
             "DataBlockId",
             "DeviceId",
             "ChannelId",
             "DataBlockName",
             "MemoryType",
             "DBNumber",
             "Description"
         };
         return(LocalBaseDAO.SelectCollection <DataBlock>(collectionNames, columnNames, sqlCommand));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #6
0
 public List <Device> GetByChannel(Channel ch)
 {
     try
     {
         SQLiteCommand sqlCommand = new SQLiteCommand();
         sqlCommand.CommandType = CommandType.Text;
         sqlCommand.CommandText = string.Format("SELECT * FROM {0} WHERE {1} = @{2}", "[Device]", "ChannelId", "ChannelId");
         sqlCommand.Parameters.Add(string.Format("@{0}", "ChannelId"), DbType.Int32).Value = ch.ChannelId;
         string[] array = new string[9]
         {
             "DeviceId",
             "ChannelId",
             "DeviceName",
             "CPUType",
             "IPAddress",
             "Rack",
             "Slot",
             "Description",
             "IsActived"
         };
         return(LocalBaseDAO.SelectCollection <Device>(array, array, sqlCommand));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #7
0
        public Device GetByName(Device objDevice)
        {
            Device result = null;

            try
            {
                SQLiteCommand sqlCommand = new SQLiteCommand();
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.CommandText = string.Format("SELECT * FROM {0} WHERE {1} = @{2} AND {3} = @{4}", "[Device]", "ChannelId", "ChannelId", "DeviceName", "DeviceName");
                sqlCommand.Parameters.Add(string.Format("@{0}", "ChannelId"), DbType.Int32).Value   = objDevice.ChannelId;
                sqlCommand.Parameters.Add(string.Format("@{0}", "DeviceName"), DbType.String).Value = objDevice.DeviceName;
                string[] array = new string[9]
                {
                    "DeviceId",
                    "ChannelId",
                    "DeviceName",
                    "CPUType",
                    "IPAddress",
                    "Rack",
                    "Slot",
                    "Description",
                    "IsActived"
                };
                List <Device> list = LocalBaseDAO.SelectCollection <Device>(array, array, sqlCommand);
                if (list.Count > 0)
                {
                    return(list[0]);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #8
0
 public List <Tag> Select()
 {
     try
     {
         SQLiteCommand sqlCommand = new SQLiteCommand();
         sqlCommand.CommandType = CommandType.Text;
         sqlCommand.CommandText = string.Format("SELECT * FROM {0}", "[Tag]");
         string[] collectionNames = new string[10]
         {
             "TagId",
             "DataBlockId",
             "DeviceId",
             "ChannelId",
             "TagName",
             "TagPrefix",
             "Address",
             "DataType",
             "Size",
             "Description"
         };
         string[] columnNames = new string[10]
         {
             "TagId",
             "DataBlockId",
             "DeviceId",
             "ChannelId",
             "TagName",
             "TagPrefix",
             "Address",
             "DataType",
             "Size",
             "Description"
         };
         return(LocalBaseDAO.SelectCollection <Tag>(collectionNames, columnNames, sqlCommand));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #9
0
        public Tag GetByAddress(Tag objTag)
        {
            Tag result = null;

            try
            {
                SQLiteCommand sqlCommand = new SQLiteCommand();
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.CommandText = string.Format("SELECT * FROM {0} WHERE {1} = @{2} AND {3} = @{4} AND {5} = @{6} AND {7} = @{8} AND {9} = @{10}", "[Tag]", "ChannelId", "ChannelId", "DeviceId", "DeviceId", "DataBlockId", "DataBlockId", "Address", "Address", "DataType", "DataType");
                sqlCommand.Parameters.Add(string.Format("@{0}", "ChannelId"), DbType.Int32).Value   = objTag.ChannelId;
                sqlCommand.Parameters.Add(string.Format("@{0}", "DeviceId"), DbType.Int32).Value    = objTag.DeviceId;
                sqlCommand.Parameters.Add(string.Format("@{0}", "DataBlockId"), DbType.Int32).Value = objTag.DataBlockId;
                sqlCommand.Parameters.Add(string.Format("@{0}", "Address"), DbType.String).Value    = objTag.Address;
                sqlCommand.Parameters.Add(string.Format("@{0}", "DataType"), DbType.Int32).Value    = objTag.DataType;
                string[] array = new string[10]
                {
                    "TagId",
                    "DataBlockId",
                    "DeviceId",
                    "ChannelId",
                    "TagName",
                    "TagPrefix",
                    "Address",
                    "DataType",
                    "Size",
                    "Description"
                };
                List <Tag> list = LocalBaseDAO.SelectCollection <Tag>(array, array, sqlCommand);
                if (list.Count > 0)
                {
                    return(list[0]);
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
 public List <Device> Select()
 {
     try
     {
         SQLiteCommand sqlCommand = new SQLiteCommand();
         sqlCommand.CommandType = CommandType.Text;
         sqlCommand.CommandText = string.Format("SELECT * FROM {0}", "[Device]");
         string[] collectionNames = new string[9]
         {
             "DeviceId",
             "ChannelId",
             "DeviceName",
             "CPUType",
             "IPAddress",
             "Rack",
             "Slot",
             "Description",
             "IsActived"
         };
         string[] columnNames = new string[9]
         {
             "DeviceId",
             "ChannelId",
             "DeviceName",
             "CPUType",
             "IPAddress",
             "Rack",
             "Slot",
             "Description",
             "IsActived"
         };
         return(LocalBaseDAO.SelectCollection <Device>(collectionNames, columnNames, sqlCommand));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #11
0
        public List <Channel> GetByName(string channelName)
        {
            List <Channel> list = new List <Channel>();

            try
            {
                SQLiteCommand sqlCommand = new SQLiteCommand();
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.CommandText = string.Format("SELECT * FROM {0} WHERE {1} = @{2}", "[Channel]", "ChannelName", "ChannelName");
                sqlCommand.Parameters.Add(string.Format("@{0}", "ChannelName"), DbType.String).Value = channelName;
                string[] array = new string[3]
                {
                    "ChannelId",
                    "ChannelName",
                    "Description"
                };
                return(LocalBaseDAO.SelectCollection <Channel>(array, array, sqlCommand));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }