internal static void GetBodyTemporaneo(EmendamentiDto emendamento, AttiDto atto, ref string body) { try { if (!string.IsNullOrEmpty(emendamento.EM_Certificato)) { return; } //EM TEMPORANEO body = body.Replace("{lblTitoloPDLEMView}", $"PROGETTO DI LEGGE N.{atto.NAtto}"); body = body.Replace("{lblSubTitoloPDLEMView}", atto.Oggetto); body = body.Replace("{lblTipoParteEMView}", $"Tipo: {emendamento.TIPI_EM.Tipo_EM}<br/>{Utility.GetParteEM(emendamento)}"); body = body.Replace("{lblEffettiFinanziari}", Utility.EffettiFinanziariEM(emendamento.EffettiFinanziari)); body = body.Replace("{lblTestoEMView}", emendamento.TestoEM_originale); body = !string.IsNullOrEmpty(emendamento.TestoREL_originale) ? body.Replace("{lblTestoRelEMView}", "<b>RELAZIONE ILLUSTRATIVA</b><br />" + emendamento.TestoREL_originale) : body.Replace("{lblTestoRelEMView}", string.Empty); var allegato_generico = string.Empty; var allegato_tecnico = string.Empty; #region Allegato Tecnico //Allegato Tecnico if (!string.IsNullOrEmpty(emendamento.PATH_AllegatoTecnico)) { allegato_tecnico = $"<tr class=\"left-border\" style=\"border-bottom: 1px solid !important\"><td colspan='2' style='text-align:left;padding-left:10px'><a href='{AppSettingsConfiguration.URL_API}/emendamenti/file?path={emendamento.PATH_AllegatoTecnico}' target='_blank'>SCARICA ALLEGATO TECNICO</a></td></tr>"; } #endregion #region Allegato Generico //Allegato Generico if (!string.IsNullOrEmpty(emendamento.PATH_AllegatoGenerico)) { allegato_generico = $"<tr class=\"left-border\" style=\"border-bottom: 1px solid !important\"><td colspan='2' style='text-align:left;padding-left:10px'><a href='{AppSettingsConfiguration.URL_API}/emendamenti/file?path={emendamento.PATH_AllegatoGenerico}' target='_blank'>SCARICA ALLEGATO GENERICO</a></td></tr>"; } #endregion body = body.Replace("{lblAllegati}", allegato_tecnico + allegato_generico); } catch (Exception e) { Log.Error("GetBodyTemporaneo", e); throw e; } }
public async Task ModificaFiles(AttiDto atto) { try { var requestUrl = $"{apiUrl}/atti/fascicoli"; var body = JsonConvert.SerializeObject(atto); await Put(requestUrl, body, _token); } catch (UnauthorizedAccessException ex) { Log.Error("ModificaFilesAtto", ex); throw ex; } catch (Exception ex) { Log.Error("ModificaFilesAtto", ex); throw ex; } }
public async Task <IHttpActionResult> ModificaFilesAtto(AttiDto atto) { try { var attoInDb = await _logic.GetAtto(atto.UIDAtto); if (attoInDb == null) { return(NotFound()); } await _logic.ModificaFascicoli(attoInDb, atto); return(Ok()); } catch (Exception e) { Log.Error("Modifica Fascicoli Atto", e); return(ErrorHandler(e)); } }
public async Task <ActionResult> SalvaAtto(AttiFormUpdateModel atto) { try { if (atto.DocAtto != null) { if (atto.DocAtto.ContentType != "application/pdf") { throw new InvalidOperationException("I file devono essere in formato PDF"); } } AttiDto attoSalvato = null; if (atto.UIDAtto == Guid.Empty) { attoSalvato = await ApiGateway.SalvaAtto(atto); } else { attoSalvato = await ApiGateway.ModificaAtto(atto); } return(Json(new ClientJsonResponse <AttiDto> { entity = attoSalvato, url = Url.Action("RiepilogoAtti", "Atti", new { id = atto.UIDSeduta }) }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { Console.WriteLine(e); return(Json(new ErrorResponse { message = e.Message }, JsonRequestBehavior.AllowGet)); } }
public async Task ModificaFascicoli(ATTI attoInDb, AttiDto attiDto) { try { if (!string.IsNullOrEmpty(attiDto.LinkFascicoloPresentazione)) { attoInDb.LinkFascicoloPresentazione = attiDto.LinkFascicoloPresentazione; attoInDb.DataCreazionePresentazione = DateTime.Now; } if (!string.IsNullOrEmpty(attiDto.LinkFascicoloVotazione)) { attoInDb.LinkFascicoloVotazione = attiDto.LinkFascicoloVotazione; attoInDb.DataCreazioneVotazione = DateTime.Now; } await _unitOfWork.CompleteAsync(); } catch (Exception e) { Log.Error("Modifica Fascicoli Atto", e); throw e; } }
internal static void GetBody(EmendamentiDto emendamento, AttiDto atto, IEnumerable <FirmeDto> firme, PersonaDto currentUser, bool enableQrCode, ref string body) { try { var firmeDtos = firme.ToList(); body = body.Replace("{lblTitoloEMView}", emendamento.N_EM); if (string.IsNullOrEmpty(emendamento.EM_Certificato)) { //EM TEMPORANEO var bodyTemp = GetTemplate(TemplateTypeEnum.FIRMA); GetBodyTemporaneo(emendamento, atto, ref bodyTemp); body = body.Replace("{ltEMView}", bodyTemp); body = body.Replace("{ltTestoModificabile}", "").Replace("{TESTOMOD_COMMENTO_START}", "<!--") .Replace("{TESTOMOD_COMMENTO_END}", "-->"); body = body.Replace("{lblFattoProprioDa}", "").Replace("{FATTOPROPRIO_COMMENTO_START}", "<!--") .Replace("{FATTOPROPRIO_COMMENTO_END}", "-->"); } else { body = body.Replace("{ltEMView}", emendamento.EM_Certificato); #region Emendamento Fatto Proprio Da body = emendamento.UIDPersonaProponenteOLD.HasValue ? body.Replace("{lblFattoProprioDa}", $"L'emendamento ritirato è stato fatto proprio da {emendamento.PersonaProponente.DisplayName}") .Replace("{FATTOPROPRIO_COMMENTO_START}", string.Empty) .Replace("{FATTOPROPRIO_COMMENTO_END}", string.Empty) : body.Replace("{lblFattoProprioDa}", string.Empty) .Replace("{FATTOPROPRIO_COMMENTO_START}", "<!--") .Replace("{FATTOPROPRIO_COMMENTO_END}", "-->"); #endregion #region Testo Modificabile body = !string.IsNullOrEmpty(emendamento.TestoEM_Modificabile) ? body.Replace("{ltTestoModificabile}", emendamento.TestoEM_Modificabile) .Replace("{TESTOMOD_COMMENTO_START}", string.Empty) .Replace("{TESTOMOD_COMMENTO_END}", string.Empty) : body.Replace("{ltTestoModificabile}", string.Empty) .Replace("{TESTOMOD_COMMENTO_START}", "<!--") .Replace("{TESTOMOD_COMMENTO_END}", "-->"); #endregion } #region Firme if (emendamento.IDStato >= (int)StatiEnum.Depositato) { //DEPOSITATO body = body.Replace("{lblDepositoEMView}", firmeDtos.Any(s => s.ufficio) ? "Emendamento Depositato d'ufficio" : $"Emendamento Depositato il {Convert.ToDateTime(emendamento.DataDeposito):dd/MM/yyyy HH:mm}"); var firmeAnte = firmeDtos.Where(f => f.Timestamp <= Convert.ToDateTime(emendamento.DataDeposito)); var firmePost = firmeDtos.Where(f => f.Timestamp > Convert.ToDateTime(emendamento.DataDeposito)); if (firmeAnte.Any()) { body = body.Replace("{radGridFirmeView}", GetFirmatariEM(firmeAnte)) .Replace("{FIRMEANTE_COMMENTO_START}", string.Empty) .Replace("{FIRMEANTE_COMMENTO_END}", string.Empty); } else { body = body.Replace("{radGridFirmeView}", string.Empty) .Replace("{FIRME_COMMENTO_START}", "<!--").Replace("{FIRME_COMMENTO_END}", "-->"); } var TemplatefirmePOST = @"<div> <div style='width:100%;'> <h5>Firme dopo il deposito</h5> </div> <div style='text-align:left'> {firme} </div> </div>"; if (firmePost.Any()) { body = body.Replace("{radGridFirmePostView}", TemplatefirmePOST.Replace("{firme}", GetFirmatariEM(firmePost))) .Replace("{FIRME_COMMENTO_START}", string.Empty) .Replace("{FIRME_COMMENTO_END}", string.Empty); } else { body = body.Replace("{radGridFirmePostView}", string.Empty) .Replace("{FIRME_COMMENTO_START}", "<!--").Replace("{FIRME_COMMENTO_END}", "-->"); } } else { //FIRMATO MA NON DEPOSITATO var firmatari = GetFirmatariEM(firmeDtos); if (!string.IsNullOrEmpty(firmatari)) { body = body.Replace("{lblDepositoEMView}", string.Empty); body = body.Replace("{radGridFirmeView}", firmatari) .Replace("{FIRMEANTE_COMMENTO_START}", string.Empty) .Replace("{FIRMEANTE_COMMENTO_END}", string.Empty); body = body.Replace("{radGridFirmePostView}", string.Empty) .Replace("{FIRME_COMMENTO_START}", "<!--") .Replace("{FIRME_COMMENTO_END}", "-->"); } else { body = body.Replace("{lblDepositoEMView}", string.Empty); body = body.Replace("{FIRMEANTE_COMMENTO_START}", "<!--") .Replace("{FIRMEANTE_COMMENTO_END}", "-->"); body = body.Replace("{radGridFirmePostView}", string.Empty) .Replace("{FIRME_COMMENTO_START}", "<!--") .Replace("{FIRME_COMMENTO_END}", "-->"); } } #endregion body = body.Replace("{lblNotePubblicheEMView}", !string.IsNullOrEmpty(emendamento.NOTE_Griglia) ? $"Note: {emendamento.NOTE_Griglia}" : string.Empty) .Replace("{NOTE_PUBBLICHE_COMMENTO_START}", !string.IsNullOrEmpty(emendamento.NOTE_Griglia) ? string.Empty : "<!--").Replace( "{NOTE_PUBBLICHE_COMMENTO_END}", !string.IsNullOrEmpty(emendamento.NOTE_Griglia) ? string.Empty : "-->"); if (currentUser != null) { if (currentUser.CurrentRole == RuoliIntEnum.Segreteria_Assemblea && !string.IsNullOrEmpty(emendamento.NOTE_EM)) { body = body.Replace("{lblNotePrivateEMView}", $"Note Riservate: {emendamento.NOTE_EM}").Replace("{NOTEPRIV_COMMENTO_START}", string.Empty).Replace("{NOTEPRIV_COMMENTO_END}", string.Empty); } else { body = body.Replace("{lblNotePrivateEMView}", string.Empty) .Replace("{NOTEPRIV_COMMENTO_START}", "<!--") .Replace("{NOTEPRIV_COMMENTO_END}", "-->"); } } else { body = body.Replace("{lblNotePrivateEMView}", string.Empty) .Replace("{NOTEPRIV_COMMENTO_START}", "<!--") .Replace("{NOTEPRIV_COMMENTO_END}", "-->"); } var textQr = string.Empty; if (enableQrCode) { var nameFileQrCode = $"QR_{emendamento.UIDEM}_{DateTime.Now:ddMMyyyy_hhmmss}.png"; //QRCODE var qrFilePathComplete = Path.Combine(AppSettingsConfiguration.CartellaTemp, nameFileQrCode); //QRCODE var qrLink = $"{AppSettingsConfiguration.urlPEM_ViewEM}{emendamento.UID_QRCode}"; var qrGenerator = new QRCodeGenerator(); var urlPayload = new PayloadGenerator.Url(qrLink); var qrData = qrGenerator.CreateQrCode(urlPayload, QRCodeGenerator.ECCLevel.Q); var qrCode = new QRCode(qrData); using (var qrCodeImage = qrCode.GetGraphic(20)) { qrCodeImage.Save(qrFilePathComplete); } textQr = $"<img src=\"{qrFilePathComplete}\" style=\"height:100px; width:100px; border=0;\" />"; } body = body.Replace("{QRCode}", textQr); } catch (Exception e) { Log.Error("GetBodyPDF", e); throw e; } }