Example #1
0
 public static Note Clone(Guid parentId, Chord chord, Repository.DataService.Measure measure, int x, int y, Note source, Collaborator collaborator)
 {
     Note obj = null;
     try
     {
         obj = Create(chord, measure, x, y);
         obj.Accidental_Id = source.Accidental_Id;
         obj.Duration = source.Duration;
         obj.Instrument_Id = source.Instrument_Id;
         obj.Chord_Id = parentId;
         obj.IsDotted = source.IsDotted;
         obj.IsSpanned = source.IsSpanned;
         obj.Location_X = source.Location_X;
         obj.Location_Y = source.Location_Y;
         obj.Key_Id = source.Key_Id;
         obj.Orientation = source.Orientation;
         obj.Slot = source.Slot;
         obj.Pitch = source.Pitch;
         obj.Type = source.Type;
         obj.Vector_Id = source.Vector_Id;
         obj.StartTime = source.StartTime;
         obj.Status = source.Status;
         obj.Audit = GetAudit();
         Cache.Notes.Add(obj);
     }
     catch (Exception ex)
     {
         Exceptions.HandleException(ex);
     }
     return obj;
 }
Example #2
0
 public static Repository.DataService.Measure Clone(Guid parentId, Repository.DataService.Measure source, Collaborator collaborator)
 {
     Repository.DataService.Measure obj;
     obj = Create(parentId, source.Sequence);
     obj.Id = Guid.NewGuid();
     obj.Staff_Id = parentId;
     obj.Sequence = source.Sequence;
     obj.Index = -1;
     obj.Width = (int.Parse(source.Width) + 7).ToString(CultureInfo.InvariantCulture);
     obj.Duration = source.Duration;
     obj.Bar_Id = source.Bar_Id;
     obj.Spacing = source.Spacing;
     obj.TimeSignature_Id = source.TimeSignature_Id;
     obj.Instrument_Id = source.Instrument_Id;
     obj.Status = CollaborationManager.GetBaseStatus();
     foreach (Chord chord in source.Chords)
     {
         obj.Chords.Add(ChordManager.Clone(obj, chord, collaborator));
     }
     Cache.AddMeasure(obj);
     return obj;
 }
Example #3
0
        //is this note actionable based on its status, note authorship, composition authorship?
        //and the currently logged on user. this function answers that question.
        public static bool IsActionable(Note n, Collaborator collaborator)
        {
            var result = false;

            //usually we are interested in the current collaborator, but sometimes we need
            //to specify a collaborater, by passing in a currentCollaborator. if currentCollaborator is null then
            //use the usual Collaborations.CurrentCollaborator.
            if (collaborator == null && Collaborations.CurrentCollaborator != null)
            {
                collaborator = Collaborations.CurrentCollaborator;
            }

            var noteIsAuthoredByAuthor = n.Audit.Author_Id == CompositionManager.Composition.Audit.Author_Id;
            var noteIsAuthoredByContributor = n.Audit.Author_Id != CompositionManager.Composition.Audit.Author_Id;
            var noteIsAuthoredBySpecifiedContributor = (collaborator != null) && n.Audit.Author_Id == collaborator.Author_Id;
            var noteIsAuthoredByCurrentUser = n.Audit.Author_Id == Current.User.Id;

            try
            {
                int idx;
                bool noteIsInactiveForAuthor;
                bool noteIsActiveForAuthor;
                bool noteIsInactiveForContributor;
                bool noteIsActiveForContributor;

                if (collaborator != null)
                {
                    //only allow packed measures to display contributor submissions
                    var isPackedMeasure = true;
                    if (!_checkingPackedState)
                    {
                        //IsPackedMeasure calls this function, so we need a mechanism to avoid circularity.
                        _checkingPackedState = true;
                        isPackedMeasure = MeasureManager.IsPackedMeasure(NoteController.GetMeasureFromNote(n));
                        _checkingPackedState = false;
                        isPackedMeasure = true;
                    }

                    if (EditorState.IsAuthor)
                    {
                        //the currently logged on user is the author, and there is a collaborator selected in the collaboration panel.
                        idx = GetUserCollaboratorIndex(n.Audit.Author_Id.ToString(CultureInfo.InvariantCulture));
                        if (n.StartTime > 4 && ! _checkingPackedState && idx==1)
                        {
                        }
                        noteIsInactiveForAuthor = IsInactiveForAuthor(n);
                        noteIsActiveForAuthor = IsActiveForAuthor(n, idx);
                        var isContributorAdded = Collaborations.GetStatus(n, collaborator.Index) == (int)_Enum.Status.ContributorAdded;

                        result = (noteIsAuthoredByAuthor && !noteIsInactiveForAuthor
                                 || noteIsAuthoredByContributor && noteIsActiveForAuthor
                                 || isPackedMeasure && noteIsAuthoredBySpecifiedContributor && isContributorAdded); //ie: note is pending
                    }
                    else
                    {
                        //the currently logged on user is a contributor, and the composition author is selected in the collaboration panel.
                        idx = GetUserCollaboratorIndex(Current.User.Id);

                        noteIsInactiveForContributor = IsInactiveForContributor(n, idx);
                        noteIsActiveForContributor = IsActiveForContributor(n, idx);
                        var isAuthorAdded = Collaborations.GetStatus(n, idx) == (int)_Enum.Status.AuthorAdded;

                        result = (noteIsAuthoredByCurrentUser && !noteIsInactiveForContributor
                                 || noteIsAuthoredByAuthor && noteIsActiveForContributor
                                 || isPackedMeasure && noteIsAuthoredByAuthor && isAuthorAdded);  //ie: note is pending
                    }
                }
                else
                {
                    //is the currently logged in user the composition author?
                    if (EditorState.IsAuthor)
                    {
                        idx = GetUserCollaboratorIndex(n.Audit.Author_Id.ToString(CultureInfo.InvariantCulture));

                        //arriving here means that the currently logged on user is the author of the composition, and there
                        //isn't a target contributor selected in the collaboration panel

                        //even though the currently logged in user is the composition author, notes authored by the composition
                        //author may not be active, and notes authored by a contributor may be inactive.

                        noteIsInactiveForAuthor = IsInactiveForAuthor(n);
                        noteIsActiveForAuthor = IsActiveForAuthor(n, idx);

                        result = (noteIsAuthoredByAuthor && !noteIsInactiveForAuthor
                                 || noteIsAuthoredByContributor && noteIsActiveForAuthor);
                    }
                    else
                    {
                        //arriving here means that the currently logged on user is a contributor to the composition, and the
                        //author isn't selected in the collaboration panel.

                        idx = GetUserCollaboratorIndex(Current.User.Id);

                        //even though the currently logged in user is a contributor, notes authored by the contributor
                        //may not be active, and notes authored by the composition author may be inactive.

                        noteIsInactiveForContributor = IsInactiveForContributor(n, idx);
                        noteIsActiveForContributor = IsActiveForContributor(n, idx);

                        result = (noteIsAuthoredByCurrentUser && !noteIsInactiveForContributor
                                 || noteIsAuthoredByAuthor && noteIsActiveForContributor);
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.HandleException(ex, "class = CollaborationManager method = IsActionable(Repository.DataService.Note n, Collaborator currentCollaborator)");
            }
            return result;
        }
Example #4
0
 public static Chord Clone(Repository.DataService.Measure measure, Chord source, Collaborator collaborator)
 {
     Chord obj;
     Measure = measure;
     EditorState.Duration = (double)source.Duration;
     obj = GetOrCreate(measure.Id, (decimal)source.StartTime);
     obj.Id = Guid.NewGuid();
     obj.Measure_Id = measure.Id;
     obj.Duration = source.Duration;
     obj.Key_Id = source.Key_Id;
     obj.Location_X = source.Location_X;
     obj.Location_Y = source.Location_Y;
     obj.Audit = GetAudit();
     obj.StartTime = source.StartTime;
     obj.Status = CollaborationManager.GetBaseStatus();
     var index = 0;
     foreach (Note note in source.Notes)
     {
         Note n = NoteController.Clone(obj.Id, source, Measure, obj.Location_X + (index * 16), note.Location_Y, note, collaborator);
         obj.Notes.Add(n);
         index++;
     }
     Cache.Chords.Add(obj);
     InertChords.Add(obj.Id);
     return obj;
 }