Exemplo n.º 1
0
        /// <summary>
        /// OnStart(): Put startup code here
        ///  - Start threads, get inital data, etc.
        /// </summary>
        /// <param name="args"></param>
        protected override void OnStart(string[] args)
        {
            base.OnStart(args);
            string userName = (string)Registry.GetValue("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WakeYourPC\\",
                                                        "UserName", "saimanoj");

            this.EventLog.WriteEntry(string.Format("User name is {0}", userName), EventLogEntryType.Information, 100, 1);
            // Checking whether the username is valid
            UserEntity agentUser = ExternalConnector.GetUser(userName);

            if (agentUser == null)
            {
                this.EventLog.WriteEntry("Invalid User name Or the user is not registered yet" +
                                         string.Format("Please register the {0} first and then try passing as a command line argument.", userName) +
                                         "Exiting Now :-(");
                return;
            }
            UserEntitySingletonFactory.CreateUserEntity(userName);

            _wolPollTimer = new Timer(WolTimerCallback, null, 0, WakeOnLanConstants.WolPollInterval);

            //WOLTimerCallback(null);

            /*string macAddress = MacAddress.GetMac("10.171.41.67");
             *
             * this.EventLog.WriteEntry("MacAddress=" + macAddress);
             * byte[] macBytes = MacAddress.GetMacBytes(macAddress, '-');
             *
             * MagicPacket mp = new MagicPacket(macBytes, "10.171.41.67");
             * mp.WakeUp();
             * bool result = mp.Verify();
             * this.EventLog.WriteEntry(result);*/
        }
Exemplo n.º 2
0
        public static List <MachineEntity> GetMachinesToAwake()
        {
            UserEntity user = UserEntitySingletonFactory.GetInstance();

            if (user == null)
            {
                Console.WriteLine("Cannot Get machines as the User information is not present.");
                return(new List <MachineEntity>());
            }

            return(GetAllResource <MachineEntity>(string.Format(WAKEUP_SUFFIX, user.Username)));
        }
Exemplo n.º 3
0
        public static void UpdateMachineInfo(MachineEntity machineToUpdate)
        {
            UserEntity user = UserEntitySingletonFactory.GetInstance();

            if (user == null)
            {
                Console.WriteLine("Cannot Update machine as the User information is not present.");
                return;
            }

            // TODO check if i should use GUID as resource identifier.
            PutResource(machineToUpdate, string.Format(MACHINE_SUFFIX, user.Username), machineToUpdate.MachineName);
        }