public void SyncAllBuilds()
        {
            string mainlineFolder = string.Format(@"{0}\SUP_Main", localMapFolder);
            foreach (string d in Directory.GetDirectories(mainlineFolder, buildPattern))
            {
                if (!d.Contains("BAD"))
                {
                    DirectoryInfo info = new System.IO.DirectoryInfo(d);
                    DirectoryInfo remoteInfo = new System.IO.DirectoryInfo(d.Replace(localMapFolder, path));

                    string branchName = System.Text.RegularExpressions.Regex.Split(info.Name, @"_[0-9]\.[0-9][0-9]\.[0-9]+")[0];
                    string releaseAndNumber = System.Text.RegularExpressions.Regex.Match(info.Name, @"[0-9]\.[0-9][0-9]\.[0-9]+").Value;
                    string number = releaseAndNumber.Substring(releaseAndNumber.LastIndexOf('.') + 1);
                    string releaseName = releaseAndNumber.Substring(0, releaseAndNumber.LastIndexOf('.'));
                    Branch tempBranch = new Branch
                    {
                        Name = branchName,
                        Path = string.Empty,
                        Description = branchName,
                        Type = (int)SyncSourceType.FromBuildServer,
                        ProductId = Product.GetProductByName(productName).ProductId,
                    };
                    Branch branch = Branch.AddOrUpdateBranch(tempBranch);
                    Release tempRelease = new Release
                    {
                        Name = releaseName,
                        Description = releaseName,
                        Type = (int)SyncSourceType.FromBuildServer,
                        Path = string.Empty,
                        ProductId = Product.GetProductByName(productName).ProductId,
                    };
                    Release release = Release.AddOrUpdateRelease(tempRelease);

                    if (IsBuildFinished(info))
                    {
                        Build b = new Build
                        {
                            Name = info.Name,
                            Description = info.Name,
                            Location = remoteInfo.FullName,
                            BranchId = branch.BranchId,
                            ReleaseId = release.ReleaseId,
                            Number = number,
                            BuildType = BuildType.BuildMachine,
                            ProductId = Product.GetProductByName(productName).ProductId,
                            BuildStatus = BuildStatus.Success,
                            ProviderId = Provider.ProviderId,
                        };
                        if (null == Build.GetBuildByLocation(b.Location))
                        {
                            Build.Add(b);
                        }
                    }
                }
            }
        }
Exemple #2
0
 public static Release AddOrUpdateRelease(Release release)
 {
     using (ES1AutomationEntities context = new ES1AutomationEntities())
     {
         Release existingRelease = context.Releases.Where(r => r.Name.ToLower() == release.Name.ToLower()&& r.Type== release.Type && r.ProductId == release.ProductId).FirstOrDefault();
         if (existingRelease != null)
         {
             existingRelease.Path = release.Path;
             existingRelease.Description = release.Description;
             context.Entry(existingRelease).State = System.Data.Entity.EntityState.Modified;
             context.SaveChanges();
             return existingRelease;
         }
         else
         {
             Release r = context.Releases.Add(release);
             context.SaveChanges();
             return r;
         }
     }
 }
Exemple #3
0
        private void getBuildsInFolder(IList<Build> builds, string rootFolder, string branchFolder, System.Text.RegularExpressions.Regex buildFolderPattern)
        {
            foreach (string d in System.IO.Directory.GetDirectories(rootFolder))
            {
                System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(d);

                string buildName = info.Name;

                if (buildFolderPattern.IsMatch(buildName))
                {

                    string releaseName = buildName.Substring(0, buildName.LastIndexOf('.'));

                    string number = info.Name.Substring(buildName.LastIndexOf('.') + 1);

                    System.IO.DirectoryInfo remoteInfo = new System.IO.DirectoryInfo(d.Replace(localMapFolder, Path));

                    Branch tempBranch = new Branch
                    {
                        Name = branchFolder,
                        Path = string.Empty,
                        Description = branchFolder,
                        Type = (int)SyncSourceType.FromBuildServer,
                        ProductId = Product.GetProductByName(ProductName).ProductId,
                    };

                    Branch branch = Branch.AddOrUpdateBranch(tempBranch);

                    Release tempRelease = new Release
                    {
                        Name = releaseName,
                        Description = releaseName,
                        Type = (int)SyncSourceType.FromBuildServer,
                        Path = string.Empty,
                        ProductId = Product.GetProductByName(ProductName).ProductId,
                    };

                    Release release = Release.AddOrUpdateRelease(tempRelease);

                    if (IsBuildFinished(info))
                    {
                        Build b = new Build
                        {
                            Name = info.Name,
                            Description = info.Name,
                            Location = remoteInfo.FullName,
                            BranchId = branch.BranchId,
                            ReleaseId = release.ReleaseId,
                            Number = number,
                            BuildType = BuildType.BuildMachine,
                            ProductId = Product.GetProductByName("Common Index Search").ProductId,
                            BuildStatus = BuildStatus.Success,
                        };

                        builds.Add(b);
                    }
                }
                else
                {
                    string tempBranchFolder = string.IsNullOrEmpty(branchFolder) ? info.Name : branchFolder + @"\" + info.Name;

                    getBuildsInFolder(builds, d, tempBranchFolder, buildFolderPattern);
                }
            }
        }
Exemple #4
0
        public IList<Build> GetAllBuildsOnBuildFileServer()
        {
            List<Build> builds = new List<Build>();
            //update SourceOne builds
            const string BuildFolderIndexName = "PATH";
            const string BuildPatternIndexName="PATTERN";
            const string BuildBranchIndexName = "BRANCH";

            List<Dictionary<string, string>> buildFoldersList = new List<Dictionary<string, string>>();

            string es1Main = System.IO.Path.Combine(localMapFolder + @"\", mainlineBuildFolder);
            Dictionary<string, string> temp = new Dictionary<string, string>();
            temp[BuildFolderIndexName] = es1Main;
            temp[BuildPatternIndexName] = mainlineBuildNamingPattern;
            temp[BuildBranchIndexName] = "Mainline";
            buildFoldersList.Add(temp);

            string featureBranch = System.IO.Path.Combine(localMapFolder + @"\", featureBranchBuildFolder);
            temp = new Dictionary<string, string>();
            temp[BuildFolderIndexName] = featureBranch;
            temp[BuildPatternIndexName] = featureBranchBuildNamingPatern;
            temp[BuildBranchIndexName] = string.Empty;
            buildFoldersList.Add(temp);

            string[] maintBranches = System.IO.Directory.GetDirectories(localMapFolder + @"\", maintBranchBuildFolderPattern);
            foreach (string maintBranch in maintBranches)
            {
                temp = new Dictionary<string, string>();
                temp[BuildFolderIndexName] = maintBranch;
                temp[BuildPatternIndexName] = maintBranchBuildNamingPattern;
                temp[BuildBranchIndexName] = new System.IO.DirectoryInfo(maintBranch).Name;//The branch name is the folder name
                buildFoldersList.Add(temp);
            }

            foreach (Dictionary<string, string> buildFolder in buildFoldersList)
            {
                foreach (string d in System.IO.Directory.GetDirectories(buildFolder[BuildFolderIndexName], buildFolder[BuildPatternIndexName]))
                {
                    if (!d.Contains("BAD"))
                    {
                        System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(d);

                        System.IO.DirectoryInfo remoteInfo = new System.IO.DirectoryInfo(d.Replace(localMapFolder, Path));

                        string branchName = string.IsNullOrEmpty(buildFolder[BuildBranchIndexName]) ? System.Text.RegularExpressions.Regex.Split(info.Name, @"_[0-9]\.[0-9]\.[0-9]\.[0-9]+")[0] : buildFolder[BuildBranchIndexName];
                        string releaseAndNumber = System.Text.RegularExpressions.Regex.Match(info.Name, @"[0-9]\.[0-9]\.[0-9]\.[0-9]+").Value;
                        string number = releaseAndNumber.Substring(releaseAndNumber.LastIndexOf('.') + 1);
                        string releaseName = releaseAndNumber.Substring(0, releaseAndNumber.LastIndexOf('.'));
                        Branch tempBranch = new Branch
                        {
                            Name = branchName,
                            Path = string.Empty,
                            Description = branchName,
                            Type = (int)SyncSourceType.FromBuildServer,
                            ProductId = Product.GetProductByName(ProductName).ProductId,
                        };
                        Branch branch = Branch.AddOrUpdateBranch(tempBranch);
                        Release tempRelease = new Release
                        {
                            Name = releaseName,
                            Description = releaseName,
                            Type = (int)SyncSourceType.FromBuildServer,
                            Path = string.Empty,
                            ProductId = Product.GetProductByName(ProductName).ProductId,
                        };
                        Release release = Release.AddOrUpdateRelease(tempRelease);

                        if (IsBuildFinished(info))
                        {
                            Build b = new Build
                            {
                                Name = info.Name,
                                Description = info.Name,
                                Location = remoteInfo.FullName,
                                BranchId = branch.BranchId,
                                ReleaseId = release.ReleaseId,
                                Number = number,
                                BuildType = BuildType.BuildMachine,
                                ProductId = Product.GetProductByName(ProductName).ProductId,
                                BuildStatus = BuildStatus.Success,
                                ProviderId = this.Provider.ProviderId,
                            };
                            builds.Add(b);
                        }
                    }
                }
            }
            return builds;
        }
Exemple #5
0
        public void SyncAllTestCase()
        {
            try
            {

                ATFEnvironment.Log.logger.Info("RQM Login");

                RQMServer.UserAuthentication(Username, Password);

                ATFEnvironment.Log.logger.Info("RQM Sync Test Cases Start");

                // disable all test cases of this provider
                TestCase.DisableTestCases(this.Provider.ProviderId);

                Product product = GetProductOfTestCaseProvider();//Product.GetProductByName(RQMProjectProductMapping["SourceOne+%28Quality+Management%29"]);

                if (product != null)
                {
                    //update the test suite hierarchy
                    var root = TestSuite.GetRootNodeOfAllTestCases();
                    CreateOrUpdateProjectLevelSuite(root);

                    //the leaf node of test suite
                    //var testSuites = TestSuite.GetTestSuitesByProviderId(Provider.ProviderId).Where(ts => ts.SubSuites == null && ts.IsActive == true && ts.Type == (int)SuiteType.Static).ToList();
                    var testSuites = TestSuite.GetAllSubSuites(root, true).Where(
                        ts => ts.SubSuites == null &&
                            ts.IsActive == true &&
                            ts.Type == (int)SuiteType.Static &&
                            ts.ProviderId == this.Provider.ProviderId
                            ).ToList();
                    //remove all the test case children of the leaf node of test suite
                    foreach (var testSuite in testSuites)
                    {
                        testSuite.CreateBy = 0;
                        testSuite.ModityBy = 0;
                        testSuite.TestCases = string.Empty;
                    }

                    foreach (var rqmTestCase in RQMServer.GetTestCasesByProject(ProjectAlias))
                    {
                        string ranking = rqmTestCase.Categories.ContainsKey("Ranking") ? rqmTestCase.Categories["Ranking"] : null;
                        string release = rqmTestCase.Categories.ContainsKey("Release") ? rqmTestCase.Categories["Release"] : null;
                        string features = rqmTestCase.Categories.ContainsKey("Features") ? rqmTestCase.Categories["Features"] : string.Empty;
                        string module = rqmTestCase.Categories.ContainsKey("Module") ? rqmTestCase.Categories["Module"] : null;
                        string platform = rqmTestCase.Categories.ContainsKey("Platform") ? rqmTestCase.Categories["Platform"] : null;
                        string runtime = rqmTestCase.Categories.ContainsKey("RunTime") ? rqmTestCase.Categories["RunTime"] : null;
                        if (string.IsNullOrEmpty(runtime))
                        {
                            //This is to fix the issue that the category of "RunTime" in SourceOne project is called "RunTIme" but in Supervisor Project, it's called "Runtime"
                            runtime = rqmTestCase.Categories.ContainsKey("Runtime") ? rqmTestCase.Categories["Runtime"] : null;
                        }
                        bool isAutomated = rqmTestCase.Categories.ContainsKey("IsAutomated") ? bool.Parse(rqmTestCase.Categories["IsAutomated"]) : false;

                        if (ranking != null)
                        {
                            Ranking rankingtemp = new Ranking
                            {
                                Name = ranking,
                                Description = ranking,

                            };
                            Ranking.AddOrUpdateRanking(rankingtemp);
                        }

                        if (release != null)
                        {
                            Release tempRelease = new Release
                            {
                                Name = release,
                                Description = release,
                                Path = string.Empty,
                                Type = (int)SyncSourceType.FromRQM,
                                ProductId = product.ProductId,
                            };

                            Release.AddOrUpdateRelease(tempRelease);
                        }

                        if (isAutomated)
                        {
                            var testCase = TestCase.CreateOrUpdateTestCase
                                (
                                    new TestCase
                                    {
                                        ProviderId = this.Provider.ProviderId,
                                        SourceId = rqmTestCase.WebId,
                                        Name = string.Format("[{0, 6}]:{1}", rqmTestCase.WebId, rqmTestCase.Title),
                                        Feature = features,
                                        Description = string.Format("WebId={0}, Release={1}, Ranking={2}, Module={3}, Feature={4}, RunTime={5}, Platform={6}, IsAutomated={7}", rqmTestCase.WebId, release, ranking, module, features, runtime, platform, isAutomated),
                                        ProductId = product.ProductId,
                                        Weight = rqmTestCase.Weight,
                                        Ranking = ranking,
                                        Release = release,
                                        IsAutomated = isAutomated,
                                        IsActive = true,
                                    }
                                );

                            // update test suite
                            // here we have a assumption that the feature names under different modules of projects should be unique.
                            foreach (var testSuite in testSuites)
                            {
                                if (rqmTestCase.Categories.Keys.Contains("Features") && rqmTestCase.Categories["Features"] == testSuite.Name)
                                {
                                    if (string.IsNullOrWhiteSpace(testSuite.TestCases))
                                    {
                                        testSuite.TestCases = testCase.TestCaseId.ToString();
                                    }
                                    else
                                    {
                                        testSuite.TestCases = testSuite.TestCases + "," + testCase.TestCaseId.ToString();
                                    }
                                }
                            }
                        }
                    }

                    TestSuite.CreateUpdateAllTestSuites(testSuites);
                }

                RQMServer.Logout();

                ATFEnvironment.Log.logger.Info("Logout RQM server");

                ATFEnvironment.Log.logger.Info("RQM Sync Test Cases Finish");
            }
            catch (Exception ex)
            {
                ATFEnvironment.Log.logger.Error("Met error while sync the test cases from RQM server.", ex);
            }
        }
Exemple #6
0
        /// <summary>
        /// Invoked when <see cref="ToEntity"/> operation is about to return.
        /// </summary>
        /// <param name="entity"><see cref="Release"/> converted from <see cref="ReleaseDTO"/>.</param>
partial         static void OnEntity(this ReleaseDTO dto, Release entity);
Exemple #7
0
        /// <summary>
        /// Converts this instance of <see cref="ReleaseDTO"/> to an instance of <see cref="Release"/>.
        /// </summary>
        /// <param name="dto"><see cref="ReleaseDTO"/> to convert.</param>
        public static Release ToEntity(this ReleaseDTO dto)
        {
            if (dto == null) return null;

            var entity = new Release();

            entity.ReleaseId = dto.ReleaseId;
            entity.Name = dto.Name;
            entity.Path = dto.Path;
            entity.Description = dto.Description;
            entity.ProductId = dto.ProductId;

            dto.OnEntity(entity);

            return entity;
        }