Пример #1
0
        public SingleObjectModel RunMessagingService()
        {
            string a = $"Running messaging services using Azure web jobs at {DateTime.Now.ToShortTimeString()}.";

            EmpiriaLog.Debug(a);

            return(new SingleObjectModel(this.Request, a));
        }
Пример #2
0
        internal ProjectItem ChangeParentAndPosition(ProjectItem item, ProjectItem newParent, int newPosition)
        {
            EmpiriaLog.Debug($"ChangeParent of {item.Name} to new parent {newParent.Name}");

            if (item.Equals(newParent))
            {
                EmpiriaLog.Info($"Trying to change the parent of a tree item to itself {item.Name} ({item.UID}).");

                return(item);
            }

            var branchToMove = this.GetBranch(item);

            Assertion.Require(!branchToMove.Contains(newParent),
                              $"Can't change the parent of '{item.Name}' because it is a branch " +
                              $"and '{newParent.Name}' is one of its children.");

            // Then remove the whole branch an reinsert it in the new position
            foreach (var branchItem in branchToMove)
            {
                ItemsList.Remove(branchItem);
            }

            item.SetParentAndPosition(newParent, newPosition);

            int insertionIndex = newPosition - 1; // insertionIndex is zero-based

            foreach (var branchItem in branchToMove)
            {
                ItemsList.Insert(insertionIndex, branchItem);

                insertionIndex++;
            }

            this.RefreshPositions();

            EmpiriaLog.Info($"ChangeParentAndPosition of {item.Name} to {newParent.Name} at position {newParent.Position + 1}.");

            return(item);
        }
Пример #3
0
        internal ProjectItem ChangePosition(ProjectItem item, int newPosition)
        {
            EmpiriaLog.Debug($"ChangePosition of {item.Name} in position {item.Position} to new position {newPosition}");

            var branchToMove = this.GetBranch(item);

            Assertion.Require(newPosition <branchToMove[0].Position ||
                                           newPosition> branchToMove[branchToMove.Count - 1].Position,
                              "Can't move item because it's a branch and the requested new position is inside it.");

            int insertionIndex = Math.Min(newPosition - 1, this.ItemsList.Count);

            // Get the insertion point before item position
            ProjectItem insertBeforeItem = insertionIndex < this.ItemsList.Count ? this.ItemsList[insertionIndex] : null;

            // Then remove the whole branch an reinsert it in the new position
            foreach (var branchItem in branchToMove)
            {
                ItemsList.Remove(branchItem);
            }

            // Recalculate the new insertion index
            insertionIndex = insertBeforeItem != null?this.ItemsList.IndexOf(insertBeforeItem) : this.ItemsList.Count;

            var newParent = insertBeforeItem != null ? insertBeforeItem.Parent : ProjectItem.Empty;

            item.SetParentAndPosition(newParent, insertionIndex);

            foreach (var branchItem in branchToMove)
            {
                ItemsList.Insert(insertionIndex, branchItem);

                insertionIndex++;
            }

            this.RefreshPositions();

            return(item);
        }
Пример #4
0
        internal ProjectItem ChangeParentKeepingPosition(ProjectItem item, ProjectItem newParent)
        {
            EmpiriaLog.Debug($"ChangeParent of {item.Name} to new parent {newParent.Name} keeping current position.");

            if (item.Equals(newParent))
            {
                EmpiriaLog.Info($"Trying to change the parent of a tree item to itself {item.Name} ({item.UID}).");

                return(item);
            }

            var branchToMove = this.GetBranch(item);

            Assertion.Require(!branchToMove.Contains(newParent),
                              $"Can't change the parent of '{item.Name}' because it is a branch " +
                              $"and '{newParent.Name}' is one of its children.");

            item.SetParent(newParent);
            item.Save();

            return(item);
        }