public void CreateApplication(VooProtocol protocol)
 {
     Console.WriteLine("Application: CreateApplication(VooProtocol protocol)");
     application = protocol.Get("application");
     Console.WriteLine("Application: CreateApplication -> application = '{0}'", application);
 }
 protected void RemoveApplication(VooProtocol protocol)
 {
     Console.WriteLine("Application: RemoveApplication(VooProtocol protocol)");
     application = String.Empty;
     Console.WriteLine("Application: RemoveApplication -> application = '{0}'", protocol.Get("application"));
 }
        protected void UnRegisterUser(VooProtocol protocol)
        {
            Console.WriteLine("Application: UnRegisterUser(VooProtocol protocol)");

            User user = FindUser(protocol.Get("username"), protocol.Get("password"), true);
            if (user != null)
            {
                Console.WriteLine("Application: UnRegisterUser -> username = '******', password = '******'", user.UserName, user.Password);
                users.Remove(user);
                Console.WriteLine("Application: UnRegisterUser -> Done.");
            }
        }
 protected void Push(VooProtocol protocol)
 {
     Console.WriteLine("Application: Push(VooProtocol protocol)");
     VooFile file = new VooFile(protocol.Source, protocol.Destination, protocol.Get("from"), protocol.Get("to"), Convert.ToInt64(protocol.Get("size")));
     Console.WriteLine("Application: Push from = '{0}', to = '{1}', size = '{2}'", file.From, file.To, file.Size);
     pushes.Add(file);
 }
 protected void RegisterUser(VooProtocol protocol)
 {
     Console.WriteLine("Application: RegisterUser(VooProtocol protocol)");
     User user = new User(protocol.Get("username"), protocol.Get("password"));
     Console.WriteLine("Application: RegisterUser -> username = '******', password = '******'", user.UserName, user.Password);
     users.Add(user);
 }
 protected void LoginUser(VooProtocol protocol)
 {
     Console.WriteLine("Application: LoginUser(VooProtocol protocol)");
     currentUser = FindUser(protocol.Get("username"), protocol.Get("password"), true);
     if (currentUser != null)
     {
         Console.WriteLine("Application: LoginUser -> username = '******', password = '******'",
             currentUser.UserName, currentUser.Password);
     }
     else
     {
         Console.WriteLine("Application: LoginUser -> User can't be found.");
     }
 }
 protected void Fetch(VooProtocol protocol)
 {
     Console.WriteLine("Application: Fetch(VooProtocol protocol)");
     Console.WriteLine("Application: Fetch -> from = '{0}', to = '{1}'",
         protocol.Get("from"), protocol.Get("to"));
     VooFile file = new VooFile(protocol.Source, protocol.Destination,
         protocol.Get("from"), protocol.Get("to"));
     fetches.Add(file);
     Console.WriteLine("Application: Fetch -> read data");
     file.ReadToEnd();
     RS485PacketManager manager = new RS485PacketManager(new RS485_dll.Voodoo.Libraries.RS485Library.RS485Terminal.InputData(RS485Packet.PriorityEnum.Highest,
         file.Data, protocol.Destination, protocol.Source, protocol.Destination), 32);
     RS485Packet packet = new RS485Packet(protocol.Destination, protocol.Destination, protocol.Source,
         RS485Packet.PriorityEnum.Highest, RS485Packet.CommandEnum.Data, protocol.CreatePushCommand());
     manager.Packets.Insert(0, packet);
     Console.WriteLine("Application: Call send packets.");
     RS485VooEvents.Instance.SendPackets(manager);
 }
        protected void ExecuteCommand(VooProtocol protocol)
        {
            Console.WriteLine("Application: ExecuteCommand(VooProtocol protocol)");

            String result = String.Empty;
            switch (protocol.CurrentPacket.Key)
            {
                case VooProtocol.Commands.CLIENT_CD:
                    String temp = protocol.Get("folder");
                    if (temp == "..")
                    {
                        if (application.Split('\\').Length > 1)
                        {
                            application = application.Substring(0, application.LastIndexOf('\\') + 1);
                        }
                    }
                    else
                    {
                        application = Path.Combine(application, temp);
                    }
                    RS485VooEvents.Instance.SendPackets(new RS485PacketManager(
                        new RS485_dll.Voodoo.Libraries.RS485Library.RS485Terminal.InputData(RS485Packet.PriorityEnum.Highest,
                            DirAction(application), protocol.Destination, protocol.Source, protocol.Destination), 64));
                    break;
                case VooProtocol.Commands.CLIENT_DIR:
                    RS485VooEvents.Instance.SendPackets(new RS485PacketManager(
                        new RS485_dll.Voodoo.Libraries.RS485Library.RS485Terminal.InputData(RS485Packet.PriorityEnum.Highest,
                            DirAction(Path.Combine(application, protocol.Get("application"))), protocol.Destination, protocol.Source, protocol.Destination), 64));
                    break;
            }
            RS485VooEvents.Instance.OutputData(result);
        }
 protected void EndSession(VooProtocol protocol)
 {
     Console.WriteLine("Application: EndSession(VooProtocol protocol)");
     machine = protocol.Get("machine");
     Console.WriteLine("Application: EndSession -> Remove machine('{0}') from sessions.", machine);
     if (!String.IsNullOrEmpty(machine) && sessions.Count > 0)
     {
         sessions.Remove(machine);
         machine = null;
         Console.WriteLine("Application: EndSession -> Done.", machine);
     }
 }
        protected void BeginSession(VooProtocol protocol)
        {
            Console.WriteLine("Application: BeginSession(VooProtocol protocol)");
            machine = protocol.Get("machine");
            Console.WriteLine("Application: BeginSession -> machine is {0}.", machine);

            // Store last machine.
            if (currentUser != null && !String.IsNullOrEmpty(machine))
            {
                sessions.Add(machine);
                Console.WriteLine("Application: BeginSession -> Add machine('{0}') to session.", machine);
                Console.WriteLine("Application: BeginSession -> Done.", machine);
            }
        }