Example #1
0
        public static string GetUserAvatarUrl(int userID, bool useOriginalImage, bool useCachedAvatarRoot)
        {
            var _avatarRoot = 0;
            var sueetieUser = GetSueetieUserList(SueetieUserType.RegisteredUser).Find(u => u.UserID == userID);

            if (!useCachedAvatarRoot)
            {
                sueetieUser = GetUser(userID, false);
            }

            if (sueetieUser != null)
            {
                _avatarRoot = sueetieUser.AvatarRoot;
            }
            else
            {
                _avatarRoot = 0;
            }

            var _extension = "t.jpg";

            if (useOriginalImage)
            {
                _extension = ".jpg";
            }
            return(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/" +
                   SueetieConfiguration.Get().AvatarSettings.AvatarFolderPath.Replace("\\", "/") + _avatarRoot + _extension);
        }
Example #2
0
        /// <summary>
        /// Calculate the required width and height of the optimized image based on the specified Bitmap. The aspect ratio
        /// of the bitmap image is preserved in the calculated values. This method does not create the optimized image -
        /// it only calculates the dimensions it should be created with.
        /// </summary>
        /// <param name="bmp">The Bitmap containing an image from which the optimized width and height values should be calculated.</param>
        /// <param name="width">The calculated width of the optimized image.</param>
        /// <param name="height">The calculated height of the optimized image.</param>
        public static void CalculateOptimizedWidthAndHeight(Image bmp, out int width, out int height)
        {
            if (bmp == null)
            {
                throw new ArgumentNullException("bmp");
            }

            // Calculate the width and height based on the user settings and aspect ratio of the specified bitmap.
            //

            ///	maxLength: The length (in pixels) of the longest edge of an optimized image.  This value is used when an optimized
            ///	image is created. The length of the shorter side is calculated automatically based on the aspect ratio of the image.

            var maxLength = SueetieConfiguration.Get().AvatarSettings.Height;
            int originalWidth, originalHeight, newWidth, newHeight;

            originalWidth  = bmp.Width;
            originalHeight = bmp.Height;

            if ((maxLength > originalWidth) && (maxLength > originalHeight))
            {
                // Bitmap is smaller than desired optimized dimensions. Don't enlarge optimized; just use bitmap size.
                newWidth  = originalWidth;
                newHeight = originalHeight;
            }
            else if (originalWidth > originalHeight)
            {
                // Bitmap is in landscape format (width > height). The width will be the longest dimension.
                newWidth  = maxLength;
                newHeight = originalHeight * newWidth / originalWidth;
            }
            else
            {
                // Bitmap is in portrait format (height > width). The height will be the longest dimension.
                newHeight = maxLength;
                newWidth  = originalWidth * newHeight / originalHeight;
            }

            width  = newWidth;
            height = newHeight;
        }
        public List <SueetieBlogComment> GetRecentComments(int numRecords, int userID, int applicationID, bool isRestricted)
        {
            ContentQuery contentQuery = new ContentQuery
            {
                NumRecords    = numRecords,
                UserID        = userID,
                ContentTypeID = (int)SueetieContentType.BlogComment,
                GroupID       = -1,
                ApplicationID = applicationID,
                IsRestricted  = isRestricted,
                TruncateText  = true
            };

            List <SueetieBlogComment> _sueetieBlogComments = SueetieBlogs.GetSueetieBlogCommentList(contentQuery);

            foreach (SueetieBlogComment msg in _sueetieBlogComments)
            {
                msg.Comment = DataHelper.TruncateText(msg.Comment, SueetieConfiguration.Get().Core.TruncateTextCount);
            }
            return(_sueetieBlogComments);
        }
Example #4
0
        private static SiteStatistics Get()
        {
            var statsKey    = "SueetieSiteStatistics" + SueetieConfiguration.Get().Core.SiteUniqueName;
            var statsLocker = new object();

            var stats = SueetieCache.Current[statsKey] as SiteStatistics;

            if (stats == null)
            {
                lock (statsLocker)
                {
                    stats = SueetieCache.Current[statsKey] as SiteStatistics;
                    if (stats == null)
                    {
                        stats = new SiteStatistics();
                        SueetieCache.Current.InsertMax(statsKey, stats);
                    }
                }
            }
            return(stats);
        }
        public List <SueetieForumMessage> GetRecentForumMessages(int numRecords, int userID, int applicationID, bool isRestricted)
        {
            ContentQuery contentQuery = new ContentQuery
            {
                NumRecords    = numRecords,
                UserID        = userID,
                ContentTypeID = (int)SueetieContentType.ForumMessage,
                GroupID       = -1,
                ApplicationID = applicationID,
                IsRestricted  = isRestricted,
                TruncateText  = true
            };

            List <SueetieForumMessage> _sueetieForumMessages = SueetieForums.GetSueetieForumMessageList(contentQuery);

            foreach (SueetieForumMessage msg in _sueetieForumMessages)
            {
                msg.Message = DataHelper.TruncateText(msg.Message, SueetieConfiguration.Get().Core.TruncateTextCount);
            }
            return(_sueetieForumMessages);
        }
        public static SueetieConfiguration Get()
        {
            var config = SueetieCache.Current[configKey] as SueetieConfiguration;

            if (config == null)
            {
                lock (configLocker)
                {
                    config = SueetieCache.Current[configKey] as SueetieConfiguration;
                    if (config == null)
                    {
                        var configPath = siteRootPath + "/util/config/Sueetie.config";
                        //string configPath = AppDomain.CurrentDomain.BaseDirectory + "Sueetie.config";
                        //string configPath = HttpContext.Current.Server.MapPath("/") + "Sueetie.config";
                        var doc = XDocument.Load(configPath);

                        config = new SueetieConfiguration(doc);
                        SueetieCache.Current.InsertMax(configKey, config, new CacheDependency(configPath));
                    }
                }
            }
            return(config);
        }
Example #7
0
 public static string UserLogActivityListCacheKey(ContentQuery contentQuery)
 {
     return(string.Format("UserLogActivityList-{0}-{1}-{2}", contentQuery.GroupID, contentQuery.SueetieContentViewTypeID, SueetieConfiguration.Get().Core.SiteUniqueName));
 }
Example #8
0
 public static string SueetieTagCloudListCacheKey(int _applicationTypeID)
 {
     return(string.Format("SueetieTagCloudList-{0}-{1}", _applicationTypeID, SueetieConfiguration.Get().Core.SiteUniqueName));
 }
Example #9
0
 public SueetieUrl MasterAccountInfo()
 {
     return(this.GetSueetieUrl("members_masteraccountinfo", new[] { SueetieConfiguration.Get().Core.ForumFolderName }));
 }
 public static string SueetieContentPageListCacheKey(int contentGroupId)
 {
     return(string.Format("SueetieContentPageList-{0}-{1}", SueetieConfiguration.Get().Core.SiteUniqueName, contentGroupId));
 }
Example #11
0
 public static string AlbumContentTypeDescriptionCacheKey()
 {
     return(string.Format("SueetieApplicationList-{0}", SueetieConfiguration.Get().Core.SiteUniqueName));
 }
Example #12
0
 public static string SueetieMediaGalleryListCacheKey()
 {
     return(string.Format("SueetieMediaGalleryList-{0}", SueetieConfiguration.Get().Core.SiteUniqueName));
 }
Example #13
0
 public SueetieUrl MasterProfile(int forumUserID)
 {
     return(this.GetSueetieUrl("members_masterprofile", new[] { SueetieConfiguration.Get().Core.ForumFolderName, forumUserID.ToString() }));
 }
Example #14
0
 protected override void OnPreInit(EventArgs e)
 {
     this.MasterPageFile = "\\themes\\" + SueetieConfiguration.Get().Core.AdminTheme + "\\masters\\admin.master";
     base.OnPreInit(e);
 }
Example #15
0
        private static UserLogActivity FormatUserLogRow(UserLogActivity _u)
        {
            _u.ActivityClass = _u.ApplicationPath;

            var _profileUrl   = SueetieUrls.Instance.MyProfile(_u.UserID).Url;
            var _toProfileUrl = SueetieUrls.Instance.MasterProfile(SueetieUsers.GetThinSueetieUser(_u.ToUserID).ForumUserID).Url;

            if (SueetieConfiguration.Get().Core.UseForumProfile)
            {
                var thinUser = SueetieUsers.GetThinSueetieUser(_u.UserID);
                if (thinUser != null)
                {
                    var masterProfile = SueetieUrls.Instance.MasterProfile(thinUser.ForumUserID);
                    if (masterProfile != null)
                    {
                        _profileUrl = masterProfile.Url;
                    }
                }
            }
            var username   = string.Format("<a href='" + _profileUrl + "' class='ActivityUser'>{0}</a> ", _u.DisplayName);
            var toUsername = string.Format("<a href='" + _profileUrl + "' class='ActivityUser'>{0}</a> ", _u.ToUserDisplayName);

            _u.Activity = string.Empty;

            switch (_u.UserLogCategoryID)
            {
            case (int)UserLogCategoryType.Following:
                var _toUserProfileUrl = SueetieUrls.Instance.MyProfile(_u.ToUserID).Url;
                if (SueetieConfiguration.Get().Core.UseForumProfile)
                {
                    _toUserProfileUrl = SueetieUrls.Instance.MasterProfile(SueetieUsers.GetThinSueetieUser(_u.ToUserID).ForumUserID).Url;
                }
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_is_now_following"),
                    username,
                    string.Format(
                        "<a href='" + _toUserProfileUrl + "' class='ActivitySource'>{0}</a>",
                        _u.ToUserDisplayName));
                break;

            case (int)UserLogCategoryType.BlogPost:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_blogged"),
                    username,
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceDescription),
                    SueetieLocalizer.GetString("activity_in"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));

                break;

            case (int)UserLogCategoryType.BlogComment:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_commented_on"),
                    username,
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceParentDescription),
                    SueetieLocalizer.GetString("activity_in"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));
                _u.ActivityClass = "blogcomment";
                break;

            case (int)UserLogCategoryType.ForumTopic:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_posted"),
                    username,
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceDescription),
                    SueetieLocalizer.GetString("activity_in"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));
                break;

            case (int)UserLogCategoryType.ForumMessage:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_replied_to"),
                    username,
                    string.Format(
                        "<a href='{0}'>{1}</a>", _u.Permalink, _u.SourceParentDescription),
                    SueetieLocalizer.GetString("activity_in"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));
                break;

            case (int)UserLogCategoryType.ForumAnswer:
                var _answerBy = SueetieLocalizer.GetString("activity_by") + " " + toUsername;
                if (_u.UserID == _u.ToUserID)
                {
                    _answerBy = string.Empty;
                }
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_marked_as_answer"),
                    username,
                    string.Format(
                        "<a href='{0}'>{1}</a>", _u.Permalink, _u.SourceDescription),
                    _answerBy,
                    SueetieLocalizer.GetString("activity_as_an_answer"),
                    SueetieLocalizer.GetString("activity_in"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));
                // {0} marked {1} {2} {3} {4} {5} {6}
                break;

            case (int)UserLogCategoryType.NewWikiPage:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_created"),
                    username,
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceDescription),
                    SueetieLocalizer.GetString("activity_in_the"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));
                break;

            case (int)UserLogCategoryType.NewWikiMessage:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_new_wiki_message"),
                    username,
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, SueetieLocalizer.GetString("activity_a_new_message")),
                    SueetieLocalizer.GetString("activity_to"),
                    string.Format(
                        "<a href='{0}' class='ActivitySourceParent'>{1}</a>",
                        _u.SourceParentPermalink,
                        _u.SourceParentDescription),
                    SueetieLocalizer.GetString("activity_in_the"),
                    string.Format("<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                                  _u.ApplicationPath,
                                  _u.ApplicationName));
                break;

            case (int)UserLogCategoryType.WikiPageUpdated:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_updated"),
                    username,
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceDescription),
                    SueetieLocalizer.GetString("activity_in_the"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));

                break;

            case (int)UserLogCategoryType.DocumentAlbum:
            case (int)UserLogCategoryType.AudioAlbum:
            case (int)UserLogCategoryType.ImageAlbum:
            case (int)UserLogCategoryType.UserMediaAlbum:
            case (int)UserLogCategoryType.MultipurposeAlbum:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_created_a_new"),
                    username,
                    _u.SourceDescription.ToLower(),
                    SueetieLocalizer.GetString("activity_named"),
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceParentDescription),
                    SueetieLocalizer.GetString("activity_in"),
                    string.Format(
                        "<a href='{0}' class='ActivitySourceParent'>{1}</a>",
                        _u.SourceParentPermalink,
                        _u.ApplicationName));
                break;

            case (int)UserLogCategoryType.AudioUploaded:
            case (int)UserLogCategoryType.DocumentUploaded:
            case (int)UserLogCategoryType.ImageUploaded:
            case (int)UserLogCategoryType.OtherMediaUploaded:
            case (int)UserLogCategoryType.VideoUploaded:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_added_new"),
                    username,
                    _u.SourceDescription.ToLower(),
                    SueetieLocalizer.GetString("activity_to"),
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceParentDescription),
                    SueetieLocalizer.GetString("activity_in"),
                    string.Format(
                        "<a href='{0}' class='ActivitySourceParent'>{1}</a>",
                        _u.SourceParentPermalink,
                        _u.ApplicationName));
                _u.ActivityClass = "mediaupload";
                break;

            case (int)UserLogCategoryType.MarketplaceProduct:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_added_a_new_product_item"),
                    username,
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceDescription),
                    SueetieLocalizer.GetString("activity_in_the"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));
                break;

            case (int)UserLogCategoryType.CMSPageUpdated:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_updated_a_cms_page"),
                    username,
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceDescription),
                    SueetieLocalizer.GetString("activity_in_the"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));
                break;

            case (int)UserLogCategoryType.CMSPageCreated:
                _u.Activity += string.Format(
                    SueetieLocalizer.GetString("activity_created_a_cms_page"),
                    username,
                    string.Format(
                        "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceDescription),
                    SueetieLocalizer.GetString("activity_in_the"),
                    string.Format(
                        "<a href='/{0}/default.aspx' class='ActivitySourceParent'>{1}</a>",
                        _u.ApplicationPath,
                        _u.ApplicationName));
                break;

            case (int)UserLogCategoryType.CalendarEvent:
                if (_u.Permalink == "na")
                {
                    _u.Activity += string.Format(
                        SueetieLocalizer.GetString("activity_new_calendar_event"),
                        username,
                        string.Format("<span) class='ActivitySpan'>{0}</span>", _u.SourceDescription),
                        SueetieLocalizer.GetString("activity_in_the"),
                        string.Format(
                            "<a href='{0}' class='ActivitySourceParent'>{1}</a>",
                            _u.SourceParentPermalink,
                            _u.SourceParentDescription));
                }
                else
                {
                    _u.Activity += string.Format(
                        SueetieLocalizer.GetString("activity_new_calendar_event"),
                        username,
                        string.Format(
                            "<a href='{0}' class='ActivitySource'>{1}</a>", _u.Permalink, _u.SourceDescription),
                        SueetieLocalizer.GetString("activity_in_the"),
                        string.Format(
                            "<a href='{0}' class='ActivitySourceParent'>{1}</a>",
                            _u.SourceParentPermalink,
                            _u.SourceParentDescription));
                }

                _u.ActivityClass = "calendarevent";
                break;

            case (int)UserLogCategoryType.JoinedCommunity:
                _u.Activity      = string.Format(SueetieLocalizer.GetString("activity_became_a_new_member"), username);
                _u.ActivityClass = "newuser";
                break;

            case (int)UserLogCategoryType.Registered:
                _u.Activity      = string.Format(SueetieLocalizer.GetString("activity_user_registered"), username);
                _u.ActivityClass = "newuser";
                break;

            case (int)UserLogCategoryType.LoggedIn:
                _u.Activity      = string.Format(SueetieLocalizer.GetString("activity_user_loggedin"), username);
                _u.ActivityClass = "newuser";
                break;

            default:
                _u.Activity = _u.UserLogCategoryID + " - " + _u.UserLogID + " - " + _u.ApplicationName;
                break;
            }
            return(_u);
        }
Example #16
0
 public static string SueetieCalendarEventListCacheKey(int calendarId)
 {
     return(string.Format("SueetieCalendarEventList-{0}-{1}", calendarId, SueetieConfiguration.Get().Core.SiteUniqueName));
 }
Example #17
0
 public static string SueetieUserListCacheKey(SueetieUserType sueetieUserType)
 {
     return(string.Format("SueetieUserList-{0}-{1}", SueetieConfiguration.Get().Core.SiteUniqueName, (int)sueetieUserType));
 }
Example #18
0
 public static string FilteredAgentListCacheKey()
 {
     return(string.Format("FilteredAgentList-{0}", SueetieConfiguration.Get().Core.SiteUniqueName));
 }
Example #19
0
 public static string SueetieMediaAlbumListCacheKey(int galleryId)
 {
     return(string.Format("SueetieMediaAlbumList-{0}-{1}", SueetieConfiguration.Get().Core.SiteUniqueName, galleryId));
 }
Example #20
0
 public static string SueetieWikiMessageListCacheKey()
 {
     return(string.Format("SueetieWikiMessageList-{0}", SueetieConfiguration.Get().Core.SiteUniqueName));
 }
Example #21
0
 private static string BlogListCacheKey(ApplicationQuery applicationQuery)
 {
     return(string.Format("BlogList-{0}-{1}", SueetieConfiguration.Get().Core.SiteUniqueName, applicationQuery.CategoryID));
 }