Exemplo n.º 1
0
 public ResultList <SimpleResultItem> GetSimilarityFieldsByParams(SendMail.Model.IndexedCatalogs ctg, IList <SendMail.Model.EntitaType> tEnt, KeyValuePair <SendMail.Model.FastIndexedAttributes, string> par, int da, int per)
 {
     using (IContattoDao dao = getDaoContext().DaoImpl.ContattoDao)
     {
         return(dao.LoadSimilarityFieldsByParams(ctg, tEnt, par, da, per));
     }
 }
Exemplo n.º 2
0
 public ResultList <SimpleResultItem> GetFieldsByParams(SendMail.Model.IndexedCatalogs ctg, IList <SendMail.Model.EntitaType> tEnt, KeyValuePair <SendMail.Model.FastIndexedAttributes, string> par, int da, int per)
 {
     using (ContattoSQLDb dao = new ContattoSQLDb())
     {
         return(dao.LoadFieldsByParams(ctg, tEnt, par, da, per));
     }
 }
Exemplo n.º 3
0
        public Dictionary <string, SimpleTreeItem> LoadTree(Int64?startNode, SendMail.Model.IndexedCatalogs catalog, int?levels)
        {
            Dictionary <string, SimpleTreeItem> list = null;
            StringBuilder query = new StringBuilder();

            try
            {
                switch (catalog)
                {
                case IndexedCatalogs.RUBR:
                    query.Append("select ID_REFERRAL AS VALUE, ");
                    query.Append("CASE WHEN REFERRAL_TYPE in ('PA','AZ_PRI','AZ_CP','GRP') then RAGIONE_SOCIALE else UFFICIO end as TEXT, ");
                    query.Append("REFERRAL_TYPE AS SUBTYPE, ");

                    query.Append("'RUBR' AS SOURCE, ");
                    query.Append("ID_PADRE AS PADRE ");
                    query.Append("from rubr_entita ");
                    query.Append("where REFERRAL_TYPE in ('PA','PA_SUB','PA_UFF','AZ_PRI','AZ_CP','AZ_UFF','GRP') ");
                    if (levels.HasValue)
                    {
                        query.Append("and level <=:pLVL ");
                    }
                    if (startNode.HasValue)
                    {
                        query.Append("start with ID_REFERRAL = :pID ");
                    }
                    else
                    {
                        query.Append("start with ID_REFERRAL = 0 ");
                    }
                    query.Append("connect by NOCYCLE prior ID_REFERRAL = ID_PADRE ");
                    break;

                case IndexedCatalogs.IPA:
                    query.Append("select ID_RUB AS VALUE, ");
                    query.Append("'IPA' AS SOURCE, ");

                    query.Append("CASE WHEN ( substr(DN,1,2)= 'c=' or substr(DN,1,2) = 'o=') then RAGIONESOCIALE ");
                    query.Append("else UFFICIO end AS TEXT, ");
                    query.Append("CASE WHEN substr(DN,1,2)= 'c=' then 'GRP' ");
                    query.Append("WHEN substr(DN,1,2)= 'o=' then 'PA' ");
                    query.Append("else 'PA_UFF' end AS SUBTYPE, ");
                    query.Append("ID_PADRE AS PADRE ");
                    query.Append("from IPA ");
                    if (levels.HasValue)
                    {
                        query.Append("where level <=:pLVL ");
                    }
                    if (startNode.HasValue)
                    {
                        query.Append("start with ID_RUB = :pID ");
                    }
                    else
                    {
                        query.Append("start with ID_RUB = 1 ");
                    }
                    query.Append("connect by NOCYCLE prior ID_RUB = ID_PADRE");

                    break;
                }

                using (OracleCommand oCmd = base.CurrentConnection.CreateCommand())
                {
                    oCmd.CommandText = query.ToString();
                    oCmd.BindByName  = true;
                    if (startNode.HasValue)
                    {
                        oCmd.Parameters.Add("pID", startNode.Value);
                    }
                    if (levels.HasValue)
                    {
                        oCmd.Parameters.Add("pLVL", levels.Value);
                    }
                    using (OracleDataReader r = oCmd.ExecuteReader())
                        if (r.HasRows)
                        {
                            list = new Dictionary <string, SimpleTreeItem>();
                            bool skip = false;
                            while (r.Read())
                            {
                                if (!skip)
                                {
                                    SimpleTreeItem it = DaoOracleDbHelper.MapToSimpleTreeItem(r);
                                    list.Add(it.ExtendedValue, it);
                                }
                            }
                        }
                }
            }
            //catch (OracleException ex)
            //{
            //    Com.Delta.Logging.Errors.ErrorLogInfo error = new Com.Delta.Logging.Errors.ErrorLogInfo();
            //    error.freeTextDetails = "Errore nel caricamento dell'albero Data Layer E033 Dettagli Errore: " + ex.Message;
            //    error.logCode = "ERR_033";
            //    error.passiveparentcodeobjectID = string.Empty;
            //    error.passiveobjectGroupID = string.Empty;
            //    error.passiveobjectID = string.Empty;
            //    error.passiveapplicationID = string.Empty;
            //    log.Error(error);
            //    throw new ManagedException(ex.Message, "E033", "Delta.CdR.INAData.OracleImpl", "LoadTree", "Caricamento dell'albero ", string.Empty, "Eccezione non Gestita", ex);
            //}
            catch (Exception ex)
            {
                //TASK: Allineamento log - Ciro
                if (!ex.GetType().Equals(typeof(ManagedException)))
                {
                    ManagedException mEx = new ManagedException("Errore nel caricamento dal database dell'albero Data Layer E035 Dettagli Errore: " + ex.Message,
                                                                "ERR_035", string.Empty, string.Empty, ex.InnerException);
                    ErrorLogInfo err = new ErrorLogInfo(mEx);

                    log.Error(err);
                    throw mEx;
                }
                else
                {
                    throw ex;
                }
                //Com.Delta.Logging.Errors.ErrorLogInfo error = new Com.Delta.Logging.Errors.ErrorLogInfo();
                //error.freeTextDetails = "Errore nel caricamento dal database dell'albero Data Layer E034 Dettagli Errore: " + ex.Message;
                //error.logCode = "ERR_034";
                //error.passiveparentcodeobjectID = string.Empty;
                //error.passiveobjectGroupID = string.Empty;
                //error.passiveobjectID = string.Empty;
                //error.passiveapplicationID = string.Empty;
                //log.Error(error);
                //throw new ManagedException(ex.Message, "E034", "Delta.CdR.INAData.OracleImpl", "LoadTree", "Caricamento dal database dell'albero Data Layer", string.Empty, "Eccezione non Gestita", ex);
            }
            return(list);
        }
Exemplo n.º 4
0
        public Dictionary <string, SimpleTreeItem> LoadTree(Int64?startNode, SendMail.Model.IndexedCatalogs catalog, int?levels)
        {
            Dictionary <string, SimpleTreeItem> list = null;
            StringBuilder query = new StringBuilder();

            switch (catalog)
            {
            case IndexedCatalogs.RUBR:
                query.Append(" with tree(value, text, subtype, source, padre, level) as ( ");
                query.Append(" select ID_REFERRAL AS VALUE, CASE ");
                query.Append(" WHEN REFERRAL_TYPE in ('PA', 'AZ_PRI', 'AZ_CP', 'GRP') then RAGIONE_SOCIALE else UFFICIO end as TEXT, ");
                query.Append(" REFERRAL_TYPE AS SUBTYPE, 'RUBR' AS SOURCE, ID_PADRE AS PADRE, 1 as level from ");
                query.Append(" [FAXPEC].[FAXPEC].[rubr_entita] where REFERRAL_TYPE in ");
                query.Append("  ('PA', 'PA_SUB', 'PA_UFF', 'AZ_PRI', 'AZ_CP', 'AZ_UFF', 'GRP') ");
                query.Append(" union all ");
                query.Append(" select ");
                query.Append(" child.ID_REFERRAL AS VALUE, CASE ");
                query.Append("  WHEN REFERRAL_TYPE in ('PA','AZ_PRI','AZ_CP','GRP') then child.RAGIONE_SOCIALE else child.UFFICIO end as TEXT, ");
                query.Append(" child.REFERRAL_TYPE AS SUBTYPE, 'RUBR' AS SOURCE, child.ID_PADRE AS PADRE, parent.level + 1 from ");
                query.Append(" [FAXPEC].[FAXPEC].[rubr_entita] as child join tree parent on parent.value = child.ID_PADRE where REFERRAL_TYPE in ");
                query.Append("  ('PA','PA_SUB','PA_UFF','AZ_PRI','AZ_CP','AZ_UFF','GRP')) ");
                query.Append("   select * from tree ");
                if (levels.HasValue || startNode.HasValue)
                {
                    query.Append(" where ");
                }
                if (levels.HasValue)
                {
                    query.Append(" level <=" + levels);
                    query.Append(" and ");
                }
                if (startNode.HasValue)
                {
                    query.Append(" tree.value >= :pID ");
                }
                else
                {
                    query.Append(" tree.value >= 0 ");
                }
                query.Append(" order by tree.level asc");
                break;

            case IndexedCatalogs.IPA:
                query.Append("select ID_RUB AS VALUE, ");
                query.Append("'IPA' AS SOURCE, ");
                query.Append("CASE WHEN ( substr(DN,1,2)= 'c=' or substr(DN,1,2) = 'o=') then RAGIONESOCIALE ");
                query.Append("else UFFICIO end AS TEXT, ");
                query.Append("CASE WHEN substr(DN,1,2)= 'c=' then 'GRP' ");
                query.Append("WHEN substr(DN,1,2)= 'o=' then 'PA' ");
                query.Append("else 'PA_UFF' end AS SUBTYPE, ");
                query.Append("ID_PADRE AS PADRE ");
                query.Append("from  [FAXPEC].[FAXPEC].[IPA] ");
                if (levels.HasValue)
                {
                    query.Append("where level <=" + levels.Value);
                }
                if (startNode.HasValue)
                {
                    query.Append("start with ID_RUB = " + startNode.Value);
                }
                else
                {
                    query.Append("start with ID_RUB = 1 ");
                }
                query.Append("connect by NOCYCLE prior ID_RUB = ID_PADRE");

                break;
            }
            using (var dbcontext = new FAXPECContext())
            {
                using (var oCmd = dbcontext.Database.Connection.CreateCommand())
                {
                    try
                    {
                        oCmd.Connection.Open();
                        oCmd.CommandText = query.ToString();
                        using (var r = oCmd.ExecuteReader())
                        {
                            if (r.HasRows)
                            {
                                list = new Dictionary <string, SimpleTreeItem>();
                                bool skip = false;
                                while (r.Read())
                                {
                                    if (!skip)
                                    {
                                        SimpleTreeItem it = DaoSQLServerDBHelper.MapToSimpleTreeItem(r);
                                        list.Add(it.ExtendedValue, it);
                                    }
                                }
                            }
                        }
                        oCmd.Connection.Close();
                    }
                    catch (Exception ex)
                    {
                        if (!ex.GetType().Equals(typeof(ManagedException)))
                        {
                            ManagedException mEx = new ManagedException("Errore nel caricamento dal database dell'albero Data Layer E035 Dettagli Errore: " + ex.Message,
                                                                        "ERR_035", string.Empty, string.Empty, ex.InnerException);
                            ErrorLogInfo err = new ErrorLogInfo(mEx);

                            log.Error(err);
                            throw mEx;
                        }
                        else
                        {
                            throw ex;
                        }
                    }
                }
            }
            return(list);
        }