コード例 #1
0
 public static void RenderWidget(this HtmlHelper helper, Models.Widget widget, bool defer = false)
 {
     if (widget.IsAuthorized)
     {
         if (!defer)
         {
             widget.ClientId = Services.Portal.NextClientId();
             try
             {
                 helper.RenderPartial("Widgets/" + widget.Manifest.FullName, widget);
                 helper.RegisterWebReferences(widget.WebReferences);
             }
             catch (Exception ex)
             {
                 helper.RenderPartial("Widgets/Core/Error", widget, new ViewDataDictionary()
                 {
                     { "Exception", ex }
                 });
             }
         }
         else
         {
             DeferredWidgets.Add(widget);
         }
     }
     //return "";
 }
コード例 #2
0
        public static Models.Widget FromViewModel(this ViewModels.Widget viewModel)
        {
            Models.Widget result = null;

            if (viewModel != null)
            {
                result      = new Models.Widget();
                result.Id   = new MongoDB.Bson.ObjectId(viewModel.Id);
                result.Name = viewModel.Name;
            }

            return(result);
        }
コード例 #3
0
        //public static string RenderDeferredWidgets(this HtmlHelper helper)
        //{
        //    foreach (var widget in DeferredWidgets)
        //        RenderWidget(helper, widget);
        //    return "";  //TODO: return string?????
        //}

        public static void RenderWidget(this HtmlHelper helper, string manifestFullName, Dictionary <string, object> attributes = null, bool defer = false, string css = null, string style = null)
        {
            var manifest = Services.Portal.GetWidgetManifest(manifestFullName);
            var widget   = new Models.Widget()
            {
                ManifestId = manifest.Id, Css = css, Style = style
            };

            if (attributes != null)
            {
                widget.Attributes = attributes;
            }
            RenderWidget(helper, widget, defer);
            //return "";
        }
コード例 #4
0
        public static ViewModels.Widget ToViewModel(this Models.Widget model)
        {
            ViewModels.Widget result = null;

            if (model != null)
            {
                result = new ViewModels.Widget();


                result.Id   = model.Id.ToString();
                result.Name = model.Name;
            }

            return(result);
        }
コード例 #5
0
        IEnumerable <WeatherStation> GetSupportedStations(Models.Widget widget)
        {
            IEnumerable <WeatherStation> supportedStations;

            if (_context.HttpContext.User.Identity.IsAuthenticated)
            {
                supportedStations = _widgetProvider.GetSupportedStations(widget);
            }
            else
            {
                supportedStations = _widgetProvider.GetSupportedPublicStations(widget);
            }

            return(supportedStations);
        }
コード例 #6
0
ファイル: CommentControl.cs プロジェクト: crazyants/videre
        public CommentControl(Models.Widget widget, string containerType, string containerId, string portalId = null)
        {
            ClientId = Services.Portal.NextClientId();
            Widget   = widget;
            Provider = widget.GetAttribute("CommentProvider", "None");

            if (Provider.Equals("Videre", StringComparison.InvariantCultureIgnoreCase))
            {
                Container = Services.Comment.Get(containerType, containerId, portalId);
                if (Container == null)
                {
                    Container = new CommentContainer()
                    {
                        ContainerType = containerType, ContainerId = containerId
                    };
                    Services.Comment.Save(Container);
                }
            }
        }
コード例 #7
0
 public Models.Widget CreateWidget(Models.Widget c)
 {
     _db.GetCollection <Models.Widget>("Widgets").InsertOne(c);
     return(c);
 }
コード例 #8
0
ファイル: PortalExtensions.cs プロジェクト: jonhenning/videre
 //public static string RenderDeferredWidgets(this HtmlHelper helper)
 //{
 //    foreach (var widget in DeferredWidgets)
 //        RenderWidget(helper, widget);
 //    return "";  //TODO: return string?????
 //}
 public static void RenderWidget(this HtmlHelper helper, string manifestFullName, Dictionary<string, object> attributes = null, bool defer = false, string css = null, string style = null)
 {
     var manifest = Services.Portal.GetWidgetManifest(manifestFullName);
     var widget = new Models.Widget() { ManifestId = manifest.Id, Css = css, Style = style };
     if (attributes != null)
         widget.Attributes = attributes;
     RenderWidget(helper, widget, defer);
     //return "";
 }