예제 #1
0
        public async Task <FileResult> Report(int Id)
        {
            try
            {
                this._logger.Information($"Start {nameof(Report)} Id = {Id}");

                ISession     session = _services.GetRequiredService <IHttpContextAccessor>()?.HttpContext.Session;
                SessionLogIn ses     = session.GetJson <SessionLogIn>("ses");

                Employee employee = await _plinovodiDutyDataRead.GetEmployee(ses.EmployeeId);

                Duty duty = await _plinovodiDutyDataRead.GetDuty(Id);

                IEnumerable <Intervention> interventionList = await _plinovodiDutyDataRead.GetInterventions(Id);

                var stream = PlinovodiDezurstvaUtils.GenerateReport(employee, duty, interventionList);

                Response.Headers.Append("content-disposition", "inline; filename=file.pdf");

                this._logger.Information($"End {nameof(Report)}");
                return(File(stream.ToArray(), "application/pdf", $"{employee.Name}{employee.Surname}{duty.From.ToString("d.M.yy")}.pdf"));
            }
            catch (Exception ex)
            {
                this._logger.Error($"Error {nameof(Report)} {ex.Message} {ex.StackTrace}");
                throw ex;
            }
        }
예제 #2
0
        public async Task <ViewResult> Index()
        {
            try
            {
                this._logger.Information($"Start {nameof(Index)}");

                ISession     session = _services.GetRequiredService <IHttpContextAccessor>()?.HttpContext.Session;
                SessionLogIn ses     = session.GetJson <SessionLogIn>("ses");
                IEnumerable <Intervention> interventionList = await _plinovodiDutyDataRead.GetInterventions(ses.DutyId);

                this._logger.Information($"End {nameof(Index)}");
                return(View(interventionList));
            }
            catch (Exception ex)
            {
                this._logger.Error($"Error {nameof(Index)} {ex.Message} {ex.StackTrace}");
                throw ex;
            }
        }