/// <summary>
        /// Check if WorkArtist object already exists with WorkArtists.
        /// </summary>
        /// <param name="workArtistID"></param>
        /// <returns></returns>
        internal static WorkArtist GetWorkArtistByID(int artistID, int workID)
        {
            WorkArtist workArtist = BsoArchiveEntities.Current.WorkArtists.FirstOrDefault(wa => wa.ArtistID == artistID && wa.WorkID == workID) ??
                                    WorkArtist.NewWorkArtist();

            return(workArtist);
        }
        public void UpdateWorkArtistTest()
        {
            WorkArtist testArtist = WorkArtist.GetWorkArtistByID(-1, -1);
            if (testArtist.IsNew)
            {
                testArtist.ArtistID = -1;
                testArtist.WorkID = -1;
            }

            testArtist.Artist.ArtistFirstName = "Adage";
            BsoArchiveEntities.Current.Save();

            WorkArtist testWorkArtist = new WorkArtist();
            var workArtistId = Helper.CreateXElement(Constants.WorkArtist.workArtistIDElement, "-1");
            var workArtistFirstName = Helper.CreateXElement(Constants.WorkArtist.workArtistFirstNameElement, "Test");
            var workArtistItem = new System.Xml.Linq.XElement(Constants.WorkArtist.workArtistElement, workArtistId, workArtistFirstName);
            var workID = new System.Xml.Linq.XElement(Constants.Work.workIDElement, "-1");
            var workGroupID = new System.Xml.Linq.XElement(Constants.Work.workGroupIDElement, "-1");
            var workItem = new System.Xml.Linq.XElement(Constants.Work.workElement, workID, workGroupID, workArtistItem);
            var eventItem = new System.Xml.Linq.XElement(Constants.Event.eventElement, workItem);

            System.Xml.Linq.XDocument doc = new System.Xml.Linq.XDocument(eventItem);

            testWorkArtist.UpdateData(doc, "WorkArtistFirstName", "workArtistFirstname");

            Assert.IsTrue(testArtist.Artist.ArtistFirstName == "Test");
            BsoArchiveEntities.Current.DeleteObject(testWorkArtist);
            BsoArchiveEntities.Current.DeleteObject(testArtist);
            BsoArchiveEntities.Current.DeleteObject(Work.GetWorkByID(-1));
            BsoArchiveEntities.Current.Save();
        }
        /// <summary>
        /// Sets the data passed to the WorkArtist object
        /// </summary>
        /// <param name="workArtistID"></param>
        /// <param name="workArtist"></param>
        /// <param name="workArtistNote"></param>
        /// <param name="workArtistStatus"></param>
        /// <param name="workArtistStatusID"></param>
        /// <returns></returns>
        private static WorkArtist SetWorkArtistData(WorkArtist workArtist, string workArtistNote, int workArtistStatus, int workArtistStatusID)
        {
            workArtist.WorkArtistStatus   = workArtistStatus;
            workArtist.WorkArtistStatusID = workArtistStatusID;
            workArtist.WorkArtistNote     = workArtistNote;

            return(workArtist);
        }
Exemple #4
0
        /// <summary>
        /// Add WorkArtist object to WorkArtists in Work
        /// </summary>
        /// <param name="work"></param>
        /// <param name="artist"></param>
        /// <remarks>
        /// Checks to see if the Work object's collection of WorkArtists contains
        /// the WorkArtist object passed. If yes then just return, otherwise Add.
        /// </remarks>
        internal static void AddWorkArtist(Work work, WorkArtist artist)
        {
            var wArtist = work.WorkArtists.FirstOrDefault(wa => wa.ArtistID == artist.ArtistID && wa.WorkID == work.WorkID);

            if (wArtist != null)
            {
                return;
            }

            work.WorkArtists.Add(artist);
        }
        /// <summary>
        /// Returns a WorkArtist object from a workItem XElement node
        /// </summary>
        /// <param name="node"></param>
        /// <remarks>
        /// Takes a XElement node and extracts the WorkArtist information
        /// and creates a new WorkArtist object and returns it.
        /// </remarks>
        /// <returns></returns>
        public static WorkArtist GetWorkArtistFromNode(System.Xml.Linq.XElement node)
        {
            if (node == null || node.Element(Constants.WorkArtist.workArtistIDElement) == null)
            {
                return(null);
            }

            int workArtistID = 0;

            int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistIDElement), out workArtistID);

            WorkArtist workArtist = WorkArtist.NewWorkArtist();

            return(BuildWorkArtist(node, workArtistID, workArtist));
        }
Exemple #6
0
        /// <summary>
        /// Add workArtists from XElement workItem and add to Work object
        /// </summary>
        /// <param name="node"></param>
        /// <param name="work"></param>
        /// <remarks>
        /// Gets the WorkArtist objects information from the XElement node and
        /// gets the WorkArtist object. Then adds it to Work's WorkArtists collection.
        /// </remarks>
        /// <returns></returns>
        public static Work GetWorkArtists(System.Xml.Linq.XElement node, Work work)
        {
            IEnumerable <System.Xml.Linq.XElement> workArtistElements = node.Descendants("workArtist");

            foreach (System.Xml.Linq.XElement workArtist in workArtistElements)
            {
                WorkArtist artist = WorkArtist.GetWorkArtistFromNode(workArtist);

                if (artist == null)
                {
                    continue;
                }

                Work.AddWorkArtist(work, artist);
            }
            return(work);
        }
        private static void CreateWorkArtistInstrument(WorkArtist workArtist, int instrumentID, string workArtistInstrument, string workArtistInstrument2)
        {
            if (String.IsNullOrEmpty(workArtistInstrument) && String.IsNullOrEmpty(workArtistInstrument2))
            {
                return;
            }

            Instrument instrument = Instrument.GetInstrumentByNames(workArtistInstrument, workArtistInstrument2);

            if (instrument.IsNew)
            {
                instrument.Instrument1  = workArtistInstrument;
                instrument.Instrument2  = workArtistInstrument2;
                instrument.InstrumentID = instrumentID;
            }

            workArtist.Instrument = instrument;
        }
        /// <summary>
        /// Updates the existing database WorkArtist on the column name using the
        /// XML document parsed using the tagName.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="columnName"></param>
        /// <param name="tagName"></param>
        public void UpdateData(System.Xml.Linq.XDocument doc, string columnName, string tagName)
        {
            IEnumerable <System.Xml.Linq.XElement> eventElements = doc.Descendants(Constants.Event.eventElement);

            foreach (System.Xml.Linq.XElement eventElement in eventElements)
            {
                var workElements = eventElement.Descendants(Constants.Work.workElement);
                foreach (var workElement in workElements)
                {
                    Work workItem = Work.GetWorkFromNode(workElement);

                    IEnumerable <System.Xml.Linq.XElement> workArtistElements = workElement.Descendants(Constants.WorkArtist.workArtistElement);
                    foreach (var workArtistElement in workArtistElements)
                    {
                        int artistID = 0;
                        int.TryParse((string)workArtistElement.GetXElement(Constants.WorkArtist.workArtistIDElement), out artistID);

                        WorkArtist updateWorkArtist = WorkArtist.GetWorkArtistByID(artistID, workItem.WorkID);

                        updateWorkArtist = WorkArtist.BuildWorkArtist(workArtistElement, artistID, updateWorkArtist);

                        if (updateWorkArtist == null)
                        {
                            continue;
                        }

                        object newValue = (string)workArtistElement.GetXElement(tagName);

                        BsoArchiveEntities.UpdateObject(updateWorkArtist, newValue, columnName);

                        BsoArchiveEntities.UpdateObject(updateWorkArtist.Artist, newValue, columnName);

                        BsoArchiveEntities.UpdateObject(updateWorkArtist.Instrument, newValue, columnName);

                        BsoArchiveEntities.Current.Save();
                    }
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Update OPAS Data
        /// </summary>
        public void UpdateOPASData(XDocument loadDocument)
        {
            var recordsToUpdate = BsoArchiveEntities.Current.OPASUpdates.Where(d => !d.HasBeenUpdated);
            var entitesToUpdate = recordsToUpdate.GroupBy(d => d.TableName);

            foreach (var entity in entitesToUpdate)
            {
                Log.Debug(string.Format("Started update processing of entity: {0}", entity.Key));
                string columnName = entity.FirstOrDefault().ColumnName;
                string tagName    = entity.FirstOrDefault().TagName;
                switch ((Table)Enum.Parse(typeof(Table), entity.Key.ToUpper()))
                {
                case Table.EVENT:
                    opasData = Event.NewEvent();
                    break;

                case Table.ARTIST:
                    opasData = Artist.NewArtist();
                    break;

                case Table.EVENTTYPE:
                    opasData = EventType.NewEventType();
                    break;

                case Table.CONDUCTOR:
                    opasData = Conductor.NewConductor();
                    break;

                case Table.ORCHESTRA:
                    opasData = Orchestra.NewOrchestra();
                    break;

                case Table.PARTICIPANT:
                    opasData = Participant.NewParticipant();
                    break;

                case Table.PROJECT:
                    opasData = Project.NewProject();
                    break;

                case Table.SEASON:
                    opasData = Season.NewSeason();
                    break;

                case Table.EVENTTYPEGROUP:
                    opasData = EventTypeGroup.NewEventTypeGroup();
                    break;

                case Table.VENUE:
                    opasData = Venue.NewVenue();
                    break;

                case Table.WORK:
                    opasData = Work.NewWork();
                    break;

                case Table.WORKARTIST:
                    opasData = WorkArtist.NewWorkArtist();
                    break;
                }
                opasData.UpdateData(loadDocument, columnName, tagName);
                entity.FirstOrDefault().HasBeenUpdated = true;
                BsoArchiveEntities.Current.Detach(opasData);

                Log.Debug(string.Format("Finished update processing of entity: {0}", entity.Key));
            }
            BsoArchiveEntities.Current.Save();
        }
        private static WorkArtist BuildWorkArtist(System.Xml.Linq.XElement node, int workArtistID, WorkArtist workArtist)
        {
            Artist artist = Artist.GetArtistByID(workArtistID);
            if (artist.IsNew)
            {
                artist.ArtistID = workArtistID;
                artist.ArtistLastName = (string)node.GetXElement(Constants.WorkArtist.workArtistLastNameElement);
                artist.ArtistFirstName = (string)node.GetXElement(Constants.WorkArtist.workArtistFirstNameElement);
                artist.ArtistName4 = (string)node.GetXElement(Constants.WorkArtist.workArtistName4Element);
                artist.ArtistName5 = (string)node.GetXElement(Constants.WorkArtist.workArtistName5Element);
            }
            workArtist.Artist = artist;

            int workArtistStatus, workArtistStatusID, instrumentID;

            int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistInstrumentIDElement), out instrumentID);
            int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistStatusElement), out workArtistStatus);
            int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistStatusIDElement), out workArtistStatusID);
            string workArtistNote = (string)node.GetXElement(Constants.WorkArtist.workArtistNoteElement);

            workArtist = SetWorkArtistData(workArtist, workArtistNote, workArtistStatus, workArtistStatusID);

            string workArtistInstrument = (string)node.GetXElement(Constants.WorkArtist.workArtistInstrumentElement);
            string workArtistInstrument2 = (string)node.GetXElement(Constants.WorkArtist.workArtistInstrument2Element);

            CreateWorkArtistInstrument(workArtist, instrumentID, workArtistInstrument, workArtistInstrument2);

            return workArtist;
        }
        /// <summary>
        /// Sets the data passed to the WorkArtist object
        /// </summary>
        /// <param name="workArtistID"></param>
        /// <param name="workArtist"></param>
        /// <param name="workArtistNote"></param>
        /// <param name="workArtistStatus"></param>
        /// <param name="workArtistStatusID"></param>
        /// <returns></returns>
        private static WorkArtist SetWorkArtistData(WorkArtist workArtist, string workArtistNote, int workArtistStatus, int workArtistStatusID)
        {
            workArtist.WorkArtistStatus = workArtistStatus;
            workArtist.WorkArtistStatusID = workArtistStatusID;
            workArtist.WorkArtistNote = workArtistNote;

            return workArtist;
        }
        private static void CreateWorkArtistInstrument(WorkArtist workArtist, int instrumentID, string workArtistInstrument, string workArtistInstrument2)
        {
            if (String.IsNullOrEmpty(workArtistInstrument) && String.IsNullOrEmpty(workArtistInstrument2))
                return;

            Instrument instrument = Instrument.GetInstrumentByNames(workArtistInstrument, workArtistInstrument2);

            if (instrument.IsNew)
            {
                instrument.Instrument1 = workArtistInstrument;
                instrument.Instrument2 = workArtistInstrument2;
                instrument.InstrumentID = instrumentID;
            }

            workArtist.Instrument = instrument;
        }
        public static WorkArtist NewWorkArtist()
        {
            WorkArtist newObject = new WorkArtist();

            BsoArchiveEntities.Current.AddToWorkArtists(newObject);
            BsoArchiveEntities.SetDefaultValue(newObject);
            return newObject;
        }
        private static WorkArtist BuildWorkArtist(System.Xml.Linq.XElement node, int workArtistID, WorkArtist workArtist)
        {
            Artist artist = Artist.GetArtistByID(workArtistID);

            if (artist.IsNew)
            {
                artist.ArtistID        = workArtistID;
                artist.ArtistLastName  = (string)node.GetXElement(Constants.WorkArtist.workArtistLastNameElement);
                artist.ArtistFirstName = (string)node.GetXElement(Constants.WorkArtist.workArtistFirstNameElement);
                artist.ArtistName4     = (string)node.GetXElement(Constants.WorkArtist.workArtistName4Element);
                artist.ArtistName5     = (string)node.GetXElement(Constants.WorkArtist.workArtistName5Element);
            }
            workArtist.Artist = artist;

            int workArtistStatus, workArtistStatusID, instrumentID;

            int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistInstrumentIDElement), out instrumentID);
            int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistStatusElement), out workArtistStatus);
            int.TryParse((string)node.GetXElement(Constants.WorkArtist.workArtistStatusIDElement), out workArtistStatusID);
            string workArtistNote = (string)node.GetXElement(Constants.WorkArtist.workArtistNoteElement);


            workArtist = SetWorkArtistData(workArtist, workArtistNote, workArtistStatus, workArtistStatusID);

            string workArtistInstrument  = (string)node.GetXElement(Constants.WorkArtist.workArtistInstrumentElement);
            string workArtistInstrument2 = (string)node.GetXElement(Constants.WorkArtist.workArtistInstrument2Element);

            CreateWorkArtistInstrument(workArtist, instrumentID, workArtistInstrument, workArtistInstrument2);

            return(workArtist);
        }
 /// <summary>
 /// Create a new WorkArtist object.
 /// </summary>
 /// <param name="workArtistID">Initial value of the WorkArtistID property.</param>
 /// <param name="workID">Initial value of the WorkID property.</param>
 /// <param name="artistID">Initial value of the ArtistID property.</param>
 /// <param name="instrumentID">Initial value of the InstrumentID property.</param>
 /// <param name="workArtistNote">Initial value of the WorkArtistNote property.</param>
 /// <param name="workArtistStatus">Initial value of the WorkArtistStatus property.</param>
 /// <param name="workArtistStatusID">Initial value of the WorkArtistStatusID property.</param>
 /// <param name="createdOn">Initial value of the CreatedOn property.</param>
 /// <param name="modifiedOn">Initial value of the ModifiedOn property.</param>
 /// <param name="stamp">Initial value of the Stamp property.</param>
 /// <param name="active">Initial value of the Active property.</param>
 /// <param name="createdBy">Initial value of the CreatedBy property.</param>
 /// <param name="modifiedBy">Initial value of the ModifiedBy property.</param>
 public static WorkArtist CreateWorkArtist(global::System.Int32 workArtistID, global::System.Int32 workID, global::System.Int32 artistID, global::System.Int32 instrumentID, global::System.String workArtistNote, global::System.Int32 workArtistStatus, global::System.Int32 workArtistStatusID, global::System.DateTime createdOn, global::System.DateTime modifiedOn, global::System.Byte[] stamp, global::System.Boolean active, global::System.Int32 createdBy, global::System.Int32 modifiedBy)
 {
     WorkArtist workArtist = new WorkArtist();
     workArtist.WorkArtistID = workArtistID;
     workArtist.WorkID = workID;
     workArtist.ArtistID = artistID;
     workArtist.InstrumentID = instrumentID;
     workArtist.WorkArtistNote = workArtistNote;
     workArtist.WorkArtistStatus = workArtistStatus;
     workArtist.WorkArtistStatusID = workArtistStatusID;
     workArtist.CreatedOn = createdOn;
     workArtist.ModifiedOn = modifiedOn;
     workArtist.Stamp = stamp;
     workArtist.Active = active;
     workArtist.CreatedBy = createdBy;
     workArtist.ModifiedBy = modifiedBy;
     return workArtist;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the WorkArtists EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToWorkArtists(WorkArtist workArtist)
 {
     base.AddObject("WorkArtists", workArtist);
 }
        /// <summary>
        /// Add WorkArtist object to WorkArtists in Work
        /// </summary>
        /// <param name="work"></param>
        /// <param name="artist"></param>
        /// <remarks>
        /// Checks to see if the Work object's collection of WorkArtists contains 
        /// the WorkArtist object passed. If yes then just return, otherwise Add.
        /// </remarks>
        internal static void AddWorkArtist(Work work, WorkArtist artist)
        {
            var wArtist = work.WorkArtists.FirstOrDefault(wa => wa.ArtistID == artist.ArtistID && wa.WorkID == work.WorkID);

            if (wArtist != null) return;

            work.WorkArtists.Add(artist);
        }