public void Update(UrlComponent component) { var command = new SqliteCommand( "UPDATE Component" + "SET Name= @name" + "SET Placement = @placement" + "SET URL = @url" + "WHERE Id = @id"); command.Parameters.Add(new SqliteParameter("name", component.Name)); command.Parameters.Add(new SqliteParameter("placement", component.Placement)); command.Parameters.Add(new SqliteParameter("url", component.Url)); command.Parameters.Add(new SqliteParameter("id", component.Id)); Execute(command); }
public void InitUI(NodeAddedEvent e, NewsItemWithUINode newsItem) { NewsItem data = newsItem.newsItem.Data; newsItem.newsItemUI.HeaderText = data.HeaderText; if (!string.IsNullOrEmpty(data.Tooltip)) { newsItem.newsItemUI.Tooltip = data.Tooltip; } if (data.Date.Year > 0x7d0) { newsItem.newsItemUI.DateText = data.Date.ToString("dd.MM.yyyy"); } if (!string.IsNullOrEmpty(data.PreviewImageGuid)) { base.Log.InfoFormat("Request load PreviewImage: {0}", data.PreviewImageGuid); base.ScheduleEvent(new AssetRequestEvent().Init <NewsItemImageDataComponent>(data.PreviewImageGuid), newsItem); } else if (!string.IsNullOrEmpty(data.PreviewImageUrl)) { Texture texture; if (this.textureCache.TryGetValue(data.PreviewImageUrl, out texture)) { base.Log.InfoFormat("Get PreviewImage from cache: {0}", data.PreviewImageUrl); this.SetImage(newsItem, texture); } else { base.Log.InfoFormat("Load PreviewImage: {0}", data.PreviewImageUrl); if (!newsItem.Entity.HasComponent <UrlComponent>()) { UrlComponent component = new UrlComponent { Url = data.PreviewImageUrl, Caching = false, NoErrorEvent = true }; newsItem.Entity.AddComponent(component); } } } if (!string.IsNullOrEmpty(data.CentralIconGuid)) { base.Log.InfoFormat("Request load CentralIcon: {0}", data.CentralIconGuid); base.ScheduleEvent(new AssetRequestEvent().Init <NewsItemCentralIconDataComponent>(data.CentralIconGuid), newsItem); } }
public static object ParseUrl(string url, UrlComponent component) { PhpArray array = ParseUrl(url); if (array == null) { return(null); } switch (component) { case UrlComponent.Fragment: return((string)array["fragment"]); case UrlComponent.Host: return((string)array["host"]); case UrlComponent.Password: return((string)array["pass"]); case UrlComponent.Path: return((string)array["path"]); case UrlComponent.Port: object port = array["port"]; if (port != null) { return((int)port); } else { return(null); } case UrlComponent.Query: return((string)array["query"]); case UrlComponent.Scheme: return((string)array["scheme"]); case UrlComponent.User: return((string)array["user"]); default: PhpException.Throw(PhpError.Warning, LibResources.GetString("arg:invalid_value", "component", component)); return(null); } }
public static object ParseUrl(string url, UrlComponent component) { PhpArray array = ParseUrl(url); if (array == null) return null; switch (component) { case UrlComponent.Fragment: return (string)array["fragment"]; case UrlComponent.Host: return (string)array["host"]; case UrlComponent.Password: return (string)array["pass"]; case UrlComponent.Path: return (string)array["path"]; case UrlComponent.Port: object port = array["port"]; if (port != null) return (int)port; else return null; case UrlComponent.Query: return (string)array["query"]; case UrlComponent.Scheme: return (string)array["scheme"]; case UrlComponent.User: return (string)array["user"]; default: PhpException.Throw(PhpError.Warning, LibResources.GetString("arg:invalid_value", "component", component)); return null; } }
/// <summary> /// Convert the content data item to dynamic object. /// </summary> /// <returns>An expando object defined in open activity object standard.</returns> public dynamic ToObject() { dynamic activity = new ExpandoObject(); var vals = this.Values; var Url = DNA.Utility.UrlUtility.CreateUrlHelper(); var request = HttpContext.Current.Request; string baseUrl = request.Url.Scheme + "://" + request.Url.Authority; dynamic actor = new ExpandoObject(); #region base properties actor.id = this.Modifier; actor.url = baseUrl + "/profiles/" + this.Modifier; actor.displayName = this.Modifier; activity.id = this.ID; activity.parentId = this.ParentItemID; activity.published = this.Published; activity.updated = this.Modified; activity.version = this.Version; //activity.tags = this.Model.Tags; activity.slug = this.Model.Slug; activity.locale = this.Locale; //activity.categories = !string.IsNullOrEmpty(this.Model.Categories) ? this.Model.Categories.Split(',') : null; activity.tags = !string.IsNullOrEmpty(this.Model.Tags) ? this.Model.Tags.Split(',') : null; activity.pos = this.Pos; activity.reads = this.Reads; activity.actor = actor; activity.annotation = this.Annotation; activity.verb = this.ShareID != Guid.Empty ? "share" : "post"; activity.url = this.UrlComponent; #endregion #region object dynamic _obj = new ExpandoObject(); dynamic owner = new ExpandoObject(); owner.id = this.Owner; owner.url = baseUrl + "/profiles/" + this.Owner; owner.displayName = this.Owner; _obj.actor = owner; var j = 0; var title = ""; foreach (var key in Values.Keys) { if (j == 0) { title = Values[key].ToString(); j++; } ((IDictionary <String, Object>)_obj).Add(key, Values[key]); } #endregion var objUrl = UrlComponent.ToString(); _obj.objectType = this.Parent.BaseType; _obj.objectTypeID = this.ParentID; _obj.id = ShareID != Guid.Empty ? ShareID.ToString() : this.ID.ToString(); ContentList originalList = null; ContentDataItem originalItem = null; if (ShareID != Guid.Empty) { originalItem = Context.Find <ContentDataItem>(this.ShareID); originalList = originalItem.ParentID.Equals(this.ParentID) ? this.Parent.Model : Context.Find <ContentList>(originalItem.ParentID); var originalWeb = originalItem.ParentID.Equals(this.ParentID) ? this.Parent.Web.Model : Context.Find <Web>(originalList.WebID); objUrl = (new Uri(string.Format("{0}/{1}/lists/{2}/items/{3}.html", baseUrl, originalWeb.Name, originalList.Name, originalItem.Slug))).ToString(); } _obj.url = objUrl; #region additional properties activity.links = new { //view = this.UrlComponent, edit = Url.Content(this.Parent.GetEditItemUrl(this)), del = Url.Content("~/api/contents/deleteItem/" + this.ParentID.ToString()) }; activity.title = title; #endregion #region categories if (Categories != null && Categories.Count() > 0) { activity.categories = Categories.Select(c => new { id = c.ID, parentId = c.ParentID, name = c.Name, desc = c.Description }); } //dynamic categories = new ExpandoObject(); #endregion #region comments dynamic replies = new ExpandoObject(); replies.totalItems = ShareID != Guid.Empty ? Context.Count <Comment>(c => c.TargetUri.Equals(objUrl, StringComparison.OrdinalIgnoreCase)) : this.TotalComments; replies.disabled = originalItem != null ? !originalItem.EnableComments : !this.Model.EnableComments; replies.link = Url.Content(string.Format("~/api/comments?url={0}", objUrl)); #endregion #region ratings dynamic ratings = new ExpandoObject(); ratings.totalItems = originalItem != null ? originalItem.TotalVotes : this.TotalVotes; ratings.value = originalItem != null ? originalItem.Ratings : this.Ratings; ratings.disabled = originalList != null ? !originalList.AllowVotes : !this.Parent.AllowVotes; if (originalList != null) { ratings.url = Url.Content(string.Format("~/api/contents/vote/{0}?list={1}", ShareID.ToString(), originalList.Name)); } else { if (this.Parent != null) { ratings.url = Url.Content(string.Format("~/api/contents/vote/{0}?list={1}", this.ID.ToString(), this.Parent.Name)); } } #endregion #region attachments dynamic attachs = new ExpandoObject(); attachs.totalItems = originalItem != null ? originalItem.TotalAttachments : this.TotalAttachments; attachs.disabled = originalList != null ? !originalList.AllowAttachments : !this.Parent.AllowAttachments; if (originalItem != null) { attachs.items = Context.Where <ContentAttachment>(c => c.ItemID.Equals(originalItem.ID)).ToList().Select(attach => new { type = attach.ContentType, url = attach.Uri, name = attach.Name, id = attach.ID, size = attach.Size }).ToArray(); } else { if (this.Parent != null && this.Attachments != null) { if (this.Parent.AllowAttachments) { attachs.items = Attachments.Select(attach => new { type = attach.ContentType, url = attach.Uri, name = attach.Name, id = attach.ID, size = attach.Size }).ToList().ToArray(); } else { attachs.items = new object[0]; } } } _obj.attachments = attachs; #endregion dynamic reshares = new ExpandoObject(); reshares.totalItems = 0; reshares.link = Url.Content("~/api/contents/shares/" + (ShareID != Guid.Empty ? this.ShareID.ToString() : this.ID.ToString())); reshares.disabled = !this.Parent.AllowResharing; if (ShareID != Guid.Empty) { reshares.totalItems = Context.Count <ContentDataItem>(i => i.ShareID == this.ShareID); } else if (this.Parent != null && this.Parent.AllowResharing) { reshares.totalItems = Reshares().Count(); } _obj.reshares = reshares; _obj.replies = replies; _obj.ratings = ratings; activity.@object = _obj; return(activity); }