示例#1
0
        private void ParseCommand(clsCommand cmd)
        {
            if (cmd.command.ToLower() == Properties.Settings.Default.TurnOnCommandDescription)
            {
                cmd.commandAddress = Properties.Settings.Default.RS485ManualControlLoadAddress;
                cmd.commandStatus  = true;
            }

            if (cmd.command.ToLower() == Properties.Settings.Default.TurnOffCommandDescription)
            {
                cmd.commandAddress = Properties.Settings.Default.RS485ManualControlLoadAddress;
                cmd.commandStatus  = false;
            }
        }//end private parse command
示例#2
0
        }// end function GetUsercommands

        public void GetuserCommandsExecute()
        {
            cmd = new SqlCommand();

            cnn = new SqlConnection(Properties.Settings.Default.DBConnectionString);
            cnn.Open();



            cmd.Connection  = cnn;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "uspGetUserCommandsExecute";
            dr = cmd.ExecuteReader();


            clsCommand cmdRS485 = new clsCommand();

            this.listCommandsExecute = new List <clsCommand>();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    cmdRS485         = new clsCommand();
                    cmdRS485.command = dr["Command"].ToString();
                    cmdRS485.users   = dr["userId"].ToString();
                    cmdRS485.slaveId = dr["slaveId"].ToString();
                    cmdRS485.id      = int.Parse(dr["id"].ToString());
                    ParseCommand(cmdRS485);
                    this.listCommandsExecute.Add(cmdRS485);
                } //end while
                this.listCommandExecuteCount = this.listCommandsExecute.Count;
            }     //end if
            else
            {
                this.listCommandExecuteCount = 0;
            }

            cnn.Close(); //close the connection
            dr.Close();  //close the data reader

            cmd.Dispose();
            cnn.Dispose();
        }// end function GetuserCommandsExecute