public async Task ExportToExcel(string GridModel, string gridId, int id, string process, int?userId) { ExcelExport exp = new ExcelExport(); GridProperties obj = (GridProperties)Syncfusion.JavaScript.Utils.DeserializeToModel(typeof(GridProperties), GridModel); //Clear if there are any filter columns //syncfusion bug in exporting while in filter mode obj.FilterSettings.FilteredColumns.Clear(); grid = gridId; count = 0; var usersRolesLanguages = await _applicationUsersService.GetUsersAndRolesAndLanguages(); var users = new List <User>(); var userPools = await LicenseMapper.GetUserPools(); users = usersRolesLanguages.Users.Where(u => userPools.Any(p => p == u.UserId)).ToList(); if (gridId == "Qualification") { var lastTrainingPublications = await _prepareService.GetLastPublications((int)PublishModeEnum.Formation); var lastEvaluationPublications = await _prepareService.GetLastPublications((int)PublishModeEnum.Evaluation); var qualificationManageViewModel = await QualificationMapper.ToQualificationManageViewModel(lastTrainingPublications, lastEvaluationPublications, users, userId); var dataSource = qualificationManageViewModel.Qualifications.ToList(); qualificationViewModelData = qualificationManageViewModel.Qualifications.ToList(); var currentDate = DateTime.Today.ToShortDateString().Replace("/", "-"); obj.Columns[10].Field = "Result"; obj.ServerExcelQueryCellInfo = QueryCellInfo; exp.Export(obj, dataSource, LocalizedStrings.GetString("Qualification") + " " + currentDate + ".xlsx", ExcelVersion.Excel2013, false, false, "flat-saffron"); } if (gridId == "QualificationDetail") { var qualification = await _prepareService.GetQualification(id); // Retrieve all the action of the publication var actionSorted = qualification.Publication.PublishedActions.Distinct() .OrderBy(a => a.WBSParts, new WBSPartsComparer()) .ToList(); var qualificationSteps = GetQualificationStepAndChilds(qualification, actionSorted); var trainingPublications = await _prepareService.GetTrainingPublications(new[] { qualification.PublicationId }); var qualificationManageViewModel = QualificationMapper.ToQualificationViewModel(qualification, qualificationSteps, users, trainingPublications); var dataSource = qualificationManageViewModel.Steps.ToList(); qualificationStepViewModelData = qualificationManageViewModel.Steps.ToList(); var currentDate = DateTime.Today.ToShortDateString().Replace("/", "-"); obj.Columns[5].Field = HeadersHelper.IsQualified; obj.ServerExcelQueryCellInfo = QueryCellInfo; exp.Export(obj, dataSource, LocalizedStrings.GetString("QualificationDetail") + " " + process + " " + currentDate + ".xlsx", ExcelVersion.Excel2013, false, false, "flat-saffron"); } }
public async Task <ActionResult> Index(int?userId, bool partial = false) { UserModel user = JwtTokenProvider.GetUserModel(Request.Cookies["token"].Value); if (!userId.HasValue && !user.Roles.Any(r => (new[] { KnownRoles.Administrator, KnownRoles.Supervisor, KnownRoles.Evaluator, KnownRoles.Trainer, KnownRoles.Documentalist }.Contains(r)))) { return(RedirectToAction("Index", new { userId = user.UserId, partial = partial })); } _traceManager.TraceDebug("QualificationController starting index"); var usersRolesLanguages = await _applicationUsersService.GetUsersAndRolesAndLanguages(); var users = usersRolesLanguages.Users.ToList(); var lastTrainingPublications = await _prepareService.GetLastSameMajorPublications((int)PublishModeEnum.Formation); var lastEvaluationPublications = await _prepareService.GetLastSameMajorPublications((int)PublishModeEnum.Evaluation); var qualificationManageViewModel = await QualificationMapper.ToQualificationManageViewModel(lastTrainingPublications, lastEvaluationPublications, users, userId); if (partial) { return(PartialView(qualificationManageViewModel)); } return(View(qualificationManageViewModel)); }