示例#1
0
        /// <summary>
        /// Creates a direct or symbolic reference with the specified name and target
        /// </summary>
        /// <param name="name">The name of the reference to create.</param>
        /// <param name="canonicalRefNameOrObjectish">The target which can be either the canonical name of a reference or a revparse spec.</param>
        /// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="Reference"/></param>
        /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
        /// <returns>A new <see cref="Reference"/>.</returns>
        public virtual Reference Add(string name, string canonicalRefNameOrObjectish, string logMessage, bool allowOverwrite)
        {
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNullOrEmptyString(canonicalRefNameOrObjectish, "canonicalRefNameOrObjectish");

            Reference reference;
            RefState  refState = TryResolveReference(out reference, this, canonicalRefNameOrObjectish);

            var gitObject = repo.Lookup(canonicalRefNameOrObjectish, GitObjectType.Any, LookUpOptions.None);

            if (refState == RefState.Exists)
            {
                return(Add(name, reference, logMessage, allowOverwrite));
            }

            if (refState == RefState.DoesNotExistButLooksValid && gitObject == null)
            {
                using (ReferenceHandle handle = Proxy.git_reference_symbolic_create(repo.Handle, name, canonicalRefNameOrObjectish, allowOverwrite,
                                                                                    logMessage))
                {
                    return(Reference.BuildFromPtr <Reference>(handle, repo));
                }
            }

            Ensure.GitObjectIsNotNull(gitObject, canonicalRefNameOrObjectish);

            if (logMessage == null)
            {
                logMessage = string.Format(CultureInfo.InvariantCulture, "{0}: Created from {1}",
                                           name.LooksLikeLocalBranch() ? "branch" : "reference", canonicalRefNameOrObjectish);
            }

            EnsureHasLog(name);
            return(Add(name, gitObject.Id, logMessage, allowOverwrite));
        }
示例#2
0
 private Reference UpdateDirectReferenceTarget(Reference directRef, ObjectId targetId, string logMessage)
 {
     using (ReferenceHandle referencePtr = RetrieveReferencePtr(directRef.CanonicalName))
         using (ReferenceHandle handle = Proxy.git_reference_set_target(referencePtr, targetId, logMessage))
         {
             return(Reference.BuildFromPtr <Reference>(handle, repo));
         }
 }
示例#3
0
 private Reference UpdateSymbolicRefenceTarget(Reference symbolicRef, Reference targetRef, string logMessage)
 {
     using (ReferenceHandle referencePtr = RetrieveReferencePtr(symbolicRef.CanonicalName))
         using (ReferenceHandle handle = Proxy.git_reference_symbolic_set_target(referencePtr, targetRef.CanonicalName, logMessage))
         {
             return(Reference.BuildFromPtr <Reference>(handle, repo));
         }
 }
示例#4
0
        /// <summary>
        /// Start a rebase operation.
        /// </summary>
        /// <param name="branch">The branch to rebase.</param>
        /// <param name="upstream">The starting commit to rebase.</param>
        /// <param name="onto">The branch to rebase onto.</param>
        /// <param name="committer">The <see cref="Identity"/> of who added the change to the repository.</param>
        /// <param name="options">The <see cref="RebaseOptions"/> that specify the rebase behavior.</param>
        /// <returns>true if completed successfully, false if conflicts encountered.</returns>
        public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, Identity committer, RebaseOptions options)
        {
            Ensure.ArgumentNotNull(upstream, "upstream");

            using (ReferenceHandle branchRefPtr = RefHandleFrom(branch))
                using (ReferenceHandle upstreamRefPtr = RefHandleFrom(upstream))
                    using (ReferenceHandle ontoRefPtr = RefHandleFrom(onto))
                        return(Start(branchRefPtr, upstreamRefPtr, ontoRefPtr, committer, options));
        }
示例#5
0
        /// <summary>
        /// Deletes the specified branch.
        /// </summary>
        /// <param name="branch">The branch to delete.</param>
        public virtual void Remove(Branch branch)
        {
            Ensure.ArgumentNotNull(branch, "branch");

            using (ReferenceHandle referencePtr = repo.Refs.RetrieveReferencePtr(branch.CanonicalName))
            {
                Proxy.git_branch_delete(referencePtr);
            }
        }
示例#6
0
        private static void Set(ReferenceHandle handle, T value)
        {
            if (!Storage.ContainsKey(handle))
            {
                throw new ArgumentException($"{typeof(ReferenceProvider<T>)} does not contain handle {handle}");
            }

            Storage[handle] = value;
        }
示例#7
0
        private static T Get(ReferenceHandle handle)
        {
            if (!Storage.TryGetValue(handle, out var value))
            {
                throw new ArgumentException($"{typeof(ReferenceProvider<T>)} does not contain handle {handle}");
            }

            return(value);
        }
示例#8
0
        /// <summary>
        /// Creates a direct reference with the specified name and target
        /// </summary>
        /// <param name="name">The canonical name of the reference to create.</param>
        /// <param name="targetId">Id of the target object.</param>
        /// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="DirectReference"/></param>
        /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
        /// <returns>A new <see cref="Reference"/>.</returns>
        public virtual DirectReference Add(string name, ObjectId targetId, string logMessage, bool allowOverwrite)
        {
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(targetId, "targetId");

            using (ReferenceHandle handle = Proxy.git_reference_create(repo.Handle, name, targetId, allowOverwrite, logMessage))
            {
                return((DirectReference)Reference.BuildFromPtr <Reference>(handle, repo));
            }
        }
示例#9
0
        internal T Resolve <T>(string name) where T : Reference
        {
            Ensure.ArgumentNotNullOrEmptyString(name, "name");

            using (ReferenceHandle referencePtr = RetrieveReferencePtr(name, false))
            {
                return(referencePtr == null
                    ? null
                    : Reference.BuildFromPtr <T>(referencePtr, repo));
            }
        }
示例#10
0
        internal static ReferenceHandle Register(MessengerImpl messenger, object target, bool weakreference)
        {
            var attrs   = MessageHandleUtil.GetAttributes(target.GetType());
            var handles = new ReferenceHandle[attrs.Length];

            for (int i = 0; i < attrs.Length; i++)
            {
                var attr = attrs[i];
                handles[i] = attr.m_Register(messenger, target, attr, weakreference);
            }
            return(new ReferenceHandle(handles));
        }
示例#11
0
        public virtual RebaseResult Start(Commit annotated, Commit upstream, Commit onto, Identity committer, RebaseOptions options)
        {
            Ensure.ArgumentNotNull(upstream, "upstream");

            // TODO: Rebase does not work with just references, is that a bug or design feature?
            using (var annotatedRef = ReferenceFrom(annotated))
                using (var upstreamRef = ReferenceFrom(upstream))
                    using (var ontoRef = ReferenceFrom(onto))
                        using (ReferenceHandle annotatedRefPtr = RefHandleFrom(annotatedRef?.CanonicalName))
                            using (ReferenceHandle upstreamRefPtr = RefHandleFrom(upstreamRef?.CanonicalName))
                                using (ReferenceHandle ontoRefPtr = RefHandleFrom(ontoRef?.CanonicalName))
                                    return(Start(annotatedRefPtr, upstreamRefPtr, ontoRefPtr, committer, options));
        }
示例#12
0
        /// <summary>
        /// Creates a symbolic reference with the specified name and target
        /// </summary>
        /// <param name="name">The canonical name of the reference to create.</param>
        /// <param name="targetRef">The target reference.</param>
        /// <param name="logMessage">The optional message to log in the <see cref="ReflogCollection"/> when adding the <see cref="SymbolicReference"/></param>
        /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
        /// <returns>A new <see cref="Reference"/>.</returns>
        public virtual SymbolicReference Add(string name, Reference targetRef, string logMessage, bool allowOverwrite)
        {
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNull(targetRef, "targetRef");

            using (ReferenceHandle handle = Proxy.git_reference_symbolic_create(repo.Handle,
                                                                                name,
                                                                                targetRef.CanonicalName,
                                                                                allowOverwrite,
                                                                                logMessage))
            {
                return((SymbolicReference)Reference.BuildFromPtr <Reference>(handle, repo));
            }
        }
示例#13
0
        /// <summary>
        /// Start a rebase operation.
        /// </summary>
        /// <param name="branch">The branch to rebase.</param>
        /// <param name="upstream">The starting commit to rebase.</param>
        /// <param name="onto">The branch to rebase onto.</param>
        /// <param name="committer">The <see cref="Identity"/> of who added the change to the repository.</param>
        /// <param name="options">The <see cref="RebaseOptions"/> that specify the rebase behavior.</param>
        /// <returns>true if completed successfully, false if conflicts encountered.</returns>
        public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, Identity committer, RebaseOptions options)
        {
            Ensure.ArgumentNotNull(upstream, "upstream");

            options = options ?? new RebaseOptions();

            EnsureNonBareRepo();

            if (this.repository.Info.CurrentOperation != CurrentOperation.None)
            {
                throw new LibGit2SharpException("A {0} operation is already in progress.",
                                                this.repository.Info.CurrentOperation);
            }

            Func <Branch, ReferenceHandle> RefHandleFromBranch = (Branch b) =>
            {
                return((b == null) ?
                       null :
                       this.repository.Refs.RetrieveReferencePtr(b.CanonicalName));
            };

            using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options))
            {
                GitRebaseOptions gitRebaseOptions = new GitRebaseOptions()
                {
                    version          = 1,
                    checkout_options = checkoutOptionsWrapper.Options,
                };

                using (ReferenceHandle branchRefPtr = RefHandleFromBranch(branch))
                    using (ReferenceHandle upstreamRefPtr = RefHandleFromBranch(upstream))
                        using (ReferenceHandle ontoRefPtr = RefHandleFromBranch(onto))
                            using (AnnotatedCommitHandle annotatedBranchCommitHandle = AnnotatedCommitHandleFromRefHandle(branchRefPtr))
                                using (AnnotatedCommitHandle upstreamRefAnnotatedCommitHandle = AnnotatedCommitHandleFromRefHandle(upstreamRefPtr))
                                    using (AnnotatedCommitHandle ontoRefAnnotatedCommitHandle = AnnotatedCommitHandleFromRefHandle(ontoRefPtr))
                                        using (RebaseHandle rebaseOperationHandle = Proxy.git_rebase_init(this.repository.Handle,
                                                                                                          annotatedBranchCommitHandle,
                                                                                                          upstreamRefAnnotatedCommitHandle,
                                                                                                          ontoRefAnnotatedCommitHandle,
                                                                                                          gitRebaseOptions))
                                        {
                                            RebaseResult rebaseResult = RebaseOperationImpl.Run(rebaseOperationHandle,
                                                                                                this.repository,
                                                                                                committer,
                                                                                                options);
                                            return(rebaseResult);
                                        }
            }
        }
示例#14
0
        internal virtual RebaseResult Start(ReferenceHandle annotatedRefPtr, ReferenceHandle upstreamRefPtr, ReferenceHandle ontoRefPtr, Identity committer, RebaseOptions options)
        {
            Ensure.ArgumentNotNull(upstreamRefPtr, "upstream");

            options = options ?? new RebaseOptions();

            EnsureNonBareRepo();

            if (this.repository.Info.CurrentOperation != CurrentOperation.None)
            {
                throw new LibGit2SharpException("A {0} operation is already in progress.",
                                                this.repository.Info.CurrentOperation);
            }

            using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options))
            {
                GitRebaseOptions gitRebaseOptions = new GitRebaseOptions()
                {
                    version          = 1,
                    checkout_options = checkoutOptionsWrapper.Options,
                };

                using (AnnotatedCommitHandle annotatedBranchCommitHandle = AnnotatedCommitHandleFromRefHandle(annotatedRefPtr))
                    using (AnnotatedCommitHandle upstreamRefAnnotatedCommitHandle = AnnotatedCommitHandleFromRefHandle(upstreamRefPtr))
                        using (AnnotatedCommitHandle ontoRefAnnotatedCommitHandle = AnnotatedCommitHandleFromRefHandle(ontoRefPtr))
                            using (RebaseHandle rebaseOperationHandle = Proxy.git_rebase_init(this.repository.Handle,
                                                                                              annotatedBranchCommitHandle,
                                                                                              upstreamRefAnnotatedCommitHandle,
                                                                                              ontoRefAnnotatedCommitHandle,
                                                                                              gitRebaseOptions))
                            {
                                this.repository.Submodules.UpdateAll(options.SubmoduleUpdateOptions);

                                RebaseResult rebaseResult = RebaseOperationImpl.Run(rebaseOperationHandle,
                                                                                    this.repository,
                                                                                    committer,
                                                                                    options);
                                return(rebaseResult);
                            }
            }
        }
示例#15
0
        /// <summary>
        /// Rename an existing local branch
        /// </summary>
        /// <param name="branch">The current local branch.</param>
        /// <param name="newName">The new name the existing branch should bear.</param>
        /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing branch, false otherwise.</param>
        /// <returns>A new <see cref="Branch"/>.</returns>
        public virtual Branch Rename(Branch branch, string newName, bool allowOverwrite)
        {
            Ensure.ArgumentNotNull(branch, "branch");
            Ensure.ArgumentNotNullOrEmptyString(newName, "newName");

            if (branch.IsRemote)
            {
                throw new GitException("Cannot rename branch '{0}'. It's a remote tracking branch.",
                                       branch.FriendlyName);
            }

            using (ReferenceHandle referencePtr = repo.Refs.RetrieveReferencePtr(Reference.LocalBranchPrefix + branch.FriendlyName))
            {
                using (Proxy.git_branch_move(referencePtr, newName, allowOverwrite))
                { }
            }

            var newBranch = this[newName];

            return(newBranch);
        }
示例#16
0
        /// <summary>
        /// Rename an existing reference with a new name, and update the reflog
        /// </summary>
        /// <param name="reference">The reference to rename.</param>
        /// <param name="newName">The new canonical name.</param>
        /// <param name="logMessage">Message added to the reflog.</param>
        /// <param name="allowOverwrite">True to allow silent overwriting a potentially existing reference, false otherwise.</param>
        /// <returns>A new <see cref="Reference"/>.</returns>
        public virtual Reference Rename(Reference reference, string newName, string logMessage, bool allowOverwrite)
        {
            Ensure.ArgumentNotNull(reference, "reference");
            Ensure.ArgumentNotNullOrEmptyString(newName, "newName");

            if (logMessage == null)
            {
                logMessage = string.Format(CultureInfo.InvariantCulture,
                                           "{0}: renamed {1} to {2}",
                                           reference.IsLocalBranch
                                               ? "branch"
                                               : "reference",
                                           reference.CanonicalName,
                                           newName);
            }

            using (ReferenceHandle referencePtr = RetrieveReferencePtr(reference.CanonicalName))
                using (ReferenceHandle handle = Proxy.git_reference_rename(referencePtr, newName, allowOverwrite, logMessage))
                {
                    return(Reference.BuildFromPtr <Reference>(handle, repo));
                }
        }
示例#17
0
        public override bool Execute(CommandActivity commandActivity)
        {
            //Set templates for FileCase creation.
            var fileCaseFfTemplateReferenceId = "B475F10A-94ED-4E75-9C64-DF6890569093";
            var fileCaseMbTemplateReferenceId = "8087873D-755F-40D4-84C6-1BA7EB8C26AC";

            var startFileCases = new List <FileCase>();

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                //Create FF FileCase
                var fileCaseTemplateFf =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject();
                if (fileCaseTemplateFf == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseFfTemplateReferenceId));
                }
                var newTitle = String.Empty;

                var ffCatalogValue = hostObject.GetProperty("#LHIND_MitberichtExtern_FederfuhrendesAmt") as SpecialdataCatalogValue;
                if (ffCatalogValue != null)
                {
                    var ffGroup = ffCatalogValue.GetProperty("#LHIND_MitberichtExtern_Spoc") as TenantGroup;
                    if (ffGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf);
                    ffFileCase.LeadingGroup = ffGroup;

                    newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName);
                    ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(ffFileCase);
                }

                //Create MB FileCases
                var fileCaseTemplateMb =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseMbTemplateReferenceId).GetObject();
                if (fileCaseTemplateMb == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseMbTemplateReferenceId));
                }

                var mbCatalogValues =
                    hostObject.GetProperty("#LHIND_MitberichtExtern_MitbeteiligtFdListe") as SpecialdataListPropertyValueCollection;

                foreach (var mbCatalogValue in mbCatalogValues)
                {
                    var mbGroup = mbCatalogValue.WrappedValue.GetProperty("#LHIND_MitberichtExtern_Spoc") as TenantGroup;
                    if (mbGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var mbFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateMb);
                    mbFileCase.LeadingGroup = mbGroup;

                    newTitle = mbFileCase.GetMultilingualValue(fc => fc.Title) + " - " + mbFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName);
                    mbFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(mbFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }
示例#18
0
 unsafe AnnotatedCommitHandle AnnotatedCommitHandleFromRefHandle(ReferenceHandle refHandle)
 {
     return((refHandle == null) ?
            new AnnotatedCommitHandle(null, false) :
            Proxy.git_annotated_commit_from_ref(this.repository.Handle, refHandle));
 }
示例#19
0
        public override bool Execute(CommandActivity commandActivity)
        {
            const string fileCaseTemplateReferenceId = "04248329-15C8-40C8-8888-90DF1C782A56";

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                var fileCaseTemplate = new ReferenceHandle <FileCaseTemplate>(fileCaseTemplateReferenceId).GetObject();

                if (fileCaseTemplate == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseTemplateReferenceId));
                }

                var startFileCases = new List <FileCase>();

                var fileCaseRecipientGroups =
                    hostObject.GetProperty("#LHIND_Mitbericht_VE_WeiterleitenAn") as SpecialdataListPropertyValueCollection;

                if (fileCaseRecipientGroups == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoRecipients
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                foreach (var recipientGroup in fileCaseRecipientGroups)
                {
                    var newFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplate);

                    if (newFileCase == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCase
                                                                               .ToLocalizedName()
                                                                               .FormatWith(commandActivity));
                    }

                    newFileCase.LeadingGroup = recipientGroup.Unwrap() as TenantGroup;
                    var newTitle = hostObject.GetMultilingualValue(fc => fc.Title) + " [" + hostObject.FormattedNumber +
                                   "] - " + newFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName);
                    newFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(newFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }
示例#20
0
        public override bool Execute(CommandActivity commandActivity)
        {
            //Set templates for FileCase creation.
            const string fileCaseFfTemplateReferenceId = "6220CB49-8E09-4AB7-B4F1-673C6C91CC7E";
            const string fileCaseMbTemplateReferenceId = "56E01B36-E6DE-4DA3-ABE8-95C6551A76D3";

            var startFileCases = new List <FileCase>();

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                //Create FF FileCase
                var fileCaseTemplateFf =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject();
                if (fileCaseTemplateFf == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseFfTemplateReferenceId));
                }
                var newTitle = String.Empty;

                var ffCatalogValue = hostObject.GetProperty("#LHIND_Mitbericht_FederführendesAmt") as SpecialdataCatalogValue;
                if (ffCatalogValue != null)
                {
                    var ffGroup = ffCatalogValue.GetProperty("#LHIND_Mitbericht_Spoc") as TenantGroup;
                    if (ffGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf);
                    ffFileCase.LeadingGroup = ffGroup;

                    newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName);
                    ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(ffFileCase);
                }

                //Create MB FileCases
                var fileCaseTemplateMb =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseMbTemplateReferenceId).GetObject();
                if (fileCaseTemplateMb == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseMbTemplateReferenceId));
                }

                var mbCatalogValues =
                    hostObject.GetProperty("#LHIND_Mitbericht_MitbeteiligtFdListe") as SpecialdataListPropertyValueCollection;

                foreach (var mbCatalogValue in mbCatalogValues)
                {
                    var mbGroup = mbCatalogValue.WrappedValue.GetProperty("#LHIND_Mitbericht_Spoc") as TenantGroup;
                    if (mbGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var mbFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateMb);
                    mbFileCase.LeadingGroup = mbGroup;

                    newTitle = mbFileCase.GetMultilingualValue(fc => fc.Title) + " - " + mbFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName);
                    mbFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(mbFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }
示例#21
0
        internal ReferenceHandle RetrieveReferencePtr(string referenceName, bool shouldThrowIfNotFound = true)
        {
            ReferenceHandle reference = Proxy.git_reference_lookup(repo.Handle, referenceName, shouldThrowIfNotFound);

            return(reference);
        }
示例#22
0
 private static void Dispose(ReferenceHandle handle)
 {
     Storage.Remove(handle);
 }
示例#23
0
        public override bool Execute(CommandActivity commandActivity)
        {
            //Set templates for FileCase creation.
            var fileCaseFfTemplateReferenceId = "F0754977-092B-481B-8A59-AA806FFE1499";

            var startFileCases = new List <FileCase>();

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                //Create FF FileCase
                var fileCaseTemplateFf =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject();
                if (fileCaseTemplateFf == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseFfTemplateReferenceId));
                }
                var newTitle = String.Empty;

                var ffCatalogValue = hostObject.GetProperty("#LHIND_Monatsgespraeche_Federfuehrung") as SpecialdataCatalogValue;
                if (ffCatalogValue != null)
                {
                    var ffGroup = ffCatalogValue.GetProperty("#LHIND_Monatsgespraeche_Spoc") as TenantGroup;
                    if (ffGroup == null)
                    {
                        throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoGroupDefined
                                                                               .ToLocalizedName()
                                                                               .FormatWith(ffCatalogValue));
                    }

                    var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf);
                    ffFileCase.LeadingGroup = ffGroup;

                    newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " + ffGroup.GetMultilingualValue(g => g.ShortName);
                    ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(ffFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }
示例#24
0
        public override bool Execute(CommandActivity commandActivity)
        {
            //Set templates for FileCase creation.
            const string fileCaseFfTemplateReferenceId = "9B9A5D57-3DC5-41A6-81DB-6D4ADC1335E6";
            const string fileCaseMbTemplateReferenceId = "7AAA0700-CA11-4759-B250-DF3BC05B9754";

            var startFileCases = new List <FileCase>();

            try
            {
                var hostObject = (File)commandActivity.WorkItem;

                if (hostObject == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFile
                                                                           .ToLocalizedName()
                                                                           .FormatWith(commandActivity));
                }

                if (!hostObject.CanEdit(true))
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NotEditable
                                                                           .ToLocalizedName()
                                                                           .FormatWith(hostObject));
                }

                //Create FF FileCase
                var fileCaseTemplateFf =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseFfTemplateReferenceId).GetObject();
                if (fileCaseTemplateFf == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseFfTemplateReferenceId));
                }
                var newTitle = String.Empty;
                var ffGroup  = hostObject.GetProperty("#LHIND_Antrag_Ff") as TenantGroup;

                if (ffGroup != null)
                {
                    var ffFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateFf);

                    ffFileCase.LeadingGroup = ffGroup;

                    newTitle = ffFileCase.GetMultilingualValue(fc => fc.Title) + " - " +
                               ffGroup.GetMultilingualValue(g => g.ShortName);
                    ffFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(ffFileCase);
                }

                //Create MB FileCases
                var fileCaseTemplateMb =
                    new ReferenceHandle <FileCaseTemplate>(fileCaseMbTemplateReferenceId).GetObject();
                if (fileCaseTemplateMb == null)
                {
                    throw new ActivityCommandException("").WithUserMessage(LocalizedUserMessages.NoFileCaseTemplate
                                                                           .ToLocalizedName()
                                                                           .FormatWith(fileCaseMbTemplateReferenceId));
                }

                var mbFileCaseRecipients =
                    hostObject.GetProperty("#LHIND_Antrag_Mb") as SpecialdataListPropertyValueCollection;

                foreach (var fileCaseRecipient in mbFileCaseRecipients)
                {
                    var mbFileCase = FileCase.NewObject(hostObject, null, null, fileCaseTemplateMb);
                    mbFileCase.LeadingGroup = fileCaseRecipient.Unwrap() as TenantGroup;

                    newTitle = mbFileCase.GetMultilingualValue(fc => fc.Title) + " - " +
                               mbFileCase.LeadingGroup.GetMultilingualValue(g => g.ShortName);
                    mbFileCase.SetMultilingualValue(fc => fc.Title, newTitle);

                    startFileCases.Add(mbFileCase);
                }

                ClientTransaction.Current.Commit();

                foreach (var startFileCase in startFileCases)
                {
                    startFileCase.StartObject();
                }

                ClientTransaction.Current.Commit();
            }
            catch (Exception ex)
            {
                s_logger.Error(ex.Message, ex);
                ClientTransaction.Current.Rollback();
                throw;
            }

            return(true);
        }
示例#25
0
 // This overload lets public-facing methods avoid having to use the pointers directly
 internal static unsafe T BuildFromPtr <T>(ReferenceHandle handle, Repository repo) where T : Reference
 {
     return(BuildFromPtr <T>((git_reference *)handle.Handle, repo));
 }