コード例 #1
0
        public void Initialize(ConfigurationOptions configurationOptions = null)
        {
            TaskManager = new CustomTaskManager()
            {
                Instance = this
            };

            if (configurationOptions == null)
            {
                configurationOptions = new ConfigurationOptions();
            }

            Config                 = configurationOptions;
            Log.Config             = Config;
            DiscoveredMaxDateTicks = DateTime.MinValue.Ticks;
            DiscoveredMinDateTicks = DateTime.MaxValue.Ticks;
            FileObjects            = new FileObjectCollection();
            FileMgr                = new FileManager(this);
            Kusto                = new KustoConnection(this);
            LogAnalytics         = new LogAnalyticsConnection(this);
            StartTime            = DateTime.Now;
            TimedOut             = false;
            TotalErrors          = 0;
            TotalFilesConverted  = 0;
            TotalFilesDownloaded = 0;
            TotalFilesEnumerated = 0;
            TotalFilesFormatted  = 0;
            TotalFilesMatched    = 0;
            TotalFilesSkipped    = 0;
            TotalRecords         = 0;
        }
コード例 #2
0
        private static int ManageTasks(CustomTaskManager instance)
        {
            if (instance.RemoveWhenComplete && instance.AllTasks.Any(x => x.IsCompleted))
            {
                string taskUpdate = $"removing completed tasks from instance {instance.CallerName} " +
                                    $"scheduled:{instance.AllTasks.Count()} " +
                                    $"queued:{instance.QueuedTaskObjects.Count()}";

                if (Config.LogDebug)
                {
                    instance.AllTasks.ForEach(x => taskUpdate += $"\r\n  ID:{x.Id.ToString().PadRight(6)} {x.Status.ToString().PadRight(15)} ({x.CreationOptions.ToString()})");
                }

                Log.Info(taskUpdate, ConsoleColor.White);

                foreach (Task badTask in instance.AllTasks.FindAll(x => x.Status > TaskStatus.RanToCompletion))
                {
                    Log.Error("task failure: ", badTask);
                    TotalErrors++;
                }

                instance.AllTasks.RemoveAll(x => x.IsCompleted);
            }

            while ((instance.CreationOptions == TaskCreationOptions.AttachedToParent | !instance.IsAboveQuota()) && instance.QueuedTaskObjects.Any())
            {
                TaskObject taskObject = instance.QueuedTaskObjects[0];
                instance.ScheduleTask(taskObject);
                instance.QueuedTaskObjects.Remove(taskObject);

                Log.Info($"scheduled task {instance.GetHashCode()} " +
                         $"instance:{instance.CallerName} " +
                         $"total:{instance.AllTasks.Count()} " +
                         $"incomplete:{instance.AllTasks.Count(x => !x.IsCompleted)} " +
                         $"queued:{instance.QueuedTaskObjects.Count()} " +
                         $"GC:{GC.GetTotalMemory(false)} " +
                         $"total records:{TotalRecords} " +
                         $"rps:{TotalRecords / (DateTime.Now - StartTime).TotalSeconds}", ConsoleColor.Magenta);
            }

            return(instance.AllTasks.Count(x => !x.IsCompleted));
        }
コード例 #3
0
 public void Close()
 {
     CustomTaskManager.Cancel();
 }