예제 #1
0
        private async Task ActivityReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var           activity = await result as Activity;
            Championships champs   = new Championships();

            if (activity.Text.Contains("how many teams"))
            {
                await context.PostAsync($"There are { champs.GetTeamCount() } teams.");
            }
            else if (activity.Text.StartsWith("who") || activity.Text.StartsWith("which team"))
            {
                if (activity.Text.Contains("best") || activity.Text.Contains("highest") || activity.Text.Contains("greatest"))
                {
                    await context.PostAsync($"The highest ranked team is { champs.GetHighestRatedTeam() }");
                }
                else if (activity.Text.Contains("worst") || activity.Text.Contains("lowest"))
                {
                    await context.PostAsync($"The lowest ranked team is { champs.GetLowestRatedTeam() }");
                }
            }
            else
            {
                await context.PostAsync("Sorry but my responses are limited. Please ask the right questsions.");
            }
            context.Wait(ActivityReceivedAsync);
        }
예제 #2
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            var activity = await result as Activity;

            //// calculate something for us to return
            //int length = (activity.Text ?? string.Empty).Length;

            //// return our reply to the user
            //await context.PostAsync($"You sent {activity.Text} which was {length} characters");

            //CodeNew
            Championships champs = new Championships();

            if (activity.Text.Contains("how many teams"))
            {
                await context.PostAsync($"There are {champs.GetTeamCount()} teams.");
            }
            else if (activity.Text.StartsWith("who") || activity.Text.StartsWith("which team"))
            {
                if (activity.Text.Contains("best") || activity.Text.Contains("hightest") || activity.Text.Contains("greatest"))
                {
                    await context.PostAsync($"The hightest ranked team is {champs.GetHighestRatedTeam()}");
                }
                else if (activity.Text.Contains("worst") || activity.Text.Contains("lowest"))
                {
                    await context.PostAsync($"The lowest ranked team is {champs.GetLowestRatedTeam()}");
                }
            }
            else
            {
                await context.PostAsync($"Sorry but my response are limited. Please ask the right questions");
            }

            context.Wait(MessageReceivedAsync);
        }
예제 #3
0
 private bool isInDataBase()
 {
     return(Championships.Contains(_championship));
 }
예제 #4
0
 public WSRContext()
 {
     //if (!(Database.GetService<IDatabaseCreator>() as RelationalDatabaseCreator).Exists())
     Database.EnsureDeleted();
     Database.EnsureCreated();
     if (!Participants.Any())
     {
         string DPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), @"..\..\"));
         DPath += "\\CSV\\";
         Database.OpenConnection();
         using (var reader = new StreamReader(DPath + "Participants.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Participants.AddRange(csv.GetRecords <Participant>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Participants ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Participants OFF;");
         using (var reader = new StreamReader(DPath + "Experts.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Experts.AddRange(csv.GetRecords <Expert>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Experts ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Experts OFF;");
         using (var reader = new StreamReader(DPath + "Admins.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Administrators.AddRange(csv.GetRecords <Administrator>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Administrators ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Administrators OFF;");
         using (var reader = new StreamReader(DPath + "Coordinators.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Coordinators.AddRange(csv.GetRecords <Coordinator>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Coordinators ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Coordinators OFF;");
         List <Competention> temp = new List <Competention>();
         using (var reader = new StreamReader(DPath + "Competentions.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 temp.AddRange(csv.GetRecords <Competention>());
             }
         using (var reader = new StreamReader(DPath + "CompetentionDesc.txt", Encoding.Default))
         {
             Competention CurrC;
             for (int Counter = 1; Counter <= temp.Count; Counter++)//relies on competencies being consequentioal from 1
             {
                 CurrC             = temp.FirstOrDefault(c => c.Id == Counter);
                 CurrC.Description = reader.ReadLine();
             }
         }
         Competentions.AddRange(temp);
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Competentions ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Competentions OFF;");
         using (var reader = new StreamReader(DPath + "Championships.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Championships.AddRange(csv.GetRecords <Championship>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Championships ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Championships OFF;");
         using (var reader = new StreamReader(DPath + "Infrastructures.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Infrastructures.AddRange(csv.GetRecords <Infrastructure>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Infrastructures ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Infrastructures OFF;");
         using (var reader = new StreamReader(DPath + "SMPs.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 SMPs.AddRange(csv.GetRecords <SMP>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.SMPs ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.SMPs OFF;");
         using (var reader = new StreamReader(DPath + "Results.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Results.AddRange(csv.GetRecords <Result>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Results ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Results OFF;");
         using (var reader = new StreamReader(DPath + "Sponsors.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Sponsors.AddRange(csv.GetRecords <Sponsor>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Sponsors ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Sponsors OFF;");
         using (var reader = new StreamReader(DPath + "Volunteers.csv"))
             using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
             {
                 Volunteers.AddRange(csv.GetRecords <Volunteer>());
             }
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Volunteers ON;");
         SaveChanges();
         Database.ExecuteSqlRaw("SET IDENTITY_INSERT dbo.Volunteers OFF;");
         Database.CloseConnection();
     }
 }