Example #1
0
        private JArray GetProfileGridColumns(int serieIndex)
        {
            string profileKey = "DashboardsModule_DashboardModule" + Name + "ChartModule";
            UserProfileResourceHandler handler = GetUserProfileResourceHandler(profileKey);

            byte[] profileByte      = handler.Fetch();
            string profileDataStr   = Encoding.UTF8.GetString(profileByte);
            var    profileData      = (JObject)Json.Deserialize(profileDataStr);
            JToken parameters       = GetParameters(serieIndex);
            string entitySchemaName = parameters.Value <string>(SchemaNameProperty);
            string xAxisColumn      = parameters.Value <string>("xAxisColumn");
            string yAxisColumn      = parameters.Value <string>("yAxisColumn");

            if (yAxisColumn == null)
            {
                yAxisColumn = "Id";
            }
            string chartKey     = String.Format("{0}_{1}_{2}", entitySchemaName, xAxisColumn, yAxisColumn);
            var    chartProfile = profileData[chartKey] as JObject;

            if (chartProfile != null)
            {
                var listedConfig = (string)chartProfile["listedConfig"];
                if (listedConfig != null)
                {
                    var data = (JObject)Json.Deserialize(listedConfig);
                    return(data["items"] as JArray);
                }
            }
            return(null);
        }
Example #2
0
        private IEnumerable <Guid> GetPeriodsId(UserConnection userConnection, Guid forecastId)
        {
            string profileKey = "ForecastProfile";
            UserProfileResourceHandler handler = GetUserProfileResourceHandler(userConnection, profileKey);

            byte[] profileByte    = handler.Fetch();
            string profileDataStr = Encoding.UTF8.GetString(profileByte);

            if (string.IsNullOrEmpty(profileDataStr))
            {
                return(Enumerable.Empty <Guid>());
            }
            Profile profile;

            try {
                var profileData = (JObject)Json.Deserialize(profileDataStr);
                var filtersObj  = profileData.Value <JObject>(forecastId.ToString());
                profile = Json.Deserialize <Profile>(filtersObj.ToString());
            } catch (Exception ex) {
                _log.Error(ex);
                return(Enumerable.Empty <Guid>());
            }
            var periodsId = profile?.Filters?.FilterPeriods?.Select(period => {
                return(new Guid(period.Id));
            });

            return(periodsId);
        }