public string UpdateRecentlyViewed(string viewid) { int refType, refID; refType = (int)ReferenceType.Assets; refID = Convert.ToInt32(viewid.Substring(1)); RecentlyViewedItem recent = (new RecentlyViewedItems(TSAuthentication.GetLoginUser()).AddNewRecentlyViewedItem()); recent.RefID = refID; recent.RefType = refType; recent.DateViewed = DateTime.UtcNow; recent.UserID = TSAuthentication.GetLoginUser().UserID; recent.BaseCollection.Save(); return(GetRecentlyViewed()); }
public static Entity CreateRecentItem(RecentlyViewedItem item) { var id = Guid.NewGuid(); var result = new Entity(RecentItem.SchemaName) { Id = id, [RecentItem.RecentItemId] = id, [RecentItem.UserId] = item.User, [RecentItem.Name] = item.DisplayName, [RecentItem.Action] = item.Action, [RecentItem.EntityTypeCode] = item.EntityTypeCode, [RecentItem.ObjectId] = item.ObjectId?.ToString("B"), [RecentItem.PinStatus] = item.PinStatus, [RecentItem.Type] = new OptionSetValue((int)item.Type), [RecentItem.Title] = item.Title, [RecentItem.LastAccessed] = item.LastAccessed }; return(result); }
public string CreateRecentlyViewed(RecentlyViewedItem recent) { string recentHTML; AssetsView assetsView = new AssetsView(TSAuthentication.GetLoginUser()); assetsView.LoadByAssetID(recent.RefID); recentHTML = @" <li> <div class=""recent-info""> <h4><a class=""assetlink"" data-assetid=""{0}"" href=""""><i class=""fa {1} {2}""></i>{3}</a></h4> </div> </li>"; string icon = "fa-truck"; string color = "color-green"; switch (assetsView[0].Location) { case "2": icon = "fa-home"; color = "color-amber"; break; case "3": icon = "fa-trash-o"; color = "color-red"; break; } var displayName = assetsView[0].Name; if (String.IsNullOrEmpty(displayName)) { displayName = assetsView[0].SerialNumber; if (String.IsNullOrEmpty(displayName)) { displayName = assetsView[0].AssetID.ToString(); } } return(string.Format(recentHTML, assetsView[0].AssetID, icon, color, displayName)); }