Esempio n. 1
0
        /// <summary>
        /// Verifica se un registro può essere eliminato
        /// </summary>
        /// <param name="registro"></param>
        /// <returns></returns>
        public static ValidationResultInfo CanDeleteRegistro(OrgRegistro registro)
        {
            ValidationResultInfo retValue = IsValidRequiredFieldsRegistro(DBActionTypeRegistroEnum.DeleteMode, registro);

            if (retValue.Value)
            {
                DocsPaDB.Query_DocsPAWS.Amministrazione dbAmministrazione = new DocsPaDB.Query_DocsPAWS.Amministrazione();
                if (registro.chaRF == "0")
                {
                    // Verifica presenza documenti protocollati (error)

                    if (dbAmministrazione.GetCountProtocolliRegistro(registro.IDRegistro) > 0)
                    {
                        retValue.Value = false;
                        BrokenRule brokenRule = new BrokenRule();
                        brokenRule.ID          = "CONTAIN_DOCUMENTS";
                        brokenRule.Description = "Nel registro è presente almeno un documento";
                        retValue.BrokenRules.Add(brokenRule);
                    }

                    // Verifica presenza fascicoli (error)
                    if (dbAmministrazione.GetCountFascicoliRegistro(registro.IDRegistro) > 0)
                    {
                        retValue.Value = false;
                        BrokenRule brokenRule = new BrokenRule();
                        brokenRule.ID          = "CONTAIN_FOLDERS";
                        brokenRule.Description = "Nel registro è presente almeno un fascicolo";
                        retValue.BrokenRules.Add(brokenRule);
                    }

                    // Verifica dipendenza del registro con almeno un ruolo (warning)
                    if (dbAmministrazione.GetCountRuoliRegistro(registro.IDRegistro) > 0)
                    {
                        BrokenRule brokenRule = new BrokenRule();
                        brokenRule.ID    = "CONTAIN_ROLES";
                        brokenRule.Level = BrokenRule.BrokenRuleLevelEnum.Warning;

                        brokenRule.Description = "Almeno un ruolo risulta collegato al registro";
                        //if (registro.chaRF != null && registro.chaRF == "1")
                        //    brokenRule.Description = "Almeno un ruolo risulta collegato all'RF";

                        retValue.BrokenRules.Add(brokenRule);
                    }

                    //Verifica se ci sono degli RF associati
                    if (dbAmministrazione.GetCountRfAssociati(registro.IDRegistro) > 0)
                    {
                        BrokenRule brokenRule = new BrokenRule();
                        brokenRule.ID = "CONTAIN_RF";
                        //brokenRule.Level = BrokenRule.BrokenRuleLevelEnum.Error;

                        brokenRule.Description = "Almeno un RF risulta collegato al registro";

                        retValue.BrokenRules.Add(brokenRule);
                    }
                }
                else
                {
                    // Verifica dipendenza del registro con almeno un ruolo (warning)
                    if (dbAmministrazione.GetCountRuoliRegistro(registro.IDRegistro) > 0)
                    {
                        BrokenRule brokenRule = new BrokenRule();
                        brokenRule.ID = "CONTAIN_ROLES";

                        brokenRule.Description = "Almeno un ruolo risulta collegato all'RF";

                        retValue.BrokenRules.Add(brokenRule);
                    }

                    // Verifica che non ci siano oggetti associati all'RF
                    if (dbAmministrazione.GetCountOggettiAssociati(registro.IDRegistro) > 0)
                    {
                        retValue.Value = false;
                        BrokenRule brokenRule = new BrokenRule();
                        brokenRule.ID          = "CONTAIN_OGGETTI";
                        brokenRule.Description = "Almeno un oggetto risulta collegato all'RF";
                        retValue.BrokenRules.Add(brokenRule);
                    }

                    // Verifica che non ci siano corrispondenti associati all'RF
                    if (dbAmministrazione.GetCountCorrispondentiAssociati(registro.IDRegistro) > 0)
                    {
                        retValue.Value = false;
                        BrokenRule brokenRule = new BrokenRule();
                        brokenRule.ID          = "CONTAIN_CORRISPONDENTI";
                        brokenRule.Description = "Almeno un corrispondente risulta collegato all'RF";
                        retValue.BrokenRules.Add(brokenRule);
                    }
                }
            }

            return(retValue);
        }