/// <summary> /// Initializes a new instance of the <see cref="Terradue.Tep.WebServer.WebUserTep"/> class. /// </summary> /// <param name="entity">Entity.</param> public WebUserProfileTep(IfyWebContext context, UserTep entity) : base(context, entity) { try{ var github = Terradue.Github.GithubProfile.FromId(context, this.Id); this.Github = github.Name; this.Gravatar = entity.GetAvatar(); }catch (Exception) {} if (String.IsNullOrEmpty(this.Gravatar)) { this.Gravatar = string.Format("http://www.gravatar.com/avatar/{0}", HashEmailForGravatar(string.IsNullOrEmpty(this.Email) ? "" : this.Email)); } DateTime timef = entity.GetFirstLoginDate(); this.FirstLoginDate = (timef == DateTime.MinValue ? null : timef.ToString("U")); DateTime timel = entity.GetLastLoginDate(); this.LastLoginDate = (timel == DateTime.MinValue ? null : timel.ToString("U")); context.AccessLevel = EntityAccessLevel.Administrator; EntityList <WpsJob> jobs = new EntityList <WpsJob>(context); jobs.UserId = this.Id; jobs.ItemVisibility = EntityItemVisibility.OwnedOnly; jobs.Load(); CreatedJobs = jobs.Count; EntityList <DataPackage> dp = new EntityList <DataPackage>(context); dp.UserId = this.Id; dp.ItemVisibility = EntityItemVisibility.OwnedOnly; dp.Load(); CreatedDataPackages = dp.Count; var dpdefault = DataPackage.GetTemporaryForUser(context, entity); DefaultDataPackageItems = dpdefault.Items.Count; }
public override AtomItem ToAtomItem(NameValueCollection parameters) { if (!IsSearchable(parameters)) { return(null); } UserTep owner = (UserTep)UserTep.ForceFromId(context, this.OwnerId); //string identifier = null; string name = (Entity.Name != null ? Entity.Name : Entity.Identifier); string description = null; Uri id = new Uri(context.BaseUrl + "/" + this.ActivityEntityType.Keyword + "/search?id=" + Entity.Identifier); switch (this.Privilege.Operation) { case EntityOperationType.Create: description = string.Format("created {0} '{1}'", this.ActivityEntityType.SingularCaption, name); break; case EntityOperationType.Change: description = string.Format("updated {0} '{1}'", this.ActivityEntityType.SingularCaption, name); break; case EntityOperationType.Delete: description = string.Format("deleted {0} '{1}'", this.ActivityEntityType.SingularCaption, name); break; case EntityOperationType.Share: description = string.Format("shared {0} '{1}'", this.ActivityEntityType.SingularCaption, name); break; default: break; } //AtomItem atomEntry = null; AtomItem result = new AtomItem(); result.Id = id.ToString(); result.Title = new TextSyndicationContent(base.Entity.Identifier); result.Content = new TextSyndicationContent(name); result.ElementExtensions.Add("identifier", "http://purl.org/dc/elements/1.1/", Guid.NewGuid()); result.Summary = new TextSyndicationContent(description); result.ReferenceData = this; result.PublishDate = this.CreationTime; result.LastUpdatedTime = this.CreationTime; var basepath = new UriBuilder(context.BaseUrl); basepath.Path = "user"; string usrUri = basepath.Uri.AbsoluteUri + "/" + owner.Username; string usrName = (!String.IsNullOrEmpty(owner.FirstName) && !String.IsNullOrEmpty(owner.LastName) ? owner.FirstName + " " + owner.LastName : owner.Username); SyndicationPerson author = new SyndicationPerson(null, usrName, usrUri); var ownername = string.IsNullOrEmpty(owner.FirstName) || string.IsNullOrEmpty(owner.LastName) ? owner.Username : owner.FirstName + " " + owner.LastName; author.ElementExtensions.Add(new SyndicationElementExtension("identifier", "http://purl.org/dc/elements/1.1/", ownername)); author.ElementExtensions.Add(new SyndicationElementExtension("avatar", "http://purl.org/dc/elements/1.1/", owner.GetAvatar())); result.Authors.Add(author); result.Links.Add(new SyndicationLink(id, "self", name, "application/atom+xml", 0)); Uri share = new Uri(context.BaseUrl + "/share?url=" + System.Web.HttpUtility.UrlEncode(id.AbsoluteUri) + (!string.IsNullOrEmpty(AppId) ? "&id=" + AppId : "")); result.Links.Add(new SyndicationLink(share, "related", "share", "application/atom+xml", 0)); return(result); }