Esempio n. 1
0
        public async Task <int> UploadFileAsync(IFormFile uploadedFile,
                                                Guid yearId,
                                                Guid departmentId,
                                                Guid documentTitleId,
                                                Guid userId)
        {
            if (uploadedFile != null)
            {
                // путь к папке Files
                string path = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Files"), DateTime.Now.Ticks.ToString() + uploadedFile.FileName);
                // сохраняем файл в папку Files в каталоге wwwroot
                using (var fileStream = new FileStream(path, FileMode.Create))
                {
                    await uploadedFile.OpenReadStream().CopyToAsync(fileStream);
                }

                Guid reportingYearDocumentTitleId = await _documentManagerService.GetCurrentReportingYearDocumentTitleId(yearId, documentTitleId);

                if (reportingYearDocumentTitleId != null)
                {
                    DepartmentsDocument departmentsDocument = await _documentManagerService.GetDepartmentsDocument(departmentId, reportingYearDocumentTitleId);

                    return(await SaveDocumentPathAsync(departmentsDocument.Id, uploadedFile.FileName, path, userId));
                }
            }
            return(-1);
        }
Esempio n. 2
0
        public async Task <IActionResult> OnGetAsync(Guid yearId, Guid departmentId, Guid documentTypeId, Guid documentTitleId)
        {
            try
            {
                if (!await _getAccountDataService.UserIsHaveAnyRoleOnDepartment(departmentId))
                {
                    return(NotFound());
                }
                selectedReportingYearId = yearId;
                selectedDepartmentId    = departmentId;
                selectedDocumentTypeId  = documentTypeId;
                selectedDocumentTitleId = documentTitleId;

                user = await _getAccountDataService.GetCurrentUser();

                DocumentsTitle = await db.DocumentTitle.FirstOrDefaultAsync(dt => dt.Id.Equals(documentTitleId));

                IsUserTheChecker = await _getAccountDataService.UserIsCheckerOnDepartment(departmentId);

                AllAvailabledocumentStatuses = await db.DocumentStatus.ToListAsync();

                departmentsDocument = await _documentManagerService
                                      .GetDepartmentsDocument(departmentId,
                                                              await _documentManagerService.GetCurrentReportingYearDocumentTitleId(yearId, documentTitleId));

                DocumentStatusHistories = await db.DocumentStatusHistory
                                          .Include(dsh => dsh.DocumentStatus)
                                          .Where(dd => dd.DepartmentsDocumentId == departmentsDocument.Id)
                                          .OrderBy(dd => dd.SettingDateTime)
                                          .Include(dsh => dsh.User)
                                          .ToListAsync();

                UploadedDocuments = await db.DepartmentsDocumentsVersion
                                    .Where(ddv => ddv.DepartmentDocumentId == departmentsDocument.Id)
                                    .OrderByDescending(ddv => ddv.UploadedDateTime)
                                    .Include(ddv => ddv.User)
                                    .ToListAsync();

                var CurrentBreadCrumb = await _breadcrumbService.GetDocumentBreadCrumbNodeAsync(
                    yearId,
                    departmentId,
                    documentTypeId,
                    documentTitleId);

                ViewData["BreadcrumbNode"] = CurrentBreadCrumb;
                ViewData["Title"]          = CurrentBreadCrumb.Title;

                return(Page());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error while getting document page");
                return(NotFound());
            }
        }