Beispiel #1
0
        /// <summary>
        /// Performs checking in documents to source control</summary>
        /// <param name="doing">True iff doing the command</param>
        /// <returns>True iff any documents checked in or can be checked in</returns>
        protected virtual bool DoCheckIn(bool doing)
        {
            if (SourceControlService == null || m_contextRegistry == null ||
                SourceControlContext == null || !SourceControlService.AllowCheckIn)
            {
                return(false);
            }

            bool             result     = false;
            List <IResource> toCheckIns = new List <IResource>();

            // return true if resources are added or checked out
            foreach (IResource resource in SourceControlContext.Resources)
            {
                SourceControlStatus status = GetStatus(resource);

                if (status == SourceControlStatus.CheckedOut ||
                    status == SourceControlStatus.Added ||
                    status == SourceControlStatus.Deleted)
                {
                    result = true;
                    if (doing)
                    {
                        toCheckIns.Add(resource);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (doing)
            {
                if (m_documentService != null)
                {
                    foreach (IResource resource in SourceControlContext.Resources)
                    {
                        // if collection has been modified save it before we check in
                        IDocument document = resource.As <IDocument>();
                        if (document != null)
                        {
                            if (document.Dirty)
                            {
                                m_documentService.Save(document);
                            }
                        }
                    }
                }

                CheckInForm form = new CheckInForm(SourceControlService, toCheckIns);
                if (m_mainForm != null)
                {
                    form.Icon = m_mainForm.Icon;
                }
                form.ShowDialog(GetDialogOwner());
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// Performs checking in documents to source control</summary>
        /// <param name="doing">True iff doing the command</param>
        /// <returns>True iff any documents checked in or can be checked in</returns>
        protected virtual bool DoCheckIn(bool doing)
        {
            if (SourceControlService == null || m_contextRegistry == null ||
                SourceControlContext == null || !SourceControlService.AllowCheckIn)
                return false;

            bool result = false;
            List<IResource> toCheckIns = new List<IResource>();

            // return true if resources are added or checked out
            foreach (IResource resource in SourceControlContext.Resources)
            {
                SourceControlStatus status = GetStatus(resource);

                if (status == SourceControlStatus.CheckedOut ||
                    status == SourceControlStatus.Added ||
                    status == SourceControlStatus.Deleted)
                {
                    result = true;
                    if (doing)
                        toCheckIns.Add(resource);
                    else
                        break;
                }
            }

            if (doing)
            {
                if (m_documentService != null)
                {
                    foreach (IResource resource in SourceControlContext.Resources)
                    {
                        // if collection has been modified save it before we check in
                        IDocument document = resource.As<IDocument>();
                        if (document != null)
                        {
                            if (document.Dirty)
                                m_documentService.Save(document);
                        }
                    }
                }

                using (var form = new CheckInForm(SourceControlService, toCheckIns))
                {
                    if (m_mainForm != null)
                        form.Icon = m_mainForm.Icon;
                    form.ShowDialog(GetDialogOwner());
                }
            }

            return result;
        }
        private bool DoCheckIn(IEnumerable<IResource> resources)
        {
            if (!CanUseSourceControl)
                return false;

            using (var dialog = new CheckInForm(SourceControlService, resources))
            {
                dialog.Icon = m_mainForm.Icon;
                dialog.ShowDialog(m_mainForm);
            }

            return true;
        }