/// <summary> /// Ricerca di una proprietà dell'oggetto da pubblicare nella storicizzazione dell'ultima pubblicazione effettuata /// </summary> /// <param name="propertyName">Nome della proprietà dell'oggetto</param> /// <param name="rule">Dati della regola</param> /// <returns></returns> protected virtual Property FindStoredProperty(string propertyName, BaseRuleInfo rule) { // Reperimento, dall'history, dei dati relativi all'ultima esecuzione della regola per l'oggetto da pubblicare RuleHistoryInfo lastExecutedRule = DataAccess.RuleHistoryDataAdapter.GetLastRuleHistory(rule.Id, this.ListenerRequest.EventInfo.PublishedObject.IdObject); return(this.FindStoredProperty(propertyName, lastExecutedRule)); }
/// <summary> /// Scrittura esito dell'esecuzione della regola /// </summary> /// <param name="rule"></param> protected virtual void WriteRuleHistory(BaseRuleInfo rule) { // Scrittura elemento di pubblicazione nell'history RuleHistoryInfo historyInfo = RuleHistoryInfo.CreateInstance(rule); historyInfo.Author = this.ListenerRequest.EventInfo.Author; historyInfo.ObjectSnapshot = this.ListenerRequest.EventInfo.PublishedObject; historyInfo = DataAccess.RuleHistoryDataAdapter.SaveHistoryItem(historyInfo); }
/// <summary> /// Ricerca di una proprietà dell'oggetto da pubblicare nella storicizzazione di una pubblicazione effettuata /// </summary> /// <param name="propertyName">Nome della proprietà dell'oggetto</param> /// <param name="lastExecutedRule">Dati storicizzati della regola</param> /// <returns></returns> protected virtual Property FindStoredProperty(string propertyName, RuleHistoryInfo lastExecutedRule) { Property p = null; if (lastExecutedRule != null && lastExecutedRule.ObjectSnapshot != null) { p = lastExecutedRule.ObjectSnapshot.Properties.Where(e => e.Name.ToLowerInvariant().Trim() == propertyName.ToLowerInvariant().Trim()).FirstOrDefault(); } return(p); }
/// <summary> /// /// </summary> /// <param name="subRule"></param> protected override void InternalExecuteSubRule(SubRuleInfo subRule) { if (this.AreEquals(subRule.SubRuleName, SUBRULE_NAME_TERMINE_DICHIARAZIONE_TERZO)) { // La scadenza legata al termine dichiarazione del terzo // deve essere calcolata se e solo se il campo dichiarazione // è impostato "A mezzo raccomandata" // Reperimento del valore del campo dichiarazione Property pDichiarazione = this.FindProperty(FIELD_NAME_DICHIARAZIONE); if (pDichiarazione != null) { if (!pDichiarazione.IsEmpty) { // Possibili valori del campo "Dichiarazione" const string MEZZO_RACCOMANDATA = "A mezzo raccomandata"; const string IN_UDIENZA = "In udienza"; if (this.AreEquals(pDichiarazione.Value.ToString(), MEZZO_RACCOMANDATA)) { // Calcolo della scadenza se il valore del campo è a mezzo raccomandata this.ExecuteDateRule(subRule, false); } else if (this.AreEquals(pDichiarazione.Value.ToString(), IN_UDIENZA)) { RuleHistoryInfo lastExecutedRule = this.GetLastExecutedRule(subRule); if (lastExecutedRule != null && lastExecutedRule.Published) { if (this.AreEquals(lastExecutedRule.MailMessageSnapshot.Appointment.Method, Subscriber.Dispatcher.CalendarMail.iCalendar.AppointmentMethodTypes.REQUEST)) { // Invio appuntamento di cancellazione per la regola legata al termine dichiarazione del terzo this.SendCancelAppointment(subRule); } } } } } else { // Campo non presente tra i dati del profilo throw new SubscriberException(ErrorCodes.MISSING_FIELD_VALUE, string.Format(ErrorDescriptions.MISSING_FIELD_VALUE, FIELD_NAME_DICHIARAZIONE)); } } else { base.InternalExecuteSubRule(subRule); } }
/// <summary> /// Reperimento dei dati dello storico relativo all'ultima pubblicazione effettuata per una regola e per un oggetto /// </summary> /// <param name="idRule">Id della regola</param> /// <param name="idObject">Id dell'oggetto</param> /// <returns></returns> public static RuleHistoryInfo GetLastRuleHistory(int idRule, string idObject) { _logger.Info("BEGIN"); try { RuleHistoryInfo history = null; Database db = DbHelper.CreateDatabase(); using (DBCommandWrapper cw = db.GetStoredProcCommandWrapper(DbHelper.GetSpNameForPackage("GetLastHistory"))) { cw.AddInParameter("pIdRule", DbType.Int32, idRule); cw.AddInParameter("pIdObject", DbType.String, idObject); using (IDataReader reader = db.ExecuteReader(cw)) { if (reader.Read()) { history = CreteRuleHistoryInfo(reader); } } } return(history); } catch (SubscriberException pubEx) { _logger.Error(pubEx.Message); throw pubEx; } catch (Exception ex) { _logger.Error(ex.Message); throw new SubscriberException(ErrorCodes.UNHANDLED_ERROR, string.Format(ErrorDescriptions.UNHANDLED_ERROR, ex.Message), ex); } finally { _logger.Info("END"); } }
/// <summary> /// Reperimento dello stato di modifica del campo "Descrizione" dell'oggetto /// </summary> /// <param name="rule"></param> /// <returns></returns> protected virtual FieldStateTypesEnum GetDescriptionFieldState(BaseRuleInfo rule) { Property pDescription = new Property { Name = "Description", Type = PropertyTypesEnum.String, Value = this.ListenerRequest.EventInfo.PublishedObject.Description }; RuleHistoryInfo lastExecutedRule = this.GetLastExecutedRule(rule); Property pOldDescription = new Property { Name = "Description", Type = PropertyTypesEnum.String }; if (lastExecutedRule != null && lastExecutedRule.ObjectSnapshot != null) { pOldDescription.Value = lastExecutedRule.ObjectSnapshot.Description; } return(this.GetFieldState(pDescription, pOldDescription)); }
/// <summary> /// /// </summary> /// <param name="subRule"></param> protected override void InternalExecuteSubRule(SubRuleInfo subRule) { if (this.AreEquals(subRule.SubRuleName, SubRulesUdienzaVerificaStatoPassivo.SCADENZA_DOMANDA_TEMPESTIVA) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaVerificaStatoPassivo.REMINDER_SCADENZA_DOMANDA_TEMPESTIVA)) { // Valore ammesso nel campo "Tipologia" const string FALLIMENTO = "Fallimento"; // Ricerca del campo "Termine" nel profilo Property pTermine = this.FindProperty(Fields.TIPOLOGIA); if (pTermine != null && !pTermine.IsEmpty) { if (this.AreEquals(pTermine.Value.ToString(), FALLIMENTO)) { // Esecuzione della regola se e solo se il valore del campo "Termine" è impostato a "Fallimento" this.ExecuteDateRule(subRule, false); } else { // Verifica se inviare un appuntamento di cancellazione RuleHistoryInfo lastExecutedRule = this.GetLastExecutedRule(subRule); if (lastExecutedRule != null && lastExecutedRule.MailMessageSnapshot != null && lastExecutedRule.MailMessageSnapshot.Appointment != null && lastExecutedRule.MailMessageSnapshot.Appointment.Status == Subscriber.Dispatcher.CalendarMail.iCalendar.AppointmentStatusTypes.CONFIRMED) { this.SendCancelAppointment(subRule); } } } else { // Campo obbligatorio throw new SubscriberException(ErrorCodes.MISSING_FIELD_VALUE, string.Format(ErrorDescriptions.MISSING_FIELD_VALUE, Fields.TIPOLOGIA)); } } else if (this.AreEquals(subRule.SubRuleName, SubRulesUdienzaVerificaStatoPassivo.SCADENZA_DOMANDA) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaVerificaStatoPassivo.REMINDER_SCADENZA_DOMANDA) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaVerificaStatoPassivo.ADUNANZA_CREDITORI) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaVerificaStatoPassivo.REMINDER_ADESIONE_CONCORDATO)) { // Valore ammesso nel campo "Tipologia" const string CONCORDATO_PREVENTIVO = "Concordato preventivo"; // Ricerca del campo "Termine" nel profilo Property pTermine = this.FindProperty(Fields.TIPOLOGIA); if (pTermine != null && !pTermine.IsEmpty) { if (this.AreEquals(pTermine.Value.ToString(), CONCORDATO_PREVENTIVO)) { // Esecuzione della regola se e solo se il valore del campo "Termine" è impostato a "Concordato preventivo" this.ExecuteDateRule(subRule, false); } else { // Verifica se inviare un appuntamento di cancellazione RuleHistoryInfo lastExecutedRule = this.GetLastExecutedRule(subRule); if (lastExecutedRule != null && lastExecutedRule.MailMessageSnapshot != null && lastExecutedRule.MailMessageSnapshot.Appointment != null && lastExecutedRule.MailMessageSnapshot.Appointment.Status == Subscriber.Dispatcher.CalendarMail.iCalendar.AppointmentStatusTypes.CONFIRMED) { this.SendCancelAppointment(subRule); } } } else { // Campo obbligatorio throw new SubscriberException(ErrorCodes.MISSING_FIELD_VALUE, string.Format(ErrorDescriptions.MISSING_FIELD_VALUE, Fields.TIPOLOGIA)); } } else { base.InternalExecuteSubRule(subRule); } }
/// <summary> /// Aggiornamento dati /// </summary> /// <param name="data"></param> /// <returns></returns> public static RuleHistoryInfo SaveHistoryItem(RuleHistoryInfo data) { _logger.Info("BEGIN"); try { Database db = DbHelper.CreateDatabase(); using (DBCommandWrapper cw = db.GetStoredProcCommandWrapper(DbHelper.GetSpNameForPackage("InsertHistory"))) { cw.AddInParameter("pRuleId", DbType.Int32, data.IdRule); cw.AddInParameter("pIdObject", DbType.String, data.ObjectSnapshot.IdObject); cw.AddInParameter("pObjectType", DbType.String, data.ObjectSnapshot.ObjectType); cw.AddInParameter("pObjectTemplateName", DbType.String, data.ObjectSnapshot.TemplateName); cw.AddInParameter("pObjectDescription", DbType.String, data.ObjectSnapshot.Description); cw.AddInParameter("pAuthorName", DbType.String, data.Author.Name); cw.AddInParameter("pAuthorId", DbType.String, data.Author.Id); cw.AddInParameter("pRoleName", DbType.String, data.Author.RoleName); cw.AddInParameter("pRoleId", DbType.String, data.Author.IdRole); if (data.ObjectSnapshot != null) { cw.AddClobParameter("pObjectSnapshot", ObjectSerializerHelper.Serialize(data.ObjectSnapshot)); } else { cw.AddClobParameter("pObjectSnapshot", DBNull.Value); } if (data.MailMessageSnapshot != null) { cw.AddClobParameter("pMailMessageSnapshot", ObjectSerializerHelper.Serialize(data.MailMessageSnapshot)); } else { cw.AddClobParameter("pMailMessageSnapshot", DBNull.Value); } cw.AddInParameter("pComputed", DbType.StringFixedLength, (data.Published ? "1" : "0")); cw.AddInParameter("pComputeDate", DbType.DateTime, data.PublishDate); if (data.ErrorInfo != null) { cw.AddInParameter("pErrorId", DbType.String, data.ErrorInfo.Id); cw.AddInParameter("pErrorDescription", DbType.String, data.ErrorInfo.Message); cw.AddInParameter("pErrorStack", DbType.String, data.ErrorInfo.Stack); } else { cw.AddInParameter("pErrorId", DbType.String, DBNull.Value); cw.AddInParameter("pErrorDescription", DbType.String, DBNull.Value); cw.AddInParameter("pErrorStack", DbType.String, DBNull.Value); } cw.AddOutParameter("pId", DbType.Int32, 4); db.ExecuteNonQuery(cw); if (cw.RowsAffected == 1) { data.Id = Convert.ToInt32(cw.GetParameterValue("pId")); } else { throw new SubscriberException(ErrorCodes.SP_EXECUTION_ERROR, string.Format(ErrorDescriptions.SP_EXECUTION_ERROR, "InsertHistory", ErrorDescriptions.SP_EXECUTE_NO_ROWS)); } } return(data); } catch (SubscriberException pubEx) { _logger.Error(pubEx.Message); throw pubEx; } catch (Exception ex) { _logger.Error(ex.Message); throw new SubscriberException(ErrorCodes.UNHANDLED_ERROR, string.Format(ErrorDescriptions.UNHANDLED_ERROR, ex.Message), ex); } finally { _logger.Info("END"); } }
/// <summary> /// Esecuzione di una SubRule /// </summary> /// <param name="subRule"></param> protected override void InternalExecuteSubRule(SubRuleInfo subRule) { if (this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntrodutto.SCADENZA_COSTITUZIONE) || this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntrodutto.SCADENZA_COSTITUZIONE_RICORRENTE) || this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntrodutto.REMINDER_SCADENZA_COSTITUZIONE) || this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntrodutto.REMINDER_SCADENZA_COSTITUZIONE_RICORRENTE)) { if (this.TerminiDimezzati) { // Se la causa prevede i termini dimezzati, è necessario inviare gli appuntamenti di cancellazione // per le 4 regole di notifica atto introduttivo non previsti per i termini dimezzati RuleHistoryInfo lastExecutedRule = this.GetLastExecutedRule(subRule); if (lastExecutedRule != null && lastExecutedRule.MailMessageSnapshot != null && lastExecutedRule.MailMessageSnapshot.Appointment != null && lastExecutedRule.MailMessageSnapshot.Appointment.Status == Subscriber.Dispatcher.CalendarMail.iCalendar.AppointmentStatusTypes.CONFIRMED) { // Invio appuntamento di cancellazione, solo se l'ultimo appuntamento inviato per la regola è di conferma this.SendCancelAppointment(subRule); } } else { // Se i termini non sono dimezzati, gestisce normalmente la regola this.ExecuteDateRule(subRule, false); } } else if (this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntroduttivoConTerminiDimezzati.SCADENZA_COSTITUZIONE_TERMINI_DIMEZZATI) || this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntroduttivoConTerminiDimezzati.SCADENZA_NOTIFICA_RICORSO_INCIDENTALE) || this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntroduttivoConTerminiDimezzati.SCADENZA_COSTITUZIONE_RICORRENTE_TERMINI_DIMEZZATI) || this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntroduttivoConTerminiDimezzati.REMINDER_SCADENZA_COSTITUZIONE_TERMINI_DIMEZZATI) || this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntroduttivoConTerminiDimezzati.REMINDER_SCADENZA_NOTIFICA_RICORSO_INCIDENTALE) || this.AreEquals(subRule.SubRuleName, SubRulesNotificaAttoIntroduttivoConTerminiDimezzati.REMINDER_SCADENZA_COSTITUZIONE_RICORRENTE_TERMINI_DIMEZZATI)) { if (!this.TerminiDimezzati) { // Se la causa NON prevede i termini dimezzati, è necessario inviare gli appuntamenti di cancellazione // per le 6 regole di notifica atto introduttivo previste per i termini dimezzati RuleHistoryInfo lastExecutedRule = this.GetLastExecutedRule(subRule); if (lastExecutedRule != null && lastExecutedRule.MailMessageSnapshot != null && lastExecutedRule.MailMessageSnapshot.Appointment != null && lastExecutedRule.MailMessageSnapshot.Appointment.Status == Subscriber.Dispatcher.CalendarMail.iCalendar.AppointmentStatusTypes.CONFIRMED) { // Invio appuntamento di cancellazione, solo se l'ultimo appuntamento inviato per la regola è di conferma this.SendCancelAppointment(subRule); } } else { // Se i termini sono dimezzati, gestisce normalmente la regola this.ExecuteDateRule(subRule, false); } } else if (this.AreEquals(subRule.SubRuleName, SubRulesComunicazioneDepositoOrdinanza.SCADENZA_PRESENTAZIONE_APPELLO_DEPOSITO_ORDINANZA)) { // Appuntamenti derivanti dalla "Data comunicazione deposito ordinanza" // L'appuntamento è alternativo a quello calcolato in base al campo "Data notifica ordinanza". // Se presente quest'ultimo, è necessario rimuovere l'eventuale appuntamento già inserito per la "Data comunicazione deposito ordinanza" this.ExecuteDateRuleAlternativeFields(subRule, Fields.DATA_NOTIFICA_ORDINANZA, Fields.DATA_COMUNICAZIONE_DEPOSITO_ORDINANZA); } else if (this.AreEquals(subRule.SubRuleName, SubRulesPubblicazioneSentenza.SCADENZA_PRESENTAZIONE_APPELLO) || this.AreEquals(subRule.SubRuleName, SubRulesPubblicazioneSentenza.REMINDER_SCADENZA_PRESENTAZIONE_APPELLO)) { // Appuntamenti derivanti dalla "Data pubblicazione sentenza". // NB: (in maniera analoga al contenzioso civile) // Se risulta valorizzata la "Data notifica sentenza", è necessario cancellare gli appuntamenti derivanti dalla "Data pubblicazione sentenza" (termine lungo per l'appello) this.ExecuteDateRuleAlternativeFields(subRule, Fields.DATA_NOTIFICA_SENTENZA, Fields.DATA_PUBBLICAZIONE_SENTENZA); } else if (this.AreEquals(subRule.SubRuleName, SubRulesUdienzaCautelare.APPUNTAMENTO_UDIENZA_CAUTELARE) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaCautelare.SCADENZA_COSTITUZIONE_UDIENZA_CAUTELARE) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaPubblica.APPUNTAMENTO_UDIENZA_PUBBLICA) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaPubblica.REMINDER_RINVIO_UDIENZA_PUBBLICA) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaPubblica.SCADENZA_DEPOSITO_DOCUMENTI) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaPubblica.REMINDER_SCADENZA_DEPOSITO_DOCUMENTI) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaPubblica.REMINDER_RITIRO_DOCUMENTI_CONTROPARTI) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaPubblica.SCADENZA_DEPOSITO_MEMORIA) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaPubblica.REMINDER_DEPOSITO_MEMORIA_CONTROPARTI) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaPubblica.SCADENZA_DEPOSITO_REPLICA) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaPubblica.REMINDER_RITIRO_REPLICHE) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaAssunzioneTesti.APPUNTAMENTO_UDIENZA_ASSUNZIONE_TESTI) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaAssunzioneTesti.REMINDER_RINVIO_UDIENZA_ASSUNZIONE_TESTI) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaGiuramentoCTU.APPUNTAMENTO_UDIENZA_GIURAMENTO_CTU) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaGiuramentoCTU.REMINDER_RINVIO_UDIENZA_GIURAMENTO_CTU) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaRichiamoCTU.APPUNTAMENTO_UDIENZA_RICHIAMO_CTU) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaRichiamoCTU.REMINDER_RINVIO_UDIENZA_RICHIAMO_CTU) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaRinvioPendentiTrattative.APPUNTAMENTO_UDIENZA_RINVIO_PENDENTI_TRATTATIVE) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaRinvioPendentiTrattative.REMINDER_RINVIO_UDIENZA_RINVIO_PENDENTI_TRATTATIVE) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaAltro.APPUNTAMENTO_UDIENZA_ALTRO) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaAltro.REMINDER_RINVIO_UDIENZA_ALTRO) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaCameraConsiglio.APPUNTAMENTO_UDIENZA_CAMERA_CONSIGLIO) || this.AreEquals(subRule.SubRuleName, SubRulesUdienzaCameraConsiglio.REMINDER_RINVIO_UDIENZA_CAMERA_CONSIGLIO) ) { // Regole associate ad uno dei 5 campi udienza del profilo this.ExecuteUdienzaRule(subRule); } else { // Esecuzione altre regole associate alle date base.InternalExecuteSubRule(subRule); } }