Ejemplo n.º 1
0
    public void AddInputWithPriority(Vector3 input, ControlPriority priority)
    {
        input.y = 0f;
        switch (priority)
        {
        case ControlPriority.Ghost:
            if (!_catchHappened)
            {
                _ghostInputVector = input;
            }
            else
            {
                _ghostInputVector = Vector3.zero;
            }
            break;

        case ControlPriority.Hunter:
            _hunterInputVector = input;
            break;

        default:
            _standardInputVector = input;
            break;
        }
    }
Ejemplo n.º 2
0
        public bool Update(string ConnectionString, ControlPriority ControlPriority)
        {
            #region Preconditions

            if (string.IsNullOrWhiteSpace(ConnectionString))
            {
                throw new InvalidOperationException();
            }

            if (ControlPriority == null)
            {
                throw new ArgumentNullException();
            }

            #endregion

            try
            {
                string storedProcedureName = "usp_ControlPriorityUpdate";

                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        command.CommandType = CommandType.StoredProcedure;
                        command.Connection  = connection;
                        command.CommandText = storedProcedureName;

                        command.Parameters.AddWithValue("@ControlPriorityId", ControlPriority.Id);
                        command.Parameters.AddWithValue("@Name", ControlPriority.Name);
                        command.Parameters.AddWithValue("@Description", ControlPriority.Description);

                        if (ControlPriority.DefinitionSource != null)
                        {
                            command.Parameters.AddWithValue("@DefinitionSourceId", ControlPriority.DefinitionSource.Id);
                        }

                        connection.Open();
                        command.ExecuteNonQuery();
                        connection.Close();
                        return(true);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        public IEnumerable <ControlPriority> GetControlPriorities(string ConnectionString, int?Id = null)
        {
            #region Preconditions

            if (string.IsNullOrWhiteSpace(ConnectionString))
            {
                throw new InvalidOperationException();
            }

            #endregion

            try
            {
                string storedProcedureName = "usp_ControlPrioritiesGet";

                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        var controlPriorities = new List <ControlPriority>();

                        command.CommandType = CommandType.StoredProcedure;
                        command.Connection  = connection;
                        command.CommandText = storedProcedureName;

                        if (Id != null)
                        {
                            command.Parameters.AddWithValue("@ControlPriorityId", Id);
                        }

                        connection.Open();

                        var reader = command.ExecuteReader();

                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                var cp = new ControlPriority();

                                cp.Id = reader.GetInt32((int)ControlPrioritiesndices.ControlPriorityId);

                                cp.Name = reader.GetString((int)ControlPrioritiesndices.Name);

                                if (!reader.IsDBNull((int)ControlPrioritiesndices.Description))
                                {
                                    cp.Description = reader.GetString((int)ControlPrioritiesndices.Description);
                                }

                                cp.DefinitionSource = new DefinitionSource
                                {
                                    Id   = reader.GetInt32((int)ControlPrioritiesndices.DefinitionSourceId),
                                    Code = reader.GetString((int)ControlPrioritiesndices.DefinitionSourceCode),
                                    MagpieCoreDefinitionSourceGuid = (!reader.IsDBNull((int)ControlPrioritiesndices.MagpieCoreDefinitionSourceGuid)) ? reader.GetGuid((int)ControlPrioritiesndices.MagpieCoreDefinitionSourceGuid) : (Guid?)null,
                                    Source = reader.GetString((int)ControlPrioritiesndices.DefinitionSource)
                                };

                                controlPriorities.Add(cp);
                            }
                        }

                        reader.Close();

                        return(controlPriorities);
                    }
                }
            }
            catch (Exception ex)
            {
                string res = ex.ToString();
                throw;
            }
        }
Ejemplo n.º 4
0
        public int?Create(string ConnectionString, ControlPriority ControlPriority)
        {
            #region Preconditions

            if (string.IsNullOrWhiteSpace(ConnectionString))
            {
                throw new InvalidOperationException();
            }

            if (ControlPriority == null)
            {
                throw new ArgumentNullException();
            }

            #endregion

            try
            {
                string storedProcedureName = "usp_ControlPriorityCreate";

                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    using (SqlCommand command = new SqlCommand())
                    {
                        int?newId = null;

                        command.CommandType = CommandType.StoredProcedure;
                        command.Connection  = connection;
                        command.CommandText = storedProcedureName;

                        command.Parameters.AddWithValue("@Name", ControlPriority.Name);

                        if (ControlPriority.Description != null)
                        {
                            command.Parameters.AddWithValue("@Description", ControlPriority.Description);
                        }

                        if (ControlPriority.DefinitionSource != null)
                        {
                            command.Parameters.AddWithValue("@DefinitionSourceId", ControlPriority.DefinitionSource.Id);
                        }

                        SqlParameter outPutVal = new SqlParameter("@NewId", SqlDbType.Int);
                        outPutVal.Direction = ParameterDirection.Output;
                        command.Parameters.Add(outPutVal);

                        connection.Open();
                        command.ExecuteNonQuery();
                        connection.Close();

                        if (outPutVal.Value != DBNull.Value)
                        {
                            newId = Convert.ToInt32(outPutVal.Value);
                        }

                        return(newId);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }