示例#1
0
 public static void UpdateVc(EA.Repository rep, EA.Package pkg)
 {
     if (pkg.IsVersionControlled)
     {
         // find                  VC=...;
         // replace by:           VC=currentState();
         string flags    = pkg.Flags;
         Regex  pattern  = new Regex(@"VC=[^;]+;");
         Match  regMatch = pattern.Match(flags);
         while (regMatch.Success)
         {
             // delete old string
             flags    = flags.Replace(regMatch.Value, "");
             regMatch = regMatch.NextMatch();
             // add new string
         }
         flags = flags + "VC=" + GetVCstate(pkg, false) + ";";
         try
         {
             SetVcFlags(rep, pkg, flags);
         }
         catch (Exception e)
         {
             string s = e.Message + " ;" + pkg.GetLastError();
             s = s + "!";
         }
     }
     // recursive package
     foreach (EA.Package pkg1 in pkg.Packages)
     {
         UpdateVc(rep, pkg1);
     }
 }
示例#2
0
        //------------------------------------------------------------------------------------------
        // resetVC   If package is controls:
        //------------------------------------------------------------------------------------------
        // - Reset packageflags field of package
        // - Check path to *.xml file
        //------------------------------------------------------------------------------------------
        // packageflags:  Recurse=0;VCCFG=unchanged;
        public static void ResetVc(EA.Repository rep, EA.Package pkg)
        {
            if (pkg.IsVersionControlled)
            {
                // check path to *.xml file
                string   filePath = GetFilePath(rep, pkg);
                FileInfo theFile  = new FileInfo(filePath);
                if (!theFile.Exists)
                {
                    MessageBox.Show("XMLPath:" + pkg.XMLPath +
                                    "\nPath to sandbox:\n" + filePath +
                                    "\nPackageFlags:\n" + pkg.Flags +
                                    "\n\n Try update sandbox/local directory or\n" +
                                    "\n 1. Checkout correct *.xml file" +
                                    "\n 2. Update the wrong paths of xml file" +
                                    "\n 3. Checkin" +
                                    "\n 4. Deactivate Version Control for package in EA" +
                                    "\n 5. Import Package",
                                    "*.xml file for Package" + pkg.Name + " not found!");
                }


                // find                  VC=...;
                string flags    = pkg.Flags;
                Regex  pattern  = new Regex(@"VCCFG=[^;]+;");
                Match  regMatch = pattern.Match(flags);
                if (regMatch.Success)
                {
                    // delete old string
                    flags = @"Recurse=0;" + regMatch.Value;
                }
                else
                {
                    return;
                }
                // write flags
                try
                {
                    SetVcFlags(rep, pkg, flags);
                }
                catch (Exception e)
                {
                    string s = e.Message + " ;" + pkg.GetLastError();
                    s = s + "!";
                }
            }
            // recursive package
            //foreach (EA.Package pkg1 in pkg.Packages)
            //{
            //    updateVC(rep, pkg1);
            //}
        }
示例#3
0
        public static Boolean GetLatest(EA.Repository rep, EA.Package pkg, Boolean recursive, ref int count, int level, ref int errorCount)
        {
            if (pkg.IsControlled)
            {
                level = level + 1;
                // check if checked out

                string path  = GetFilePath(rep, pkg);
                string fText = "";
                //rep.WriteOutput("Debug", "Path:" + pkg.Name + path, 0);
                string sLevel = new string(' ', level * 2);
                rep.WriteOutput("Debug", sLevel + (count + 1).ToString(",0") + " Work for:" + path, 0);
                if (path != "")
                {
                    count = count + 1;
                    rep.ShowInProjectView(pkg);
                    // delete a potential write protection
                    try
                    {
                        FileInfo       fileInfo   = new FileInfo(path);
                        FileAttributes attributes = (FileAttributes)(fileInfo.Attributes - FileAttributes.ReadOnly);
                        System.IO.File.SetAttributes(fileInfo.FullName, attributes);
                        System.IO.File.Delete(path);
                    }
                    catch (FileNotFoundException e)
                    {
                        fText = path + " " + e.Message;
                        rep.WriteOutput("Debug", fText, 0);
                        errorCount = errorCount + 1;
                    }
                    catch (DirectoryNotFoundException e)
                    {
                        fText = path + " " + e.Message;
                        rep.WriteOutput("Debug", fText, 0);
                        errorCount = errorCount + 1;
                    }
                    // get latest
                    try
                    {
                        // to make sure pkg is the correct reference
                        // new load of pkg after GetLatest
                        string pkgGuid = pkg.PackageGUID;
                        pkg.VersionControlGetLatest(true);
                        pkg   = rep.GetPackageByGuid(pkgGuid);
                        count = count + 1;
                    }
                    catch
                    {
                        fText = path + " " + pkg.GetLastError();
                        rep.WriteOutput("Debug", fText, 0);
                        errorCount = errorCount + 1;
                    }
                }
                else
                {
                    fText = pkg.XMLPath + " invalid path";
                    rep.WriteOutput("Debug", fText, 0);
                    errorCount = errorCount + 1;
                }
            }

            //rep.WriteOutput("Debug", "Recursive:" +recursive.ToString(), 0);
            if (recursive)
            {
                //rep.WriteOutput("Debug","Recursive count:" + pkg.Packages.Count.ToString(), 0);
                // over all contained packages
                foreach (EA.Package pkgNested in pkg.Packages)
                {
                    //rep.WriteOutput("Debug", "Recursive:"+ pkgNested.Name, 0);
                    GetLatest(rep, pkgNested, true, ref count, level, ref errorCount);
                }
            }
            return(true);
        }