Exemplo n.º 1
0
        public ActionResult <PrisonerVM> AddPrisoner(PrisonerDTO prisonerDTO)
        {
            string userName      = User.Identity.Name;
            var    prisonerModel = _mapper.Map <Prisoner>(prisonerDTO);

            _prisonerService.CreatePrisoner(prisonerModel);
            _prisonerService.SaveChanges();
            _loggerService.AddLog(controller, "Dodano więźnia", userName);

            return(Ok());
        }
 private void MoveFiledPackage(string PathFileStart, string PathFileEnd)
 {
     try
     {
         File.Move(PathFileStart, PathFileEnd);
         _consoleService.ConsoleAddText("Fichier déplacer: " + PathFileEnd, 3);
         _loggerService.AddLog(3, "Fichier déplacer: " + PathFileEnd);
     }
     catch (IOException ioe)
     {
         _consoleService.ConsoleAddText("MoveFiledPackage==>" + ioe.ToString(), 2);
         _loggerService.AddLog(2, "MoveFiledPackage==>" + ioe.ToString());
     }
 }
Exemplo n.º 3
0
        public ActionResult <Cell> AllCell()
        {
            string userName = User.Identity.Name;

            try
            {
                var cell = _cellService.AllCell(userName);
                return(new JsonResult(cell));
            }
            catch (Exception ex)
            {
                _loggerService.AddLog(controller, ex.Message, userName);
                return(NoContent());
            }
        }
Exemplo n.º 4
0
        public ActionResult <IsolationVM> AddPass([FromBody] IsolationDTO isolationDTO)
        {
            string userName       = User.Identity.Name;
            var    isolationModel = _mapper.Map <Isolation>(isolationDTO);

            if (isolationModel == null)
            {
                return(NotFound());
            }
            _isolationService.CreateIsolation(isolationModel);
            _isolationService.SetPrisonerStatusTrue(isolationModel);
            _isolationService.SaveChanges();
            _loggerService.AddLog(controller, "Dodano więźnia do izolatki", userName);
            return(Ok(StatusCode(200)));
        }
        public ActionResult <Punishment> AddPunishment([FromBody] PunishmentDTO punishmentDTO)
        {
            string userName = User.Identity.Name;

            var punishmentModel = _mapper.Map <Punishment>(punishmentDTO);

            if (punishmentModel == null)
            {
                return(NotFound());
            }
            _punishmentService.CreatePunishment(punishmentModel);
            _punishmentService.SaveChanges();
            _loggerService.AddLog(controller, "Dodano karę dla więźnia", userName);

            return(Ok(StatusCode(200)));
        }
Exemplo n.º 6
0
        public ActionResult <CellVM> AddCell(CellDTO cellDTO)
        {
            string userName = User.Identity.Name;

            var cellModel = _mapper.Map <Cell>(cellDTO);

            cellModel.IdPrison = _cellService.PrisonID(userName);
            if (cellModel.Id == null)
            {
                return(NotFound());
            }
            _cellService.CreateCell(cellModel);
            _cellService.SaveChanges();
            _loggerService.AddLog(controller, "Dodano nową cele", userName);
            return(Ok());
        }
Exemplo n.º 7
0
        public ActionResult <PassVM> AddPass(PassDTO passDTO)
        {
            string userName  = User.Identity.Name;
            var    passModel = _mapper.Map <Pass>(passDTO);

            if (passModel == null)
            {
                return(NotFound());
            }
            _passService.CreatePass(passModel);
            _passService.SetPrisonerStatusTrue(passModel);
            _passService.SaveChanges();

            _loggerService.AddLog(controller, "Dodano przepustkę więźnia", userName);

            return(Ok());
        }
Exemplo n.º 8
0
 public async Task AddLog(string message)
 {
     await _logger.AddLog(new Log
     {
         HOSTNAME    = Request.GetDisplayUrl(),
         HOSTADDRESS = HttpContext.Connection.RemoteIpAddress.ToString(),
         MANAGERID   = int.Parse(User.Claims.Where(c => c.Type == ClaimTypes.Sid).Select(s => s.Value).SingleOrDefault()),
         MESSAGE     = message
     });
 }
Exemplo n.º 9
0
        public async Task <IActionResult> Index(Manager manager)
        {
            var redirectUri = "/dashboard";

            var r = _login.Get(manager.USERNAME, manager.PASSWORD);

            if (r != null)
            {
                var claims = new List <Claim>
                {
                    new Claim(ClaimTypes.Name, r.USERNAME),
                    new Claim(ClaimTypes.Sid, r.MANAGERID.ToString()),
                    new Claim(ClaimTypes.Role, "Manager"),
                    new Claim(ClaimTypes.Hash, r.TOKEN)
                };

                var userIndentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);

                var authProperties = new AuthenticationProperties
                {
                    IsPersistent = true,
                    ExpiresUtc   = DateTime.UtcNow.AddDays(1),
                    RedirectUri  = redirectUri
                };

                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(userIndentity), authProperties);

                await _logger.AddLog(new Log
                {
                    HOSTNAME    = Request.GetDisplayUrl(),
                    HOSTADDRESS = HttpContext.Connection.RemoteIpAddress.ToString(),
                    MANAGERID   = r.MANAGERID,
                    MESSAGE     = "Giriş yapıldı."
                });

                return(Redirect(redirectUri));
            }
            else
            {
                ViewData["script"] = "swal('Giriş','Hatalı Giriş','error')";
                return(View());
            }
        }
Exemplo n.º 10
0
        public async Task <Result <CompanyInfo> > FoundCompany(string query)
        {
            return(await Task.Run(() =>
            {
                Result <CompanyInfo> result = new Result <CompanyInfo>();

                try
                {
                    var list = _repositoryEgrul.GetCollectionCompany(query);

                    if (list == null || !list.Any())
                    {
                        result.ErrorResult = new ErrorResult("Данных нет", EnumTypeError.ResultNotFound);
                    }
                    else
                    {
                        result.Items = list.Select(x =>
                        {
                            return new CompanyInfo()
                            {
                                Address = x.Address,
                                Director = x.Director,
                                Inn = x.Inn,
                                Ogrn = x.Ogrn,
                                Title = x.Title,
                                DateOgrn = x.DateOgrn,
                                DateRemove = x.DateRemove,
                                FullTitle = x.FullTitle,
                                Kpp = x.Kpp,
                                TokenLoadFile = x.TokenLoadFile
                            };
                        });
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorResult = new ErrorResult(ex.Message, EnumTypeError.ErrorSite);
                    _logger.AddLog(ex.Message);
                }

                return result;
            }).ConfigureAwait(false));
        }
Exemplo n.º 11
0
        public List <EntityPerson> GetPersons(string fileName)
        {
            List <EntityPerson> list = new List <EntityPerson>();

            var str = File.ReadLines(fileName).Skip(1);

            foreach (var item in str)
            {
                try
                {
                    var obj = JsonConvert.DeserializeObject <Response>(item);

                    list.Add(obj.CollectionPerson[0]);
                }
                catch (Exception ex)
                {
                    _logger?.AddLog(ex.Message);
                    _logger?.AddLog(item);
                }
            }

            return(list);
        }
Exemplo n.º 12
0
        private void ReaderHandler(Process p, StreamReader strReader, bool sendFinish)
        {
            try
            {
                string line = "";
                while ((line = strReader.ReadLine()) != null)
                {
                    _consoleService.ConsoleAddText("Console===>" + line, 0);
                    _loggerService.AddLog(0, line);
                }
                if (sendFinish)
                {
                    _eventAggregator.GetEvent <CmdIsFinishEvent>().Publish();
                }
            }
            catch (IOException ioe)
            {
                _consoleService.ConsoleAddText("ReaderHandler---->" + ioe.ToString(), 2);
                _loggerService.AddLog(2, "ReaderHandler---- > " + ioe.ToString());
            }

            p.Close();
        }
Exemplo n.º 13
0
        public async Task <Result <CompanyInfo> > FoundCompany(string query)
        {
            return(await Task.Run(() =>
            {
                Result <CompanyInfo> result = new Result <CompanyInfo>();

                try
                {
                    var list = _repositorySpark.FoundCompany(query);

                    result.Items = list.Select(x =>
                    {
                        return new CompanyInfo()
                        {
                            Address = x.Address,
                            Director = x.Director,
                            Inn = x.Inn,
                            Link = x.Link,
                            Ogrn = x.Ogrn,
                            Title = x.Title
                        };
                    });

                    if (!result.Items.Any())
                    {
                        result.ErrorResult = new ErrorResult("Данных нет", EnumTypeError.ResultNotFound);
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorResult = new ErrorResult(ex.Message, EnumTypeError.ErrorBd);
                    _logger.AddLog(ex.Message);
                }

                return result;
            }).ConfigureAwait(false));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Index()
        {
            await _logger.AddLog(new Log
            {
                HOSTNAME    = Request.GetDisplayUrl(),
                HOSTADDRESS = HttpContext.Connection.RemoteIpAddress.ToString(),
                MANAGERID   = int.Parse(User.Claims.Where(c => c.Type == ClaimTypes.Sid).Select(s => s.Value).SingleOrDefault()),
                MESSAGE     = "Gösterge listelendi."
            });

            ViewData["StudentCount"] = _dashboard.GetStudentCount();
            ViewData["LessonCount"]  = _dashboard.GetLessonCount();
            ViewData["ClassCount"]   = _dashboard.GetClassCount();
            return(View());
        }
Exemplo n.º 15
0
 public async void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
 {
     _loggerService.AddLog(logLevel.ToString(), state.ToString());
 }