Пример #1
0
        public static int GetLastMinuteRequestCount(LoginUser loginUser, int organizationID)
        {
            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = @"
                    SELECT
                        COUNT(1)
                    FROM
	                    ApiLogs
	                    JOIN 
                        (
                            SELECT
                                organizationId
					        FROM
                                Organizations
                            WHERE
						        organizationId = @organizationId
						        OR parentId = @organizationId
                        ) AS Organizations
		                    ON ApiLogs.organizationId = Organizations.organizationId
                    WHERE
	                    DateCreated > DATEADD(mi, -1, GETUTCDATE())
                        AND ApiLogs.StatusCode <> 403";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@OrganizationID", organizationID);

                ApiLogs apiLogs = new ApiLogs(loginUser);
                return((int)apiLogs.ExecuteScalar(command));
            }
        }
Пример #2
0
        public static ApiLog GetApiLog(LoginUser loginUser, int apiLogID)
        {
            ApiLogs apiLogs = new ApiLogs(loginUser);

            apiLogs.LoadByApiLogID(apiLogID);
            if (apiLogs.IsEmpty)
            {
                return(null);
            }
            else
            {
                return(apiLogs[0]);
            }
        }
Пример #3
0
        public static bool IsUrlBlackListed(LoginUser loginUser, int organizationID, string url)
        {
            using (SqlCommand command = new SqlCommand())
            {
                command.CommandText = @"
                    SELECT COUNT(*)
                    FROM ApiBlacklist
                    WHERE OrganizationID=@OrganizationID
                    AND Url = @url";
                command.CommandType = CommandType.Text;
                command.Parameters.AddWithValue("@OrganizationID", organizationID);
                command.Parameters.AddWithValue("@Url", url);

                ApiLogs apiLogs = new ApiLogs(loginUser);
                return((int)apiLogs.ExecuteScalar(command) > 0);
            }
        }
Пример #4
0
 public ApiLog(DataRow row, ApiLogs apiLogs) : base(row, apiLogs)
 {
     _apiLogs = apiLogs;
 }