Ejemplo n.º 1
0
        /// <summary>
        /// Get activity specific records from a log type
        /// </summary>
        /// <param name="activity"></param>
        /// <param name="maxRecords"></param>
        /// <returns></returns>
        internal static IEnumerable <PlatformLogTableEntity> GetActivityLogByTime(PlatformLogType activity, int maxRecords)
        {
            string logName = activity.LogName.ToLower() + "byactivity";

            CloudTableClient cloudTableClient = EnvironmentSettings.StorageConnection.PlatformStorage.CreateCloudTableClient();
            CloudTable       cloudTable       = cloudTableClient.GetTableReference(logName);

            cloudTable.CreateIfNotExists();

            TableQuery <PlatformLogTableEntity> query = new TableQuery <PlatformLogTableEntity>().Take(maxRecords).
                                                        Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, activity.Activity));

            return(cloudTable.ExecuteQuery(query));
        }
Ejemplo n.º 2
0
        public static void LogActivity(PlatformLogType activity, string description, string details = null)
        {
            #region Fire & Forget on a background thread (More overhead)

            /*
             * System.Threading.ThreadStart threadStart = delegate
             * {
             *  //Log the activity
             *  PrivateMethods.WritePlatformLog(activity, description, details);
             *
             * };
             * System.Threading.Thread thread = new System.Threading.Thread(threadStart);
             * thread.IsBackground = true;
             * thread.Start();
             */
            #endregion

            #region Fire & Forget using ThreadPool.QueueUserWorkItem (Pool of threads at the ready)

            ThreadPool.QueueUserWorkItem(o => PrivateMethods.WritePlatformLog(activity, description, details));
            #endregion
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns all records of a particular activity in a log, newest records first
 /// </summary>
 /// <param name="activity"></param>
 /// <param name="maxRecords"></param>
 /// <returns></returns>
 public static IEnumerable <PlatformLogTableEntity> GetLog(PlatformLogType activity, int maxRecords)
 {
     return(PrivateMethods.GetActivityLogByTime(activity, maxRecords));
 }