예제 #1
0
            private void LoadRoles()
            {
                if (m_roles != null)
                {
                    return;
                }

                m_roles = new RobotList <Role>();

                // No roles to load on new users.
                if (IsNew)
                {
                    return;
                }

                Query q = new StoredProc("usp_GetUsersRoles");

                q.CnnStr = Helpers.Config["DB:Security"];
                q.Parameters.AddWithValue("@Username", Login);

                IList <int> roles = q.ExecuteList <int>();

                foreach (int role in roles)
                {
                    Role r = UserSecurity.Roles.Find(Role.ById, role);

                    if (r != null)
                    {
                        m_roles.Add(r);
                    }
                }
            }
예제 #2
0
        private void CreateNewOrg()
        {
            EditOrganizationForm dlg = new EditOrganizationForm(null);

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                m_organizations.Add(dlg.Organization);
                suppSelList.EditValue = dlg.Organization.Id;
            }
        }
예제 #3
0
        private void CreateNewOrg()
        {
            EditOrganizationForm dlg = new EditOrganizationForm(null);

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                RobotList <Organization> orgs = (RobotList <Organization>)
                                                customerEdit.Properties.DataSource;

                orgs.Add(dlg.Organization);
                customerEdit.EditValue = dlg.Organization.Id;
            }
        }
예제 #4
0
        public bool InputRobotData(string type, string name, int x, int y, int price, int distance, int power)
        {
            switch (type)
            {
            case "c":

                var newCleaningRobot = new CleaningRobot(Utils.CreateNewIndex(RobotList), name, price, x, y, distance, power);
                RobotList.Add(newCleaningRobot);
                return(true);

            case "d":

                var newDogRobot = new DogRobot(Utils.CreateNewIndex(RobotList), name, price, x, y, distance, power);
                RobotList.Add(newDogRobot);
                return(true);

            default:
                return(false);
            }
        }
예제 #5
0
    private IEnumerator handleRegistrations()
    {
        while (continueRegistrationRoutine)
        {
            if (_continueRegistration)
            {
                // Debug.Log("Handling new registration request on main thread");

                _continueRegistration = false;

                Communicator connection = _connection;
                Message      newMessage = _newMessage;

                _ev.Set();

                //TODO: Replace nao with the variable from the message that indicates the type
                // Debug.Log("newMessage: " + newMessage.identificationResponse);
                string robotType = newMessage.identificationResponse.robotType.ToLower();
                Debug.LogFormat("Robot type: {0}", robotType);

                //Get the robot object which contains a Robot component with predefined shape data (this is a reference object)
                GameObject robotPrefab = null;

                switch (robotType)
                {
                case "nao":
                {
                    robotPrefab = RobotRefModel_Nao;
                    break;
                }

                case "nxt":
                {
                    robotPrefab = RobotRefModel_NXT;
                    break;
                }

                default:
                {
                    robotType   = "default";
                    robotPrefab = RobotRefModel_Default;
                    break;
                }
                }

                // Clone the reference object
                GameObject robotGameObject = (GameObject)Instantiate(robotPrefab, robotPrefab.transform.position, Quaternion.identity, robotObjectContainer.transform);

                // Check if the object actually has the oh-so-important robot component
                Robot robot = robotGameObject.GetComponent <Robot>();

                // An idiot removed the component from the prefab or had gone to another dimension
                if (robot == null)
                {
                    throw new ArgumentNullException("Expected gameObject to contain a robot component: robot_prefab_" + robotType);
                }

                // Reset and (re-)initialise the robot script
                robot.Init(connection, ++robotIdentityID, "Unknown harry", robotType);

                robotList.Add(robot);
                robot.Communicator.GetPresentationProtocol().SetReceiver(robot);
                robot.Communicator.GetDataLink().SetReceiver(robot.Communicator.GetPresentationProtocol());

                robot.Indicate();

                //Accept connection not as a general client but as a robot
                communicators.Remove(connection);
            }
            else
            {
                yield return(new WaitForSeconds(0.01F));
            }
        }

        yield return(null);
    }