Exemplo n.º 1
0
 protected override OlapRow BuildRow(AdomdDataReader rdr)
 {
     var row = new DimensionRow();
     row.Caption = rdr.GetString(0);
     row.DisplayFolder = rdr.GetString(1);
     row.DimensionType = rdr.GetInt16(2);
     return row;
 }
Exemplo n.º 2
0
        protected override OlapRow BuildRow(AdomdDataReader rdr)
        {
            var row = new DimensionRow();

            row.Caption       = rdr.GetString(0);
            row.DisplayFolder = rdr.GetString(1);
            row.DimensionType = rdr.GetInt16(2);
            return(row);
        }
Exemplo n.º 3
0
        public HttpResponseMessage ventas(Filtro info)
        {
            //string WITH = @"WITH SET [TopVentas] AS NONEMPTY( ORDER (STRTOSET(@Dimension), [Measures].[Fact Ventas Netas], BDESC ) ) ";
            string COLUMNS   = @" NON EMPTY { [Measures].[Fact Ventas Netas] } ON COLUMNS,";
            string ROWS      = @"NON EMPTY { [Dim Tiempo].[Dim Tiempo Año].CHILDREN } * { [Dim Tiempo].[Dim Tiempo Mes Siglas].CHILDREN } ON ROWS ";
            string CUBO_NAME = @"[DWH Northwind] ";

            string WHERE = "";

            if (info.Item != 0 && info.Nombre != "")
            {
                string dimension = @"";
                switch (info.Item)
                {
                case 1: dimension = @"[Dim Cliente].[Dim Cliente Nombre].&[" + info.Nombre + "]"; break;

                case 2: dimension = @"[Dim Producto].[Dim Producto Nombre].&[" + info.Nombre + "]"; break;

                case 3: dimension = @"[Dim Producto].[Dim Producto Categoria].&[" + info.Nombre + "]"; break;

                case 4: dimension = @"[Dim Empleado].[Dim Empleado Nombre].&[" + info.Nombre + "]"; break;
                }

                WHERE = " WHERE " + dimension;
            }

            string MDXQuery = "SELECT " + COLUMNS + ROWS + "FROM " + CUBO_NAME + WHERE;

            List <Venta> ventasUsuario = new List <Venta>();

            using (AdomdConnection cnn = new AdomdConnection(ConfigurationManager.ConnectionStrings["CuboNorthwind"].ConnectionString))
            {
                cnn.Open();
                using (AdomdCommand cmd = new AdomdCommand(MDXQuery, cnn))
                {
                    using (AdomdDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        while (dr.Read())
                        {
                            Venta v = new Venta();
                            //v.ano = ;
                            v.mes    = dr.GetString(1) + " " + dr.GetInt16(0);
                            v.ventas = dr.GetDecimal(2);
                            ventasUsuario.Add(v);
                        }
                        dr.Close();
                    }
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK, ventasUsuario));
        }