public async Task <IHttpActionResult> ModificaMetaDatiEmendamento(EmendamentiDto model) { try { var em = await _logicEm.GetEM(model.UIDEM); if (em == null) { return(NotFound()); } var session = await GetSession(); var persona = await _logicPersone.GetPersona(session._currentUId); persona.CurrentRole = session._currentRole; await _logicEm.ModificaMetaDatiEmendamento(model, em, persona); return(Ok()); } catch (Exception e) { Log.Error("ModificaMetaDatiEmendamento", e); return(ErrorHandler(e)); } }
public async Task <ActionResult> SalvaEmendamento(EmendamentiDto model) { try { var apiGateway = new ApiGateway(_Token); if (model.UIDEM == Guid.Empty) { await apiGateway.Emendamento.Salva(model); return(Json(Url.Action("RiepilogoEmendamenti", "Emendamenti", new { id = model.UIDAtto }), JsonRequestBehavior.AllowGet)); } await apiGateway.Emendamento.Modifica(model); return(Json(Url.Action("ViewEmendamento", "Emendamenti", new { id = model.UIDEM }), JsonRequestBehavior.AllowGet)); } catch (Exception e) { Console.WriteLine(e); return(Json(new ErrorResponse(e.Message), JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Controlla che l'emendamento sia firmabile /// </summary> /// <param name="em"></param> /// <param name="persona"></param> /// <returns></returns> public async Task <bool> CheckIfFirmabile(EmendamentiDto em, PersonaDto persona) { if (em.STATI_EM.IDStato > (int)StatiEnum.Depositato) { return(false); } var firma_personale = await CheckFirmato(em.UIDEM, persona.UID_persona); var firma_proponente = await CheckFirmato(em.UIDEM, em.UIDPersonaProponente.Value); if (firma_personale == false && (firma_proponente || em.UIDPersonaProponente == persona.UID_persona) && (persona.CurrentRole == RuoliIntEnum.Consigliere_Regionale || persona.CurrentRole == RuoliIntEnum.Assessore_Sottosegretario_Giunta || persona.CurrentRole == RuoliIntEnum.Presidente_Regione)) { return(true); } if (persona.CurrentRole != RuoliIntEnum.Amministratore_PEM && persona.CurrentRole != RuoliIntEnum.Segreteria_Assemblea) { return(false); } var firmatoUfficio = await CheckFirmatoDaUfficio(em.UIDEM); return(!firmatoUfficio); }
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; } }
/// <summary> /// Metodo per visualizzare la parte dell'emendamento /// </summary> /// <param name="em"></param> /// <returns></returns> public static string GetParteEM(EmendamentiDto em) { switch (em.PARTI_TESTO.IDParte) { case PartiEMEnum.Titolo_PDL: return(em.PARTI_TESTO.Parte); case PartiEMEnum.Titolo: return($"Titolo: {em.NTitolo}"); case PartiEMEnum.Capo: return($"Capo: {em.NCapo}"); case PartiEMEnum.Articolo: { var strArticolo = string.Empty; if (em.UIDArticolo.HasValue) { strArticolo += $"Articolo: {em.ARTICOLI.Articolo}"; } if (em.UIDComma.HasValue && em.UIDComma.GetValueOrDefault() != Guid.Empty) { strArticolo += $", Comma: {em.COMMI.Comma}"; } if (!string.IsNullOrEmpty(em.NLettera)) { strArticolo += $", Lettera: {em.NLettera}"; } else { if (em.UIDLettera.HasValue) { strArticolo += $", Lettera: {em.LETTERE.Lettera}"; } } return(strArticolo); } case PartiEMEnum.Missione: return($"Missione: {em.NMissione} Programma: {em.NProgramma} titolo: {em.NTitoloB}"); case PartiEMEnum.Allegato_Tabella: return("Allegato/Tabella"); default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Controlla che l'emendamento sia modificabile dall'utente /// </summary> /// <param name="em"></param> /// <param name="persona"></param> /// <returns></returns> public async Task <bool> CheckIfModificabile(EmendamentiDto em, PersonaDto persona) { if (string.IsNullOrEmpty(em.EM_Certificato)) { return(em.UIDPersonaProponente == persona.UID_persona || em.UIDPersonaCreazione == persona.UID_persona || persona.CurrentRole == RuoliIntEnum.Responsabile_Segreteria_Politica || persona.CurrentRole == RuoliIntEnum.Responsabile_Segreteria_Giunta); } return((em.UIDPersonaProponente == persona.UID_persona || em.UIDPersonaCreazione == persona.UID_persona) && (em.IDStato == (int)StatiEnum.Bozza || em.IDStato == (int)StatiEnum.Bozza_Riservata) && em.ConteggioFirme == 1); }
/// <summary> /// Controlla che l'emendamento sia depositabile /// </summary> /// <param name="em"></param> /// <param name="persona"></param> /// <returns></returns> public async Task <bool> CheckIfDepositabile(EmendamentiDto em, PersonaDto persona) { if (!string.IsNullOrEmpty(em.DataDeposito)) { return(false); } if (persona.CurrentRole == RuoliIntEnum.Amministratore_PEM || persona.CurrentRole == RuoliIntEnum.Segreteria_Assemblea) { if (em.Firma_da_ufficio) { return(true); } } var firmaProponente = await PRContext .FIRME .FindAsync(em.UIDEM, em.UIDPersonaProponente); // Se proponente non ha firmato non è possibile depositare if (firmaProponente == null) { return(false); } // Se proponente ha ritirato la firma non è possibile depositare if (!string.IsNullOrEmpty(firmaProponente.Data_ritirofirma)) { return(false); } switch (persona.CurrentRole) { case RuoliIntEnum.Consigliere_Regionale: case RuoliIntEnum.Assessore_Sottosegretario_Giunta: case RuoliIntEnum.Presidente_Regione: return(em.UIDPersonaProponente == persona.UID_persona); case RuoliIntEnum.Amministratore_PEM: case RuoliIntEnum.Segreteria_Assemblea: return(true); } if (persona.Gruppo != null) { return(em.id_gruppo == persona.Gruppo.id_gruppo); } return(false); }
private string ComposeBodyRow(EmendamentiDto em) { var row = string.Empty; row += "<tr>"; row += ComposeBodyColumn(em.OrdineVotazione.ToString()); row += ComposeBodyColumn(em.N_EM); row += ComposeBodyColumn(em.TestoEM_originale); row += ComposeBodyColumn(em.TestoREL_originale); row += ComposeBodyColumn(em.PersonaProponente.DisplayName); row += ComposeBodyColumn(em.STATI_EM.Stato); row += "</tr>"; return(row); }
/// <summary> /// Controlla che l'emendamento sia modificabile dall'utente /// </summary> /// <param name="em"></param> /// <param name="persona"></param> /// <returns></returns> public async Task <bool> CheckIfModificabile(EmendamentiDto em, PersonaDto persona) { if (string.IsNullOrEmpty(em.EM_Certificato)) { return(em.UIDPersonaProponente == persona.UID_persona || em.UIDPersonaCreazione == persona.UID_persona || persona.CurrentRole == RuoliIntEnum.Responsabile_Segreteria_Politica || persona.CurrentRole == RuoliIntEnum.Responsabile_Segreteria_Giunta); } var counter = await PRContext.FIRME.CountAsync(f => f.UIDEM == em.UIDEM && string.IsNullOrEmpty(f.Data_ritirofirma)); return((em.UIDPersonaProponente == persona.UID_persona || em.UIDPersonaCreazione == persona.UID_persona) && (em.IDStato == (int)StatiEnum.Bozza || em.IDStato == (int)StatiEnum.Bozza_Riservata) && counter == 1); }
public bool CheckIfNotificabile(EmendamentiDto em, PersonaDto persona) { if (em.IDStato >= (int)StatiEnum.Depositato) { return(false); } if (em.ATTI.Chiuso) { return(false); } if (persona.CurrentRole == RuoliIntEnum.Amministratore_PEM || persona.CurrentRole == RuoliIntEnum.Segreteria_Assemblea) { return(true); } if (em.id_gruppo != persona.Gruppo.id_gruppo) { return(false); } if (persona.CurrentRole == RuoliIntEnum.Consigliere_Regionale || persona.CurrentRole == RuoliIntEnum.Assessore_Sottosegretario_Giunta || persona.CurrentRole == RuoliIntEnum.Presidente_Regione) { if (em.UIDPersonaProponente.Value != persona.UID_persona) { return(false); } var firma = PRContext.FIRME.Find(em.UIDEM, persona.UID_persona); if (firma == null) { return(false); } if (!string.IsNullOrEmpty(firma.Data_ritirofirma)) { return(false); } } return(true); }
internal static string GetNomeEM(EmendamentiDto emendamento, EmendamentiDto emendamento_riferimento) { try { var result = string.Empty; if (emendamento.Rif_UIDEM.HasValue == false) { //EMENDAMENTO if (!string.IsNullOrEmpty(emendamento.N_EM)) { result = "EM " + DecryptString(emendamento.N_EM, AppSettingsConfiguration.masterKey); } else { result = "TEMP " + emendamento.Progressivo; } } else { //SUB EMENDAMENTO if (!string.IsNullOrEmpty(emendamento.N_SUBEM)) { result = "SUBEM " + DecryptString(emendamento.N_SUBEM, AppSettingsConfiguration.masterKey); } else { result = "SUBEM TEMP " + emendamento.SubProgressivo; } var n_em_riferimento = GetNomeEM(emendamento_riferimento, null); result = $"{result} all' {n_em_riferimento}"; } return(result); } catch (Exception e) { Log.Error("GetNomeEM", e); throw e; } }
/// <summary> /// Controlla che l'emendamento sia eliminabile /// </summary> /// <param name="em"></param> /// <param name="persona"></param> /// <returns></returns> public bool CheckIfEliminabile(EmendamentiDto em, PersonaDto persona) { if (persona.Gruppo == null) { return(false); } if (em.id_gruppo != persona.Gruppo.id_gruppo) { return(false); } if (!string.IsNullOrEmpty(em.DataDeposito)) { return(false); } return(persona.CurrentRole == RuoliIntEnum.Responsabile_Segreteria_Politica || persona.CurrentRole == RuoliIntEnum.Responsabile_Segreteria_Giunta || persona.UID_persona == em.UIDPersonaCreazione); }
public async Task ModificaMetaDati(EmendamentiDto model) { try { var requestUrl = $"{apiUrl}/emendamenti/meta-dati"; var body = JsonConvert.SerializeObject(model); await Put(requestUrl, body, _token); } catch (UnauthorizedAccessException ex) { Log.Error("ModificaMetaDatiEmendamento", ex); throw ex; } catch (Exception ex) { Log.Error("ModificaMetaDatiEmendamento", ex); throw ex; } }
public async Task <IHttpActionResult> ModificaEmendamento(EmendamentiDto model) { try { var em = await _logicEm.GetEM(model.UIDEM); if (em == null) { return(NotFound()); } var session = await GetSession(); var persona = await _logicPersone.GetPersona(session); if (persona.CurrentRole != RuoliIntEnum.Amministratore_PEM && persona.CurrentRole != RuoliIntEnum.Segreteria_Assemblea) { var countFirme = await _logicFirme.CountFirme(model.UIDEM); if (countFirme > 1) { return(BadRequest( $"Non è possibile modificare l'emendamento. Ci sono ancora {countFirme} attive.")); } } await _logicEm.ModificaEmendamento(model, em, persona); return(Ok()); } catch (Exception e) { Log.Error("ModificaEmendamento", e); return(ErrorHandler(e)); } }
public async Task <EmendamentiDto> Salva(EmendamentiDto model) { try { var requestUrl = $"{apiUrl}/emendamenti"; if (model.DocAllegatoGenerico != null) { using var memoryStream = new MemoryStream(); await model.DocAllegatoGenerico.InputStream.CopyToAsync(memoryStream); model.DocAllegatoGenerico_Stream = memoryStream.ToArray(); } if (model.DocEffettiFinanziari != null) { using var memoryStream = new MemoryStream(); await model.DocEffettiFinanziari.InputStream.CopyToAsync(memoryStream); model.DocEffettiFinanziari_Stream = memoryStream.ToArray(); } var body = JsonConvert.SerializeObject(model); var result = JsonConvert.DeserializeObject <EmendamentiDto>(await Post(requestUrl, body, _token)); return(result); } catch (UnauthorizedAccessException ex) { Log.Error("SalvaEmendamento", ex); throw ex; } catch (Exception ex) { Log.Error("SalvaEmendamento", ex); throw ex; } }
public static async Task Modifica(EmendamentiDto model) { try { var requestUrl = $"{apiUrl}/emendamenti"; if (model.DocAllegatoGenerico != null) { using var memoryStream = new MemoryStream(); await model.DocAllegatoGenerico.InputStream.CopyToAsync(memoryStream); model.DocAllegatoGenerico_Stream = memoryStream.ToArray(); } if (model.DocEffettiFinanziari != null) { using var memoryStream = new MemoryStream(); await model.DocEffettiFinanziari.InputStream.CopyToAsync(memoryStream); model.DocEffettiFinanziari_Stream = memoryStream.ToArray(); } var body = JsonConvert.SerializeObject(model); await Put(requestUrl, body); } catch (UnauthorizedAccessException ex) { Log.Error("ModificaEmendamento", ex); throw ex; } catch (Exception ex) { Log.Error("ModificaEmendamento", ex); throw ex; } }
public static void CreaPDF(string txtHTML, string path, EmendamentiDto em, string urlPEM) { try { if (string.IsNullOrEmpty(txtHTML)) { throw new Exception("Nessun testo da inserire nel PDF."); } if (string.IsNullOrEmpty(path)) { throw new Exception("Percorso del PDF non valido."); } //Create a byte array that will eventually hold our final PDF byte[] bytes; //Boilerplate iTextSharp setup here //Create a stream that we can write to, in this case a MemoryStream using (var ms = new MemoryStream()) { //Create an iTextSharp Document which is an abstraction of a PDF but **NOT** a PDF using (var doc = new Document(new Rectangle(600, 800), 20, 20, 20, 60)) { //Create a writer that's bound to our PDF abstraction and our stream using (var writer = PdfWriter.GetInstance(doc, ms)) { var ev = new ITextEvents { EM = em }; writer.PageEvent = ev; //Open the document for writing doc.Open(); //XMLWorker also reads from a TextReader and not directly from a string var hDocument = new HtmlDocument { OptionWriteEmptyNodes = true, OptionAutoCloseOnEnd = true }; hDocument.LoadHtml(txtHTML); txtHTML = hDocument.DocumentNode.WriteTo(); try { //Parse the HTML using (var srHtml = new StringReader(txtHTML)) { XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, srHtml); } } catch (Exception ex) { try { using (var srHtml = new StringReader(txtHTML.Replace("<ol", "<div").Replace("</ol>", "</div>"))) { XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, srHtml); } } catch (Exception ex2) { var linkPemError = $"{urlPEM}/{em.UIDEM}"; using (var srHtml_ERR = new StringReader( $"<html><body>ATTENZIONE, Si è verificato un problema durante la generazione del pdf di questo EM/SUBEM: {ex2.Message} <br/> L'emendamento/subemendamento è stato comunque correttamente acquisito dal sistema ed è visualizzabile attraverso la piattaforma PEM all'indirizzo <a href='{linkPemError}'>{linkPemError}</a></body></html>") ) { XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, srHtml_ERR); } } } doc.Close(); } } //After all of the PDF "stuff" above is done and closed but **before** we //close the MemoryStream, grab all of the active bytes from the stream bytes = ms.ToArray(); } //Now we just need to do something with those bytes. //Here I'm writing them to disk but if you were in ASP.Net you might Response.BinaryWrite() them. //You could also write the bytes to a database in a varbinary() column (but please don't) or you //could pass them to another function for further PDF processing. //var testFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.pdf"); File.WriteAllBytes(path, bytes); //********************************************************************************** //MAX: ELIMINO LA FUFFA //********************************************************************************** //try //{ // if (File.Exists(path)) File.Delete(path); //} //catch (Exception ex) //{ // Log.Error("[CreaPDF]: Impossibile eliminare il file temporaneo " + path + " -->", ex); //} //********************************************************************************** } catch (Exception ex) { Log.Error("CreaPDF Error-->", ex); throw ex; } }
internal static void GetBodyPDF(EmendamentiDto emendamento, IEnumerable <FirmeDto> firme, PersonaDto currentUser, ref string body) { try { var firmeDtos = firme.ToList(); body = body.Replace("{lblTitoloEMView}", emendamento.DisplayTitle); if (string.IsNullOrEmpty(emendamento.EM_Certificato)) { //EM TEMPORANEO var bodyEMView = string.Empty; GetBodyTemporaneo(emendamento, ref bodyEMView); body = body.Replace("{ltEMView}", bodyEMView); 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.STATI_EM.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)); body = body.Replace("{radGridFirmeView}", GetFirmatariEM(firmeAnte)) .Replace("{FIRMEANTE_COMMENTO_START}", string.Empty) .Replace("{FIRMEANTE_COMMENTO_END}", string.Empty); 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 body = body.Replace("{lblDepositoEMView}", string.Empty); body = body.Replace("{radGridFirmeView}", GetFirmatariEM(firmeDtos)) .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}", "-->"); } #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.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}", "-->"); } body = body.Replace("{QRCode}", string.Empty); } catch (Exception e) { Log.Error("GetBodyPDF", e); throw e; } }
public async Task <IEnumerable <FIRME> > GetFirme(EmendamentiDto emDto, FirmeTipoEnum tipo) { var em = await _unitOfWork.Emendamenti.Get(emDto.UIDEM); return(await GetFirme(em, tipo)); }
public async Task <IHttpActionResult> NuovoEmendamento(EmendamentiDto model) { try { if (!model.UIDPersonaProponente.HasValue) { return(BadRequest("L'emendamento deve avere un proponente")); } if (model.IDParte == 0) { return(BadRequest("E' obbligatorio indicare l'elemento da emendare")); } if (model.IDTipo_EM == 0) { return(BadRequest("E' obbligatorio indicare il modo")); } if (string.IsNullOrEmpty(model.TestoEM_originale)) { return(BadRequest("Il testo dell'emendamento non può essere vuoto")); } if (model.IDParte == (int)PartiEMEnum.Articolo) { if (!model.UIDArticolo.HasValue) { return(BadRequest("Manca il valore dell'articolo")); } } if (model.IDParte == (int)PartiEMEnum.Capo) { if (string.IsNullOrEmpty(model.NCapo)) { return(BadRequest("Manca il valore del capo")); } } if (model.IDParte == (int)PartiEMEnum.Titolo) { if (string.IsNullOrEmpty(model.NTitolo)) { return(BadRequest("Manca il valore del titolo")); } } if (model.IDParte == (int)PartiEMEnum.Missione) { if (!model.NTitoloB.HasValue || !model.NMissione.HasValue || !model.NProgramma.HasValue) { return(BadRequest("I valori Missione - Programma - Titolo sono obbligatori")); } } var isGiunta = model.id_gruppo == AppSettingsConfiguration.GIUNTA_REGIONALE_ID; var proponente = await _logicPersone.GetPersona(model.UIDPersonaProponente.Value, isGiunta); var em = await _logicEm.NuovoEmendamento(model, proponente, isGiunta); return(Created(new Uri(Request.RequestUri + "/" + em.UIDEM), em)); } catch (Exception e) { Log.Error("NuovoEmendamento", e); return(ErrorHandler(e)); } }
internal static void GetBodyMail(EmendamentiDto emendamento, IEnumerable <FirmeDto> firme, bool isDeposito, ref string body) { try { var firmeDtos = firme.ToList(); if (isDeposito) { body = body.Replace("{MESSAGGIOINIZIALE}", AppSettingsConfiguration.MessaggioInizialeDeposito.Replace("{br}", "<br/>")); body = body.Replace("{azione}", "visualizzare"); body = body.Replace("{LINKPEMRIEPILOGO_FIRME}", string.Empty); } else { body = body.Replace("{MESSAGGIOINIZIALE}", AppSettingsConfiguration.MessaggioInizialeInvito.Replace("{br}", "<br/>")); body = body.Replace("{azione}", "firmare"); body = body.Replace("{LINKPEMRIEPILOGO_FIRME}", "<a href='" + string.Format(AppSettingsConfiguration.urlPEM_RiepilogoEM, emendamento.UIDAtto) + "'>Clicca qui</a> per visualizzare gli em in cui sei indicato come firmatario."); } body = body.Replace("{lblTitoloEMView}", emendamento.N_EM); body = body.Replace("{ltEMView}", emendamento.EM_Certificato); #region Firme if (emendamento.STATI_EM.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)); body = body.Replace("{radGridFirmeView}", GetFirmatariEM(firmeAnte)); var TemplatefirmePOST = @"<div> <div style='width:100%;'> <h5>Firme dopo il deposito</h5> </div> <div style='text-align:left'> {firme} </div> </div>"; body = body.Replace("{radGridFirmePostView}", firmePost.Any() ? TemplatefirmePOST.Replace("{firme}", GetFirmatariEM(firmePost)) : string.Empty); } #endregion body = body.Replace("{IMGLOGO}", "<img src='" + Path.Combine(AppSettingsConfiguration.urlPEM, "/images/LogoCRL120px.gif") + " style='120px;'/>"); body = body.Replace("{LINKPEM}", $"{AppSettingsConfiguration.urlPEM_ViewEM}{emendamento.UID_QRCode}"); body = body.Replace("{LINKPEMRIEPILOGO}", string.Empty); } catch (Exception e) { Log.Error("GetBodyMail", 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; } }
public async Task <IHttpActionResult> NuovoEmendamento(EmendamentiDto model) { try { if (!model.UIDPersonaProponente.HasValue) { return(BadRequest("L'emendamento deve avere un proponente")); } if (model.IDParte == 0) { return(BadRequest("E' obbligatorio indicare l'elemento da emendare")); } if (model.IDTipo_EM == 0) { return(BadRequest("E' obbligatorio indicare il modo")); } if (string.IsNullOrEmpty(model.TestoEM_originale)) { return(BadRequest("Il testo dell'emendamento non può essere vuoto")); } if (model.IDParte == (int)PartiEMEnum.Articolo) { if (!model.UIDArticolo.HasValue) { return(BadRequest("Manca il valore dell'articolo")); } } if (model.IDParte == (int)PartiEMEnum.Capo) { if (string.IsNullOrEmpty(model.NCapo)) { return(BadRequest("Manca il valore del capo")); } } if (model.IDParte == (int)PartiEMEnum.Titolo) { if (string.IsNullOrEmpty(model.NTitolo)) { return(BadRequest("Manca il valore del titolo")); } } if (model.IDParte == (int)PartiEMEnum.Missione) { if (!model.NTitoloB.HasValue || !model.NMissione.HasValue || !model.NProgramma.HasValue) { return(BadRequest("I valori Missione - Programma - Titolo sono obbligatori")); } } var isGiunta = model.id_gruppo >= AppSettingsConfiguration.GIUNTA_REGIONALE_ID; var proponente = await _logicPersone.GetPersona(model.UIDPersonaProponente.Value, isGiunta); var em = await _logicEm.NuovoEmendamento(model, proponente, isGiunta); var atto = await _unitOfWork.Atti.Get(em.UIDAtto); var personeInDb = await _unitOfWork.Persone.GetAll(); var personeInDbLight = personeInDb.Select(Mapper.Map <View_UTENTI, PersonaLightDto>).ToList(); return(Ok(await _logicEm.GetEM_DTO(em.UIDEM, atto, null, personeInDbLight))); } catch (Exception e) { Log.Error("NuovoEmendamento", e); return(ErrorHandler(e)); } }
/// <summary> /// Metodo per avere i metadati dell'emendamento in formato visualizzabile /// </summary> /// <param name="em"></param> /// <returns></returns> public static string MetaDatiEM_Label(EmendamentiDto em) { var result = $"Emendamento {em.TIPI_EM.Tipo_EM} - {GetParteEM(em)}"; return(result); }