<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using Microsoft.ServiceBus.Messaging;
using Microsoft.ServiceBus;

namespace GenerateSAS
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("What is your service bus namespace?");
            string sbNamespace = Console.ReadLine();
           

            Console.WriteLine("What is the path?");
            string sbPath = Console.ReadLine();

            Console.WriteLine("What existing shared access policy would you like to use to generate your SAS?");
            string sbPolicy = Console.ReadLine();

            Console.WriteLine("What is that policy's shared access key (primary or secondary)?");
            string sbKey = Console.ReadLine();

            Console.WriteLine("When should this expire (MM/DD/YY HH, GMT)? (press enter for 10/31/2020 12:00)");
            string sbExpiry = Console.ReadLine();
            if (sbExpiry.Length == 0) sbExpiry = "10/31/2020 12";

            // convert the string into a timespan... 
            DateTime tmpDT;
            DateTime.TryParseExact(sbExpiry, "MM/dd/YY HH", null, DateTimeStyles.None, out tmpDT);
            TimeSpan expiry = DateTime.UtcNow.Subtract(tmpDT);

            var serviceUri = ServiceBusEnvironment.CreateServiceUri("https", sbNamespace, sbPath).ToString().Trim('/');
            string generatedSaS = SharedAccessSignatureTokenProvider.GetSharedAccessSignature(sbPolicy, sbKey, serviceUri, expiry);

            Console.WriteLine("Your SAS is:\n{0}", generatedSaS);
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
    }
}



<commit_msg>Changed text shown in command line and added error handling<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using Microsoft.ServiceBus.Messaging;
using Microsoft.ServiceBus;

namespace GenerateSAS
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("What is your service bus namespace?");
            string sbNamespace = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine("What is the Notification Hub name?");
            string sbPath = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine("What existing shared access policy would you like to use to generate your SAS? (press enter for 'DefaultFullSharedAccessSignature')");
            string sbPolicy = Console.ReadLine();
            if (sbPolicy.Length == 0) sbPolicy = "DefaultFullSharedAccessSignature";

            Console.WriteLine();
            Console.WriteLine("What is that policy's shared access key?");
            string sbKey = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine("When should this expire (MM/DD/YY HH, GMT)? (press enter for 10/31/2020 12:00)");
            string sbExpiry = Console.ReadLine();
            if (sbExpiry.Length == 0) sbExpiry = "10/31/2020 12";

            // convert the expiry date string into a timespan... 
            DateTime tmpDT;
            DateTime.TryParseExact(sbExpiry, "MM/dd/YY HH", null, DateTimeStyles.None, out tmpDT);
            TimeSpan expiry = DateTime.UtcNow.Subtract(tmpDT);

            Console.WriteLine();
            try
            {
                var serviceUri = ServiceBusEnvironment.CreateServiceUri("https", sbNamespace, sbPath).ToString().Trim('/');
                string generatedSaS = SharedAccessSignatureTokenProvider.GetSharedAccessSignature(sbPolicy, sbKey, serviceUri, expiry);
               
                Console.WriteLine("Your SAS is:\n{0}", generatedSaS);
                Console.WriteLine();
                Console.WriteLine("Copy the above generated key");
            }
            catch
            {
                Console.WriteLine("An error occured, please check the values you entered and try again");
            }
           
            
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
    }
}




{'fraction_non_alphanumeric': 0.10156798502223262, 'fraction_numerical': 0.011467353147671425, 'mean_word_length': 2.3234836702954897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7316684', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1045, 'n_words': 304}