Ejemplo n.º 1
0
        protected IHostV50 MockHost()
        {
            if (!System.IO.Directory.Exists(testDir))
            {
                System.IO.Directory.CreateDirectory(testDir);
            }

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

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

            mocks.Replay(host);

            return(host);
        }
Ejemplo n.º 2
0
        /// <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
            };
            CloudTable     table           = _cloudTableClient.GetTableReference(LogsTable);
            TableOperation insertOperation = TableOperation.Insert(logEntity);

            table.Execute(insertOperation);

            int logSize = LogSize;

            if (logSize > int.Parse(_host.GetGlobalSettingValue(GlobalSettingName.MaxLogSize)))
            {
                CutLog((int)(logSize * 0.75));
            }
        }
Ejemplo n.º 3
0
 private string BuildDbConnectionString(IHostV50 host)
 {
     return("Data Source = '" + Path.Combine(host.GetGlobalSettingValue(GlobalSettingName.PublicDirectory), "ScrewTurnWiki.sdf") + "';");
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the data directory.
 /// </summary>
 /// <param name="host">The host object.</param>
 /// <returns>The data directory.</returns>
 protected string GetDataDirectory(IHostV50 host)
 {
     return(host.GetGlobalSettingValue(GlobalSettingName.PublicDirectory));
 }