Exemplo n.º 1
0
        public static bool IsOrganizationHoliday(int organizationId, DateTime date)
        {
            bool isHoliday = false;

            using (SqlConnection connection = new SqlConnection(LoginUser.GetConnectionString(-1)))
            {
                connection.Open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connection;
                command.CommandText = @"SELECT IsHoliday FROM CalendarEvents WHERE OrganizationID = @organizationId AND @date BETWEEN StartDateUtc AND EndDateUTC";
                command.Parameters.AddWithValue("@organizationId", organizationId);
                command.Parameters.AddWithValue("@date", date);
                command.CommandType = CommandType.Text;

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    isHoliday = (bool)reader["IsHoliday"];
                }

                reader.Close();
                connection.Close();
            }

            return(isHoliday);
        }
Exemplo n.º 2
0
        public static string ReadString(string key, string defaultValue)
        {
            string result = defaultValue;

            using (SqlConnection connection = new SqlConnection(LoginUser.GetConnectionString(-1)))
            {
                connection.Open();

                SqlCommand command = new SqlCommand();
                command.Connection  = connection;
                command.CommandText = "SELECT SettingValue FROM SystemSettings WHERE (SettingKey=@SettingKey)";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@SettingKey", key);

                SqlDataReader reader = command.ExecuteReader(CommandBehavior.SingleRow);
                if (reader.Read())
                {
                    result = (string)reader[0];
                }
                reader.Close();
                connection.Close();
            }

            return(result);
        }
Exemplo n.º 3
0
        public static List <DateTime> GetSpecificDaysToPause(int triggerId)
        {
            List <DateTime> daysToPause = new List <DateTime>();

            using (SqlConnection connection = new SqlConnection(LoginUser.GetConnectionString(-1)))
            {
                connection.Open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connection;
                command.CommandText = @"SELECT DateToPause FROM SlaPausedDays WHERE SlaTriggerId = @triggerId";
                command.Parameters.AddWithValue("@triggerId", triggerId);
                command.CommandType = CommandType.Text;

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    daysToPause.Add((DateTime)reader["DateToPause"]);
                }

                reader.Close();
                connection.Close();
            }

            return(daysToPause);
        }