Example #1
0
        /// <summary>
        /// Checks existing Orchestra based upon the given ID. If the Orchestra
        /// already exists then return it. Otherwise create a new Orchestra
        /// and return it.
        /// </summary>
        /// <param name="projectID"></param>
        /// <returns></returns>
        internal static Orchestra GetOrchestraByID(int orchestraID)
        {
            Orchestra orchestra = BsoArchiveEntities.Current.Orchestras.FirstOrDefault(o => o.OrchestraID == orchestraID)
                                  ?? Orchestra.NewOrchestra();

            return(orchestra);
        }
Example #2
0
        /// <summary>
        /// Returns a Orchestra object based on the eventOrchestra data passed by the
        /// XElement eventItem element.
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static Orchestra GetOrchestraFromNode(System.Xml.Linq.XElement node)
        {
            System.Xml.Linq.XElement orchestraElement = node.Element(Constants.Orchestra.orchestraElement);
            if (orchestraElement == null || string.IsNullOrEmpty(orchestraElement.GetXElement(Constants.Orchestra.orchestraIDElement)))
            {
                return(null);
            }

            int orchestraID;

            int.TryParse(orchestraElement.GetXElement(Constants.EventRoot + Constants.Orchestra.OrchestraID), out orchestraID);

            Orchestra orchestra = Orchestra.GetOrchestraByID(orchestraID);

            if (!orchestra.IsNew)
            {
                return(orchestra);
            }

            string orchestraName = orchestraElement.GetXElement(Constants.Orchestra.orchestraNameElement);
            string orchestraURL  = orchestraElement.GetXElement(Constants.Orchestra.orchestraURLElement);
            string orchestraNote = orchestraElement.GetXElement(Constants.Orchestra.orchestraNotesElement);

            orchestra = SetOrchestraData(orchestraID, orchestra, orchestraName, orchestraURL, orchestraNote);

            return(orchestra);
        }
        private static Orchestra SetOrchestraData(int orchestraID, Orchestra orchestra, string orchestraName, string orchestraURL, string orchestraNote)
        {
            orchestra.OrchestraID = orchestraID;
            orchestra.OrchestraName = orchestraName;
            orchestra.OrchestraURL = orchestraURL;
            orchestra.OrchestraNote = orchestraNote;

            return orchestra;
        }
Example #4
0
        private static Orchestra SetOrchestraData(int orchestraID, Orchestra orchestra, string orchestraName, string orchestraURL, string orchestraNote)
        {
            orchestra.OrchestraID   = orchestraID;
            orchestra.OrchestraName = orchestraName;
            orchestra.OrchestraURL  = orchestraURL;
            orchestra.OrchestraNote = orchestraNote;

            return(orchestra);
        }
Example #5
0
        /// <summary>
        /// Create EventOrchestra object
        /// </summary>
        /// <param name="eventItem"></param>
        /// <remarks>
        /// Takes an Event object along with an XElement node and returns
        /// an EventOrchestra object based on the Event object and the Orchestra
        /// object created from the XElement node.
        /// </remarks>
        /// <param name="node"></param>
        public Orchestra AddEventOrchestra(Event eventItem, XElement node)
        {
            Log.Debug("Started adding event orchestra.");
            Orchestra orchestraItem = Orchestra.GetOrchestraFromNode(node);

            if (orchestraItem != null && orchestraItem.OrchestraID != 0)
            {
                eventItem.Orchestra = orchestraItem;
            }

            Log.Debug("Finished adding event orchestra.");
            return(orchestraItem);
        }
Example #6
0
        /// <summary>
        /// Updates the existing database Orchestra 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 element in eventElements)
            {
                Orchestra updateOrchestra = Orchestra.GetOrchestraFromNode(element);

                if (updateOrchestra == null)
                {
                    continue;
                }

                System.Xml.Linq.XElement orchestraNode = element.Element(Constants.Orchestra.orchestraElement);

                object newValue = orchestraNode.GetXElement(tagName);

                BsoArchiveEntities.UpdateObject(updateOrchestra, newValue, columnName);
            }
        }
 /// <summary>
 /// Create a new Orchestra object.
 /// </summary>
 /// <param name="orchestraID">Initial value of the OrchestraID property.</param>
 /// <param name="orchestraName">Initial value of the OrchestraName property.</param>
 /// <param name="orchestraURL">Initial value of the OrchestraURL property.</param>
 /// <param name="orchestraNote">Initial value of the OrchestraNote 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 Orchestra CreateOrchestra(global::System.Int32 orchestraID, global::System.String orchestraName, global::System.String orchestraURL, global::System.String orchestraNote, global::System.DateTime createdOn, global::System.DateTime modifiedOn, global::System.Byte[] stamp, global::System.Boolean active, global::System.Int32 createdBy, global::System.Int32 modifiedBy)
 {
     Orchestra orchestra = new Orchestra();
     orchestra.OrchestraID = orchestraID;
     orchestra.OrchestraName = orchestraName;
     orchestra.OrchestraURL = orchestraURL;
     orchestra.OrchestraNote = orchestraNote;
     orchestra.CreatedOn = createdOn;
     orchestra.ModifiedOn = modifiedOn;
     orchestra.Stamp = stamp;
     orchestra.Active = active;
     orchestra.CreatedBy = createdBy;
     orchestra.ModifiedBy = modifiedBy;
     return orchestra;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Orchestras EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrchestras(Orchestra orchestra)
 {
     base.AddObject("Orchestras", orchestra);
 }
Example #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();
        }
        public static Orchestra NewOrchestra()
        {
            Orchestra newObject = new Orchestra();

            BsoArchiveEntities.Current.AddToOrchestras(newObject);
            BsoArchiveEntities.SetDefaultValue(newObject);
            return newObject;
        }