public async Task <IActionResult> PostAnalyticsAlmaty( DateTime DateFrom, DateTime DateTo, DateTime TimeFrom, DateTime TimeTo, List <string> MonitoringPostsId) { string url = "api/Analytics/ExcelFormationAlmaty", route = ""; DateTime dateTimeFrom = DateFrom.Date + TimeFrom.TimeOfDay, dateTimeTo = DateTo.Date + TimeTo.TimeOfDay; if (dateTimeFrom != null) { DateTimeFormatInfo dateTimeFormatInfo = CultureInfo.CreateSpecificCulture("en").DateTimeFormat; route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"DateTimeFrom={dateTimeFrom.ToString(dateTimeFormatInfo)}"; } if (dateTimeTo != null) { DateTimeFormatInfo dateTimeFormatInfo = CultureInfo.CreateSpecificCulture("en").DateTimeFormat; route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"DateTimeTo={dateTimeTo.ToString(dateTimeFormatInfo)}"; } if (MonitoringPostsId.Count != 0) { foreach (var monitoringPostId in MonitoringPostsId) { route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"MonitoringPostsId={monitoringPostId}".Replace(',', '.'); } } route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Server={Startup.Configuration["Server"]}"; HttpResponseMessage response = await _HttpApiClient.PostAsync(url + route, null); //if (response.IsSuccessStatusCode) //{ //} ViewBag.ExcelSent = "Excel-файл отправлен на Ваш E-mail"; ViewBag.DateFrom = DateFrom.ToString("yyyy-MM-dd"); ViewBag.TimeFrom = (DateTime.Today).ToString("HH:mm:ss"); ViewBag.DateTo = DateTo.ToString("yyyy-MM-dd"); ViewBag.TimeTo = new DateTime(2000, 1, 1, 23, 59, 00).ToString("HH:mm:ss"); return(View()); }
public async Task <IActionResult> SetMaximumValue(decimal?value) { string url = "api/MeasuredParameters/SetMaximumValue", route = ""; try { HttpResponseMessage response = await _HttpApiClient.PostAsync(url + route, null); ViewBag.SetMaxValue = "Установка значений прошла успешно"; } catch { ViewBag.SetMaxValue = "Установка значений не удалась"; } return(View()); }
public async Task <IActionResult> Create([Bind("Id,Number,Name,AdditionalInformation,NorthLatitude,EastLongitude")] KazHydrometSoilPost kazHydrometSoilPost, string SortOrder, int?NumberFilter, int?PageSize, int?PageNumber) { ViewBag.SortOrder = SortOrder; ViewBag.PageSize = PageSize; ViewBag.PageNumber = PageNumber; ViewBag.NumberFilter = NumberFilter; if (ModelState.IsValid) { int logNumber = kazHydrometSoilPost.Number; decimal logNorthLatitude = kazHydrometSoilPost.NorthLatitude; decimal logEastLongitude = kazHydrometSoilPost.EastLongitude; DateTime logDateTimeStart = DateTime.Now; string url = "api/Logs/AddNote", route = ""; route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"Number={logNumber.ToString()}"; route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"NorthLatitude={logNorthLatitude.ToString()}".Replace(',', '.'); route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"EastLongitude={logEastLongitude.ToString()}".Replace(',', '.'); route += string.IsNullOrEmpty(route) ? "?" : "&"; route += $"DateTimeStart={logDateTimeStart.ToString()}"; HttpResponseMessage responseLog = await _HttpApiClient.PostAsync(url + route, null); HttpResponseMessage response = await _HttpApiClient.PostAsJsonAsync( "api/KazHydrometSoilPosts", kazHydrometSoilPost); string OutputViewText = await response.Content.ReadAsStringAsync(); OutputViewText = OutputViewText.Replace("<br>", Environment.NewLine); try { response.EnsureSuccessStatusCode(); } catch { dynamic errors = JsonConvert.DeserializeObject <dynamic>(OutputViewText); foreach (Newtonsoft.Json.Linq.JProperty property in errors.Children()) { ModelState.AddModelError(property.Name, property.Value[0].ToString()); } return(View(kazHydrometSoilPost)); } return(RedirectToAction(nameof(Index), new { SortOrder = ViewBag.SortOrder, PageSize = ViewBag.PageSize, PageNumber = ViewBag.PageNumber, NumberFilter = ViewBag.NumberFilter })); } return(View(kazHydrometSoilPost)); }