コード例 #1
0
        /// <summary>
        /// Persist information about the specified <paramref name="ex">exception</paramref> to the data store and return
        /// the instance. Send an e-mail notification if that option is enabled.
        /// </summary>
        /// <param name="ex">The exception to be recorded to the data store.</param>
        /// <param name="appSettings">The application settings containing the e-mail configuration data.</param>
        /// <param name="galleryId">The ID of the gallery the <paramref name="ex">exception</paramref> is associated with.
        /// If the exception is not specific to a particular gallery, specify null.</param>
        /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify
        /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param>
        /// <returns>An instance of <see cref="IEvent" />.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="ex"/> is null.</exception>
        public static IEvent RecordError(Exception ex, IAppSetting appSettings, int?galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null)
        {
            if (ex == null)
            {
                throw new ArgumentNullException("ex");
            }

            if (galleryId == null)
            {
                using (var repo = new GalleryRepository())
                {
                    galleryId = repo.Where(g => g.IsTemplate).First().GalleryId;
                }
            }

            var ev = new Event(ex, galleryId.Value);

            Save(ev);

            if (gallerySettingsCollection != null)
            {
                SendEmail(ev, appSettings, gallerySettingsCollection);
            }

            if (appSettings != null)
            {
                ValidateLogSize(appSettings.MaxNumberErrorItems);
            }

            return(ev);
        }
コード例 #2
0
        /// <summary>
        /// Persist information about the specified <paramref name="msg" /> to the data store and return
        /// the instance. Send an e-mail notification if that option is enabled.
        /// </summary>
        /// <param name="msg">The message to be recorded to the data store.</param>
        /// <param name="eventType">Type of the event. Defaults to <see cref="EventType.Info" /> if not specified.</param>
        /// <param name="galleryId">The ID of the gallery the <paramref name="msg" /> is associated with.
        /// If the message is not specific to a particular gallery, specify null.</param>
        /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify
        /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param>
        /// <param name="appSettings">The application settings. You may specify null if the value is not known.</param>
        /// <param name="data">Additional optional data to record. May be null.</param>
        /// <returns>An instance of <see cref="IEvent" />.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">galleryId</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="galleryId" /> is <see cref="Int32.MinValue" />.</exception>
        public static IEvent RecordEvent(string msg, EventType eventType = EventType.Info, int?galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null, IAppSetting appSettings = null, Dictionary <string, string> data = null)
        {
            if (galleryId == Int32.MinValue)
            {
                throw new ArgumentOutOfRangeException("galleryId", String.Format("The galleryId parameter must represent an existing gallery. Instead, it was {0}", galleryId));
            }

            if (galleryId == null)
            {
                using (var repo = new GalleryRepository())
                {
                    galleryId = repo.Where(g => g.IsTemplate).First().GalleryId;
                }
            }

            var ev = new Event(msg, galleryId.Value, eventType, data);

            Save(ev);

            if (appSettings != null && gallerySettingsCollection != null)
            {
                SendEmail(ev, appSettings, gallerySettingsCollection);
            }

            if (appSettings != null)
            {
                ValidateLogSize(appSettings.MaxNumberErrorItems);
            }

            return(ev);
        }
コード例 #3
0
 /// <summary>
 /// Gets the ID of the template gallery.
 /// </summary>
 /// <returns>System.Int32.</returns>
 private static int GetTemplateGalleryId()
 {
     using (var repo = new GalleryRepository())
     {
         return(repo.Where(g => g.IsTemplate).Single().GalleryId);
     }
 }
コード例 #4
0
        /// <summary>
        /// Persist information about the specified <paramref name="msg" /> to the data store and return
        /// the instance. Send an e-mail notification if that option is enabled.
        /// </summary>
        /// <param name="msg">The message to be recorded to the data store.</param>
        /// <param name="eventType">Type of the event. Defaults to <see cref="EventType.Info" /> if not specified.</param>
        /// <param name="galleryId">The ID of the gallery the <paramref name="msg" /> is associated with.
        /// If the message is not specific to a particular gallery, specify null.</param>
        /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify
        /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param>
        /// <param name="appSettings">The application settings. You may specify null if the value is not known.</param>
        /// <param name="data">Additional optional data to record. May be null.</param>
        /// <returns>An instance of <see cref="IEvent" />.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">galleryId</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="galleryId" /> is <see cref="Int32.MinValue" />.</exception>
        public static IEvent RecordEvent(string msg, EventType eventType = EventType.Info, int? galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null, IAppSetting appSettings = null, Dictionary<string, string> data = null)
        {
            if (galleryId == Int32.MinValue)
                throw new ArgumentOutOfRangeException("galleryId", String.Format("The galleryId parameter must represent an existing gallery. Instead, it was {0}", galleryId));

            if (galleryId == null)
            {
                using (var repo = new GalleryRepository())
                {
                    galleryId = repo.Where(g => g.IsTemplate).First().GalleryId;
                }
            }

            var ev = new Event(msg, galleryId.Value, eventType, data);

            Save(ev);

            if (appSettings != null && gallerySettingsCollection != null)
            {
                SendEmail(ev, appSettings, gallerySettingsCollection);
            }

            if (appSettings != null)
            {
                ValidateLogSize(appSettings.MaxNumberErrorItems);
            }

            return ev;
        }
コード例 #5
0
        /// <summary>
        /// Persist information about the specified <paramref name="ex">exception</paramref> to the data store and return
        /// the instance. Send an e-mail notification if that option is enabled.
        /// </summary>
        /// <param name="ex">The exception to be recorded to the data store.</param>
        /// <param name="appSettings">The application settings containing the e-mail configuration data.</param>
        /// <param name="galleryId">The ID of the gallery the <paramref name="ex">exception</paramref> is associated with.
        /// If the exception is not specific to a particular gallery, specify null.</param>
        /// <param name="gallerySettingsCollection">The collection of gallery settings for all galleries. You may specify
        /// null if the value is not known; however, this value must be specified for e-mail notification to occur.</param>
        /// <returns>An instance of <see cref="IEvent" />.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="ex"/> is null.</exception>
        public static IEvent RecordError(Exception ex, IAppSetting appSettings, int? galleryId = null, IGallerySettingsCollection gallerySettingsCollection = null)
        {
            if (ex == null)
                throw new ArgumentNullException("ex");

            if (galleryId == null)
            {
                using (var repo = new GalleryRepository())
                {
                    galleryId = repo.Where(g => g.IsTemplate).First().GalleryId;
                }
            }

            var ev = new Event(ex, galleryId.Value);

            Save(ev);

            if (gallerySettingsCollection != null)
            {
                SendEmail(ev, appSettings, gallerySettingsCollection);
            }

            if (appSettings != null)
            {
                ValidateLogSize(appSettings.MaxNumberErrorItems);
            }

            return ev;
        }
コード例 #6
0
ファイル: Factory.cs プロジェクト: Jiyuu/galleryserverpro
		/// <summary>
		/// Fill the <paramref name="emptyCollection"/> with all the galleries in the current application. The return value is the same reference
		/// as the parameter. The template gallery is not included (that is, the one where <see cref="GalleryDto.IsTemplate" /> = <c>true</c>).
		/// </summary>
		/// <param name="emptyCollection">An empty <see cref="IGalleryCollection"/> object to populate with the list of galleries in the current
		/// application. This parameter is required because the library that implements this interface does not have
		/// the ability to directly instantiate any object that implements <see cref="IGalleryCollection"/>.</param>
		/// <returns>
		/// Returns an <see cref="IGalleryCollection"/> representing the galleries in the current application. The returned object is the
		/// same object in memory as the <paramref name="emptyCollection"/> parameter.
		/// </returns>
		/// <exception cref="ArgumentNullException">Thrown when <paramref name="emptyCollection" /> is null.</exception>		/// 
		private static IGalleryCollection LoadGalleries(IGalleryCollection emptyCollection)
		{
			if (emptyCollection == null)
				throw new ArgumentNullException("emptyCollection");

			if (emptyCollection.Count > 0)
			{
				emptyCollection.Clear();
			}

			using (var repo = new GalleryRepository())
			{
				//var galleries = from i in ctx.Galleries where i.GalleryId > int.MinValue select i;
				var galleries = repo.Where(g => !g.IsTemplate);

				foreach (GalleryDto gallery in galleries)
				{
					IGallery g = emptyCollection.CreateEmptyGalleryInstance();

					g.GalleryId = gallery.GalleryId;
					g.Description = gallery.Description;
					g.CreationDate = gallery.DateAdded;
					g.Albums = FlattenGallery(gallery.GalleryId);

					emptyCollection.Add(g);
				}
			}

			return emptyCollection;
		}
コード例 #7
0
ファイル: Factory.cs プロジェクト: Jiyuu/galleryserverpro
		/// <summary>
		/// Gets the ID of the template gallery (that is, the one where <see cref="GalleryDto.IsTemplate" /> = <c>true</c>).
		/// </summary>
		/// <returns>System.Int32.</returns>
		public static int GetTemplateGalleryId()
		{
			if (!_templateGalleryId.HasValue)
			{
				using (var repo = new GalleryRepository())
				{
					_templateGalleryId = repo.Where(g => g.IsTemplate).Select(g => g.GalleryId).FirstOrDefault();
				}
			}

			return _templateGalleryId.Value;
		}