Пример #1
0
		public AlbumReport(Album album, AlbumReportType reportType, User user, string hostname, string notes)
			: base(user, hostname, notes) {

			Album = album;
			ReportType = reportType;

		}
Пример #2
0
        /*
         * [Obsolete("Integrated to saving properties")]
         * public PVContract CreatePV(int albumId, string pvUrl, PVType pvType) {
         *
         *      ParamIs.NotNullOrEmpty(() => pvUrl);
         *
         *      VerifyManageDatabase();
         *
         *      var result = VideoServiceHelper.ParseByUrl(pvUrl);
         *
         *      if (!result.IsOk)
         *              throw result.Exception;
         *
         *      return HandleTransaction(session => {
         *
         *              var album = session.Load<Album>(albumId);
         *              AuditLog(string.Format("creating a PV for {0}", EntryLinkFactory.CreateEntryLink(album)), session);
         *
         *              var pv = album.CreatePV(result.Service, result.Id, pvType, string.Empty);
         *              session.Save(pv);
         *
         *              return new PVContract(pv);
         *
         *      });
         *
         * }*/

        public bool CreateReport(int albumId, AlbumReportType reportType, string hostname, string notes)
        {
            ParamIs.NotNull(() => hostname);
            ParamIs.NotNull(() => notes);

            return(HandleTransaction(session => {
                var loggedUserId = PermissionContext.LoggedUserId;
                var existing = session.Query <AlbumReport>()
                               .FirstOrDefault(r => r.Album.Id == albumId &&
                                               ((loggedUserId != 0 && r.User.Id == loggedUserId) || r.Hostname == hostname));

                if (existing != null)
                {
                    return false;
                }

                var album = session.Load <Album>(albumId);
                var report = new AlbumReport(album, reportType, GetLoggedUserOrDefault(session), hostname, notes.Truncate(200));

                var msg = string.Format("reported {0} as {1} ({2})", EntryLinkFactory.CreateEntryLink(album), reportType, HttpUtility.HtmlEncode(notes));
                AuditLog(msg.Truncate(200), session, new AgentLoginData(GetLoggedUserOrDefault(session), hostname));

                session.Save(report);
                return true;
            }, IsolationLevel.ReadUncommitted));
        }
Пример #3
0
        public bool CreateReport(int albumId, AlbumReportType reportType, string hostname, string notes, int?versionNumber)
        {
            ParamIs.NotNull(() => hostname);
            ParamIs.NotNull(() => notes);

            return(HandleTransaction(ctx => {
                return new Model.Service.Queries.EntryReportQueries().CreateReport(ctx, PermissionContext,
                                                                                   entryLinkFactory, report => report.Entry.Id == albumId,
                                                                                   (album, reporter, notesTruncated) => new AlbumReport(album, reportType, reporter, hostname, notesTruncated, versionNumber),
                                                                                   () => reportType != AlbumReportType.Other ? enumTranslations.AlbumReportTypeNames[reportType] : null,
                                                                                   albumId, reportType, hostname, notes);
            }));
        }
Пример #4
0
 public void CreateReport(int albumId, AlbumReportType reportType, string notes)
 {
     Service.CreateReport(albumId, reportType, CfHelper.GetRealIp(Request), notes ?? string.Empty);
 }
Пример #5
0
 public void CreateReport(int albumId, AlbumReportType reportType, string notes)
 {
     Service.CreateReport(albumId, reportType, CfHelper.GetRealIp(Request), notes ?? string.Empty);
 }
Пример #6
0
 public void CreateReport(int albumId, AlbumReportType reportType, string notes, int?versionNumber)
 {
     queries.CreateReport(albumId, reportType, WebHelper.GetRealHost(Request), notes ?? string.Empty, versionNumber);
 }
Пример #7
0
 public AlbumReport(Album album, AlbumReportType reportType, User user, string hostname, string notes)
     : base(user, hostname, notes)
 {
     Album      = album;
     ReportType = reportType;
 }