GetLockingUser() 공개 메소드

public GetLockingUser ( ) : string
리턴 string
        public static string GetVCstate(EA.Repository rep, EA.Package pkg, bool isLong) {
                        string[] checkedOutStatusLong = { "Uncontrolled",
                                                      "Checked in",
                                                      "Checked out to this user",
                                                      "Read only version",
                                                      "Checked out to another user",
                                                      @"Offline checked in",
                                                      @"Offline checked out by user",
                                                      @"Offline checked out by other user", 
                                                      "Deleted" };
                        string[] checkedOutStatusShort = { "Uncontrolled",
                                                      "Checked in",
                                                      "Checked out",
                                                      "Read only",
                                                      "Checked out",
                                                      @"Offline checked in",
                                                      @"Offline checked out",
                                                      @"Offline checked out", 
                                                      @"Deleted" };

                        try
                        {
                            var svnHandle = new Svn(rep, pkg);
                            var s = svnHandle.GetLockingUser();
                            if (s != "") s = "CheckedOutTo=" + s ;
                            else s = "Checked in";
                            return s;
                        }
                        catch (Exception e)
                        {
                            if (isLong) return "VC State Error: " + e.Message;
                            else return "State Error";
                        }

        }
        /// <summary>
        /// Check in of a package. If there are the following package tagged values a get latest is performed to update keywords:
        /// -- svnDoc
        /// -- svnRevision
        /// </summary>
        /// <param name="rep">Repository</param>
        /// <param name="pkg">Package, default null</param>
        /// <param name="withGetLatest">false if you want to avoid a getLatest to update VC keywords
        /// Tagged Value "svnDoc" or "svnRevision" of package are true</param>
        /// <param name="comment">A check in comment, default="0" = aks for checkin comment</param>
        static void CheckIn(Repository rep, Package pkg = null, bool withGetLatest = false, string comment = "0")
        {
            if (pkg == null) pkg = rep.GetTreeSelectedPackage();
            if (pkg == null) return;

            pkg = Util.GetFirstControlledPackage(rep, pkg);
            if (pkg == null) return;

            var svnHandle = new Svn(rep, pkg);
            string userNameLockedPackage = svnHandle.GetLockingUser();
            if (userNameLockedPackage == "")
            {
                MessageBox.Show(@"Package isn't checked out");
                return;
            }


            if (InputBox(@"Checkin comment", @"Checkin", ref comment) == DialogResult.OK)
            {
                //
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    pkg.VersionControlCheckin(comment);
                    Cursor.Current = Cursors.Default;
                }
                catch (Exception e)
                {
                    MessageBox.Show($"{e} \n\n {pkg.GetLastError()}", @"Error Checkin");
                    return;
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
            if (withGetLatest)
            {
                // check if GetLatest is appropriate
                Element el = rep.GetElementByGuid(pkg.PackageGUID);
                foreach (EA.TaggedValue t in el.TaggedValues)
                {
                    if (t.Name == "svnDoc" | t.Name == "svnRevision")
                    {
                        pkg.VersionControlResynchPkgStatus(false);
                        if (pkg.Flags.Contains("Checkout"))
                        {
                            MessageBox.Show($"Flags={pkg.Flags}", @"Package Checked out, Break!");
                            return;
                        }
                        pkg.VersionControlGetLatest(true);
                        return;
                    }
                }
            }
        }
        /// <summary>
        /// Update VC (Version Control state of a controlled package:
        /// - Returns user name of user who have checked out the package
        /// - Updates the package flags
        /// </summary>
        /// <param name="rep">Repository</param>
        /// <param name="pkg">Package to check</param>
        public static string UpdateVc(EA.Repository rep, EA.Package pkg)
        {
            string userNameLockedPackage = "";
            if (pkg.IsVersionControlled)
            {
                // find                  VC=...;
                // replace by:           VC=currentState();
                string flags = pkg.Flags;
                
                // remove check out flags
                flags = Regex.Replace(flags, @"VC=[^;]*;", "");
                flags = Regex.Replace(flags, @"CheckedOutTo=[^;]*;", "");


                var svnHandle = new Svn(rep, pkg);
                userNameLockedPackage = svnHandle.GetLockingUser();
                if (userNameLockedPackage != "") flags = flags + "CheckedOutTo=" + userNameLockedPackage + ";";
                try
                {
                    SetVcFlags(rep, pkg, flags);
                    rep.ShowInProjectView(pkg);
                }
                catch (Exception e)
                {
                    string s = e.Message + " ;" + pkg.GetLastError();
                    s = s + "!";
                    MessageBox.Show(s, @"Error UpdateVC state");
                }


            }
            return userNameLockedPackage;
         }
        private static void CheckOut(Repository rep, Package pkg = null)
        {
            if (pkg == null) pkg = rep.GetTreeSelectedPackage();
            if (pkg == null) return;

            pkg = Util.GetFirstControlledPackage(rep, pkg);
            if (pkg == null) return;

            var svnHandle = new Svn(rep, pkg);
            string userNameLockedPackage = svnHandle.GetLockingUser();
            if (userNameLockedPackage != "")
            {
                MessageBox.Show($"Package is checked out by '{userNameLockedPackage}'");
                return;
            }

            //
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                pkg.VersionControlCheckout("");
                Cursor.Current = Cursors.Default;
            }
            catch (Exception e)
            {
                MessageBox.Show($"{e}\n\n{pkg.GetLastError()}", @"Error Checkout");
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }