Exemplo n.º 1
0
        /// <summary>
        /// Storico delle regole eseguite
        /// </summary>
        /// <param name="requestInfo">
        /// Dati di filtro per la ricerca delle regole
        /// </param>
        /// <returns></returns>
        public static GetRuleHistoryListResponse GetRuleHistoryList(GetRuleHistoryListRequest requestInfo)
        {
            _logger.Info("BEGIN");

            try
            {
                GetRuleHistoryListResponse response = new GetRuleHistoryListResponse();

                List <RuleHistoryInfo> list = new List <RuleHistoryInfo>();

                Database db = DbHelper.CreateDatabase();

                //using (DBCommandWrapper cw = db.GetStoredProcCommandWrapper(DbHelper.GetSpNameForPackage("GetRuleHistory")))
                using (DBCommandWrapper cw = db.GetStoredProcCommandWrapper(DbHelper.GetSpNameForPackage("GetRuleHistoryPaging")))
                {
                    cw.AddInParameter("pIdRule", DbType.Int32, requestInfo.IdRule);

                    // Filtri personalizzati
                    if (requestInfo.CustomFilters != null)
                    {
                        cw.AddInParameter("pObjectDescription", DbType.String, GetStringParamValue(requestInfo.CustomFilters.ObjectDescription));
                        cw.AddInParameter("pAuthorName", DbType.String, GetStringParamValue(requestInfo.CustomFilters.AuthorName));
                        cw.AddInParameter("pRoleName", DbType.String, GetStringParamValue(requestInfo.CustomFilters.RoleName));
                    }
                    else
                    {
                        cw.AddInParameter("pObjectDescription", DbType.String, DBNull.Value);
                        cw.AddInParameter("pAuthorName", DbType.String, DBNull.Value);
                        cw.AddInParameter("pRoleName", DbType.String, DBNull.Value);
                    }

                    // Criteri di paginazione
                    if (requestInfo.PagingContext != null)
                    {
                        cw.AddInParameter("pPage", DbType.Int32, requestInfo.PagingContext.PageNumber);
                        cw.AddInParameter("pObjectsPerPage", DbType.Int32, requestInfo.PagingContext.ObjectsPerPage);
                        cw.AddOutParameter("pObjectsCount", DbType.Int32, 4);
                    }
                    else
                    {
                        cw.AddInParameter("pPage", DbType.Int32, 1);
                        cw.AddInParameter("pObjectsPerPage", DbType.Int32, Int32.MaxValue);
                        cw.AddOutParameter("pObjectsCount", DbType.Int32, 4);
                    }

                    using (IDataReader reader = db.ExecuteReader(cw))
                    {
                        while (reader.Read())
                        {
                            list.Add(CreteRuleHistoryInfo(reader));
                        }

                        object objectsCountParam = cw.GetParameterValue("pObjectsCount");

                        if (objectsCountParam != null)
                        {
                            // Reperimento numero di oggetti totali
                            requestInfo.PagingContext.TotalObjects = Convert.ToInt32(objectsCountParam.ToString());
                        }
                    }
                }

                response.Rules         = list.ToArray();
                response.PagingContext = requestInfo.PagingContext;

                return(response);
            }
            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));
            }
            finally
            {
                _logger.Info("END");
            }
        }
Exemplo n.º 2
0
 public GetRuleHistoryListResponse GetRuleHistoryList(GetRuleHistoryListRequest requestInfo)
 {
     return(DataAccess.RuleHistoryDataAdapter.GetRuleHistoryList(requestInfo));
 }