// GET: Testsummary
        public ActionResult AllTests(int Id, int OutCome, string branch, int page = 1, bool isPrevSelected = false, bool isNextSelected = false)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                TestSummarySet model = new TestSummarySet();
                int PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"].ToString());
                List<TestSummary> TestResultsSummary = null;
                int TotalPages = 0;
                string searchTxt = string.Empty;

                model.passedtests = getTestresults(Id, 0, branch, searchTxt, page, PageSize, out TestResultsSummary, out TotalPages);
                ViewBag.PassedTotalPages = (int)Math.Ceiling((double)TotalPages / PageSize);

                model.skippedtests = getTestresults(Id, 1, branch, searchTxt, page, PageSize, out TestResultsSummary, out TotalPages);
                ViewBag.SkippedTotalPages = (int)Math.Ceiling((double)TotalPages / PageSize);

                model.failedtests = getTestresults(Id, 2, branch, searchTxt, page, PageSize, out TestResultsSummary, out TotalPages);
                ViewBag.FailedTotalPages = (int)Math.Ceiling((double)TotalPages / PageSize);

                model.notfoundtests = getTestresults(Id, 3, branch, searchTxt, page, PageSize, out TestResultsSummary, out TotalPages);
                ViewBag.NotfoundTotalPages = (int)Math.Ceiling((double)TotalPages / PageSize);

                SetViewBagProperties(page, PageSize, Id, OutCome, branch, isPrevSelected, isNextSelected, searchTxt);

                model.testConfigDetails = getTesummaryConfigDetails(Id);
                return View(model);
            }
        }
        public ActionResult SaveSettings(string email)
        {
            try
            {
                if (Request.IsAuthenticated)
                {
                    var           username     = User.Identity.Name;
                    StringBuilder sbUserStatus = new StringBuilder();
                    using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
                    {
                        var user = dbContext.UsersSets.SingleOrDefault(u => u.UPN.Equals(username, StringComparison.InvariantCultureIgnoreCase));

                        if (user != null)
                        {
                            user.SendTestResults = true;
                            user.Email           = email;
                            dbContext.SaveChanges();

                            SendEmail(email);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(View());
        }
        public static bool IsCoreTeamMember(IPrincipal principal)
        {
            try
            {
                if (!principal.Identity.IsAuthenticated)
                {
                    return false;
                }

                using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
                {
                    var user = dc.UsersSets.Where(u => u.UPN.Equals(principal.Identity.Name, StringComparison.InvariantCultureIgnoreCase)).First();
                    if (user == null)
                    {
                        return false;
                    }
                    else
                    {
                        return user.IsCoreMember;
                    }
                }
            }
            catch (Exception ex)
            {
                //log error
                return false;
            }
        }
示例#4
0
        public ActionResult PrintLog(int Id)
        {
            GenerateLog TestResults = null;

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                if (Request.IsAuthenticated && AuthorizationManager.IsCoreTeamMember(User))
                {
                    TestResults = (from testrunsets in dc.TestRunSets
                                   where testrunsets.Id == Id
                                   select new GenerateLog
                    {
                        Log = testrunsets.MSBuildLog
                    }).SingleOrDefault();
                }
                else
                {
                    TestResults = (from testrunsets in dc.TestRunSets
                                   join configset in dc.TestConfigurationSets on testrunsets.TestConfigurationId equals configset.Id
                                   where testrunsets.Id == Id && configset.AnonymousAccess == true
                                   select new GenerateLog
                    {
                        Log = testrunsets.MSBuildLog
                    }).SingleOrDefault();
                }
            }

            return(View(TestResults));
        }
示例#5
0
        public List <TestSummary> getTestresults(int Id, int outcome, string branch, string searchTestcaseString, int page, int PageSize, out List <TestSummary> TestResults, out int TotalPages)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                TestResults = new List <TestSummary>();
                TotalPages  = 0;

                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                {
                    configset.Id,
                    configset.AnonymousAccess
                };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                List <TestSummary> data = (from testreultset in dc.TestResultSets
                                           join testrunset in dc.TestRunSets on testreultset.TestRunId equals testrunset.Id
                                           join configset in configDetails on testrunset.TestConfigurationId equals configset.Id
                                           where testreultset.TestRunId == Id && testreultset.Outcome == outcome &&
                                           ((!string.IsNullOrEmpty(searchTestcaseString) ? testreultset.TestCaseName.Contains(searchTestcaseString) : true))
                                           select new TestSummary
                {
                    Outcome = testreultset.Outcome,
                    Error = testreultset.ErrorMessage,
                    StackTrace = testreultset.ErrorStackTrace,
                    TestDuration = testreultset.Duration,
                    TestCasename = testreultset.TestCaseName,
                    Id = testreultset.Id,
                    Branch = branch
                }).OrderByDescending(d => d.Id).Skip((page - 1) * PageSize).Take(PageSize).ToList();

                if (data != null && data.Any())
                {
                    var totaltests = (from testreultset in dc.TestResultSets
                                      where testreultset.TestRunId == Id && testreultset.Outcome == outcome && (!string.IsNullOrEmpty(searchTestcaseString) ? testreultset.TestCaseName.Contains(searchTestcaseString) : true)
                                      select new { testreultset }).ToList();
                    if (totaltests != null && totaltests.Any())
                    {
                        TotalPages = totaltests.Count;
                    }

                    TestResults = (from testreult in data
                                   select new TestSummary
                    {
                        Outcome = testreult.Outcome,
                        Error = testreult.Error,
                        StackTrace = testreult.StackTrace,
                        TestDuration = testreult.TestDuration,
                        TestCasename = testreult.TestCasename,
                        Id = testreult.Id,
                        Branch = branch
                    }).OrderByDescending(t => t.Id).ToList();
                }
                return(TestResults);
            }
        }
示例#6
0
        public static bool IsCoreTeamMember(IPrincipal principal)
        {
            try
            {
                if (!principal.Identity.IsAuthenticated)
                {
                    return(false);
                }

                using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
                {
                    var user = dc.UsersSets.Where(u => u.UPN.Equals(principal.Identity.Name, StringComparison.InvariantCultureIgnoreCase)).First();
                    if (user == null)
                    {
                        return(false);
                    }
                    else
                    {
                        return(user.IsCoreMember);
                    }
                }
            }
            catch (Exception ex)
            {
                //log error
                return(false);
            }
        }
示例#7
0
        public string PopulateConfigurationDetails(int[] CategoryIds)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                {
                    configset.Id,
                    configset.Name,
                    configset.TestCategory_Id,
                    configset.AnonymousAccess
                };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                var           Configurations = configDetails.Where(a => CategoryIds.Contains(a.TestCategory_Id)).ToList();
                StringBuilder sb             = new StringBuilder();

                foreach (var configuration in Configurations)
                {
                    sb.Append("<option value='" + configuration.Id + "'>" + configuration.Name + "</option>");
                }

                return(sb.ToString());
            }
        }
示例#8
0
        // GET: Testsummary
        public ActionResult AllTests(int Id, int OutCome, string branch, int page = 1, bool isPrevSelected = false, bool isNextSelected = false)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                TestSummarySet     model              = new TestSummarySet();
                int                PageSize           = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"].ToString());
                List <TestSummary> TestResultsSummary = null;
                int                TotalPages         = 0;
                string             searchTxt          = string.Empty;

                model.passedtests        = getTestresults(Id, 0, branch, searchTxt, page, PageSize, out TestResultsSummary, out TotalPages);
                ViewBag.PassedTotalPages = (int)Math.Ceiling((double)TotalPages / PageSize);

                model.skippedtests        = getTestresults(Id, 1, branch, searchTxt, page, PageSize, out TestResultsSummary, out TotalPages);
                ViewBag.SkippedTotalPages = (int)Math.Ceiling((double)TotalPages / PageSize);

                model.failedtests        = getTestresults(Id, 2, branch, searchTxt, page, PageSize, out TestResultsSummary, out TotalPages);
                ViewBag.FailedTotalPages = (int)Math.Ceiling((double)TotalPages / PageSize);

                model.notfoundtests        = getTestresults(Id, 3, branch, searchTxt, page, PageSize, out TestResultsSummary, out TotalPages);
                ViewBag.NotfoundTotalPages = (int)Math.Ceiling((double)TotalPages / PageSize);

                SetViewBagProperties(page, PageSize, Id, OutCome, branch, isPrevSelected, isNextSelected, searchTxt);

                model.testConfigDetails = getTesummaryConfigDetails(Id);
                return(View(model));
            }
        }
示例#9
0
        public TestSummaryConfigDetails getTesummaryConfigDetails(int TestRunId)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                TestSummaryConfigDetails TestConfigDetails = new TestSummaryConfigDetails();


                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                {
                    configset.Id,
                    configset.Name,
                    configset.AnonymousAccess
                };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }


                TestConfigDetails = (from testreultset in dc.TestResultSets
                                     join testrunset in dc.TestRunSets on testreultset.TestRunId equals testrunset.Id
                                     join configset in configDetails on testrunset.TestConfigurationId equals configset.Id
                                     where testreultset.TestRunId == TestRunId
                                     select new TestSummaryConfigDetails
                {
                    ConfiguratioName = configset.Name,
                    Testdate = testrunset.TestDate
                }).FirstOrDefault();
                return(TestConfigDetails);
            }
        }
示例#10
0
        // GET: Testcase
        public ActionResult Details(int Id, string branch)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                Testcase TestResults = null;

                IEnumerable <Testcase> testResultSets = from testreultset in dc.TestResultSets
                                                        join testrunset in dc.TestRunSets on testreultset.TestRunId equals testrunset.Id
                                                        join configset in dc.TestConfigurationSets on testrunset.TestConfigurationId equals configset.Id
                                                        where testreultset.Id == Id
                                                        select new Testcase
                {
                    AnonymousAccess = configset.AnonymousAccess,
                    Outcome         = testreultset.Outcome,
                    Error           = testreultset.ErrorMessage,
                    StackTrace      = testreultset.ErrorStackTrace,
                    TestDuration    = testreultset.Duration,
                    TestCasename    = testreultset.TestCaseName,
                    Id       = testreultset.Id,
                    Testdate = testreultset.StartTime
                };


                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    TestResults = testResultSets.Where(c => c.AnonymousAccess == true).SingleOrDefault();
                }
                else
                {
                    TestResults = testResultSets.SingleOrDefault();
                }

                if (TestResults != null)
                {
                    List <Testcase> testcaseConsoleOutput = (from resultmessage in dc.TestResultMessageSets
                                                             where resultmessage.TestResultId == Id
                                                             select new Testcase
                    {
                        ConsoleOutPut = resultmessage.Text
                    }).ToList();
                    string consoleoutput = string.Empty;
                    if (testcaseConsoleOutput != null && testcaseConsoleOutput.Any())
                    {
                        foreach (Testcase consoleOutPutText in testcaseConsoleOutput)
                        {
                            consoleoutput += consoleOutPutText.ConsoleOutPut + "\n";
                        }
                    }

                    TestResults.ConsoleOutPut = consoleoutput;

                    TestResults.Branch = String.Format(Constants.Constants.gitBranch, branch);
                }
                return(View(TestResults));
            }
        }
示例#11
0
        // GET: Testcase
        public ActionResult Details(int Id,string branch)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                Testcase TestResults = null;

                IEnumerable<Testcase> testResultSets = from testreultset in dc.TestResultSets
                               join testrunset in dc.TestRunSets on testreultset.TestRunId equals testrunset.Id
                               join configset in dc.TestConfigurationSets on testrunset.TestConfigurationId equals configset.Id
                               where testreultset.Id == Id
                               select new Testcase
                               {
                                   AnonymousAccess = configset.AnonymousAccess,
                                   Outcome = testreultset.Outcome,
                                   Error = testreultset.ErrorMessage,
                                   StackTrace = testreultset.ErrorStackTrace,
                                   TestDuration = testreultset.Duration,
                                   TestCasename = testreultset.TestCaseName,
                                   Id = testreultset.Id,
                                   Testdate = testreultset.StartTime
                               };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    TestResults = testResultSets.Where(c => c.AnonymousAccess == true).SingleOrDefault();
                }
                else
                {
                    TestResults = testResultSets.SingleOrDefault();
                }

                if (TestResults != null)
                {
                    List<Testcase> testcaseConsoleOutput = (from resultmessage in dc.TestResultMessageSets
                                                            where resultmessage.TestResultId == Id
                                                            select new Testcase
                                                            {
                                                                ConsoleOutPut = resultmessage.Text
                                                            }).ToList();
                    string consoleoutput = string.Empty;
                    if (testcaseConsoleOutput != null && testcaseConsoleOutput.Any())
                    {
                        foreach (Testcase consoleOutPutText in testcaseConsoleOutput)
                        {
                            consoleoutput += consoleOutPutText.ConsoleOutPut + "\n";
                        }
                    }

                    TestResults.ConsoleOutPut = consoleoutput;

                    TestResults.Branch = String.Format(Constants.Constants.gitBranch, branch);
                }
                return View(TestResults);
            }
        }
示例#12
0
        // GET: Usersettings
        public ActionResult Index()
        {
            UserSettings userSettings = null;

            if (Request.IsAuthenticated)
            {
                var           username     = User.Identity.Name;
                StringBuilder sbUserStatus = new StringBuilder();
                using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
                {
                    userSettings = (from userset in dbContext.UsersSets
                                    where userset.UPN.ToLower() == username.ToLower()
                                    select new UserSettings
                    {
                        UserPrinciplename = userset.UPN,
                        isAdmin = userset.IsAdmin,
                        isCommunityMember = true,
                        isCoreMember = userset.IsCoreMember,
                        TestSummaryEmail = userset.Email,
                        SendTestResults = userset.SendTestResults,
                        isEmailverified = userset.IsEmailVerified
                    }).SingleOrDefault();
                    if (userSettings != null)
                    {
                        if (userSettings.isCommunityMember)
                        {
                            sbUserStatus.Append("Community Member");
                        }
                        if (userSettings.isCoreMember)
                        {
                            sbUserStatus.Append(" | Core Member");
                        }
                        if (userSettings.isAdmin)
                        {
                            sbUserStatus.Append(" | Administrator");
                        }

                        userSettings.Memberstatus = sbUserStatus.ToString();
                    }
                }
            }
            else
            {
                HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties {
                    RedirectUri = "/Usersettings/Index"
                },
                                                                      OpenIdConnectAuthenticationDefaults.AuthenticationType);
            }

            return(View(userSettings));
        }
示例#13
0
        public ActionResult AllTestsPassed(int Id, int OutCome, string branch, string searchTestcaseString, int page = 1
                                           , bool isPrevSelected = false, bool isNextSelected = false)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                List <TestSummary> TestResultsSummary = null;
                int PageSize   = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"].ToString());
                int TotalPages = 0;

                getTestresults(Id, 0, branch, searchTestcaseString, page, PageSize, out TestResultsSummary, out TotalPages);
                SetViewBagProperties(page, PageSize, Id, OutCome, branch, isPrevSelected, isNextSelected, searchTestcaseString);
                ViewBag.PassedTotalPages     = (int)Math.Ceiling((double)TotalPages / PageSize);
                ViewBag.TestCaseSeacrhString = searchTestcaseString;
                return(PartialView("AllTestsPassed", TestResultsSummary));
            }
        }
示例#14
0
        public ActionResult AllTestsFailed(int Id, int OutCome, string branch, string searchTestcaseString, int page = 1
            , bool isPrevSelected = false, bool isNextSelected = false)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                List<TestSummary> TestResultsSummary = null;
                int PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"].ToString()); ;
                int TotalPages = 0;

                getTestresults(Id, 2, branch, searchTestcaseString, page, PageSize, out TestResultsSummary, out TotalPages);
                SetViewBagProperties(page, PageSize, Id, OutCome, branch, isPrevSelected, isNextSelected, searchTestcaseString);
                ViewBag.FailedTotalPages = (int)Math.Ceiling((double)TotalPages / PageSize);
                ViewBag.TestCaseSeacrhString = searchTestcaseString;

                return PartialView("AllTestsFailed", TestResultsSummary);
            }
        }
示例#15
0
        public ActionResult UpdateSettings(string email, bool isSendTestResults)
        {
            EmailConfirmation emailConfirmation = new EmailConfirmation();

            try
            {
                if (Request.IsAuthenticated)
                {
                    var           username     = User.Identity.Name;
                    StringBuilder sbUserStatus = new StringBuilder();
                    using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
                    {
                        var user = dbContext.UsersSets.SingleOrDefault(u => u.UPN.Equals(username, StringComparison.InvariantCultureIgnoreCase));

                        if (user != null)
                        {
                            if (!isSendTestResults)
                            {
                                user.SendTestResults = false;
                                user.Email           = email;
                                user.IsEmailVerified = false;
                                dbContext.SaveChanges();

                                emailConfirmation.IsSettingsUpdated = true;
                            }
                            else if (isSendTestResults && user.Email != email)
                            {
                                user.SendTestResults = true;
                                user.Email           = email;
                                dbContext.SaveChanges();

                                SendEmail(email);
                                emailConfirmation.IsEmailSent = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(View(emailConfirmation));
        }
        public ActionResult Edit(Configuration config)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var configuration = dc.TestConfigurationSets.SingleOrDefault(c => c.Id == config.ConfigurationId);
                configuration.Branch = config.GithubBranch;
                configuration.Description = config.Description;
                configuration.TenantUrl = config.Tenantadminsitecollection;
                configuration.TestSiteUrl = config.Testsitecollection;
                configuration.VSBuildConfiguration = config.VSBuildConfiguration;
                configuration.Type = (int)Enum.Parse(typeof(EnvironmentType), config.Platform);

                var testauthenticationset = dc.TestAuthenticationSets.SingleOrDefault(a => a.Id == configuration.TestAuthentication_Id);
                if (testauthenticationset != null)
                {
                    testauthenticationset.AppSecret = config.ClientSecret;
                    testauthenticationset.AppId = config.ClientID;
                    testauthenticationset.CredentialManagerLabel = config.CredentialManagerLabel;

                    testauthenticationset.User = config.UserName;
                    testauthenticationset.Domain = config.Domain;
                    testauthenticationset.Password = config.PassWord;
                }

                dc.SaveChanges();

                if (config.ConfigCustomProperties != null && config.ConfigCustomProperties.Count > 0)
                {
                    foreach (ConfigurationpropertySet configpropertySet in config.ConfigCustomProperties)
                    {
                        var configurationpropertySetData = dc.TestConfigurationPropertySets.SingleOrDefault(c => c.Id == configpropertySet.ID);
                        if (configurationpropertySetData != null)
                        {
                            configurationpropertySetData.Name = configpropertySet.Name;
                            configurationpropertySetData.Value = configpropertySet.Value;
                            dc.SaveChanges();
                        }
                    }
                }

            }

            return RedirectToAction("Edit", new { id = config.TestRunId, IsConfigurationUpdated = true });
        }
        // GET: Usersettings
        public ActionResult Index()
        {
            UserSettings userSettings = null;
            if (Request.IsAuthenticated)
            {
                var username = User.Identity.Name;
                StringBuilder sbUserStatus = new StringBuilder();
                using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
                {
                    userSettings = (from userset in dbContext.UsersSets
                                    where userset.UPN.ToLower() == username.ToLower()
                                    select new UserSettings
                                    {
                                        UserPrinciplename = userset.UPN,
                                        isAdmin = userset.IsAdmin,
                                        isCommunityMember = true,
                                        isCoreMember = userset.IsCoreMember,
                                        TestSummaryEmail = userset.Email,
                                        SendTestResults = userset.SendTestResults,
                                        isEmailverified = userset.IsEmailVerified
                                    }).SingleOrDefault();
                    if (userSettings != null)
                    {
                        if (userSettings.isCommunityMember)
                            sbUserStatus.Append("Community Member");
                        if (userSettings.isCoreMember)
                            sbUserStatus.Append(" | Core Member");
                        if (userSettings.isAdmin)
                            sbUserStatus.Append(" | Administrator");

                        userSettings.Memberstatus = sbUserStatus.ToString();
                    }
                }

            }
            else
            {
                HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/Usersettings/Index" },
                   OpenIdConnectAuthenticationDefaults.AuthenticationType);
            }

            return View(userSettings);
        }
示例#18
0
        public ActionResult Edit(Configuration config)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var configuration = dc.TestConfigurationSets.SingleOrDefault(c => c.Id == config.ConfigurationId);
                configuration.Branch               = config.GithubBranch;
                configuration.Description          = config.Description;
                configuration.TenantUrl            = config.Tenantadminsitecollection;
                configuration.TestSiteUrl          = config.Testsitecollection;
                configuration.VSBuildConfiguration = config.VSBuildConfiguration;
                configuration.Type = (int)Enum.Parse(typeof(EnvironmentType), config.Platform);

                var testauthenticationset = dc.TestAuthenticationSets.SingleOrDefault(a => a.Id == configuration.TestAuthentication_Id);
                if (testauthenticationset != null)
                {
                    testauthenticationset.AppSecret = config.ClientSecret;
                    testauthenticationset.AppId     = config.ClientID;
                    testauthenticationset.CredentialManagerLabel = config.CredentialManagerLabel;

                    testauthenticationset.User     = config.UserName;
                    testauthenticationset.Domain   = config.Domain;
                    testauthenticationset.Password = config.PassWord;
                }

                dc.SaveChanges();

                if (config.ConfigCustomProperties != null && config.ConfigCustomProperties.Count > 0)
                {
                    foreach (ConfigurationpropertySet configpropertySet in config.ConfigCustomProperties)
                    {
                        var configurationpropertySetData = dc.TestConfigurationPropertySets.SingleOrDefault(c => c.Id == configpropertySet.ID);
                        if (configurationpropertySetData != null)
                        {
                            configurationpropertySetData.Name  = configpropertySet.Name;
                            configurationpropertySetData.Value = configpropertySet.Value;
                            dc.SaveChanges();
                        }
                    }
                }
            }

            return(RedirectToAction("Edit", new { id = config.TestRunId, IsConfigurationUpdated = true }));
        }
示例#19
0
        public ActionResult ConfirmEmail(string validateToken)
        {
            EmailConfirmation emailconf = new EmailConfirmation();

            try
            {
                if (Request.IsAuthenticated)
                {
                    var    username       = User.Identity.Name;
                    string decryptedEmail = EncryptionUtility.Decrypt(validateToken);
                    emailconf.Email = decryptedEmail;
                    using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
                    {
                        var user = dbContext.UsersSets.FirstOrDefault(
                            u => u.Email.Equals(decryptedEmail, StringComparison.InvariantCultureIgnoreCase) &&
                            u.UPN.Equals(username, StringComparison.InvariantCultureIgnoreCase));
                        if (user != null)
                        {
                            user.IsEmailVerified = true;
                            user.SendTestResults = true;
                            dbContext.SaveChanges();
                            emailconf.IsEmailVerified = true;
                        }
                    }
                }
                else
                {
                    HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties {
                        RedirectUri = "/Usersettings/ConfirmEmail/" + validateToken
                    },
                                                                          OpenIdConnectAuthenticationDefaults.AuthenticationType);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(View(emailconf));
        }
        public ActionResult ConfirmEmail(string validateToken)
        {
            EmailConfirmation emailconf = new EmailConfirmation();

            try
            {
                if (Request.IsAuthenticated)
                {
                    var username = User.Identity.Name;
                    string decryptedEmail = EncryptionUtility.Decrypt(validateToken);
                    emailconf.Email = decryptedEmail;
                    using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
                    {
                        var user = dbContext.UsersSets.FirstOrDefault(
                        u => u.Email.Equals(decryptedEmail, StringComparison.InvariantCultureIgnoreCase)
                        && u.UPN.Equals(username, StringComparison.InvariantCultureIgnoreCase));
                        if (user != null)
                        {
                            user.IsEmailVerified = true;
                            user.SendTestResults = true;
                            dbContext.SaveChanges();
                            emailconf.IsEmailVerified = true;
                        }
                    }
                }
                else
                {
                    HttpContext.GetOwinContext().Authentication.Challenge(new AuthenticationProperties { RedirectUri = "/Usersettings/ConfirmEmail/" + validateToken },
                  OpenIdConnectAuthenticationDefaults.AuthenticationType);
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return View(emailconf);
        }
        private Configuration GetConfigurationData(int TestRunID, bool IsAdmin)
        {
            Configuration configDetails = null;

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                IEnumerable<Configuration> configurationDetails = from configset in dc.TestConfigurationSets
                                                                  join categorySet in dc.TestCategorySets on configset.TestCategory_Id equals categorySet.Id
                                                                  join testrunsets in dc.TestRunSets on configset.Id equals testrunsets.TestConfigurationId
                                                                  join testauthenticationset in dc.TestAuthenticationSets on configset.TestAuthentication_Id equals testauthenticationset.Id
                                                                  where testrunsets.Id == TestRunID
                                                                  select new Configuration
                                                                  {
                                                                      ConfigurationId = configset.Id,
                                                                      ConfiguratioName = configset.Name,
                                                                      CategoryName = categorySet.Name,
                                                                      Description = configset.Description,
                                                                      AnonymousAccess = configset.AnonymousAccess,
                                                                      VSBuildConfiguration = configset.VSBuildConfiguration,
                                                                      GithubBranch = configset.Branch,
                                                                      Type = testauthenticationset.AppOnly,
                                                                      ClientID = testauthenticationset.AppId,
                                                                      ClientSecret = testauthenticationset.AppSecret,
                                                                      UserName = testauthenticationset.User,
                                                                      PassWord = testauthenticationset.Password,
                                                                      Domain = testauthenticationset.Domain,
                                                                      CredentialManagerLabel = testauthenticationset.CredentialManagerLabel,
                                                                      PlatformType = configset.Type,
                                                                      Testsitecollection = configset.TestSiteUrl,
                                                                      Tenantadminsitecollection = configset.TenantUrl,
                                                                      TestRunId = TestRunID
                                                                  };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configurationDetails.Where(c => c.AnonymousAccess == true).SingleOrDefault();
                }
                else
                {
                    configDetails = configurationDetails.SingleOrDefault();
                }

                if (configDetails != null)
                {
                    var configpropertyDetails = (from configsetproperty in dc.TestConfigurationPropertySets
                                                 where configsetproperty.TestConfigurationId == configDetails.ConfigurationId
                                                 select new ConfigurationpropertySet { ID = configsetproperty.Id, Name = configsetproperty.Name, Value = configsetproperty.Value }).ToList();
                    switch (configDetails.Type)
                    {
                        case true:
                            configDetails.IdentityUserNameDisplayText = "ClientID";
                            configDetails.IdentityPassWordDisplayText = "Client Secret";
                            configDetails.IdentityUserNameValue = configDetails.ClientID;
                            configDetails.IdentityPassWordValue = configDetails.ClientSecret;
                            break;
                        case false:
                            configDetails.IdentityUserNameDisplayText = "Credential Manager";
                            configDetails.IdentityPassWordDisplayText = "Password";
                            if (configDetails.CredentialManagerLabel != null)
                            {
                                configDetails.IdentityUserNameValue = configDetails.CredentialManagerLabel;
                                configDetails.IdentityPassWordValue = string.Empty;
                            }
                            else
                            {
                                configDetails.IdentityUserNameValue = configDetails.Domain + @"\" + configDetails.UserName;
                                configDetails.IdentityPassWordValue = configDetails.PassWord;
                            }
                            break;
                    }

                    configDetails.AppType = Enum.GetName(typeof(AppOnly), configDetails.Type);
                    configDetails.Platform = Enum.GetName(typeof(EnvironmentType), configDetails.PlatformType);
                    configDetails.ConfigCustomProperties = configpropertyDetails;

                    if (!IsAdmin) // Mask data for non-admins
                    {
                        configDetails.IdentityUserNameValue = "*******************";
                        configDetails.IdentityPassWordValue = "*******************";
                        if (configDetails.CredentialManagerLabel != null)
                        {
                            configDetails.IdentityPassWordValue = string.Empty;
                        }

                        var lstConfig = new List<ConfigurationpropertySet>();
                        foreach (ConfigurationpropertySet customproperty in configDetails.ConfigCustomProperties)
                        {
                            lstConfig.Add(new ConfigurationpropertySet { ID = customproperty.ID, Name = customproperty.Name, Value = "*******************" });
                        }
                        configDetails.ConfigCustomProperties = lstConfig;
                    }
                }
            }

            return configDetails;
        }
        public ActionResult UpdateSettings(string email, bool isSendTestResults)
        {
            EmailConfirmation emailConfirmation = new EmailConfirmation();

            try
            {
                if (Request.IsAuthenticated)
                {
                    var username = User.Identity.Name;
                    StringBuilder sbUserStatus = new StringBuilder();
                    using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
                    {
                        var user = dbContext.UsersSets.SingleOrDefault(u => u.UPN.Equals(username, StringComparison.InvariantCultureIgnoreCase));

                        if (user != null)
                        {
                            if (!isSendTestResults)
                            {
                                user.SendTestResults = false;
                                user.Email = email;
                                user.IsEmailVerified = false;
                                dbContext.SaveChanges();

                                emailConfirmation.IsSettingsUpdated = true;
                            }
                            else if (isSendTestResults && user.Email != email)
                            {
                                user.SendTestResults = true;
                                user.Email = email;
                                dbContext.SaveChanges();

                                SendEmail(email);
                                emailConfirmation.IsEmailSent = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return View(emailConfirmation);
        }
示例#23
0
        public ActionResult PrintLog(int Id)
        {
            GenerateLog TestResults = null;

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                if (Request.IsAuthenticated && AuthorizationManager.IsCoreTeamMember(User))
                {
                    TestResults = (from testrunsets in dc.TestRunSets
                                   where testrunsets.Id == Id
                                   select new GenerateLog
                                   {
                                       Log = testrunsets.MSBuildLog
                                   }).SingleOrDefault();
                }
                else
                {
                    TestResults = (from testrunsets in dc.TestRunSets
                                   join configset in dc.TestConfigurationSets on testrunsets.TestConfigurationId equals configset.Id
                                   where testrunsets.Id == Id && configset.AnonymousAccess == true
                                   select new GenerateLog
                                   {
                                       Log = testrunsets.MSBuildLog
                                   }).SingleOrDefault();
                }
            }

            return View(TestResults);
        }
示例#24
0
        public string PopulateConfigurationDetails(int[] CategoryIds)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                                    {
                                        configset.Id,
                                        configset.Name,
                                        configset.TestCategory_Id,
                                        configset.AnonymousAccess
                                    };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                var Configurations = configDetails.Where(a => CategoryIds.Contains(a.TestCategory_Id)).ToList();
                StringBuilder sb = new StringBuilder();

                foreach (var configuration in Configurations)
                {
                    sb.Append("<option value='" + configuration.Id + "'>" + configuration.Name + "</option>");
                }

                return sb.ToString();
            }
        }
示例#25
0
        public AllRunsSet GetTestRunDetails(DateTime? fromDate, DateTime? toDate, int[] configIDs, int[] CategoryIDs, int page, int PageSize)
        {
            AllRunsSet model = new AllRunsSet();
            model.FromDate = Convert.ToDateTime(fromDate);
            model.ToDate = Convert.ToDateTime(toDate);

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var categoryDetails = from Categoryset in dc.TestCategorySets
                                      select new
                                      {
                                          Categoryset.Id,
                                          Categoryset.Name
                                      };

                List<CategoryList> testCategory = new List<CategoryList>();
                foreach (var category in categoryDetails.ToList())
                {
                    testCategory.Add(new CategoryList { ID = category.Id, Name = category.Name });
                }

                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                                    {
                                        configset.Id,
                                        configset.Name,
                                        configset.Type,
                                        configset.AnonymousAccess,
                                        configset.TestCategory_Id,
                                        configset.TestAuthentication_Id,
                                        configset.Branch
                                    };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                if (CategoryIDs != null && CategoryIDs.Any())
                {
                    configDetails = configDetails.Where(c => CategoryIDs.Contains(c.TestCategory_Id));
                }

                List<ConfigurationList> testConfigurations = new List<ConfigurationList>();
                foreach (var config in configDetails.ToList())
                {
                    testConfigurations.Add(new ConfigurationList { ID = config.Id, Name = config.Name });
                }

                if (configIDs != null && configIDs.Any())
                {
                    configDetails = configDetails.Where(c => configIDs.Contains(c.Id));

                        //model.SelectedCategory = category;

                }

                var testResults = (from configset in configDetails
                                   join categorySet in dc.TestCategorySets on configset.TestCategory_Id equals categorySet.Id
                                   join authenticationset in dc.TestAuthenticationSets on configset.TestAuthentication_Id equals authenticationset.Id
                                   join testrunsets in dc.TestRunSets on configset.Id equals testrunsets.TestConfigurationId
                                   where DbFunctions.TruncateTime(testrunsets.TestDate) >= DbFunctions.TruncateTime(fromDate)
                                   && DbFunctions.TruncateTime(testrunsets.TestDate) <= DbFunctions.TruncateTime(toDate)
                                   select new
                                   {
                                       Status = testrunsets.Status,
                                       Testdate = testrunsets.TestDate,
                                       TestDuration = testrunsets.TestTime,
                                       Passed = testrunsets.TestsPassed,
                                       Skipped = testrunsets.TestsSkipped,
                                       Failed = testrunsets.TestsFailed,
                                       Log = (testrunsets.MSBuildLog != null ? true : false),
                                       TestRunSetId = testrunsets.Id,
                                       CId = testrunsets.TestConfigurationId,
                                       cName = configset.Name,
                                       CategoryName = categorySet.Name,
                                       appOnly = authenticationset.AppOnly,
                                       cType = configset.Type,
                                       GithubBranch = configset.Branch
                                   }).OrderByDescending(t => t.Testdate).Skip((page - 1) * PageSize).Take(PageSize).ToList();

                List<AllRuns> configTestRuns = (from testrunsets in testResults
                                                select new AllRuns
                                                {
                                                    Status = testrunsets.Status,
                                                    ConfiguratioName = testrunsets.cName,
                                                    GithubBranch = testrunsets.GithubBranch,
                                                    CategoryName = testrunsets.CategoryName,
                                                    AppOnly = Enum.GetName(typeof(AppOnly), testrunsets.appOnly),
                                                    Environment = Enum.GetName(typeof(EnvironmentType), testrunsets.cType),
                                                    Testdate = testrunsets.Testdate,
                                                    TestDuration = (testrunsets.TestDuration != null ? Convert.ToString(testrunsets.TestDuration).Remove(Convert.ToString(testrunsets.TestDuration).IndexOf('.')) : "N/A"),
                                                    Passed = (testrunsets.Passed != null ? testrunsets.Passed : 0),
                                                    Skipped = (testrunsets.Skipped != null ? testrunsets.Skipped : 0),
                                                    Failed = (testrunsets.Failed != null ? testrunsets.Failed : 0),
                                                    Log = testrunsets.Log,
                                                    TestRunSetId = testrunsets.TestRunSetId,
                                                    Tests = ((testrunsets.Passed != null ? testrunsets.Passed : 0)
                                                      + (testrunsets.Skipped != null ? testrunsets.Skipped : 0)
                                                      + (testrunsets.Failed != null ? testrunsets.Failed : 0))
                                                }).OrderByDescending(d => d.Testdate.Date).ThenByDescending(t => t.Testdate.TimeOfDay).ToList();

                model.pnptestresults = configTestRuns;
                model.TestConfigurations = testConfigurations;
                model.TestCategory = testCategory;

                model.TestResultsCount = (from testrunsets in dc.TestRunSets
                                          join config in configDetails on testrunsets.TestConfigurationId equals config.Id
                                          where DbFunctions.TruncateTime(testrunsets.TestDate) >= DbFunctions.TruncateTime(fromDate) && DbFunctions.TruncateTime(testrunsets.TestDate) <= DbFunctions.TruncateTime(toDate)
                                          select new { testrunsets.Id }).ToList().Count;

            }

            return model;
        }
示例#26
0
        private Configuration GetConfigurationData(int TestRunID, bool IsAdmin)
        {
            Configuration configDetails = null;

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                IEnumerable <Configuration> configurationDetails = from configset in dc.TestConfigurationSets
                                                                   join testrunsets in dc.TestRunSets on configset.Id equals testrunsets.TestConfigurationId
                                                                   join testauthenticationset in dc.TestAuthenticationSets on configset.TestAuthentication_Id equals testauthenticationset.Id
                                                                   where testrunsets.Id == TestRunID
                                                                   select new Configuration
                {
                    ConfigurationId      = configset.Id,
                    ConfiguratioName     = configset.Name,
                    Description          = configset.Description,
                    AnonymousAccess      = configset.AnonymousAccess,
                    VSBuildConfiguration = configset.VSBuildConfiguration,
                    GithubBranch         = configset.Branch,
                    Type                      = testauthenticationset.AppOnly,
                    ClientID                  = testauthenticationset.AppId,
                    ClientSecret              = testauthenticationset.AppSecret,
                    UserName                  = testauthenticationset.User,
                    PassWord                  = testauthenticationset.Password,
                    Domain                    = testauthenticationset.Domain,
                    CredentialManagerLabel    = testauthenticationset.CredentialManagerLabel,
                    PlatformType              = configset.Type,
                    Testsitecollection        = configset.TestSiteUrl,
                    Tenantadminsitecollection = configset.TenantUrl,
                    TestRunId                 = TestRunID
                };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configurationDetails.Where(c => c.AnonymousAccess == true).SingleOrDefault();
                }
                else
                {
                    configDetails = configurationDetails.SingleOrDefault();
                }

                if (configDetails != null)
                {
                    var configpropertyDetails = (from configsetproperty in dc.TestConfigurationPropertySets
                                                 where configsetproperty.TestConfigurationId == configDetails.ConfigurationId
                                                 select new ConfigurationpropertySet {
                        ID = configsetproperty.Id, Name = configsetproperty.Name, Value = configsetproperty.Value
                    }).ToList();
                    switch (configDetails.Type)
                    {
                    case true:
                        configDetails.IdentityUserNameDisplayText = "ClientID";
                        configDetails.IdentityPassWordDisplayText = "Client Secret";
                        configDetails.IdentityUserNameValue       = configDetails.ClientID;
                        configDetails.IdentityPassWordValue       = configDetails.ClientSecret;
                        break;

                    case false:
                        configDetails.IdentityUserNameDisplayText = "Credential Manager";
                        configDetails.IdentityPassWordDisplayText = "Password";
                        if (configDetails.CredentialManagerLabel != null)
                        {
                            configDetails.IdentityUserNameValue = configDetails.CredentialManagerLabel;
                            configDetails.IdentityPassWordValue = string.Empty;
                        }
                        else
                        {
                            configDetails.IdentityUserNameValue = configDetails.Domain + @"\" + configDetails.UserName;
                            configDetails.IdentityPassWordValue = configDetails.PassWord;
                        }
                        break;
                    }

                    configDetails.AppType  = Enum.GetName(typeof(AppOnly), configDetails.Type);
                    configDetails.Platform = Enum.GetName(typeof(EnvironmentType), configDetails.PlatformType);
                    configDetails.ConfigCustomProperties = configpropertyDetails;

                    if (!IsAdmin) // Mask data for non-admins
                    {
                        configDetails.IdentityUserNameValue = "*******************";
                        configDetails.IdentityPassWordValue = "*******************";
                        if (configDetails.CredentialManagerLabel != null)
                        {
                            configDetails.IdentityPassWordValue = string.Empty;
                        }

                        var lstConfig = new List <ConfigurationpropertySet>();
                        foreach (ConfigurationpropertySet customproperty in configDetails.ConfigCustomProperties)
                        {
                            lstConfig.Add(new ConfigurationpropertySet {
                                ID = customproperty.ID, Name = customproperty.Name, Value = "*******************"
                            });
                        }
                        configDetails.ConfigCustomProperties = lstConfig;
                    }
                }
            }

            return(configDetails);
        }
示例#27
0
        public TestSummaryConfigDetails getTesummaryConfigDetails(int TestRunId)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                TestSummaryConfigDetails TestConfigDetails = new TestSummaryConfigDetails();

                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                                    {
                                        configset.Id,
                                        configset.Name,
                                        configset.AnonymousAccess
                                    };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                TestConfigDetails = (from testreultset in dc.TestResultSets
                                     join testrunset in dc.TestRunSets on testreultset.TestRunId equals testrunset.Id
                                     join configset in configDetails on testrunset.TestConfigurationId equals configset.Id
                                     where testreultset.TestRunId == TestRunId
                                     select new TestSummaryConfigDetails
                                     {
                                         ConfiguratioName = configset.Name,
                                         Testdate = testrunset.TestDate
                                     }).FirstOrDefault();
                return TestConfigDetails;

            }
        }
        public ActionResult SaveSettings(string email)
        {
            try
            {
                if (Request.IsAuthenticated)
                {
                    var username = User.Identity.Name;
                    StringBuilder sbUserStatus = new StringBuilder();
                    using (PnPTestAutomationEntities dbContext = new PnPTestAutomationEntities())
                    {
                        var user = dbContext.UsersSets.SingleOrDefault(u => u.UPN.Equals(username, StringComparison.InvariantCultureIgnoreCase));

                        if (user != null)
                        {
                            user.SendTestResults = true;
                            user.Email = email;
                            dbContext.SaveChanges();

                            SendEmail(email);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return View();
        }
示例#29
0
        // GET: TestDetails
        public ActionResult Overview(int Id)
        {
            TestDetailsSet model = new TestDetailsSet();
            TestDetails detailedReport = null;
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                IEnumerable<TestDetails> testDetails = from configset in dc.TestConfigurationSets
                                      join testrunsets in dc.TestRunSets on configset.Id equals testrunsets.TestConfigurationId
                                      join testauthenticationset in dc.TestAuthenticationSets on configset.TestAuthentication_Id equals testauthenticationset.Id
                                      where testrunsets.Id == Id
                                      select new TestDetails
                                      {
                                          ConfiguratioName = configset.Name,
                                          Description = configset.Description,
                                          VSBuildConfiguration = configset.VSBuildConfiguration,
                                          AnonymousAccess = configset.AnonymousAccess,
                                          GithubBranch = configset.Branch,
                                          PlatformType = configset.Type,
                                          Build = testrunsets.Build,
                                          Testdate = testrunsets.TestDate,
                                          TestDuration = testrunsets.TestTime,
                                          Status = testrunsets.Status,
                                          Passed = (testrunsets.TestsPassed != null ? testrunsets.TestsPassed : 0),
                                          Skipped = (testrunsets.TestsSkipped != null ? testrunsets.TestsSkipped : 0),
                                          Failed = (testrunsets.TestsFailed != null ? testrunsets.TestsFailed : 0),
                                          Tests = ((testrunsets.TestsPassed != null ? testrunsets.TestsPassed : 0)
                                               + (testrunsets.TestsSkipped != null ? testrunsets.TestsSkipped : 0)
                                               + (testrunsets.TestsFailed != null ? testrunsets.TestsFailed : 0)),
                                          TestRunId = Id,
                                          ConfigurationId = testrunsets.TestConfigurationId
                                      };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    detailedReport = testDetails.Where(t => t.AnonymousAccess == true).SingleOrDefault();
                }
                else
                {
                    detailedReport = testDetails.SingleOrDefault();
                }

                if (detailedReport != null)
                {
                    var computerName = (from testrunset in dc.TestResultSets
                                        where testrunset.TestRunId == Id
                                        select testrunset.ComputerName).FirstOrDefault();

                    int noOfmonths = Convert.ToInt32(ConfigurationManager.AppSettings["Graphdatatoshow"]);
                    DateTime fromDate = DateTime.Today.AddMonths(-noOfmonths);
                    DateTime toDate = DateTime.Today;

                    List<GraphData> detailedReportListGraph = (from testrunsets in dc.TestRunSets
                                                                 where ((testrunsets.TestDate >= fromDate && testrunsets.TestDate <= toDate)
                                                                 && (testrunsets.TestConfigurationId == detailedReport.ConfigurationId))
                                                                 select new GraphData
                                                                 {
                                                                     Testdate = testrunsets.TestDate,
                                                                     Passed = (testrunsets.TestsPassed != null ? testrunsets.TestsPassed : 0),
                                                                     Failed = (testrunsets.TestsFailed != null ? testrunsets.TestsFailed : 0),
                                                                     TestRunID=testrunsets.Id
                                                                 }).ToList();

                    EnvironmentType s = (EnvironmentType)Enum.Parse(typeof(EnvironmentType), Convert.ToString(detailedReport.PlatformType));
                    detailedReport.Platform = Convert.ToString(s);
                    detailedReport.Computer = computerName;
                    model.detailedReport = detailedReport;
                    model.rootSiteURL = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"];
                    model.detailedConfigurationReport = detailedReportListGraph;
                }
            }

            return View(model);
        }
示例#30
0
        // GET: TestDetails
        public ActionResult Overview(int Id)
        {
            TestDetailsSet model          = new TestDetailsSet();
            TestDetails    detailedReport = null;

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                IEnumerable <TestDetails> testDetails = from configset in dc.TestConfigurationSets
                                                        join testrunsets in dc.TestRunSets on configset.Id equals testrunsets.TestConfigurationId
                                                        join testauthenticationset in dc.TestAuthenticationSets on configset.TestAuthentication_Id equals testauthenticationset.Id
                                                        where testrunsets.Id == Id
                                                        select new TestDetails
                {
                    ConfiguratioName     = configset.Name,
                    Description          = configset.Description,
                    VSBuildConfiguration = configset.VSBuildConfiguration,
                    AnonymousAccess      = configset.AnonymousAccess,
                    GithubBranch         = configset.Branch,
                    PlatformType         = configset.Type,
                    Build        = testrunsets.Build,
                    Testdate     = testrunsets.TestDate,
                    TestDuration = testrunsets.TestTime,
                    Status       = testrunsets.Status,
                    Passed       = (testrunsets.TestsPassed != null ? testrunsets.TestsPassed : 0),
                    Skipped      = (testrunsets.TestsSkipped != null ? testrunsets.TestsSkipped : 0),
                    Failed       = (testrunsets.TestsFailed != null ? testrunsets.TestsFailed : 0),
                    Tests        = ((testrunsets.TestsPassed != null ? testrunsets.TestsPassed : 0)
                                    + (testrunsets.TestsSkipped != null ? testrunsets.TestsSkipped : 0)
                                    + (testrunsets.TestsFailed != null ? testrunsets.TestsFailed : 0)),
                    TestRunId       = Id,
                    ConfigurationId = testrunsets.TestConfigurationId
                };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    detailedReport = testDetails.Where(t => t.AnonymousAccess == true).SingleOrDefault();
                }
                else
                {
                    detailedReport = testDetails.SingleOrDefault();
                }

                if (detailedReport != null)
                {
                    var computerName = (from testrunset in dc.TestResultSets
                                        where testrunset.TestRunId == Id
                                        select testrunset.ComputerName).FirstOrDefault();

                    int      noOfmonths = Convert.ToInt32(ConfigurationManager.AppSettings["Graphdatatoshow"]);
                    DateTime fromDate   = DateTime.Today.AddMonths(-noOfmonths);
                    DateTime toDate     = DateTime.Today;

                    List <GraphData> detailedReportListGraph = (from testrunsets in dc.TestRunSets
                                                                where ((testrunsets.TestDate >= fromDate && testrunsets.TestDate <= toDate) &&
                                                                       (testrunsets.TestConfigurationId == detailedReport.ConfigurationId))
                                                                select new GraphData
                    {
                        Testdate = testrunsets.TestDate,
                        Passed = (testrunsets.TestsPassed != null ? testrunsets.TestsPassed : 0),
                        Failed = (testrunsets.TestsFailed != null ? testrunsets.TestsFailed : 0),
                        TestRunID = testrunsets.Id
                    }).ToList();

                    EnvironmentType s = (EnvironmentType)Enum.Parse(typeof(EnvironmentType), Convert.ToString(detailedReport.PlatformType));
                    detailedReport.Platform           = Convert.ToString(s);
                    detailedReport.Computer           = computerName;
                    model.detailedReport              = detailedReport;
                    model.rootSiteURL                 = ConfigurationManager.AppSettings["ida:PostLogoutRedirectUri"];
                    model.detailedConfigurationReport = detailedReportListGraph;
                }
            }

            return(View(model));
        }
示例#31
0
        public AllRunsSet GetTestRunDetails(DateTime?fromDate, DateTime?toDate, int[] configIDs, int page, int PageSize)
        {
            AllRunsSet model = new AllRunsSet();

            model.FromDate = Convert.ToDateTime(fromDate);
            model.ToDate   = Convert.ToDateTime(toDate);

            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                {
                    configset.Id,
                    configset.Name,
                    configset.Type,
                    configset.AnonymousAccess,
                    configset.TestAuthentication_Id,
                    configset.Branch
                };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }
                List <ConfigurationList> testConfigurations = new List <ConfigurationList>();
                foreach (var config in configDetails.ToList())
                {
                    testConfigurations.Add(new ConfigurationList {
                        ID = config.Id, Name = config.Name
                    });
                }

                if (configIDs != null && configIDs.Any())
                {
                    configDetails = configDetails.Where(c => configIDs.Contains(c.Id));
                }


                var testResults = (from configset in configDetails
                                   join authenticationset in dc.TestAuthenticationSets on configset.TestAuthentication_Id equals authenticationset.Id
                                   join testrunsets in dc.TestRunSets on configset.Id equals testrunsets.TestConfigurationId
                                   where DbFunctions.TruncateTime(testrunsets.TestDate) >= DbFunctions.TruncateTime(fromDate) &&
                                   DbFunctions.TruncateTime(testrunsets.TestDate) <= DbFunctions.TruncateTime(toDate)
                                   select new
                {
                    Status = testrunsets.Status,
                    Testdate = testrunsets.TestDate,
                    TestDuration = testrunsets.TestTime,
                    Passed = testrunsets.TestsPassed,
                    Skipped = testrunsets.TestsSkipped,
                    Failed = testrunsets.TestsFailed,
                    Log = (testrunsets.MSBuildLog != null ? true : false),
                    TestRunSetId = testrunsets.Id,
                    CId = testrunsets.TestConfigurationId,
                    cName = configset.Name,
                    appOnly = authenticationset.AppOnly,
                    cType = configset.Type,
                    GithubBranch = configset.Branch
                }).OrderByDescending(t => t.Testdate).Skip((page - 1) * PageSize).Take(PageSize).ToList();

                List <AllRuns> configTestRuns = (from testrunsets in testResults
                                                 select new AllRuns
                {
                    Status = testrunsets.Status,
                    ConfiguratioName = testrunsets.cName,
                    GithubBranch = testrunsets.GithubBranch,
                    AppOnly = Enum.GetName(typeof(AppOnly), testrunsets.appOnly),
                    Environment = Enum.GetName(typeof(EnvironmentType), testrunsets.cType),
                    Testdate = testrunsets.Testdate,
                    TestDuration = (testrunsets.TestDuration != null ? Convert.ToString(testrunsets.TestDuration).Remove(Convert.ToString(testrunsets.TestDuration).IndexOf('.')) : "N/A"),
                    Passed = (testrunsets.Passed != null ? testrunsets.Passed : 0),
                    Skipped = (testrunsets.Skipped != null ? testrunsets.Skipped : 0),
                    Failed = (testrunsets.Failed != null ? testrunsets.Failed : 0),
                    Log = testrunsets.Log,
                    TestRunSetId = testrunsets.TestRunSetId,
                    Tests = ((testrunsets.Passed != null ? testrunsets.Passed : 0)
                             + (testrunsets.Skipped != null ? testrunsets.Skipped : 0)
                             + (testrunsets.Failed != null ? testrunsets.Failed : 0))
                }).OrderByDescending(d => d.Testdate.Date).ThenByDescending(t => t.Testdate.TimeOfDay).ToList();

                model.pnptestresults     = configTestRuns;
                model.TestConfigurations = testConfigurations;

                model.TestResultsCount = (from testrunsets in dc.TestRunSets
                                          join config in configDetails on testrunsets.TestConfigurationId equals config.Id
                                          where DbFunctions.TruncateTime(testrunsets.TestDate) >= DbFunctions.TruncateTime(fromDate) && DbFunctions.TruncateTime(testrunsets.TestDate) <= DbFunctions.TruncateTime(toDate)
                                          select new { testrunsets.Id }).ToList().Count;
            }

            return(model);
        }
示例#32
0
        public List<TestSummary> getTestresults(int Id, int outcome, string branch, string searchTestcaseString, int page, int PageSize, out List<TestSummary> TestResults, out int TotalPages)
        {
            using (PnPTestAutomationEntities dc = new PnPTestAutomationEntities())
            {
                TestResults = new List<TestSummary>();
                TotalPages = 0;

                var configDetails = from configset in dc.TestConfigurationSets
                                    select new
                                    {
                                        configset.Id,
                                        configset.AnonymousAccess
                                    };

                if (!Request.IsAuthenticated || !AuthorizationManager.IsCoreTeamMember(User))
                {
                    configDetails = configDetails.Where(c => c.AnonymousAccess == true);
                }

                List<TestSummary> data = (from testreultset in dc.TestResultSets
                                          join testrunset in dc.TestRunSets on testreultset.TestRunId equals testrunset.Id
                                          join configset in configDetails on testrunset.TestConfigurationId equals configset.Id
                                          where testreultset.TestRunId == Id && testreultset.Outcome == outcome
                                          && ((!string.IsNullOrEmpty(searchTestcaseString) ? testreultset.TestCaseName.Contains(searchTestcaseString) : true))
                                          select new TestSummary
                                          {
                                              Outcome = testreultset.Outcome,
                                              Error = testreultset.ErrorMessage,
                                              StackTrace = testreultset.ErrorStackTrace,
                                              TestDuration = testreultset.Duration,
                                              TestCasename = testreultset.TestCaseName,
                                              Id = testreultset.Id,
                                              Branch = branch
                                          }).OrderByDescending(d => d.Id).Skip((page - 1) * PageSize).Take(PageSize).ToList();

                if (data != null && data.Any())
                {
                    var totaltests = (from testreultset in dc.TestResultSets
                                      where testreultset.TestRunId == Id && testreultset.Outcome == outcome && (!string.IsNullOrEmpty(searchTestcaseString) ? testreultset.TestCaseName.Contains(searchTestcaseString) : true)
                                      select new { testreultset }).ToList();
                    if (totaltests != null && totaltests.Any())
                        TotalPages = totaltests.Count;

                    TestResults = (from testreult in data
                                   select new TestSummary
                                   {
                                       Outcome = testreult.Outcome,
                                       Error = testreult.Error,
                                       StackTrace = testreult.StackTrace,
                                       TestDuration = testreult.TestDuration,
                                       TestCasename = testreult.TestCasename,
                                       Id = testreult.Id,
                                       Branch = branch
                                   }).OrderByDescending(t => t.Id).ToList();
                }
                return TestResults;

            }
        }