Exemplo n.º 1
0
 private ICollection<SessionUser> CreateSessionUsers(Session session)
 {
     return new[]
     {
         new SessionUser()
         {
             SessionId = 1,
             SessionUserId = 1,
             Session = session,
             Identity = new Identity()
             {
                 FirstName = "An awesome user",
                 LastName = "With a cool name",
                 Email = "*****@*****.**"
             }
         },
         new SessionUser()
         {
             SessionId = 1,
             SessionUserId = 1,
             Session = session,
             Identity = new Identity()
             {
                 FirstName = "An awesome user",
                 LastName = "With a cool name",
                 Email = "*****@*****.**"
             }
         }
     };
 }
Exemplo n.º 2
0
        private Session CreateSession()
        {
            var session = new Session()
            {
                SessionId = 1,
                SessionName = "[AcceptanceTest]Test Session",
                StartDate = DateTimeOffset.Now,
                EndDate = DateTimeOffset.Now.AddHours(1),
                Lab = new Lab()
                {
                    LabId = 1,
                    Name = "[AcceptanceTest]Test Lab",
                    Description = "A test lab for all",
                    CreationDate = DateTime.Now.AddDays(-1),
                    Removed = false,
                    ImageName = "A_very_cool_image"
                },
                LabId = 1,
                Removed = false,
                SchedulingType = 1,
                Version = "Version 1.0",
                VmSize = "Small",
            };

            session.SessionUsers = CreateSessionUsers(session);
            session.VirtualMachines = CreateVirtualMachines(session);

            return session;
        }
Exemplo n.º 3
0
        public static Email BuildSessionStartVmsEmails(string trainerFirstName, string toEmailAddress, Session session, string serviceName, int nbOfUsers)
        {
            string template = GetTemplate("StartingVirtualMachines");
            var builtEmails = new List<EmailMessage>();

            builtEmails.Add(
              new EmailMessage()
              {
                  Body = Engine.Razor.RunCompile(template, "StartingVirtualMachines", null,
                          new
                          {
                              TrainerFirstName = trainerFirstName,
                              NumberOfUsers = nbOfUsers,
                              SessionName = session.SessionName,
                              StartDate = session.StartDate,
                              EndDate = session.EndDate,
                              LabName = session.Lab.Name,
                              ServiceName = serviceName
                          }),
                  To = toEmailAddress,
                  Subject = string.Format("[GbLabs] Starting VM(s) for the {0} training session", session.SessionName),
              });

            return new Email(builtEmails);
        }
Exemplo n.º 4
0
        public static Email BuildSessionEmails(Session session, string serviceName)
        {
            string template = GetTemplate("ConnectionDetails");
            var emails = session.VirtualMachines.Select(virtualMachine =>
                new EmailMessage()
                {
                    Body = Engine.Razor.RunCompile(template, "sessionTemplate", null,
                        new
                        {
                            User = virtualMachine.Identity.FirstName,
                            UserName = string.Format(@"{0}\{1}", virtualMachine.VmName, virtualMachine.VmAdminUser),
                            Password = virtualMachine.VmAdminPass,
                            virtualMachine.Session.SessionName,
                            RDPHost = serviceName + ".cloudapp.net:" + virtualMachine.VmRdpPort

                        }),
                    To = virtualMachine.Identity.Email,
                    Subject = string.Format("Connection details for {0} training session", virtualMachine.Session.SessionName),
                    Attachement = BuildRdpAttachement(serviceName, virtualMachine.VmRdpPort),
                    AttachementName = serviceName + ".rdp"
                }).ToList();
            var email = new Email(emails);

            return email;
        }
Exemplo n.º 5
0
        private ICollection<VirtualMachine> CreateVirtualMachines(Session session)
        {
            return new[]
            {
                new VirtualMachine()
                {
                    SessionId = 1,
                    Deleted = false,
                    Stopped = false,
                    Identity = new Identity()
                    {
                        FirstName = "An awesome user",
                        LastName = "With a cool name",
                        Email = "*****@*****.**"
                    },
                    Session = session,
                    VmAdminUser = "******",
                    VmAdminPass = "******",
                    VmName = "Awesome VM",
                    VmRdpPort = 6666,
                    VirtualMachineId = 1

                },
                new VirtualMachine()
                {
                    SessionId = 1,
                    Deleted = false,
                    Stopped = false,
                    Session = session,
                    Identity = new Identity()
                    {
                        FirstName = "An awesome user",
                        LastName = "With a cool name",
                        Email = "*****@*****.**"
                    },
                    VmAdminUser = "******",
                    VmAdminPass = "******",
                    VmName = "Awesome VM",
                    VmRdpPort = 6666,
                    VirtualMachineId = 1

                }
            };
        }
Exemplo n.º 6
0
 public static int CalculateSessionCPUs(Session session)
 {
     VmSizeEnum vmSize = (VmSizeEnum)Enum.Parse(typeof(VmSizeEnum), session.VmSize);
     int cpuCount = (int)vmSize;
     return session.SessionUsers.Count * cpuCount;
 }