protected void Page_Load(object sender, EventArgs e)
        {
            string path       = this.ViewName.ControlPath();
            string headerpath = this.HeaderViewName.ControlPath();

            ContentQuery contentQuery = new ContentQuery
            {
                NumRecords    = this.NumRecords,
                UserID        = this.UserID,
                GroupID       = this.GroupID,
                ApplicationID = this.ApplicationID,
                IsRestricted  = this.IsRestricted,
                TruncateText  = false,
                CacheMinutes  = this.CacheMinutes
            };

            List <UserLogActivity> userLogActivityList = SueetieLogs.GetUserLogActivityList(contentQuery);

            foreach (UserLogActivity userLogActivity in userLogActivityList)
            {
                if (userLogActivity.ShowHeader)
                {
                    Sueetie.Controls.UserLogActivityView headercontrol = (Sueetie.Controls.UserLogActivityView)LoadControl(headerpath);
                    headercontrol.LogActivity = userLogActivity;
                    phUserLogActivity.Controls.Add(headercontrol);
                }

                Sueetie.Controls.UserLogActivityView control = (Sueetie.Controls.UserLogActivityView)LoadControl(path);
                control.LogActivity = userLogActivity;
                phUserLogActivity.Controls.Add(control);
            }
        }
Пример #2
0
    private int ProcessAddAnswer(int topicID, int messageID, int userID, int applicationID, bool isFirst)
    {
        ForumAnswerKey _forumAnswerKey = new ForumAnswerKey
        {
            IsFirst   = isFirst,
            MessageID = messageID,
            TopicID   = topicID,
            UserID    = userID
        };

        int answerID = ForumAnswers.RecordAnswer(_forumAnswerKey);

        if (answerID > 0)
        {
            string appKey = SueetieCommon.GetSueetieApplication(applicationID).ApplicationKey;

            SueetieContent _sueetieContent = new SueetieContent
            {
                SourceID      = answerID,
                ApplicationID = applicationID,
                ContentTypeID = (int)SueetieContentType.ForumAnswer,
                Permalink     = "/" + appKey + "/default.aspx?g=posts&m=" + messageID + "#post" + messageID,
                UserID        = userID
            };
            int contentID = SueetieCommon.AddSueetieContent(_sueetieContent);

            SueetieLogs.LogUserEntry(UserLogCategoryType.ForumAnswer, contentID, userID);
            ForumAnswers.ClearForumAnswerKeyListCache();
        }
        return(answerID);
    }
Пример #3
0
        public void UpdateIndex(SueetieIndexTaskItem _taskItem)
        {
            DateTime startTime = DateTime.Now;

            try
            {
                _taskItem.BlogPosts     = AddSueetieSearchDocs(ProcessBlogPosts(_taskItem.TaskStartDateTime));
                _taskItem.WikiPages     = AddSueetieSearchDocs(ProcessSueetieWikiPages(_taskItem.TaskStartDateTime));
                _taskItem.ForumMessages = AddSueetieSearchDocs(ProcessSueetieForumMessages(_taskItem.TaskStartDateTime));
                _taskItem.MediaAlbums   = AddSueetieSearchDocs(ProcessSueetieMediaAlbums(_taskItem.TaskStartDateTime));
                _taskItem.MediaObjects  = AddSueetieSearchDocs(ProcessSueetieMediaObjects(_taskItem.TaskStartDateTime));
                _taskItem.ContentPages  = AddSueetieSearchDocs(ProcessSueetieContentPages(_taskItem.TaskStartDateTime));

                _taskItem.DocumentsIndexed = GetTotalIndexedCount();
                CommitAndCloseWriter();

                if (_taskItem.TaskTypeID == (int)SueetieTaskType.BuildSearchIndex)
                {
                    SueetieSearchDataProvider _provider = SueetieSearchDataProvider.LoadProvider();
                    _provider.UpdateAndEndTask(_taskItem);
                }
                DateTime endTime = DateTime.Now;
                SueetieLogs.LogSiteEntry(SiteLogType.General, SiteLogCategoryType.TasksMessage, "INDEX SUCCESSFUL: " +
                                         string.Format("Blog Posts: {0}, Wiki Pages: {1}, Forum Messages: {2}, Media Albums: {3}, Media Objects: {4}, Content Pages: {5}, Indexed Documents: {6}",
                                                       _taskItem.BlogPosts, _taskItem.WikiPages, _taskItem.ForumMessages, _taskItem.MediaAlbums, _taskItem.MediaObjects, _taskItem.ContentPages, _taskItem.DocumentsIndexed) +
                                         " - REBUILD INDEX DURATION: " + (endTime - startTime).TotalMilliseconds + " Milliseconds.");
            }
            catch (Exception e)
            {
                DateTime endTime = DateTime.Now;
                SueetieLogs.LogSearchException("SEARCH REBUILD INDEX ERROR: " + e.Message + "\n\nSTACKTRACE: " + e.StackTrace + " - REBUILD INDEX DURATION: " + (endTime - startTime).TotalMilliseconds + " Milliseconds.");
            }
        }
Пример #4
0
        void Login1_LoggedIn(object sender, EventArgs e)
        {
            if (IsCaptchaValid && Page.IsValid && IsPostBack)
            {
                MembershipUser user        = Membership.GetUser(Login1.UserName);
                SueetieUser    sueetieUser = SueetieUsers.GetUser(user.UserName);

                bool   hasIP = String.IsNullOrEmpty(sueetieUser.IP);
                string ip    = String.IsNullOrEmpty(sueetieUser.IP) ?
                               HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] : sueetieUser.IP;
                if (SueetieUsers.IsIPBanned(ip))
                {
                    Response.Redirect("/members/message.aspx?msgid=9");
                }
                else
                {
                    SueetieUsers.CreateUpdateUserProfileCookie(sueetieUser);
                    SueetieLogs.LogUserEntry(UserLogCategoryType.LoggedIn, -1, sueetieUser.UserID);

                    sueetieUser.IP = ip;
                    SueetieUsers.UpdateSueetieUserIP(sueetieUser);

                    string returnUrl = Request.QueryString["ReturnUrl"];
                    if (returnUrl != null)
                    {
                        Response.Redirect(returnUrl);
                    }
                    else
                    {
                        Response.Redirect("/default.aspx", true);
                    }
                }
            }
        }
Пример #5
0
    public string AddCalendarEvent(string id, string title, string description, string start, string end, string allDay, string endRepeat, int calendarID, string url, int sourceContentID)
    {
        int _currentSueetieUserID = SueetieContext.Current.User.UserID;
        SueetieCalendarEvent sueetieCalendarEvent = new SueetieCalendarEvent
        {
            EventGuid        = new Guid(id),
            EventTitle       = title,
            EventDescription = description,
            StartDateTime    = SueetieCalendars.ConvertJsonDate(start),
            EndDateTime      = SueetieCalendars.ConvertJsonDate(end),
            CalendarID       = calendarID,
            AllDayEvent      = DataHelper.StringToBool(allDay),
            RepeatEndDate    = DataHelper.SafeMinDate(endRepeat),
            SourceContentID  = 0,
            CreatedBy        = _currentSueetieUserID
        };

        if (string.IsNullOrEmpty(url))
        {
            sueetieCalendarEvent.SourceContentID = sourceContentID;
            sueetieCalendarEvent.Url             = url;
        }

        if (!string.IsNullOrEmpty(endRepeat))
        {
            try
            {
                Convert.ToDateTime(endRepeat);
            }
            catch { }
        }

        int eventID = SueetieCalendars.CreateSueetieCalendarEvent(sueetieCalendarEvent);


        SueetieContent sueetieContent = new SueetieContent
        {
            SourceID      = eventID,
            ContentTypeID = (int)SueetieContentType.CalendarEvent,
            Permalink     = "na",
            ApplicationID = (int)SueetieApplicationType.Unknown,
            UserID        = _currentSueetieUserID
        };
        int contentID = SueetieCommon.AddSueetieContent(sueetieContent);

        if (SueetieContext.Current.User.IsContentAdministrator)
        {
            SueetieLogs.LogUserEntry(UserLogCategoryType.CalendarEvent, contentID, _currentSueetieUserID);
        }

        SueetieCalendars.ClearSueetieCalendarEventListCache(calendarID);

        return("<b>NEW EVENT ITEM:</b> " + id + "\n\n<b>TITLE:</b> " + title + "\n<b>DESCRIPTION:</b> " + description + " \n<b>START DATETIME:</b> " + SueetieCalendars.ConvertJsonDate(start).ToString() +
               "\n<b>END DATETIME:</b> " + SueetieCalendars.ConvertJsonDate(end).ToString() + "\n<b>END REPEAT DATE:</b> " + endRepeat + "\n<b>ALL DAY EVENT:</b> " +
               allDay + "\n<b>CALENDAR ID:</b> " + calendarID);
    }
Пример #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         EventLogItems = SueetieLogs.GetEventLogCount();
         ResetEventlogPageProperties();
         PopulateSiteLogTypeList(ddlSiteLogTypeIDs);
         BindUserAccounts();
     }
 }
Пример #7
0
    public string BlogCommenterFollow(int userID, string postGuid)
    {
        SueetieBlogComment sueetieBlogComment = SueetieBlogs.GetSueetieBlogComment(postGuid);

        if (userID > 0)
        {
            if (sueetieBlogComment.SueetieCommentID > 0)
            {
                string        result        = "You are now following " + sueetieBlogComment.DisplayName;
                SueetieFollow sueetieFollow = new SueetieFollow
                {
                    FollowerUserID    = userID,
                    FollowingUserID   = sueetieBlogComment.UserID,
                    ContentIDFollowed = sueetieBlogComment.SueetieCommentID
                };

                if (sueetieBlogComment.UserID > 0)
                {
                    if (sueetieFollow.FollowerUserID == sueetieFollow.FollowingUserID)
                    {
                        result = "Sorry, you cannot follow yourself...";
                    }
                    else
                    {
                        int followID = SueetieUsers.FollowUser(sueetieFollow);
                        if (followID < 0)
                        {
                            result = "You are already following " + sueetieBlogComment.DisplayName;
                        }
                        else
                        {
                            SueetieLogs.LogUserEntry(UserLogCategoryType.Following, sueetieBlogComment.UserID, userID);
                        }
                    }
                }
                else
                {
                    result = "Sorry, " + sueetieBlogComment.Author + " is not a member and thus cannot be followed.";
                }
                return(result);
            }
            else
            {
                return("Sorry, we added following after this comment was posted. Please use a more current comment to follow this member.");
            }
        }
        else
        {
            return("Please login or become a member to follow this person.");
        }
    }
Пример #8
0
 protected void Submit_Click(object sender, EventArgs e)
 {
     lblResults.Visible = true;
     if (SueetieUIHelper.GetCurrentTrustLevel() >= AspNetHostingPermissionLevel.High)
     {
         HttpRuntime.UnloadAppDomain();
         lblResults.Text = "Sueetie restarted.  The cache is clear.  Surface!  Surface!";
     }
     else
     {
         SueetieLogs.LogException("Unable to restart Sueetie. Must have High/Unrestricted Trust to Unload Application.");
         lblResults.Text = "Unable to restart Sueetie. Must have High/Unrestricted Trust to Unload Application.";
     }
 }
Пример #9
0
 void EnsureIndexWriter()
 {
     if (_writer == null)
     {
         if (IndexWriter.IsLocked(_directory))
         {
             SueetieLogs.LogSiteEntry("SEARCH INDEX WRITER MESSAGE: Deleting Lock");
             IndexWriter.Unlock(_directory);
             SueetieLogs.LogSiteEntry("SEARCH INDEX WRITER MESSAGE: Lock Deleted");
         }
         _writer = new IndexWriter(_directory, _analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
         _writer.SetMergePolicy(new LogDocMergePolicy(_writer));
         _writer.SetMergeFactor(5);
     }
 }
Пример #10
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            string _theme       = txtTheme.Text.ToLower().Trim();
            string _mobileTheme = txtMobileTheme.Text.ToLower().Trim();

            // Update Application and Group Themes
            // Each theme has to have an associated blog theme

            foreach (SueetieApplication _sueetieApplication in SueetieApplications.Get().All)
            {
                if (_sueetieApplication.ApplicationTypeID == (int)SueetieApplicationType.Blog && _sueetieApplication.GroupID == 0)
                {
                    try
                    {
                        SueetieBlogUtils.UpdateBlogTheme(_sueetieApplication.ApplicationKey, _theme);
                    }
                    catch (Exception ex)
                    {
                        SueetieLogs.LogException("Blog Theme Update Error: " + ex.Message + " Stacktrace: " + ex.StackTrace);
                    }
                }
            }
            SueetieForums.UpdateForumTheme(_theme);
            WikiThemes.UpdateWikiTheme(SueetieApplications.Get().Wiki.ApplicationKey, _theme);

            //// Update BlogEngine Group Themes - Will add to SueetieApplications logic
            // SueetieBlogUtils.UpdateBlogTheme("groups/demo/blog", _theme);
            // WikiThemes.UpdateWikiTheme("groups/demo/wiki", _theme);

            SueetieCommon.UpdateSiteSetting(new SiteSetting("Theme", _theme));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("MobileTheme", _mobileTheme));

            if (SueetieUIHelper.GetCurrentTrustLevel() >= AspNetHostingPermissionLevel.High)
            {
                HttpRuntime.UnloadAppDomain();
            }
            else
            {
                SueetieLogs.LogException("Unable to restart Sueetie. Must have High/Unrestricted Trust to Unload Application.");
            }

            lblResults.Visible        = true;
            lblResults.Text           = "Current Themes updated!";
            lblResultsDetails.Visible = true;
            lblResultsDetails.Text    = "New application themes may not appear right away. Touch web.configs to restart the app if this is the case.";
        }
Пример #11
0
        public SaltieUrl GetSaltieUrl(string _name)
        {
            SaltieUrl _SaltieUrl = new SaltieUrl();

            foreach (SaltieUrl url in _urls)
            {
                if (url.Name == _name)
                {
                    _SaltieUrl = url;
                }
            }
            if (string.IsNullOrEmpty(_SaltieUrl.Name))
            {
                SueetieLogs.LogException("Saltie URL " + _name + " was not found.");
            }

            return(_SaltieUrl);
        }
Пример #12
0
        public SaltieUrl GetSaltieUrl(string _name, string[] args)
        {
            SaltieUrl _SaltieUrl = new SaltieUrl();

            foreach (SaltieUrl url in _urls)
            {
                if (url.Name == _name)
                {
                    url.Url    = FormatUrl(url.Pattern, args);
                    _SaltieUrl = url;
                }
            }
            if (string.IsNullOrEmpty(_SaltieUrl.Name))
            {
                SueetieLogs.LogException("SALTIE URL " + _name + " was not found.");
            }

            return(_SaltieUrl);
        }
Пример #13
0
        private int AddSueetieSearchDocs(List <SueetieSearchDoc> sueetieSearchDocs)
        {
            int _docsIndexed = 0;

            foreach (SueetieSearchDoc sueetieSearchDoc in sueetieSearchDocs)
            {
                ExecuteRemoveDoc(sueetieSearchDoc.ContentID);
                try
                {
                    SueetieSearchDoc currentSueetieSearchDoc = sueetieSearchDoc;
                    DoWriterAction(writer => writer.AddDocument(CreateLuceneDocument(currentSueetieSearchDoc)));
                    _docsIndexed++;
                }
                catch (Exception ex)
                {
                    SueetieLogs.LogSearchException(sueetieSearchDoc.ContentID, sueetieSearchDoc.Title, ex.Message + "\n\nSTACKTRACE: " + ex.StackTrace);
                }
            }
            return(_docsIndexed);
        }
Пример #14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SueetieContentPage _page = SueetieContentParts.CurrentContentPage;

            _text.Text = txtEditor.Text;
            _sueetieContentPart.ContentText        = txtEditor.Text;
            _sueetieContentPart.ContentPageID      = _page.ContentPageID;
            _sueetieContentPart.ContentPageGroupID = _page.ContentPageGroupID;
            _sueetieContentPart.Permalink          = "/" + _page.ApplicationKey + "/" + _page.PageSlug + ".aspx";
            _sueetieContentPart.LastUpdateUserID   = this.CurrentSueetieUserID;
            _sueetieContentPart.ApplicationID      = _page.ApplicationID;
            SueetieContentParts.ClearContentPartCache(_sueetieContentPart.ContentName);
            int _contentID = SueetieContentParts.UpdateSueetieContentPart(_sueetieContentPart);

            if (checkBoxLog.Checked)
            {
                SueetieLogs.LogUserEntry(UserLogCategoryType.CMSPageUpdated, _contentID, CurrentSueetieUserID);
            }

            this._panel.Visible = false;
        }
Пример #15
0
        public void Dispose()
        {
            lock (WriterLock)
            {
                if (!_disposed)
                {
                    var writer = _writer;

                    if (writer != null)
                    {
                        try
                        {
                            writer.Close();
                        }
                        catch (ObjectDisposedException e)
                        {
                            SueetieLogs.LogSiteEntry(SiteLogType.Exception, SiteLogCategoryType.SearchException, "EXCEPTION CLOSING INDEX WRITER: " + e.Message);
                        }
                        _writer = null;
                    }

                    var directory = _directory;
                    if (directory != null)
                    {
                        try
                        {
                            directory.Close();
                        }
                        catch (ObjectDisposedException e)
                        {
                            SueetieLogs.LogSiteEntry(SiteLogType.Exception, SiteLogCategoryType.SearchException, "EXCEPTION CLOSING SEARCH DIRECTORY: " + e.Message);
                        }
                    }

                    _disposed = true;
                }
            }
            GC.SuppressFinalize(this);
        }
Пример #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUser user;

            string username  = Request.QueryString["uname"];
            string valBinary = Request.QueryString["key"];
            int    userid    = DataHelper.GetIntFromQueryString("uid", -1);

            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(valBinary) && userid > 0)
            {
                user = Membership.GetUser(username);

                SueetieUser sueetieUser = SueetieUsers.GetUser(username);

                if ((user.IsApproved == false) && (valBinary == user.CreationDate.ToBinary().ToString()) && !sueetieUser.IsBanned)
                {
                    user.IsApproved = true;
                    Membership.UpdateUser(user);
                    SueetieUsers.CreateUpdateUserProfileCookie(sueetieUser);
                    SueetieLogs.LogUserEntry(UserLogCategoryType.JoinedCommunity, -1, userid);

                    phActivated.Visible = true;
                    phNot.Visible       = false;
                }
                else
                {
                    phActivated.Visible = false;
                    phNot.Visible       = true;
                }
            }
            else
            {
                phActivated.Visible = false;
                phNot.Visible       = true;
            }
        }
Пример #17
0
        /// <summary>
        /// Adds the uploaded files to the gallery. This method is called when the application is operating under full trust. In this case,
        /// the ComponentArt Upload control is used. The logic is nearly identical to that in AddUploadedFilesLessThanFullTrust - the only
        /// differences are syntax differences arising from the different file upload control.
        /// </summary>
        /// <param name="files">The files to add to the gallery.</param>
        private void AddUploadedFilesForFullTrust(UploadedFileInfoCollection files)
        {
            // Clear the list of hash keys so we're starting with a fresh load from the data store.
            try
            {
                MediaObjectHashKeys.Clear();

                string albumPhysicalPath = this.GetAlbum().FullPhysicalPathOnDisk;

                HelperFunctions.BeginTransaction();

                UploadedFileInfo[] fileInfos = new UploadedFileInfo[files.Count];
                files.CopyTo(fileInfos, 0);
                Array.Reverse(fileInfos);

                foreach (UploadedFileInfo file in fileInfos)
                {
                    if (String.IsNullOrEmpty(file.FileName))
                    {
                        continue;
                    }

                    if ((System.IO.Path.GetExtension(file.FileName).Equals(".zip", StringComparison.OrdinalIgnoreCase)) && (!chkDoNotExtractZipFile.Checked))
                    {
                        #region Extract the files from the zipped file.

                        lock (file)
                        {
                            if (File.Exists(file.TempFileName))
                            {
                                using (ZipUtility zip = new ZipUtility(Util.UserName, GetGalleryServerRolesForUser()))
                                {
                                    this._skippedFiles.AddRange(zip.ExtractZipFile(file.GetStream(), this.GetAlbum(), chkDiscardOriginalImage.Checked));
                                }
                            }
                            else
                            {
                                // When one of the files causes an OutOfMemoryException, this can cause the other files to disappear from the
                                // temp upload directory. This seems to be an issue with the ComponentArt Upload control, since this does not
                                // seem to happen with the ASP.NET FileUpload control. If the file doesn't exist, make a note of it and move on
                                // to the next one.
                                this._skippedFiles.Add(new KeyValuePair <string, string>(file.FileName, Resources.GalleryServerPro.Task_Add_Objects_Uploaded_File_Does_Not_Exist_Msg));
                                continue;                                 // Skip to the next file.
                            }
                        }

                        // Sueetie Modified - Add contents of ZIP file - All

                        List <SueetieMediaObject> sueetieMediaObjects = SueetieMedia.GetSueetieMediaUpdateList(this.GetAlbumId());
                        int i = 0;
                        foreach (SueetieMediaObject _sueetieMediaObject in sueetieMediaObjects)
                        {
                            int            _moid          = _sueetieMediaObject.MediaObjectID;
                            IGalleryObject mo             = Factory.LoadMediaObjectInstance(_moid);
                            SueetieContent sueetieContent = new SueetieContent
                            {
                                SourceID        = _sueetieMediaObject.MediaObjectID,
                                ContentTypeID   = MediaHelper.ConvertContentType(mo.MimeType.TypeCategory),
                                ApplicationID   = (int)SueetieApplications.Current.ApplicationID,
                                UserID          = _sueetieMediaObject.SueetieUserID,
                                DateTimeCreated = mo.DateAdded,
                                IsRestricted    = mo.IsPrivate,
                                Permalink       = MediaHelper.SueetieMediaObjectUrl(_moid, this.GalleryId)
                            };

                            // Add Sueetie-specific data to Sueetie_gs_MediaObject
                            _sueetieMediaObject.ContentTypeID    = MediaHelper.ConvertContentType(mo.MimeType.TypeCategory);
                            _sueetieMediaObject.AlbumID          = this.GetAlbum().Id;
                            _sueetieMediaObject.InDownloadReport = false;
                            SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject);
                            SueetieCommon.AddSueetieContent(sueetieContent);
                            i++;
                        }


                        #endregion
                    }
                    else
                    {
                        #region Add the file

                        string filename = HelperFunctions.ValidateFileName(albumPhysicalPath, file.FileName);
                        string filepath = Path.Combine(albumPhysicalPath, filename);

                        lock (file)
                        {
                            if (File.Exists(file.TempFileName))
                            {
                                file.SaveAs(filepath);
                            }
                            else
                            {
                                // When one of the files causes an OutOfMemoryException, this can cause the other files to disappear from the
                                // temp upload directory. This seems to be an issue with the ComponentArt Upload control, since this does not
                                // seem to happen with the ASP.NET FileUpload control. If the file doesn't exist, make a note of it and move on
                                // to the next one.
                                this._skippedFiles.Add(new KeyValuePair <string, string>(file.FileName, Resources.GalleryServerPro.Task_Add_Objects_Uploaded_File_Does_Not_Exist_Msg));
                                continue;                                 // Skip to the next file.
                            }
                        }

                        try
                        {
                            IGalleryObject go = Factory.CreateMediaObjectInstance(filepath, this.GetAlbum());
                            GalleryObjectController.SaveGalleryObject(go);

                            if ((chkDiscardOriginalImage.Checked) && (go is Business.Image))
                            {
                                ((Business.Image)go).DeleteHiResImage();
                                GalleryObjectController.SaveGalleryObject(go);
                            }


                            // Sueetie Modified - Add mediaobject to Sueetie_Content - Single File

                            SueetieContent sueetieContent = new SueetieContent
                            {
                                SourceID      = go.Id,
                                ContentTypeID = MediaHelper.ConvertContentType(go.MimeType.TypeCategory),
                                ApplicationID = (int)SueetieApplications.Current.ApplicationID,
                                UserID        = CurrentSueetieUserID,
                                IsRestricted  = this.GetAlbum().IsPrivate,
                                Permalink     = MediaHelper.SueetieMediaObjectUrl(go.Id, this.GalleryId)
                            };
                            SueetieCommon.AddSueetieContent(sueetieContent);

                            // Add Sueetie-specific data to Sueetie_gs_MediaObject

                            SueetieMediaObject _sueetieMediaObject = new SueetieMediaObject();
                            _sueetieMediaObject.MediaObjectID    = go.Id;
                            _sueetieMediaObject.ContentTypeID    = MediaHelper.ConvertContentType(go.MimeType.TypeCategory);
                            _sueetieMediaObject.AlbumID          = this.GetAlbum().Id;
                            _sueetieMediaObject.InDownloadReport = false;
                            SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject);

                            SueetieMediaAlbum sueetieAlbum = SueetieMedia.GetSueetieMediaAlbum(this.GetAlbum().Id);
                            if (CurrentSueetieGallery.IsLogged)
                            {
                                SueetieLogs.LogUserEntry((UserLogCategoryType)sueetieAlbum.AlbumMediaCategoryID, sueetieAlbum.ContentID, CurrentSueetieUserID);
                            }
                        }
                        catch (UnsupportedMediaObjectTypeException ex)
                        {
                            try
                            {
                                File.Delete(filepath);
                            }
                            catch (UnauthorizedAccessException) { }                             // Ignore an error; the file will end up getting deleted during cleanup maintenance

                            this._skippedFiles.Add(new KeyValuePair <string, string>(filename, ex.Message));
                        }

                        #endregion
                    }
                }

                SueetieMedia.ClearMediaPhotoListCache(0);
                SueetieMedia.ClearSueetieMediaObjectListCache(this.CurrentSueetieGalleryID);

                HelperFunctions.CommitTransaction();
            }
            catch
            {
                HelperFunctions.RollbackTransaction();
                throw;
            }
            finally
            {
                // Delete the uploaded temporary files, as by this time they have been saved to the destination directory.
                foreach (UploadedFileInfo file in files)
                {
                    try
                    {
                        System.IO.File.Delete(file.TempFileName);
                    }
                    catch (UnauthorizedAccessException) { }                     // Ignore an error; the file will end up getting deleted during cleanup maintenance
                }

                // Clear the list of hash keys to free up memory.
                MediaObjectHashKeys.Clear();

                HelperFunctions.PurgeCache();
            }
        }
Пример #18
0
        private int btnOkClicked()
        {
            //User clicked 'Create album'. Create the new album and return the new album ID.
            TreeViewNode selectedNode  = tvUC.SelectedNode;
            int          parentAlbumID = Int32.Parse(selectedNode.Value, CultureInfo.InvariantCulture);
            IAlbum       parentAlbum   = Factory.LoadAlbumInstance(parentAlbumID, false);

            this.CheckUserSecurity(SecurityActions.AddChildAlbum, parentAlbum);

            int newAlbumID;

            if (parentAlbumID > 0)
            {
                IAlbum newAlbum = Factory.CreateEmptyAlbumInstance(parentAlbum.GalleryId);
                newAlbum.Title = GetAlbumTitle();
                //newAlbum.ThumbnailMediaObjectId = 0; // not needed
                newAlbum.Parent    = parentAlbum;
                newAlbum.IsPrivate = (parentAlbum.IsPrivate ? true : chkIsPrivate.Checked);
                GalleryObjectController.SaveGalleryObject(newAlbum);
                newAlbumID = newAlbum.Id;


                // Sueetie Modified - Save New Album to Sueetie_Content, Sueetie_gs_Album and log it in User Activity Log

                string grpString = string.Empty;
                if (SueetieApplications.Current.IsGroup)
                {
                    grpString = "/" + SueetieApplications.Current.GroupKey;
                }
                string albumUrl = grpString + "/" + SueetieApplications.Current.ApplicationKey + "/" + CurrentSueetieGallery.GalleryKey + ".aspx?aid=" + newAlbumID.ToString();

                SueetieContent sueetieContent = new SueetieContent
                {
                    SourceID      = newAlbumID,
                    ContentTypeID = int.Parse(ddSueetieAlbumType.SelectedValue),
                    ApplicationID = (int)SueetieApplications.Current.ApplicationID,
                    UserID        = CurrentSueetieUserID,
                    IsRestricted  = newAlbum.IsPrivate,
                    Permalink     = albumUrl,
                };
                int contentID = SueetieCommon.AddSueetieContent(sueetieContent);

                var albumLogCategory = SueetieMedia.GetAlbumContentTypeDescriptionList().Single(contentDescription => contentDescription.ContentTypeID.Equals(sueetieContent.ContentTypeID));

                UserLogEntry entry = new UserLogEntry
                {
                    UserLogCategoryID = albumLogCategory.UserLogCategoryID,
                    ItemID            = contentID,
                    UserID            = CurrentSueetieUserID,
                };
                if (CurrentSueetieGallery.IsLogged)
                {
                    SueetieLogs.LogUserEntry(entry);
                }

                string albumPath = SueetieMedia.CreateSueetieAlbumPath(newAlbum.FullPhysicalPath);
                SueetieMedia.CreateSueetieAlbum(newAlbumID, albumPath, sueetieContent.ContentTypeID);
                SueetieMedia.ClearSueetieMediaAlbumListCache(CurrentSueetieGalleryID);
                SueetieMedia.ClearSueetieMediaGalleryListCache();

                HelperFunctions.PurgeCache();
            }
            else
            {
                throw new GalleryServerPro.ErrorHandler.CustomExceptions.InvalidAlbumException(parentAlbumID);
            }

            return(newAlbumID);
        }
Пример #19
0
 public static void LogMarketplaceException(string desc, Exception ex)
 {
     SueetieLogs.LogSiteEntry(SiteLogType.Exception, SiteLogCategoryType.MarketplaceException, desc + ex.Message + "\n\nSTACK TRACE: " + ex.StackTrace, SueetieApplications.Current.ApplicationID);
 }
Пример #20
0
        protected void CreateUser_Click(object sender, System.EventArgs e)
        {
            if (txtDisplayName.Text.Trim().Length < 2)
            {
                labelUserMessage.Text = SueetieLocalizer.GetString("register_validator_displayname");
                InitializeCaptcha();
                return;
            }

            if (!SueetieUsers.IsNewDisplayName(txtDisplayName.Text))
            {
                labelUserMessage.Text = string.Format(SueetieLocalizer.GetString("register_exists_displayname_long"));
                InitializeCaptcha();
                return;
            }

            string ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

            if (SueetieUsers.IsIPBanned(ip))
            {
                MailMessage msg = new MailMessage();
                msg.From = new MailAddress(SiteSettings.Instance.FromEmail, SiteSettings.Instance.FromName);
                MailAddress userAddress = new
                                          MailAddress(SiteSettings.Instance.ContactEmail, SiteSettings.Instance.SiteName + SueetieLocalizer.GetString("register_emailtoadmin_admin"));
                msg.To.Add(userAddress);
                msg.Subject = SueetieLocalizer.GetString("register_bannedattempt_subject");

                string body = SueetieLocalizer.GetString("register_bannedattempt_firstline");
                body    += Environment.NewLine + Environment.NewLine;
                body    += SueetieLocalizer.GetString("register_bannedattempt_ipaddress") + ip;
                body    += SueetieLocalizer.GetString("register_bannedattempt_user") + txtUsername.Text + " (" + txtDisplayName.Text + ") " + txtEmailAddress.Text;
                body    += Environment.NewLine + Environment.NewLine;
                msg.Body = body;

                if (SueetieConfiguration.Get().Core.SendEmails)
                {
                    EmailHelper.AsyncSendEmail(msg);
                }

                Response.Redirect("/members/message.aspx?msgid=8");
                return;
            }

            if (!IsCaptchaValid || !Page.IsValid || !IsPostBack)
            {
                return;
            }

            if (Membership.GetUser(txtUsername.Text) != null || Membership.GetUserNameByEmail(txtEmailAddress.Text) != null)
            {
                string loginUrl = "/members/login.aspx";
                if (Request.QueryString["ReturnUrl"] != null)
                {
                    loginUrl += "?ReturnUrl=" + Request.QueryString["ReturnUrl"];
                }

                if (Membership.GetUser(txtUsername.Text) != null)
                {
                    labelUserMessage.Text = string.Format(SueetieLocalizer.GetString("register_exists_username_long"), SiteSettings.Instance.SiteName, loginUrl);
                    InitializeCaptcha();
                }
                else if (Membership.GetUserNameByEmail(txtEmailAddress.Text) != null)
                {
                    labelUserMessage.Text = string.Format(SueetieLocalizer.GetString("register_exists_email_long"), SiteSettings.Instance.SiteName, loginUrl);
                    InitializeCaptcha();
                }

                return;
            }

            if (registrationType == SueetieRegistrationType.Automatic)
            {
                FormsAuthentication.SetAuthCookie(txtUsername.Text, true);
            }

            var user = Membership.CreateUser(txtUsername.Text, txtPassword1.Text, txtEmailAddress.Text);

            if (registrationType != SueetieRegistrationType.Automatic)
            {
                user.IsApproved = false;
                Membership.UpdateUser(user);
            }

            ProfileBase profile = (ProfileBase)SueetieUserProfile.Create(txtUsername.Text, true);

            profile["DisplayName"] = txtDisplayName.Text;
            if (chkNewsletter != null)
            {
                profile["Newsletter"] = chkNewsletter.Checked;
            }
            profile.Save();

            // SUEETIE NOTE: [BLOG]  BlogEngine.NET will throw an error if authorizing a user and they do not appear in be_User table.
            // When Blog Application added, uncomment these lines.

            try
            {
                beDataContext dataContext = new beDataContext();
                be_User       _be_User    = new be_User();
                _be_User.UserName      = user.UserName;
                _be_User.Password      = string.Empty;
                _be_User.LastLoginTime = DateTime.Now;
                _be_User.EmailAddress  = user.Email;
                dataContext.be_Users.InsertOnSubmit(_be_User);
                dataContext.SubmitChanges();
            }
            catch { }

            Roles.AddUserToRole(user.UserName, "Registered");

            if (SiteSettings.Instance.CreateWikiUserAccount)
            {
                WikiUsers.AddUser(txtUsername.Text, txtEmailAddress.Text, null, txtDisplayName.Text);
            }

            SueetieUser sueetieUser = new SueetieUser();

            sueetieUser.UserName     = user.UserName.ToLower();
            sueetieUser.Email        = user.Email.ToLower();
            sueetieUser.MembershipID = (Guid)user.ProviderUserKey;
            sueetieUser.DisplayName  = txtDisplayName.Text;
            sueetieUser.IP           = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            sueetieUser.IsActive     = true;
            sueetieUser.TimeZone     = Convert.ToInt32(ddTimeZones.SelectedValue);

            int userid = SueetieUsers.CreateSueetieUser(sueetieUser);

            SueetieForums.CreateForumUser(sueetieUser);

            Uri    uri  = HttpContext.Current.Request.Url;
            string port = uri.Port != 80 ? ":" + uri.Port : string.Empty;

            if (registrationType == SueetieRegistrationType.EmailVerification)
            {
                string valBinary;

                valBinary = user.CreationDate.ToBinary().ToString();

                MailMessage msg = new MailMessage();

                msg.From = new MailAddress(SiteSettings.Instance.FromEmail, SiteSettings.Instance.FromName);

                MailAddress userAddress = new MailAddress(user.Email.ToLower().ToString(), txtDisplayName.Text.ToString());
                msg.To.Add(userAddress);
                msg.Subject = string.Format(SueetieLocalizer.GetString("register_emailvalidation_subject"), SiteSettings.Instance.SiteName);

                string msgbody;

                string activateUrl = uri.Scheme + Uri.SchemeDelimiter + uri.Host + port + "/members/Activate.aspx";

                msgbody  = string.Format(SueetieLocalizer.GetString("register_emailvalidation_firstline"), SiteSettings.Instance.SiteName);
                msgbody += Environment.NewLine + Environment.NewLine;
                msgbody += activateUrl + "?uname=" + user.UserName + "&uid=" + userid + "&key=" + valBinary;
                msgbody += Environment.NewLine + Environment.NewLine;
                msgbody += SueetieLocalizer.GetString("register_emailvalidation_yourusername") + txtUsername.Text + Environment.NewLine;
                //msgbody += SueetieLocalizer.GetString("register_emailvalidation_yourpassword") + txtPassword1.Text + Environment.NewLine;

                msg.Body = msgbody;

                if (SueetieConfiguration.Get().Core.SendEmails)
                {
                    EmailHelper.AsyncSendEmail(msg);
                }
            }
            else if (registrationType == SueetieRegistrationType.AdministrativeApproval)
            {
                string approveUrl = uri.Scheme + Uri.SchemeDelimiter + uri.Host + port + "/admin/approveusers.aspx";

                MailMessage msg = new MailMessage();

                msg.From = new MailAddress(SiteSettings.Instance.FromEmail, SiteSettings.Instance.FromName);

                MailAddress userAddress = new MailAddress(SiteSettings.Instance.ContactEmail, SiteSettings.Instance.SiteName + SueetieLocalizer.GetString("register_emailtoadmin_admin"));
                msg.To.Add(userAddress);
                msg.Subject = SueetieLocalizer.GetString("register_emailtoadmin_subject");

                string msgbody;

                msgbody  = SueetieLocalizer.GetString("register_emailtoadmin_firstline");
                msgbody += Environment.NewLine + Environment.NewLine;
                msgbody += user.UserName.ToString() + " (" + sueetieUser.DisplayName + ")";
                msgbody += Environment.NewLine + Environment.NewLine;
                msgbody += approveUrl;


                msg.Body = msgbody;

                if (SueetieConfiguration.Get().Core.SendEmails)
                {
                    EmailHelper.AsyncSendEmail(msg);
                }
            }

            if (registrationType != SueetieRegistrationType.Automatic)
            {
                SaltieUserEvents.OnPreUserAccountApproval(CurrentSueetieUser);
                SueetieLogs.LogUserEntry(UserLogCategoryType.Registered, -1, userid);
            }

            switch (registrationType)
            {
            case SueetieRegistrationType.Automatic:
                SaltieUserEvents.OnPostUserAccountApproval(sueetieUser);
                SueetieUsers.CreateUpdateUserProfileCookie(sueetieUser);
                SueetieLogs.LogUserEntry(UserLogCategoryType.JoinedCommunity, -1, userid);
                string returnUrl = Request.QueryString["ReturnUrl"];
                if (returnUrl != null)
                {
                    Response.Redirect(returnUrl);
                }
                else
                {
                    Response.Redirect("/members/welcome.aspx", true);
                }
                break;

            case SueetieRegistrationType.EmailVerification:
                Response.Redirect("/members/message.aspx?msgid=6");
                break;

            case SueetieRegistrationType.AdministrativeApproval:
                Response.Redirect("/members/message.aspx?msgid=7");
                break;

            default:
                break;
            }
        }
Пример #21
0
    public string CreateUpdateCalendarEvent(int sourceContentID, string title, string description, string startDate, string endDate, string endRepeatDate, string startTime, string endTime, string url)
    {
        DateTime _startDate = DateTime.Parse(startDate).AddMinutes(EventTime(startTime));
        DateTime _endDate   = DateTime.Parse(startDate).AddMinutes(EventTime(endTime));

        // Calendar Control uses Default Calendar Only in v2.0
        SueetieCalendarEvent _sueetieCalendarEvent = SueetieCalendars.GetSueetieCalendarEvent(sourceContentID, 1);

        if (_sueetieCalendarEvent == null)
        {
            _sueetieCalendarEvent = new SueetieCalendarEvent
            {
                EventGuid = new Guid(EMPTYGUID)
            };
        }

        int _currentSueetieUserID = SueetieContext.Current.User.UserID;

        if (!string.IsNullOrEmpty(endDate))
        {
            _endDate = DateTime.Parse(endDate).AddMinutes(EventTime(endTime));
        }

        SueetieCalendarEvent sueetieCalendarEvent = new SueetieCalendarEvent
        {
            EventGuid        = _sueetieCalendarEvent.EventGuid,
            EventTitle       = title,
            EventDescription = description,
            StartDateTime    = _startDate,
            EndDateTime      = _endDate,
            AllDayEvent      = _startDate.Hour == 0 ? true : false,
            RepeatEndDate    = DataHelper.SafeMinDate(endRepeatDate),
            CalendarID       = 1,
            CreatedBy        = _currentSueetieUserID,
            Url             = url,
            SourceContentID = sourceContentID,
            IsActive        = true
        };

        string _result = SueetieLocalizer.GetString("calendar_created_success");

        if (sueetieCalendarEvent.EventGuid != new Guid(EMPTYGUID))
        {
            SueetieCalendars.UpdateSueetieCalendarEvent(sueetieCalendarEvent);
            _result = SueetieLocalizer.GetString("calendar_updated_success");
        }
        else
        {
            sueetieCalendarEvent.EventGuid = Guid.NewGuid();
            int eventID = SueetieCalendars.CreateSueetieCalendarEvent(sueetieCalendarEvent);

            SueetieContent sueetieContent = new SueetieContent
            {
                SourceID      = eventID,
                ContentTypeID = (int)SueetieContentType.CalendarEvent,
                Permalink     = url,
                ApplicationID = (int)SueetieApplicationType.Unknown,
                UserID        = _currentSueetieUserID
            };
            int contentID = SueetieCommon.AddSueetieContent(sueetieContent);

            if (SueetieContext.Current.User.IsContentAdministrator)
            {
                SueetieLogs.LogUserEntry(UserLogCategoryType.CalendarEvent, contentID, _currentSueetieUserID);
            }
        }

        SueetieCalendars.ClearSueetieCalendarEventListCache(1);
        return(_result);
    }
Пример #22
0
        protected void btnAddUpdate_OnCommand(object sender, CommandEventArgs e)
        {
            SueetieContentPageGroup _group = SueetieContentParts.GetSueetieContentPageGroup(this.GroupID);
            SueetieContentPage      _page  = new SueetieContentPage
            {
                PageKey            = txtPageKey.Text.Trim(),
                PageTitle          = txtPageTitle.Text,
                PageDescription    = txtDescription.Text,
                ReaderRoles        = txtReaders.Text,
                LastUpdateUserID   = CurrentSueetieUserID,
                IsPublished        = chkActive.Checked,
                DisplayOrder       = DataHelper.IntOrDefault(txtDisplayOrder.Text.Trim(), -1),
                PageSlug           = string.IsNullOrEmpty(txtPageSlug.Text) ? SueetieContentParts.CreatePageSlug(txtPageTitle.Text) : SueetieContentParts.CreatePageSlug(txtPageSlug.Text),
                ContentPageGroupID = this.GroupID
            };

            if (e.CommandName == "Add")
            {
                if (int.Parse(ddlContentPages.SelectedValue) < 0)
                {
                    int            _contentPageID = SueetieContentParts.CreateContentPage(_page);
                    SueetieContent sueetieContent = new SueetieContent
                    {
                        ApplicationID = _group.ApplicationID,
                        ContentTypeID = (int)SueetieContentType.CMSPage,
                        SourceID      = _contentPageID,
                        UserID        = CurrentSueetieUserID,
                        IsRestricted  = !string.IsNullOrEmpty(txtReaders.Text),
                        Permalink     = "/" + _group.ApplicationKey + "/" + _page.PageSlug + ".aspx"
                    };
                    int contentID = SueetieCommon.AddSueetieContent(sueetieContent);
                    SueetieLogs.LogUserEntry(UserLogCategoryType.CMSPageCreated, contentID, CurrentSueetieUserID);
                    lblResults.Text = "Content Page Created!";
                }
                else
                {
                    lblResults.Text = "Content Page dropdown selector must be empty when creating a content page.";
                    return;
                }
            }
            else if (e.CommandName == "Update")
            {
                _page.ContentPageID = int.Parse(ddlContentPages.SelectedValue);

                SueetieContentParts.UpdateSueetieContentPage(_page);
                _page.Permalink = "/" + _group.ApplicationKey + "/" + _page.PageSlug + ".aspx";
                SueetieContentParts.UpdateCmsPermalink(_page);
                SueetieCommon.UpdateSueetieContentIsRestricted(_page.ContentID, !string.IsNullOrEmpty(txtReaders.Text));

                SueetieCommon.ClearUserLogActivityListCache((int)SueetieContentViewType.Unassigned);
                SueetieCommon.ClearUserLogActivityListCache((int)SueetieContentViewType.SyndicatedUserLogActivityList);

                lblResults.Text = "Content Page Updated!";
                SueetieContentParts.ClearSueetieContentPageCache(int.Parse(ddlContentPages.SelectedValue));
            }
            else
            {
                SueetieContentParts.DeleteContentPage(int.Parse(ddlContentPages.SelectedValue));
            }
            SueetieContentParts.ClearSueetieContentPageListCache(this.GroupID);
            SueetieContentParts.ClearSueetieContentPageListCache(-1); // Clear All Pages for ContentPartView Control
            ClearForm();
        }
Пример #23
0
 protected void lbtnClearLog_OnClick(object sender, EventArgs e)
 {
     SueetieLogs.ClearEventLog();
     Response.Redirect("eventlogs.aspx?r=1");
 }
Пример #24
0
        /// <summary>
        /// Adds the uploaded files to the gallery. This method is called when the application is operating at lesss than full trust. In this case,
        /// the ASP.NET FileUpload control is used. The logic is nearly identical to that in AddUploadedFilesForFullTrust - the only
        /// differences are syntax differences arising from the different file upload control.
        /// </summary>
        private void AddUploadedFilesLessThanFullTrust()
        {
            // Clear the list of hash keys so we're starting with a fresh load from the data store.
            try
            {
                MediaObjectHashKeys.Clear();

                string albumPhysicalPath = this.GetAlbum().FullPhysicalPathOnDisk;

                HelperFunctions.BeginTransaction();

                for (int i = 0; i < 5; i++)
                {
                    FileUpload file = (FileUpload)phUpload.FindControl("fuUpload" + i);

                    if (!file.HasFile)
                    {
                        continue;
                    }

                    if ((System.IO.Path.GetExtension(file.FileName).Equals(".zip", StringComparison.OrdinalIgnoreCase)) && (!chkDoNotExtractZipFile.Checked))
                    {
                        #region Extract the files from the zipped file.

                        // Extract the files from the zipped file.
                        using (ZipUtility zip = new ZipUtility(Util.UserName, GetGalleryServerRolesForUser()))
                        {
                            this._skippedFiles.AddRange(zip.ExtractZipFile(file.FileContent, this.GetAlbum(), chkDiscardOriginalImage.Checked));
                        }

                        #endregion
                    }
                    else
                    {
                        #region Add the file

                        string filename = HelperFunctions.ValidateFileName(albumPhysicalPath, file.FileName);
                        string filepath = Path.Combine(albumPhysicalPath, filename);

                        file.SaveAs(filepath);

                        try
                        {
                            IGalleryObject go = Factory.CreateMediaObjectInstance(filepath, this.GetAlbum());

                            // Sueetie Modified - Fix Blank Title on individual uploads
                            if (go.Title.Trim().Length == 0)
                            {
                                go.Title = go.Original.FileName;
                            }

                            GalleryObjectController.SaveGalleryObject(go);

                            if ((chkDiscardOriginalImage.Checked) && (go is Business.Image))
                            {
                                ((Business.Image)go).DeleteHiResImage();
                                GalleryObjectController.SaveGalleryObject(go);
                            }

                            // Sueetie Modified - Add mediaobject to Sueetie_Content - Single File

                            SueetieContent sueetieContent = new SueetieContent
                            {
                                SourceID      = go.Id,
                                ContentTypeID = MediaHelper.ConvertContentType(go.MimeType.TypeCategory),
                                ApplicationID = (int)SueetieApplications.Current.ApplicationID,
                                UserID        = CurrentSueetieUserID,
                                IsRestricted  = this.GetAlbum().IsPrivate,
                                Permalink     = MediaHelper.SueetieMediaObjectUrl(go.Id, this.GalleryId)
                            };
                            SueetieCommon.AddSueetieContent(sueetieContent);

                            // Add Sueetie-specific data to Sueetie_gs_MediaObject

                            SueetieMediaObject _sueetieMediaObject = new SueetieMediaObject();
                            _sueetieMediaObject.MediaObjectID    = go.Id;
                            _sueetieMediaObject.ContentTypeID    = MediaHelper.ConvertContentType(go.MimeType.TypeCategory);
                            _sueetieMediaObject.AlbumID          = this.GetAlbum().Id;
                            _sueetieMediaObject.InDownloadReport = false;
                            SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject);

                            SueetieMediaAlbum sueetieAlbum = SueetieMedia.GetSueetieMediaAlbum(this.GetAlbum().Id);
                            if (CurrentSueetieGallery.IsLogged)
                            {
                                SueetieLogs.LogUserEntry((UserLogCategoryType)sueetieAlbum.AlbumMediaCategoryID, sueetieAlbum.ContentID, CurrentSueetieUserID);
                            }
                            SueetieMedia.ClearMediaPhotoListCache(0);
                            SueetieMedia.ClearSueetieMediaObjectListCache(this.CurrentSueetieGalleryID);
                        }
                        catch (UnsupportedMediaObjectTypeException ex)
                        {
                            try
                            {
                                File.Delete(filepath);
                            }
                            catch (UnauthorizedAccessException) { }                             // Ignore an error; the file will end up getting deleted during cleanup maintenance

                            this._skippedFiles.Add(new KeyValuePair <string, string>(filename, ex.Message));
                        }

                        #endregion
                    }
                }

                HelperFunctions.CommitTransaction();
            }
            catch
            {
                HelperFunctions.RollbackTransaction();
                throw;
            }
            finally
            {
                // Clear the list of hash keys to free up memory.
                MediaObjectHashKeys.Clear();

                HelperFunctions.PurgeCache();
            }
        }
Пример #25
0
        protected void PostAdWizard_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            if (this.Page.IsValid)
            {
                var purchaseType = PurchaseType.Commercial;
                if (Enum.IsDefined(typeof(PurchaseType), Convert.ToInt32(this.rblPurchaseTypes.SelectedValue)))
                {
                    purchaseType = (PurchaseType)Enum.Parse(typeof(PurchaseType), this.rblPurchaseTypes.SelectedValue);
                }

                var sueetieProduct = new SueetieProduct
                {
                    UserID             = this.CurrentSueetieUserID,
                    CategoryID         = this.CategoryPath.CurrentCategoryId,
                    Title              = this.TitleTextBox.Text,
                    SubTitle           = this.SubTitleTextBox.Text,
                    ProductDescription = this.DescriptionTextBox.Text,
                    DateCreated        = DateTime.Now,
                    DownloadURL        = this.UrlTextBox.Text,
                    Price              = decimal.Parse(this.PriceTextBox.Text),
                    PurchaseTypeID     = (int)purchaseType,
                    ProductTypeID      = int.Parse(this.rblProductTypes.SelectedValue.ToString()),
                    StatusTypeID       = 100
                };

                if (this.FileUploadControl != null && string.IsNullOrWhiteSpace(sueetieProduct.DownloadURL) && !string.IsNullOrWhiteSpace(this.FileUploadControl.FileName))
                {
                    sueetieProduct.DownloadURL = this.FileUploadControl.FileName;
                }

                int id = Products.CreateSueetieProduct(sueetieProduct);

                if (this.FileUploadControl != null && this.FileUploadControl.FileBytes != null && this.FileUploadControl.FileBytes.Length != 0)
                {
                    var localPath = sueetieProduct.ResolveFilePath(this.Server);
                    var directory = Path.GetDirectoryName(localPath);
                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }

                    this.FileUploadControl.SaveAs(localPath);
                }

                var sueetieContent = new SueetieContent
                {
                    ContentTypeID = 0x12,
                    ApplicationID = SueetieApplications.Get().Marketplace.ApplicationID,
                    IsRestricted  = false,
                    SourceID      = id,
                    UserID        = base.CurrentSueetieUserID,
                    Permalink     = string.Concat(new object[] { "/", SueetieApplications.Get().Marketplace.ApplicationKey, "/ShowProduct.aspx?id=", id })
                };

                var contentId = SueetieCommon.AddSueetieContent(sueetieContent);
                SueetieLogs.LogUserEntry(UserLogCategoryType.MarketplaceProduct, contentId, base.CurrentSueetieUserID);

                this.UploadImagesLink.Visible     = true;
                this.UploadImagesLink.NavigateUrl = "ManagePhotos.aspx?id=" + id.ToString();

                CommerceCommon.ClearMarketplaceCache();
            }
        }
Пример #26
0
        /// <summary>
        /// Adds the <paramref name="zipContentFile"/> as a media object to the <paramref name="album"/>.
        /// </summary>
        /// <param name="zipContentFile">A reference to a file in a ZIP archive.</param>
        /// <param name="album">The album to which the file should be added as a media object.</param>
        /// // Sueetie Modified - passing i for single logging of action
        private void AddMediaObjectToGallery(ZipEntry zipContentFile, IAlbum album, int i)
        {
            string zipFileName = Path.GetFileName(zipContentFile.Name).Trim();

            if (zipFileName.Length == 0)
            {
                return;
            }

            string uniqueFilename = HelperFunctions.ValidateFileName(album.FullPhysicalPathOnDisk, zipFileName);
            string uniqueFilepath = Path.Combine(album.FullPhysicalPathOnDisk, uniqueFilename);

            // Extract the file from the zip stream and save as the specified filename.
            ExtractFileFromZipStream(uniqueFilepath);

            // Get the file we just saved to disk.
            FileInfo mediaObjectFile = new FileInfo(uniqueFilepath);

            try
            {
                IGalleryObject mediaObject = Factory.CreateMediaObjectInstance(mediaObjectFile, album);
                HelperFunctions.UpdateAuditFields(mediaObject, this._userName);

                // Sueetie Modified - Fixes a weird bug where zipped Image file titles are empty when zipped from my machine
                if (mediaObject.Title.Trim().Length == 0)
                {
                    mediaObject.Title = mediaObjectFile.Name;
                }

                mediaObject.Save();

                if ((_discardOriginalImage) && (mediaObject is Business.Image))
                {
                    ((Business.Image)mediaObject).DeleteHiResImage();
                    mediaObject.Save();
                }

                // Sueetie Modified - Add mediaobject to Sueetie_Content - Single File

                SueetieContent sueetieContent = new SueetieContent
                {
                    SourceID      = mediaObject.Id,
                    ContentTypeID = SueetieMedia.ConvertContentType((int)mediaObject.MimeType.TypeCategory),
                    ApplicationID = (int)SueetieApplications.Current.ApplicationID,
                    UserID        = SueetieContext.Current.User.UserID,
                    IsRestricted  = ((Album)mediaObject.Parent).IsPrivate,
                    Permalink     = SueetieMedia.SueetieMediaObjectUrl(mediaObject.Id, mediaObject.GalleryId)
                };
                SueetieCommon.AddSueetieContent(sueetieContent);

                // Add Sueetie-specific data to Sueetie_gs_MediaObject

                SueetieMediaObject _sueetieMediaObject = new SueetieMediaObject();
                _sueetieMediaObject.MediaObjectID    = mediaObject.Id;
                _sueetieMediaObject.ContentTypeID    = SueetieMedia.ConvertContentType((int)mediaObject.MimeType.TypeCategory);
                _sueetieMediaObject.AlbumID          = mediaObject.Parent.Id;
                _sueetieMediaObject.InDownloadReport = false;
                SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject);

                SueetieMediaAlbum   sueetieAlbum   = SueetieMedia.GetSueetieMediaAlbum(mediaObject.Parent.Id);
                SueetieMediaGallery sueetieGallery = SueetieMedia.GetSueetieMediaGallery(((Album)mediaObject.Parent).GalleryId);
                if (i == 0 && sueetieGallery.IsLogged)
                {
                    SueetieLogs.LogUserEntry((UserLogCategoryType)sueetieAlbum.AlbumMediaCategoryID, sueetieAlbum.ContentID, SueetieContext.Current.User.UserID);
                }

                SueetieMedia.ClearMediaPhotoListCache(0);
                SueetieMedia.ClearSueetieMediaObjectListCache(mediaObject.GalleryId);
            }
            catch (ErrorHandler.CustomExceptions.UnsupportedMediaObjectTypeException ex)
            {
                this._skippedFiles.Add(new KeyValuePair <string, string>(mediaObjectFile.Name, ex.Message));
                File.Delete(mediaObjectFile.FullName);
            }
        }
Пример #27
0
        protected override void OnLoad(EventArgs e)
        {
            HyperLink _sueetieLink = new HyperLink();

            string _languageFile = "sueetie.xml";

            if (!string.IsNullOrEmpty(this.LanguageFile))
            {
                _languageFile = this.LanguageFile;
            }


            SueetieUrl _sueetieUrl = GetSueetieUrl();

            if (_sueetieUrl == null)
            {
                _sueetieUrl = SueetieUrls.Instance.GetSueetieUrl(this.UrlName);
            }

            if (_sueetieUrl.Url != null)
            {
                if (!string.IsNullOrEmpty(_sueetieUrl.Roles))
                {
                    if (!SueetieUIHelper.IsUserAuthorized(_sueetieUrl.Roles))
                    {
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(this.ArgUrl1))
                {
                    string[] _urlArgs = new string[] { this.ArgUrl1, this.ArgUrl2, this.ArgUrl3, this.ArgUrl4, this.ArgUrl5 };
                    _sueetieLink.NavigateUrl = SueetieUrls.Instance.FormatUrl(_sueetieUrl.Url, _urlArgs);
                }
                else
                {
                    _sueetieLink.NavigateUrl = _sueetieUrl.Url;
                }

                if (!string.IsNullOrEmpty(this.ArgText1))
                {
                    string[] _textArgs = new string[] { this.ArgText1, this.ArgText2, this.ArgText3, this.ArgText4, this.ArgText5 };
                    _sueetieLink.Text = SueetieLocalizer.GetString(this.TextKey, _languageFile, _textArgs);
                }
                else if (!string.IsNullOrEmpty(this.Text))
                {
                    _sueetieLink.Text = SueetieLocalizer.GetString(this.Text, _languageFile);
                }
                else
                {
                    _sueetieLink.Text = SueetieLocalizer.GetString(this.TextKey, _languageFile);
                }


                if (!string.IsNullOrEmpty(this.TitleKey))
                {
                    _sueetieLink.ToolTip = SueetieLocalizer.GetString(this.TitleKey, _languageFile);
                }

                if (!string.IsNullOrEmpty(this.LinkCssClass))
                {
                    _sueetieLink.CssClass = this.LinkCssClass;
                }
                Controls.Add(_sueetieLink);
            }
            else
            {
                SueetieLogs.LogException("SUEETIE URL NOT FOUND. UrlName: " + this.UrlName ?? this.SueetieUrlLinkTo.ToString());
            }
        }