Exemplo n.º 1
0
 public IActionResult EditBuilding(int keyid)
 {
     if (EditesChecker.IsMaxEditesPerDay())
     {
         return(PartialView("EditBuildingModal", new UserBuilding {
             Keyid = keyid
         }));
     }
     else
     {
         _logger.LogWarning($"Превышен лимит правок в день. ({HttpContext.Connection.RemoteIpAddress.ToString()})");
         return(StatusCode(StatusCodes.Status405MethodNotAllowed, "Превышен лимит правок в день."));
     }
 }
Exemplo n.º 2
0
        public IActionResult EditBuilding(UserBuilding userbuilding)
        {
            if (ModelState.IsValid)
            {
                userbuilding.IpAddressUser = HttpContext.Connection.RemoteIpAddress.ToString();
                var usersTable = _layersList.Value.FirstOrDefault(o => o.Name == "users_data");
                if (usersTable != null)
                {
                    using (GisAccess gis = new GisAccess(usersTable))
                    {
                        //if (gis.IsMaxEditesPerDay())
                        //{
                        int retry_cnt = 5;
                        int cnt       = retry_cnt;
                        do
                        {
                            --cnt;
                            try
                            {
                                gis.WriteUserData(userbuilding);
                                EditesChecker.AddEditsCnt();
                                break;
                            }
                            catch (Exception ex)
                            {
                                _logger.LogError($"Not write userdata {retry_cnt - cnt}/{retry_cnt}. {ex.Message}");
                                Thread.Sleep(2);
                            }
                        } while (cnt > 0);
                        //}
                    }
                }
            }

            return(PartialView("EditBuildingModal", userbuilding));
        }