Пример #1
0
		public SongReport(Song song, SongReportType reportType, User user, string hostname, string notes) 
			: base(user, hostname, notes) {

			Song = song;
			ReportType = reportType;

		}
Пример #2
0
        public bool CreateReport(int songId, SongReportType reportType, string hostname, string notes)
        {
            ParamIs.NotNull(() => hostname);
            ParamIs.NotNull(() => notes);

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

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

                var song = session.Load <Song>(songId);
                var report = new SongReport(song, reportType, GetLoggedUserOrDefault(session), hostname, notes.Truncate(EntryReport.MaxNotesLength));

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

                session.Save(report);
                return true;
            }, IsolationLevel.ReadUncommitted));
        }
Пример #3
0
        private (bool created, SongReport report) CallCreateReport(SongReportType reportType, int?versionNumber = null, Song song = null, DateTime?created = null)
        {
            song ??= _song;
            var result = _queries.CreateReport(song.Id, reportType, "39.39.39.39", "It's Miku, not Rin", versionNumber);
            var report = _repository.Load <SongReport>(result.reportId);

            if (created != null)
            {
                report.Created = created.Value;
            }
            return(result.created, report);
        }
Пример #4
0
        public bool CreateReport(int songId, SongReportType 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 == songId,
                                                                                   (song, reporter, notesTruncated) => new SongReport(song, reportType, reporter, hostname, notesTruncated, versionNumber),
                                                                                   () => reportType != SongReportType.Other ? enumTranslations.SongReportTypeNames[reportType] : null,
                                                                                   songId, reportType, hostname, notes);
            }));
        }
Пример #5
0
 public SongReport(Song song, SongReportType reportType, User user, string hostname, string notes)
     : base(user, hostname, notes)
 {
     Song       = song;
     ReportType = reportType;
 }
Пример #6
0
        private (bool created, SongReport report) CallCreateReport(SongReportType reportType, int?versionNumber = null)
        {
            var result = queries.CreateReport(song.Id, reportType, "39.39.39.39", "It's Miku, not Rin", versionNumber);

            return(result.created, repository.Load <SongReport>(result.reportId));
        }
Пример #7
0
 public void CreateReport(int songId, SongReportType reportType, string notes)
 {
     Service.CreateReport(songId, reportType, CfHelper.GetRealIp(Request), notes ?? string.Empty);
 }
Пример #8
0
 public void CreateReport(int songId, SongReportType reportType, string notes, int?versionNumber)
 {
     queries.CreateReport(songId, reportType, WebHelper.GetRealHost(Request), notes ?? string.Empty, versionNumber);
 }
Пример #9
0
 public void CreateReport(int songId, SongReportType reportType, string notes)
 {
     Service.CreateReport(songId, reportType, CfHelper.GetRealIp(Request), notes ?? string.Empty);
 }