public async Task <IEnumerable <NotificaDto> > GetNotificheInviate(BaseRequest <NotificaDto> model, PersonaDto currentUser, bool Archivio) { try { Log.Debug($"Logic - GetNotificheInviate - page[{model.page}], pageSize[{model.size}]"); var queryFilter = new Filter <NOTIFICHE>(); queryFilter.ImportStatements(model.filtro); var idGruppo = 0; if (currentUser.CurrentRole == RuoliIntEnum.Responsabile_Segreteria_Politica || currentUser.CurrentRole == RuoliIntEnum.Responsabile_Segreteria_Giunta) { idGruppo = currentUser.Gruppo.id_gruppo; } var notifiche = (await _unitOfWork.Notifiche .GetNotificheInviate(currentUser, idGruppo, Archivio, model.page, model.size, queryFilter)) .Select(Mapper.Map <NOTIFICHE, NotificaDto>) .ToList(); if (!notifiche.Any()) { return(new List <NotificaDto>()); } var result = new List <NotificaDto>(); var firstEM = await _unitOfWork.Emendamenti.Get(notifiche.First().UIDEM); var atto = await _unitOfWork.Atti.Get(firstEM.UIDAtto); var personeInDb = await _unitOfWork.Persone.GetAll(); var personeInDbLight = personeInDb.Select(Mapper.Map <View_UTENTI, PersonaLightDto>).ToList(); foreach (var notifica in notifiche) { notifica.EM = await _logicEm.GetEM_DTO(notifica.UIDEM, atto, currentUser, personeInDbLight); notifica.UTENTI_NoCons = await _logicPersone.GetPersona(notifica.Mittente, notifica.EM.id_gruppo >= AppSettingsConfiguration.GIUNTA_REGIONALE_ID); result.Add(notifica); } return(result); } catch (Exception e) { Log.Error("Logic - GetNotificheInviate", e); throw e; } }
public async Task <PersonaDto> GetPersona(SessionManager session) { return(await _logicPersona.GetPersona(session)); }
public async Task <HttpResponseMessage> EsportaGrigliaWord(Guid id, OrdinamentoEnum ordine, PersonaDto persona) { try { var _pathTemp = AppSettingsConfiguration.CartellaTemp; if (!Directory.Exists(_pathTemp)) { Directory.CreateDirectory(_pathTemp); } var nameFileDOC = $"EstrazioneEM_{DateTime.Now:ddMMyyyy_hhmmss}.docx"; var FilePathComplete = Path.Combine(_pathTemp, nameFileDOC); var atto = await _unitOfWork.Atti.Get(id); using (var fs = new FileStream(FilePathComplete, FileMode.Create, FileAccess.Write)) { var doc = new XWPFDocument(); var para = doc.CreateParagraph(); para.Alignment = ParagraphAlignment.CENTER; var r0 = para.CreateRun(); r0.IsBold = true; r0.SetText($"{atto.TIPI_ATTO.Tipo_Atto} {atto.NAtto}"); var table = doc.CreateTable(1, 7); #region HEADERS var c0 = table.GetRow(0).GetCell(0); var headerCell0 = c0.AddParagraph(); headerCell0.Alignment = ParagraphAlignment.CENTER; var headerCell0_Run = headerCell0.CreateRun(); headerCell0_Run.IsBold = true; headerCell0_Run.SetText("Ordine di Votazione"); var c1 = table.GetRow(0).GetCell(1); var headerCell1 = c1.AddParagraph(); headerCell1.Alignment = ParagraphAlignment.CENTER; var headerCell1_Run = headerCell1.CreateRun(); headerCell1_Run.IsBold = true; headerCell1_Run.SetText("N.EM/SUBEM"); var c2 = table.GetRow(0).GetCell(2); var headerCell2 = c2.AddParagraph(); headerCell2.Alignment = ParagraphAlignment.CENTER; var headerCell2_Run = headerCell2.CreateRun(); headerCell2_Run.IsBold = true; headerCell2_Run.SetText("Testo EM/SUBEM"); var c3 = table.GetRow(0).GetCell(3); var headerCell3 = c3.AddParagraph(); headerCell3.Alignment = ParagraphAlignment.CENTER; var headerCell3_Run = headerCell3.CreateRun(); headerCell3_Run.IsBold = true; headerCell3_Run.SetText("Relazione Illustrativa"); var c4 = table.GetRow(0).GetCell(4); var headerCell4 = c4.AddParagraph(); headerCell4.Alignment = ParagraphAlignment.CENTER; var headerCell4_Run = headerCell4.CreateRun(); headerCell4_Run.IsBold = true; headerCell4_Run.SetText("Proponente"); var c5 = table.GetRow(0).GetCell(5); var headerCell5 = c5.AddParagraph(); headerCell5.Alignment = ParagraphAlignment.CENTER; var headerCell5_Run = headerCell5.CreateRun(); headerCell5_Run.IsBold = true; headerCell5_Run.SetText("Firme prima del deposito"); var c6 = table.GetRow(0).GetCell(6); var headerCell6 = c6.AddParagraph(); headerCell6.Alignment = ParagraphAlignment.CENTER; var headerCell6_Run = headerCell6.CreateRun(); headerCell6_Run.IsBold = true; headerCell6_Run.SetText("Stato"); #endregion var emList = await _logicEm.GetEmendamenti(new BaseRequest <EmendamentiDto> { id = id, ordine = ordine, page = 1, size = 50 }, persona, (int)ClientModeEnum.GRUPPI); foreach (var em in emList) { var row = table.CreateRow(); var c0_em = row.GetCell(0); var headerCell0_em = c0_em.AddParagraph(); headerCell0_em.Alignment = ParagraphAlignment.CENTER; var headerCell0_Run_em = headerCell0_em.CreateRun(); headerCell0_Run_em.SetText(em.OrdineVotazione.ToString()); var c1_em = row.GetCell(1); var headerCell1_em = c1_em.AddParagraph(); headerCell1_em.Alignment = ParagraphAlignment.CENTER; var headerCell1_Run_em = headerCell1_em.CreateRun(); headerCell1_Run_em.SetText(GetNomeEM(em, em.Rif_UIDEM.HasValue ? Mapper.Map <EM, EmendamentiDto>(await _logicEm.GetEM(em.Rif_UIDEM.Value)) : null)); var c2_em = row.GetCell(2); var headerCell2_em = c2_em.AddParagraph(); headerCell2_em.Alignment = ParagraphAlignment.CENTER; var headerCell2_Run_em = headerCell2_em.CreateRun(); headerCell2_Run_em.SetText(em.TestoEM_originale); var c3_em = row.GetCell(3); var headerCell3_em = c3_em.AddParagraph(); headerCell3_em.Alignment = ParagraphAlignment.CENTER; var headerCell3_Run_em = headerCell3_em.CreateRun(); headerCell3_Run_em.SetText(string.IsNullOrEmpty(em.TestoREL_originale) ? "" : em.TestoREL_originale); var proponente = await _logicPersone.GetPersona(em.UIDPersonaProponente.Value, em.id_gruppo >= AppSettingsConfiguration.GIUNTA_REGIONALE_ID); var c4_em = row.GetCell(4); var headerCell4_em = c4_em.AddParagraph(); headerCell4_em.Alignment = ParagraphAlignment.CENTER; var headerCell4_Run_em = headerCell4_em.CreateRun(); headerCell4_Run_em.SetText(proponente.DisplayName); var firme = await _logicFirme.GetFirme(Mapper.Map <EmendamentiDto, EM>(em), FirmeTipoEnum.TUTTE); var firmeDto = firme.Select(Mapper.Map <FIRME, FirmeDto>).ToList(); var firmeAnte = firmeDto.Where(f => f.Timestamp < Convert.ToDateTime(Decrypt(em.DataDeposito))); var c5_em = row.GetCell(5); var headerCell5_em = c5_em.AddParagraph(); headerCell5_em.Alignment = ParagraphAlignment.CENTER; var headerCell5_Run_em = headerCell5_em.CreateRun(); headerCell5_Run_em.SetText(GetFirmatariEM_OPENDATA(firmeAnte, persona.CurrentRole)); var c6_em = row.GetCell(6); var headerCell6_em = c6_em.AddParagraph(); headerCell6_em.Alignment = ParagraphAlignment.CENTER; var headerCell6_Run_em = headerCell6_em.CreateRun(); headerCell6_Run_em.SetText(em.STATI_EM.Stato); } doc.Write(fs); } var stream = new MemoryStream(); using (var fileStream = new FileStream(FilePathComplete, FileMode.Open)) { await fileStream.CopyToAsync(stream); } stream.Position = 0; var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(stream.GetBuffer()) }; result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = nameFileDOC }; result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); return(result); } catch (Exception e) { Log.Error("Logic - EsportaGrigliaXLS", e); throw e; } }