private static void Demo_Jobs_Summarize_FailedAUHours_By_Submitter(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 300;

            listing_parameters.Filter.Result.IsOneOf(MSADLA.Models.JobResult.Failed);
            listing_parameters.Filter.StartTime.IsNotNull();

            var failed_jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            var results = from job in failed_jobs
                          group job by job.Submitter into job_group
                          select new
            {
                Submitter = job_group.Key,
                Count     = job_group.Count(),
                AUHours   = job_group.Sum(j => j.AUSeconds) / (60.0 * 60.0),
            };

            foreach (var i in results)
            {
                Console.WriteLine("----------------");
                Console.WriteLine("Submitter = {0}", i.Submitter);
                Console.WriteLine("NumJobs = {0}", i.Count);
                Console.WriteLine("AU Hours = {0}", i.AUHours);
            }
        }
        private static void Demo_Jobs_Summarize_AUHours_By_JobResult_nad_Submitter(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 300;

            //opts.Filter.Result.OneOf(MS_ADLA.Models.JobResult.Failed);

            var jobs = adla.Jobs.ListJobs(listing_parameters).Where(j => j.StartTime != null).ToList();

            var results = from job in jobs
                          group job by
                          new
            {
                job.Result,
                job.Submitter
            }
            into job_group
                select new
            {
                Submitter = job_group.Key.Submitter,
                Result    = job_group.Key.Result,
                Count     = job_group.Count(),
                AUHours   = job_group.Sum(j => j.AUSeconds) / (60.0 * 60.0),
            };

            foreach (var row in results)
            {
                Console.WriteLine("----------------");
                Console.WriteLine("Submitter = {0}", row.Submitter);
                Console.WriteLine("Result = {0}", row.Result);
                Console.WriteLine("NumJobs = {0}", row.Count);
                Console.WriteLine("AU Hours = {0}", row.AUHours);
            }
        }
        private static void Demo_GetJobsSubmitedInLast2hours(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Filter.SubmitTime.IsInRange(AdlClient.Models.RangeDateTime.InTheLastNHours(2));
            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_MostExpensive_In_Last24hours(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Filter.SubmitTime.IsInRange(AdlClient.Models.RangeDateTime.InTheLastNHours(24));
            var jobs = adla.Jobs.ListJobs(listing_parameters).OrderByDescending(j => j.AUSeconds).Take(10).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_SubmittedBetween_MidnightAndNow(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Filter.SubmitTime.IsInRange(AdlClient.Models.RangeDateTime.SinceLocalMidnight());
            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_SingleMostRecent(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 1;
            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_NeverStarted(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 2;
            listing_parameters.Filter.StartTime.IsNull();
            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList().ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_Oldest(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 10;
            listing_parameters.Sorting.BySubmitTime(AdlClient.OData.Models.OrderByDirection.Ascending);

            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_SubmittedBy_UserContains(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 10;
            listing_parameters.Filter.Submitter.Contains("eenr");

            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_SubmittedBy_Users(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 10;
            listing_parameters.Filter.Submitter.IsOneOf("*****@*****.**", "*****@*****.**");

            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_SubmittedBy_AuthenticatedUser(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 10;
            listing_parameters.Filter.Submitter.IsOneOf(adla.Authentication.Token.DisplayableId);

            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_Failed(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 5;

            listing_parameters.Filter.Result.IsOneOf(MSADLA.Models.JobResult.Failed);

            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_List_Recent(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 10;

            var jobfields = new AdlClient.Models.JobFields();

            listing_parameters.Sorting.Direction = AdlClient.OData.Models.OrderByDirection.Descending;
            listing_parameters.Sorting.Field     = jobfields.SubmitTime;

            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_JobsDetails(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 5;
            listing_parameters.Filter.State.IsOneOf(MSADLA.Models.JobState.Ended);
            listing_parameters.Filter.Result.IsOneOf(MSADLA.Models.JobResult.Succeeded);
            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            var first_job = jobs.FirstOrDefault();

            if (first_job != null)
            {
                var jobdetails = adla.Jobs.GetJobDetails(first_job.JobId, true);
            }
        }
        private static void Demo_Jobs_List_Oldest_from_Submitter(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 1;

            var jobfields = new AdlClient.Models.JobFields();

            listing_parameters.Sorting.Direction = AdlClient.OData.Models.OrderByDirection.Ascending;
            listing_parameters.Sorting.Field     = jobfields.SubmitTime;

            listing_parameters.Filter.Submitter.Contains("saveenr");

            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            PrintJobs(jobs);
        }
        private static void Demo_Jobs_GetJobUrl(AdlClient.AnalyticsClient adla)
        {
            var listing_parameters = new AdlClient.Models.JobListingParameters();

            listing_parameters.Top = 3;
            var jobs = adla.Jobs.ListJobs(listing_parameters).ToList();

            foreach (var job in jobs)
            {
                var job_ref = job.GetJobReference();

                var job_uri        = new JobUri(job_ref);
                var job_portal_uri = new JobAzurePortalUri(job_ref);

                Console.WriteLine(job_uri.ToString());
                Console.WriteLine(job_portal_uri.ToString());
            }
        }