Exemple #1
0
 public List <Widget> GetAllWidgets(Enumerations.WidgetType widgetType)
 {
     return(this.GetAllWidgets().Where(w => w.WidgetType == (int)widgetType).ToList());
     //return AspectF.Define
     //    .CacheList<Widget, List<Widget>>(_cacheResolver, CacheKeys.WidgetKeys.WidgetsByType((int)widgetType),
     //    w => CacheKeys.WidgetKeys.Widget(w.ID))
     //    .Return<List<Widget>>(() =>
     //        _database.GetList<Widget, Enumerations.WidgetTypeEnum>(widgetType, CompiledQueries.WidgetQueries.GetAllWidgets_ByWidgetType));
 }
Exemple #2
0
        public static Enumerations.WidgetType Deserialize(this XElement widgetType)
        {
            Enumerations.WidgetType thisWidgetType = Enumerations.WidgetType.Unknown;
            Enum.TryParse(widgetType.Value.Replace(" ", "_"), out thisWidgetType);

            var widgetTypes = (int[])Enum.GetValues(typeof(Enumerations.WidgetType));

            if (!widgetTypes.Contains((int)thisWidgetType))
            {
                thisWidgetType = Enumerations.WidgetType.Unknown;
            }
            return(thisWidgetType);
        }
Exemple #3
0
 public static Widget CreateWidget(this Enumerations.WidgetType widgetType)
 {
     return(new Widget()
     {
         Id = Guid.NewGuid(),
         Title = string.Empty.GetRandom(),
         ShowTitle = true.GetRandom(),
         WidgetType = widgetType,
         Dictionary = new List <Tuple <string, string> >()
         {
             new Tuple <string, string>("content", string.Empty.GetRandom())
         }
     });
 }
Exemple #4
0
        public IEnumerable <Widget> GetAllWidgets()
        {
            var fileSystem = _serviceProvider.GetService <IFile>();

            var    results      = new List <Widget>();
            String widgetPath   = System.IO.Path.Combine(_rootDataPath, _widgetRelativePath);
            String zoneFilePath = System.IO.Path.Combine(widgetPath, "be_WIDGET_ZONE.xml");

            var zoneData = fileSystem.ReadAllText(zoneFilePath);
            var zones    = XElement.Parse(zoneData);

            foreach (var widget in zones.Descendants().Where(d => d.Name.LocalName == "widget"))
            {
                var thisDictionary = new List <Tuple <string, string> >();
                Enumerations.WidgetType thisWidgetType = widget.Deserialize();

                var thisWidget = new Widget()
                {
                    Id         = Guid.Parse(widget.Attributes().Single(a => a.Name == "id").Value),
                    Title      = widget.Attributes().Single(a => a.Name == "title").Value,
                    ShowTitle  = Boolean.Parse(widget.Attributes().Single(a => a.Name == "showTitle").Value),
                    WidgetType = thisWidgetType,
                    Dictionary = thisDictionary
                };

                String fileName   = $"{thisWidget.Id.ToString()}.xml";
                String filePath   = System.IO.Path.Combine(widgetPath, fileName);
                String widgetFile = string.Empty;
                if (fileSystem.Exists(filePath))
                {
                    widgetFile = fileSystem.ReadAllText(filePath);
                }

                if (!string.IsNullOrEmpty(widgetFile))
                {
                    var w     = XElement.Parse(widgetFile);
                    var entry = w.Descendants().Single(n => n.Name.LocalName == "DictionaryEntry");
                    thisDictionary.Add(new Tuple <string, string>(entry.Attribute("Key").Value, entry.Attribute("Value").Value));
                }

                if (thisWidget.WidgetType != Enumerations.WidgetType.Unknown)
                {
                    results.Add(thisWidget);
                }
            }

            return(results);
        }
Exemple #5
0
        public List <Widget> GetWidgetList(string username, Enumerations.WidgetType widgetType)
        {
            var userGuid  = this.GetUserGuidFromUserName(username);
            var userRoles = this.userRepository.GetRolesOfUser(userGuid);
            var widgets   = this.widgetRepository.GetAllWidgets(widgetType);

            if (userRoles.Count > 0)
            {
                return(widgets.Where(w => this.widgetsInRolesRepository.GetWidgetsInRolesByWidgetId(w.ID)
                                     .Exists(wr => userRoles.Exists(role => role.RoleId == wr.AspNetRole.RoleId))).ToList());
            }
            else
            {
                return(widgets);
            }
        }
Exemple #6
0
 public List <Widget> GetWidgetList(Enumerations.WidgetType widgetType)
 {
     return(this.widgetRepository.GetAllWidgets(widgetType));
 }