Esempio n. 1
0
        private EntDiscover DataReaderToObject(SqlCeDataReader reader)
        {
            EntDiscover machine = new EntDiscover();

            machine.MachineID = reader.GetInt32(reader.GetOrdinal("MachineID"));
            machine.IPAddr = reader.GetString(reader.GetOrdinal("IPAddress"));
            machine.LastChecked = reader.GetDateTime(reader.GetOrdinal("LastChecked"));
            machine.Discovered = reader.GetBoolean(reader.GetOrdinal("Discovered"));
            machine.StatusMessage = reader.GetString(reader.GetOrdinal("StatusMessage"));
            machine.DomainName = reader.GetString(reader.GetOrdinal("DomainName"));
            machine.MachineName = reader.GetString(reader.GetOrdinal("MachineName"));
            machine.CredentialID = reader.GetInt32(reader.GetOrdinal("CredentialID"));

            return machine;
        }
Esempio n. 2
0
        public DBCode InsertDiscover(EntDiscover discover)
        {
            DBCode retCode = DBCode.Ok;
            try
            {
                using (DbTransaction transaction = Connection.BeginTransaction())
                {
                    using (SqlCeCommand command = Connection.CreateCommand())
                    {
                        command.CommandText = @"
                            INSERT INTO Discover
                                (IPAddress, LastChecked, Discovered, StatusMessage, DomainName, MachineName, CredentialID)
                                 VALUES (?, ?, ?, ?, ?, ?, ?)";
                        command.Parameters.Add(new SqlCeParameter("IPAddress",
                            SqlDbType.NVarChar, 20)).Value = discover.IPAddr;
                        command.Parameters.Add(new SqlCeParameter("LastChecked",
                            SqlDbType.DateTime)).Value = DateTime.Now;
                        command.Parameters.Add(new SqlCeParameter("Discovered",
                            SqlDbType.Bit)).Value = discover.Discovered;
                        command.Parameters.Add(new SqlCeParameter("StatusMessage",
                            SqlDbType.NVarChar, 512)).Value = discover.StatusMessage;
                        command.Parameters.Add(new SqlCeParameter("DomainName",
                            SqlDbType.NVarChar, 200)).Value = discover.DomainName;
                        command.Parameters.Add(new SqlCeParameter("MachineName",
                            SqlDbType.NVarChar, 200)).Value = discover.MachineName;
                        command.Parameters.Add(new SqlCeParameter("CredentialID",
                            SqlDbType.Int, 4)).Value = discover.CredentialID;

                        command.ExecuteNonQuery();
                    }
                    transaction.Commit();
                    retCode = DBCode.Ok;
                }
            }
            catch (Exception)
            {
                retCode = DBCode.Error;
            }
            return retCode;
        }
Esempio n. 3
0
        public DBCode UpdateDiscover(EntDiscover discover)
        {
            DBCode retCode = DBCode.Ok;
            try
            {
                using (DbTransaction transaction = Connection.BeginTransaction())
                {
                    using (SqlCeCommand command = Connection.CreateCommand())
                    {
                        command.CommandText = @"
                            UPDATE Discover SET LastChecked = ?, Discovered = ?, StatusMessage = ? WHERE MachineID = ?";

                        command.Parameters.Add(new SqlCeParameter("LastChecked",
                            SqlDbType.DateTime)).Value = DateTime.Now;
                        command.Parameters.Add(new SqlCeParameter("Discovered",
                            SqlDbType.Bit)).Value = discover.Discovered;
                        command.Parameters.Add(new SqlCeParameter("StatusMessage",
                            SqlDbType.NVarChar, 512)).Value = discover.StatusMessage;
                        command.Parameters.Add(new SqlCeParameter("MachineID",
                            SqlDbType.Int, 4)).Value = discover.MachineID;

                        command.ExecuteNonQuery();
                    }
                    transaction.Commit();
                    retCode = DBCode.Ok;
                }
            }
            catch (Exception)
            {
                retCode = DBCode.Error;
            }
            return retCode;
        }
Esempio n. 4
0
 /// <summary>
 /// function called when the Machine found event is raised by the nethelper
 /// </summary>
 /// <param name="sender">Nethelper object</param>
 /// <param name="args">MachineDetailsArgs class contains machine details</param>
 private void netHelper_MachineFound(object sender, MachineDetailsArgs args)
 {
     _logger.Info("Found machine "+args.MachineName);
     EntDiscover objDbMachine = new EntDiscover();
     objDbMachine.DomainName = args.DomainName;
     objDbMachine.MachineName = args.MachineName;
     objDbMachine.IPAddr = args.IPAddress;
     objDbMachine.CredentialID = args.CredentialID;
     objDbMachine.StatusMessage = args.StatusMessage;
     objDbMachine.Discovered = args.Discovered;
     FireStatusMessage("Found machine: " + args.MachineName);
     if (disDB.InsertDiscover(objDbMachine) == DBCode.Ok)
     {
         if (MachineFound != null)
         {
             MachineFound(this, args);
         }
     }
     objDbMachine = null;
 }