static string Greet(int hour)
{
int timeNow = hour;
string hi = "";
if ((timeNow >= 6) & (timeNow <= 12))
hi = "Доброе утро, ";
else if ((timeNow >= 12) & (timeNow <= 18))
hi = "Добрый день, ";
else hi = "Добрый вечер, ";
return hi;
}
Console.WriteLine(Greet(5)); // Добрый вечер
Console.WriteLine(Greet(6)); // Доброе утро
Console.WriteLine(Greet(7)); // Доброе утро
Console.WriteLine(Greet(11)); // Доброе утро
Console.WriteLine(Greet(12)); // Доброе утро
Console.WriteLine(Greet(13)); // Добрый день
Console.WriteLine(Greet(17)); // Добрый день
Console.WriteLine(Greet(18)); // Добрый день
Console.WriteLine(Greet(19)); // Добрый вечер
builder.Services.AddControllers()
.ConfigureApiBehaviorOptions(options =>
{
options.SuppressConsumesConstraintForFormFileParameters = true;
options.SuppressInferBindingSourcesForParameters = true;
options.SuppressModelStateInvalidFilter = true; // вот это
options.SuppressMapClientErrors = true;
options.ClientErrorMapping[StatusCodes.Status404NotFound].Link =
"https://httpstatuses.com/404";
});
я не могу его передать в сервисный класс.
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Так же я не могу понять, как его правильно зарегистрировать в Program.cs, что бы внедрить его в конвейер DI
Проблема заключается в том, что мне нужно получить путь к статической папке
http {
...
limit_req_zone $binary_remote_addr zone=reqlimit:10m rate=30r/s;
...
}
server {
...
location / {
...
limit_req zone=reqlimit burst=10 nodelay;
}
}
[Definition]
failregex = limiting requests, excess: .* by zone .*, client: <HOST>
ignoreregex =
[nginx-req-limit]
enabled = true
port = http,https
filter = nginx-req-limit
logpath = /var/www/*/*/logs/error.log # Здесь укажите свой путь к логам виртуального хоста
findtime = 600
maxretry = 10
bantime = 7200
(ns su.gornostaev.rstatfr2csv
(:use [clojure.xml :only (parse)])
(:use [clojure.string :only [index-of join split]])
(:use [clojure.java.io])
(:import java.io.File))
(defn parse-cmd
[args]
(when-let [file-name (first args)]
file-name))
(defn parse-file
[file-name]
(if (nil? file-name) nil (parse (File. file-name))))
(defn format-datetime
[dt]
(let [[date time] (split dt #"\s")]
(str (join "." (reverse (split date #"\."))) " " (subs time 0 (index-of time \:)) ":00")))
(defn merge-counters
[counters]
(map
(fn [item]
(let [[k & v] item]
(assoc (reduce (fn [acc val] (merge-with + acc val)) (first v)) :dt k)))
(reduce
(fn [acc val]
(let [{:keys [dt in out]} val]
(update-in acc [dt] (fnil #(conj % {:in in :out out}) []))))
{} counters)))
(defn parse-counters
[sensor]
(map
(fn [counter]
{:dt (format-datetime (:datetime (:attrs counter)))
:in (read-string (:realin (:attrs counter)))
:out (read-string (:realout (:attrs counter)))})
sensor))
(defn parse-sensors
[shop]
(map
(fn [sensor]
{:name (:name (:attrs sensor)) :counters (merge-counters (parse-counters (:content sensor)))})
shop))
(defn parse-shops
[dom]
(map
(fn [shop]
{:name (:name (:attrs shop)) :sensors (seq (parse-sensors (:content shop)))})
dom))
(defn parse-doc
[doc]
(parse-shops
(->>
doc
:content
first
:content)))
(defn save-csv
[data]
(with-open [w (writer (file "output.csv"))]
(doseq [shop data]
(doseq [sensor (:sensors shop)]
(doseq [counter (:counters sensor)]
(.write w (str (join "\t" (concat [(:name shop) (:name sensor)] (vals (into (sorted-map) counter)))) "\n")))))))
(save-csv (parse-doc (parse-file (parse-cmd *command-line-args*))))