/// <summary>
        /// Records a message to the System Log.
        /// </summary>
        /// <param name="message">The Log Message.</param>
        /// <param name="entryType">The Type of the Entry.</param>
        /// <param name="user">The User.</param>
        /// <param name="wiki">The wiki, <c>null</c> if is an application level log.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="message"/> or <paramref name="user"/> are <c>null</c>.</exception>
        /// <exception cref="ArgumentException">If <paramref name="message"/> or <paramref name="user"/> are empty.</exception>
        public void LogEntry(string message, EntryType entryType, string user, string wiki)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }
            if (message.Length == 0)
            {
                throw new ArgumentException("Message cannot be empty", "message");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (user.Length == 0)
            {
                throw new ArgumentException("User cannot be empty", "user");
            }

            DateTime dateTime = DateTime.UtcNow;

            LogEntity logEntity = new LogEntity()
            {
                PartitionKey = "0",
                RowKey       = dateTime.Ticks + "-" + Guid.NewGuid().ToString("N"),
                Type         = EntryTypeToString(entryType),
                DateTime     = dateTime,
                User         = user,
                Message      = message,
                Wiki         = wiki
            };

            _context.AddObject(LogsTable, logEntity);
            _context.SaveChangesStandard();

            int logSize = LogSize;

            if (logSize > int.Parse(_host.GetGlobalSettingValue(GlobalSettingName.MaxLogSize)))
            {
                CutLog((int)(logSize * 0.75));
            }
        }
        protected IHostV40 MockHost()
        {
            if (!Directory.Exists(testDir))
            {
                Directory.CreateDirectory(testDir);
            }
            //Console.WriteLine("Temp dir: " + testDir);

            IHostV40 host = mocks.DynamicMock <IHostV40>();

            Expect.Call(host.GetGlobalSettingValue(GlobalSettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce();

            Expect.Call(host.GetGlobalSettingValue(GlobalSettingName.LoggingLevel)).Return("3").Repeat.Any();
            Expect.Call(host.GetGlobalSettingValue(GlobalSettingName.MaxLogSize)).Return(MaxLogSize.ToString()).Repeat.Any();
            Expect.Call(host.GetSettingValue(SettingName.MaxRecentChanges)).Constraints(Rhino.Mocks.Constraints.Is.Equal(SettingName.MaxRecentChanges)).Return(MaxRecentChanges.ToString()).Repeat.Any();

            mocks.Replay(host);

            return(host);
        }
Beispiel #3
0
        protected IHostV40 MockHost()
        {
            if (!Directory.Exists(testDir))
            {
                Directory.CreateDirectory(testDir);
            }

            IHostV40 host = mocks.DynamicMock <IHostV40>();

            Expect.Call(host.GetGlobalSettingValue(GlobalSettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce();

            mocks.Replay(host);

            return(host);
        }
 private string BuildDbConnectionString(IHostV40 host)
 {
     return("Data Source = '" + Path.Combine(host.GetGlobalSettingValue(GlobalSettingName.PublicDirectory), "ScrewTurnWiki.sdf") + "';");
 }
Beispiel #5
0
 /// <summary>
 /// Gets the data directory.
 /// </summary>
 /// <param name="host">The host object.</param>
 /// <returns>The data directory.</returns>
 protected string GetDataDirectory(IHostV40 host)
 {
     return(host.GetGlobalSettingValue(GlobalSettingName.PublicDirectory));
 }
Beispiel #6
0
        private IFilesStorageProviderV40 GetDefaultFilesStorageProvider()
        {
            string defaultFilesStorageProviderName = _host.GetGlobalSettingValue(GlobalSettingName.DefaultFilesStorageProvider);

            return(_host.GetFilesStorageProviders().First(p => p.GetType().FullName == defaultFilesStorageProviderName));
        }