Beispiel #1
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);
    }
        protected void ActivitiesGridView_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow && ((e.Row.RowState & DataControlRowState.Edit) > 0))
            {
                SueetieApplication sueetieApplication = ((SueetieApplication)e.Row.DataItem);

                DropDownList ddApplicationTypes = (DropDownList)e.Row.FindControl("ddApplicationTypes") as DropDownList;
                Array        values             = Enum.GetValues(typeof(SueetieApplicationType));
                foreach (SueetieApplicationType appType in Enum.GetValues(typeof(SueetieApplicationType)))
                {
                    ddApplicationTypes.Items.Add(new ListItem(Enum.GetName(typeof(SueetieApplicationType), appType), appType.ToString("D")));
                }
                ddApplicationTypes.Items.FindByValue(sueetieApplication.ApplicationTypeID.ToString()).Selected = true;
                ddApplicationTypes.DataBind();

                List <SueetieGroup> sueetieGroups = SueetieCommon.GetSueetieGroupList();
                DropDownList        ddGroups      = (DropDownList)e.Row.FindControl("ddGroups") as DropDownList;
                foreach (SueetieGroup sueetieGroup in sueetieGroups)
                {
                    ddGroups.Items.Add(new ListItem(sueetieGroup.GroupName, sueetieGroup.GroupID.ToString()));
                }
                ddGroups.Items.FindByValue(sueetieApplication.GroupID.ToString()).Selected = true;
                ddGroups.DataBind();
            }
        }
Beispiel #3
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);
    }
        private List <SiteLogEntry> SiteLogEntryList()
        {
            SiteLogEntry siteLogEntry = new SiteLogEntry
            {
                ApplicationID     = this.ApplicationID,
                SiteLogTypeID     = this.SiteLogTypeID,
                SiteLogCategoryID = this.SiteLogCategoryID
            };

            List <SiteLogEntry> siteLog = SueetieCommon.GetSiteLogEntryList(siteLogEntry);

            return(siteLog);
        }
Beispiel #5
0
        private void SaveSettings()
        {
            List <SueetieMediaAlbum> sueetieMediaAlbums = SueetieMedia.GetSueetieAlbumUpdateList(this.GalleryId);
            int j = 0;

            foreach (SueetieMediaAlbum _sueetieMediaAlbum in sueetieMediaAlbums)
            {
                IAlbum         album = Factory.LoadAlbumInstance(_sueetieMediaAlbum.AlbumID, false, true);
                SueetieContent sueetieAlbumContent = new SueetieContent
                {
                    SourceID      = _sueetieMediaAlbum.AlbumID,
                    ContentTypeID = (int)SueetieContentType.OtherAlbum,
                    ApplicationID = (int)SueetieApplications.Current.ApplicationID,
                    UserID        = _sueetieMediaAlbum.SueetieUserID,
                    IsRestricted  = _sueetieMediaAlbum.IsRestricted,
                    Permalink     = "/" + SueetieApplications.Current.ApplicationKey + "/" + CurrentSueetieGallery.GalleryKey + ".aspx?aid=" + _sueetieMediaAlbum.AlbumID,
                };
                SueetieCommon.AddSueetieContent(sueetieAlbumContent);
                string sueetieAlbumPath = SueetieMedia.CreateSueetieAlbumPath(album.FullPhysicalPath);
                SueetieMedia.CreateSueetieAlbum(_sueetieMediaAlbum.AlbumID, sueetieAlbumPath, (int)SueetieContentType.OtherAlbum);
                j++;
            }

            List <SueetieMediaObject> sueetieMediaObjects = SueetieMedia.GetSueetieMediaUpdateList();
            int i = 0;

            foreach (SueetieMediaObject _sueetieMediaObject in sueetieMediaObjects)
            {
                int            _moid = _sueetieMediaObject.MediaObjectID;
                IGalleryObject mo    = Factory.LoadMediaObjectInstance(_moid);
                SueetieContent sueetieMediaContent = 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)
                };
                SueetieCommon.AddSueetieContent(sueetieMediaContent);
                SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject);
                i++;
            }
            SueetieMedia.ClearMediaPhotoListCache(0); // Clear Recent Photos for top level Gallery
            SueetieMedia.ClearSueetieMediaAlbumListCache(this.GalleryId);
            SueetieMedia.ClearSueetieMediaObjectListCache(this.GalleryId);

            this.wwMessage.CssClass = "wwErrorSuccess gsp_msgfriendly gsp_bold";
            this.wwMessage.ShowMessage(i.ToString() + " media objects, " + j.ToString() + " albums added to Sueetie Content Core.");
        }
Beispiel #6
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            SiteSetting setting = new SiteSetting
            {
                SettingName  = "HtmlHeader",
                SettingValue = txtHtmlHeader.Text
            };

            SueetieCommon.UpdateSiteSetting(setting);

            setting.SettingName  = "TrackingScript";
            setting.SettingValue = txtTrackingScript.Text ?? string.Empty;
            SueetieCommon.UpdateSiteSetting(setting);

            lblResults.Visible = true;
            lblResults.Text    = "Site Header and Tracking Script updated!";
        }
Beispiel #7
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.";
        }
        private void PopulateSiteLogTypeList(DropDownList list)
        {
            string selectedValue = SiteLogTypeID.ToString();

            list.Items.Clear();
            List <SiteLogEntry> siteLogEntry = SueetieCommon.GetSiteLogTypeList();

            foreach (SiteLogEntry _siteLogEntry in siteLogEntry)
            {
                list.Items.Add(new ListItem(DataHelper.AllCategoriesIt(_siteLogEntry.SiteLogTypeCode), _siteLogEntry.SiteLogTypeID.ToString()));
            }

            if (list.Items.FindByValue(selectedValue) != null)
            {
                list.SelectedValue = selectedValue;
            }
        }
Beispiel #9
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            SueetieCommon.UpdateSiteSetting(new SiteSetting("SiteName", txtSiteName.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("RegistrationType", rblRegistrationType.SelectedValue));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("CreateWikiUserAccount", chkCreateWikiAccount.Checked.ToString()));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("GroupsFolderName", txtGroupsFolderName.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("DefaultLanguage", txtDefaultLanguage.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("SitePageTitleLead", txtSitePageTitleLead.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("DefaultTimeZone", ddTimeZones.SelectedValue));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("RecordAnalytics", chkRecordAnalytics.Checked.ToString()));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("HandleWwwSubdomain", rblWwwSubdomain.SelectedValue));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("IpGeoLookupUrl", txtIpGeoLookupUrl.Text));
            SueetieCommon.ClearSiteSettingsCache();

            lblResults.Visible = true;
            lblResults.Text    = "Site settings have been updated!";
        }
Beispiel #10
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            SueetieCommon.UpdateSiteSetting(new SiteSetting("ContactEmail", txtContactEmail.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("FromEmail", txtFromEmail.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("FromName", txtFromName.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("SmtpServer", txtSmtpServer.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("SmtpServerPort", txtSmtpServerPort.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("SmtpUserName", txtSmtpUserName.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("SmtpPassword", txtSmtpPassword.Text));
            SueetieCommon.UpdateSiteSetting(new SiteSetting("ErrorEmails", txtErrorEmails.Text));

            SueetieCommon.UpdateSiteSetting(new SiteSetting("EnableSSL", chkEnableSSL.Checked.ToString()));

            SueetieCommon.ClearSiteSettingsCache();

            lblResults.Visible = true;
            lblResults.Text    = "Email settings have been updated!";
        }
Beispiel #11
0
    public string ProcessTags(int _itemID, int _contentID, int _contentTypeID, string _tags)
    {
        if (string.IsNullOrEmpty(_tags))
        {
            return(SueetieLocalizer.GetString("no_tags_entered"));
        }
        string          pipedTags       = SueetieTags.PipedTags(_tags);
        SueetieTagEntry sueetieTagEntry = new SueetieTagEntry
        {
            ItemID        = _itemID,
            ContentID     = _contentID,
            ContentTypeID = _contentTypeID,
            UserID        = SueetieContext.Current.User.UserID,
            Tags          = pipedTags
        };

        if (_contentTypeID == (int)SueetieContentType.CMSPage)
        {
            SueetieContentParts.EnterContentPageTags(sueetieTagEntry);
        }
        else if (SueetieCommon.IsMediaObject(_contentTypeID))
        {
            SueetieMedia.EnterMediaObjectTags(sueetieTagEntry);
        }
        else if (SueetieCommon.IsMediaAlbum(_contentTypeID))
        {
            SueetieMedia.EnterMediaAlbumTags(sueetieTagEntry);
        }
        else if (_contentTypeID == (int)SueetieContentType.WikiPage)
        {
            SueetieWikis.EnterWikiPageTags(sueetieTagEntry);
        }
        else if (_contentTypeID == (int)SueetieContentType.ForumTopic)
        {
            SueetieForums.EnterForumTopicTags(sueetieTagEntry);
        }

        SueetieTags.ClearSueetieTagCache();
        return(SueetieTags.TagUrls(pipedTags));
    }
        protected void UpdateActivitiesDetailsView_OnDataBound(object sender, EventArgs e)
        {
            DropDownList ddApplicationDetailsTypes = UpdateActivitiesDetailsView.FindControl("ddApplicationDetailsTypes") as DropDownList;
            Array        values = Enum.GetValues(typeof(SueetieApplicationType));

            foreach (SueetieApplicationType appType in Enum.GetValues(typeof(SueetieApplicationType)))
            {
                ddApplicationDetailsTypes.Items.Add(new ListItem(Enum.GetName(typeof(SueetieApplicationType), appType), appType.ToString("D")));
            }
            ddApplicationDetailsTypes.Items.FindByValue("0").Selected = true;
            //ddApplicationDetailsTypes.DataBind();

            List <SueetieGroup> sueetieGroups = SueetieCommon.GetSueetieGroupList();
            DropDownList        ddGroups      = UpdateActivitiesDetailsView.FindControl("ddGroupsDetails") as DropDownList;

            foreach (SueetieGroup sueetieGroup in sueetieGroups)
            {
                ddGroups.Items.Add(new ListItem(sueetieGroup.GroupName, sueetieGroup.GroupID.ToString()));
            }
            ddGroups.Items.FindByValue("0").Selected = true;
            //ddGroups.DataBind();
        }
        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);
        }
        /// <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();
            }
        }
        /// <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();
            }
        }
        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();
        }
Beispiel #17
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();
            }
        }
Beispiel #18
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);
    }
Beispiel #19
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);
            }
        }
Beispiel #20
0
        public void Execute(XElement _xTaskElement)
        {
            var hour = (int)_xTaskElement.Attribute("hour");

            SueetieCommon.TestTaskEntry();
        }