本文整理汇总了C#中BoxSocial.Internals.ItemKey类的典型用法代码示例。如果您正苦于以下问题:C# ItemKey类的具体用法?C# ItemKey怎么用?C# ItemKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemKey类属于BoxSocial.Internals命名空间,在下文中一共展示了ItemKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishPost
public static bool PublishPost(Core core, Job job)
{
core.LoadUserProfile(job.UserId);
User owner = core.PrimitiveCache[job.UserId];
ItemKey sharedItemKey = new ItemKey(job.ItemId, job.ItemTypeId);
IActionableItem sharedItem = null;
core.ItemCache.RequestItem(sharedItemKey);
try
{
sharedItem = (IActionableItem)core.ItemCache[sharedItemKey];
}
catch
{
try
{
sharedItem = (IActionableItem)NumberedItem.Reflect(core, sharedItemKey);
HttpContext.Current.Response.Write("<br />Fallback, had to reflect: " + sharedItemKey.ToString());
}
catch
{
return true; // Item is probably deleted, report success to delete from queue
}
}
UpdateQuery uQuery = new UpdateQuery(typeof(ItemInfo));
uQuery.AddCondition("info_item_id", sharedItemKey.Id);
uQuery.AddCondition("info_item_type_id", sharedItemKey.TypeId);
try
{
if (owner.UserInfo.FacebookAuthenticated) // are we still authenticated
{
string postDescription = job.Body;
Facebook fb = new Facebook(core.Settings.FacebookApiAppid, core.Settings.FacebookApiSecret);
FacebookAccessToken token = fb.OAuthAppAccessToken(core, owner.UserInfo.FacebookUserId);
FacebookPost post = fb.StatusesUpdate(token, postDescription, sharedItem.Info.ShareUri, owner.UserInfo.FacebookSharePermissions);
if (post != null)
{
uQuery.AddField("info_facebook_post_id", post.PostId);
}
core.Db.Query(uQuery);
}
}
catch (System.Net.WebException ex)
{
HttpWebResponse response = (HttpWebResponse)ex.Response;
if (response.StatusCode == HttpStatusCode.Forbidden)
{
return true; // This request cannot succeed, so remove it from the queue
}
return false; // Failed for other reasons, retry
}
return true; // success
}
示例2: Show
public static void Show(Core core)
{
string path = core.Http.Query["path"];
long ownerId = core.Functions.RequestLong("owner_id", 0);
long ownerTypeId = core.Functions.RequestLong("owner_type_id", 0);
ItemKey ownerKey = new ItemKey(ownerId, ownerTypeId);
try
{
core.PrimitiveCache.LoadPrimitiveProfile(ownerKey);
Primitive owner = core.PrimitiveCache[ownerKey];
Page thePage = new Page(core, owner, path);
JsonSerializer js;
StringWriter jstw;
JsonTextWriter jtw;
js = new JsonSerializer();
jstw = new StringWriter();
jtw = new JsonTextWriter(jstw);
js.NullValueHandling = NullValueHandling.Ignore;
core.Http.WriteJson(js, thePage);
}
catch (PageNotFoundException)
{
}
catch
{
}
}
示例3: AjaxPermissionGroupDictionaryItem
public AjaxPermissionGroupDictionaryItem(ItemKey ik, string value, string tile)
{
this.Id = ik.Id;
this.TypeId = ik.TypeId;
this.Value = value;
this.Tile = tile;
}
示例4: PublishPost
public static bool PublishPost(Core core, Job job)
{
core.LoadUserProfile(job.UserId);
User owner = core.PrimitiveCache[job.UserId];
ItemKey sharedItemKey = new ItemKey(job.ItemId, job.ItemTypeId);
IActionableItem sharedItem = null;
core.ItemCache.RequestItem(sharedItemKey);
try
{
sharedItem = (IActionableItem)core.ItemCache[sharedItemKey];
}
catch
{
try
{
sharedItem = (IActionableItem)NumberedItem.Reflect(core, sharedItemKey);
HttpContext.Current.Response.Write("<br />Fallback, had to reflect: " + sharedItemKey.ToString());
}
catch
{
job.Cancel = true;
return true; // Item is probably deleted, report success to delete from queue
}
}
UpdateQuery uQuery = new UpdateQuery(typeof(ItemInfo));
uQuery.AddCondition("info_item_id", sharedItemKey.Id);
uQuery.AddCondition("info_item_type_id", sharedItemKey.TypeId);
try
{
if (owner.UserInfo.TumblrAuthenticated) // are we still authenticated
{
string postDescription = job.Body;
Tumblr t = new Tumblr(core.Settings.TumblrApiKey, core.Settings.TumblrApiSecret);
TumblrPost post = t.StatusesUpdate(new TumblrAccessToken(owner.UserInfo.TumblrToken, owner.UserInfo.TumblrTokenSecret), owner.UserInfo.TumblrHostname, sharedItem.PostType, string.Empty, postDescription, sharedItem.Info.ShareUri, sharedItem.Data, sharedItem.DataContentType);
if (post != null)
{
uQuery.AddField("info_tumblr_post_id", post.Id);
}
core.Db.Query(uQuery);
}
}
catch (System.Net.WebException ex)
{
HttpWebResponse response = (HttpWebResponse)ex.Response;
if (response.StatusCode == HttpStatusCode.Forbidden)
{
return true; // This request cannot succeed, so remove it from the queue
}
job.Error = ex.ToString();
return false; // Failed for other reasons, retry
}
return true; // success
}
示例5: return
public Primitive this[ItemKey key]
{
get
{
return (Primitive)core.ItemCache[key];
}
}
示例6: UnsavedAccessControlGrant
public UnsavedAccessControlGrant(Core core, ItemKey primitiveKey, ItemKey itemKey, long permissionId, AccessControlGrants grantAllow)
{
this.core = core;
this.itemKey = itemKey;
this.primitiveKey = primitiveKey;
this.permissionId = permissionId;
this.grantAllow = (sbyte)grantAllow;
}
示例7: Access
internal Access(Core core, ItemKey key, Primitive leafOwner)
{
if (core == null)
{
throw new NullCoreException();
}
this.core = core;
this.item = null;
this.owner = leafOwner;
this.itemKey = key;
this.viewer = core.Session.LoggedInMember;
}
示例8: PermissionGroupSelectBox
public PermissionGroupSelectBox(Core core, string name, ItemKey permissibleItem, List<PrimitivePermissionGroup> itemKeys)
{
this.core = core;
this.name = name;
this.permissibleItem = permissibleItem;
this.itemKeys = itemKeys;
disabled = false;
visible = true;
width = new StyleLength(100F, LengthUnits.Percentage);
script = new ScriptProperty();
}
示例9: IsNetworkMember
public bool IsNetworkMember(ItemKey key)
{
if (key != null)
{
if (networkMemberCache.ContainsKey(key))
{
return networkMemberCache[key];
}
else
{
DataTable memberTable = db.Query(string.Format("SELECT user_id FROM network_members WHERE network_id = {0} AND user_id = {1} AND member_active = 1",
networkId, key.Id));
if (memberTable.Rows.Count > 0)
{
networkMemberCache.Add(key, true);
return true;
}
else
{
networkMemberCache.Add(key, false);
return false;
}
}
}
return false;
}
示例10: LoadPrimitiveProfile
public void LoadPrimitiveProfile(ItemKey key)
{
core.ItemCache.RequestItem(key);
}
示例11: ExecuteCall
public override void ExecuteCall(string callName)
{
switch (callName)
{
case "list_galleries":
{
long ownerId = core.Functions.RequestLong("owner_id", core.Session.LoggedInMember.Id);
long ownerTypeId = core.Functions.RequestLong("owner_type_id", core.Session.LoggedInMember.ItemKey.TypeId);
long galleryId = core.Functions.RequestLong("gallery_id", 0);
ItemKey ownerKey = new ItemKey(ownerId, ownerTypeId);
Gallery gallery = null;
if (galleryId > 0)
{
gallery = new Gallery(core, galleryId);
}
else
{
core.PrimitiveCache.LoadPrimitiveProfile(ownerKey);
Primitive owner = core.PrimitiveCache[ownerKey];
gallery = new Gallery(core, owner);
}
if (gallery != null)
{
if (gallery.Access.Can("VIEW"))
{
List<Gallery> galleries = gallery.GetGalleries();
List<Gallery> responseGalleries = new List<Gallery>();
foreach (Gallery g in galleries)
{
if (gallery.Access.Can("VIEW"))
{
responseGalleries.Add(g);
}
}
core.Response.WriteObject(responseGalleries);
}
else
{
}
}
}
break;
case "list_gallery_items":
{
long galleryId = core.Functions.RequestLong("gallery_id", 0);
long offsetId = core.Functions.RequestLong("offset_id", 0);
Gallery gallery = null;
if (galleryId > 0)
{
gallery = new Gallery(core, galleryId);
}
if (gallery != null)
{
if (gallery.Access.Can("VIEW_ITEMS"))
{
List<GalleryItem> galleryItems = gallery.GetItems(core, 1, 12, offsetId);
core.Response.WriteObject(galleryItems);
}
}
}
break;
case "gallery_item":
GalleryItem.Show(core);
break;
case "upload":
Gallery.Upload(core);
break;
}
}
示例12: ItemSubscribedEventArgs
public ItemSubscribedEventArgs(User rater, ItemKey itemKey)
{
this.rater = rater;
this.itemKey = itemKey;
}
示例13: ParseACL
public void ParseACL(Template template, Primitive owner, string variable)
{
Template aclTemplate = new Template("std.acl.html");
aclTemplate.Medium = core.Template.Medium;
aclTemplate.SetProse(core.Prose);
if (itemPermissions == null)
{
itemPermissions = GetPermissions(core, item);
}
if (itemGrants == null)
{
itemGrants = AccessControlGrant.GetGrants(core, item);
}
if (unsavedGrants == null)
{
unsavedGrants = new List<UnsavedAccessControlGrant>();
}
if (itemGrants != null)
{
foreach (AccessControlGrant itemGrant in itemGrants)
{
core.PrimitiveCache.LoadPrimitiveProfile(itemGrant.PrimitiveKey);
}
}
bool simple = item.IsSimplePermissions;
string mode = core.Http["aclmode"];
switch (mode)
{
case "simple":
simple = true;
break;
case "detailed":
simple = false;
break;
}
bool first = true;
PermissionTypes lastType = PermissionTypes.View;
VariableCollection permissionTypeVariableCollection = null;
PermissionGroupSelectBox typeGroupSelectBox = null;
List<PrimitivePermissionGroup> ownerGroups = null;
if (itemPermissions != null)
{
foreach (AccessControlPermission itemPermission in itemPermissions)
{
if (first || itemPermission.PermissionType != lastType)
{
if (typeGroupSelectBox != null)
{
permissionTypeVariableCollection.Parse("S_SIMPLE_SELECT", typeGroupSelectBox);
}
permissionTypeVariableCollection = aclTemplate.CreateChild("permision_types");
typeGroupSelectBox = new PermissionGroupSelectBox(core, "group-select-" + itemPermission.PermissionType.ToString(), item.ItemKey);
permissionTypeVariableCollection.Parse("TITLE", AccessControlLists.PermissionTypeToString(itemPermission.PermissionType));
first = false;
lastType = itemPermission.PermissionType;
}
if (simple)
{
if (ownerGroups == null)
{
ownerGroups = new List<PrimitivePermissionGroup>();
int itemGroups = 0;
Type type = item.GetType();
if (type.GetMethod(type.Name + "_GetItemGroups", new Type[] { typeof(Core) }) != null)
{
ownerGroups.AddRange((List<PrimitivePermissionGroup>)type.InvokeMember(type.Name + "_GetItemGroups", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { core }));
itemGroups = ownerGroups.Count;
}
ownerGroups.AddRange(core.GetPrimitivePermissionGroups(owner));
}
VariableCollection permissionVariableCollection = permissionTypeVariableCollection.CreateChild("permission_desc");
permissionVariableCollection.Parse("ID", itemPermission.Id.ToString());
permissionVariableCollection.Parse("TITLE", itemPermission.Name);
permissionVariableCollection.Parse("DESCRIPTION", itemPermission.Description);
if (itemGrants != null)
{
foreach (AccessControlGrant itemGrant in itemGrants)
{
if (itemGrant.PermissionId == itemPermission.Id)
{
switch (itemGrant.Allow)
{
case AccessControlGrants.Allow:
PrimitivePermissionGroup ppg = null;
//.........这里部分代码省略.........
示例14: DoSearch
public override SearchResult DoSearch(string input, int pageNumber, Primitive filterByOwner, Type filterByType)
{
Initialise();
int perPage = 10;
int start = (pageNumber - 1) * perPage;
List<ISearchableItem> results = new List<ISearchableItem>();
List<ItemKey> itemKeys = new List<ItemKey>();
List<long> applicationIds = new List<long>();
IndexSearcher searcher = new IndexSearcher(directory);
QueryParser parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, "item_string", analyzer);
BooleanQuery query = new BooleanQuery();
Query bodyQuery = parser.Parse(input);
query.Add(bodyQuery, Occur.MUST);
BooleanQuery accessQuery = new BooleanQuery();
TermQuery accessPublicQuery = new TermQuery(new Term("item_public", "1"));
accessQuery.Add(accessPublicQuery, Occur.SHOULD);
if (core.Session.IsLoggedIn)
{
List<long> friends = core.Session.LoggedInMember.GetFriendsWithMeIds();
BooleanQuery accessFriendQuery = new BooleanQuery();
TermQuery friendQuery = new TermQuery(new Term("item_public", "2"));
accessFriendQuery.Add(friendQuery, Occur.MUST);
string userTypeId = ItemType.GetTypeId(core, typeof(User)).ToString();
foreach (long friendId in friends)
{
BooleanQuery ownerQuery = new BooleanQuery();
TermQuery ownerIdQuery = new TermQuery(new Term("owner_id", friendId.ToString()));
TermQuery ownerTypeQuery = new TermQuery(new Term("owner_type_id", userTypeId));
ownerQuery.Add(ownerIdQuery, Occur.MUST);
ownerQuery.Add(ownerTypeQuery, Occur.MUST);
accessFriendQuery.Add(ownerQuery, Occur.SHOULD);
}
accessQuery.Add(accessFriendQuery, Occur.SHOULD);
}
query.Add(accessQuery, Occur.MUST);
if (filterByType != null)
{
TermQuery typeQuery = new TermQuery(new Term("item_type_id", ItemType.GetTypeId(core, filterByType).ToString()));
query.Add(typeQuery, Occur.MUST);
}
if (filterByOwner != null)
{
TermQuery ownerIdQuery = new TermQuery(new Term("owner_id", filterByOwner.Id.ToString()));
TermQuery ownerTypeIdQuery = new TermQuery(new Term("owner_type_id", filterByOwner.TypeId.ToString()));
query.Add(ownerIdQuery, Occur.MUST);
query.Add(ownerTypeIdQuery, Occur.MUST);
}
TopScoreDocCollector collector = TopScoreDocCollector.Create(start + perPage, true);
searcher.Search(query, collector);
ScoreDoc[] hits = collector.TopDocs().ScoreDocs;
int totalResults = collector.TotalHits;
int returnResults = hits.Length;
int end = Math.Min(hits.Length, start + perPage);
for (int i = start; i < end; i++)
{
Document doc = searcher.Doc(hits[i].Doc);
long itemId = 0;
long itemTypeId = 0;
long applicationId = 0;
long.TryParse(doc.GetField("item_id").StringValue, out itemId);
long.TryParse(doc.GetField("item_type_id").StringValue, out itemTypeId);
long.TryParse(doc.GetField("application_id").StringValue, out applicationId);
ItemKey key = new ItemKey(itemId, itemTypeId);
if (!applicationIds.Contains(applicationId))
{
applicationIds.Add(applicationId);
}
itemKeys.Add(key);
}
// Force each application with results to load
//.........这里部分代码省略.........
示例15: GetDefaultCan
public bool GetDefaultCan(string permission, ItemKey viewer)
{
return false;
}