当前位置: 首页>>代码示例>>C#>>正文


C# ItemKey.ToString方法代码示例

本文整理汇总了C#中BoxSocial.Internals.ItemKey.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ItemKey.ToString方法的具体用法?C# ItemKey.ToString怎么用?C# ItemKey.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BoxSocial.Internals.ItemKey的用法示例。


在下文中一共展示了ItemKey.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
                {
                    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
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:60,代码来源:Tumblr.cs

示例2: 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
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:60,代码来源:Facebook.cs

示例3: RequestItem

        public void RequestItem(ItemKey itemKey)
        {
            if (itemKey.TypeId == 0)
            {
                return;
            }
            if (!typesAccessed.ContainsKey(itemKey.TypeId))
            {
                // We need to make sure that the application is loaded
                if (itemKey.GetType(core).ApplicationId > 0)
                {
                    core.ItemCache.RegisterType(typeof(ApplicationEntry));

                    ItemKey applicationKey = new ItemKey(itemKey.GetType(core).ApplicationId, ItemType.GetTypeId(core, typeof(ApplicationEntry)));
                    core.ItemCache.RequestItem(applicationKey);

                    ApplicationEntry ae = (ApplicationEntry)core.ItemCache[applicationKey];

                    typesAccessed.Add(itemKey.TypeId, ae.Assembly.GetType(itemKey.GetType(core).TypeNamespace));
                }
                else
                {
                    try
                    {
                        typesAccessed.Add(itemKey.TypeId, Type.GetType(itemKey.GetType(core).TypeNamespace));
                    }
                    catch
                    {
                        HttpContext.Current.Response.Write(itemKey.ToString());
                        HttpContext.Current.Response.End();
                    }
                }
            }
            NumberedItemId loadedId = new NumberedItemId(itemKey.Id, itemKey.TypeId);
            if (!(batchedItemIds.Contains(loadedId) || itemsCached.ContainsKey(loadedId)))
            {
                batchedItemIds.Add(loadedId);
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:39,代码来源:NumberedItemsCache.cs


注:本文中的BoxSocial.Internals.ItemKey.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。