Beispiel #1
0
        public void insertNewPartitureABC(string path, string login, int originalVersionId)
        {
            ABCParser parser    = new ABCParser();
            ABCScore  newScore  = parser.GetABCScore(path);
            partiture partiture = new partiture
            {
                pk_partiture_id = partituresTable.Count() + 1,
                work_number     = newScore.Header.Reference.ToString(),
                title           = newScore.Header.Titles.FirstOrDefault <string>(),
                tempo           = newScore.Header.Tempo,
                meter           = newScore.Header.Meter,
                note_length     = newScore.Header.NoteLength,
                part_key        = newScore.Header.Key,
                filepath        = path,
                version_of      = (originalVersionId > 0) ? originalVersionId : partituresTable.Count() + 1
            };

            if (newScore.Header.Composers.Count() > 0)
            {
                creators creators = new creators
                {
                    pk_creators_id = creatorsTable.Count() + 1,
                    composer       = newScore.Header.Composers.FirstOrDefault(),
                    poet           = newScore.Header.Composers.FirstOrDefault(),
                    authors_of     = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1
                };
                creatorsTable.InsertOnSubmit(creators);
            }
            instruments instrument = new instruments
            {
                pk_instrument_id = instrumentsTable.Count() + 1,
                instrument_name  = newScore.Header.Instrument.ToString(),
                fk_part_in       = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1
            };

            instrumentsTable.InsertOnSubmit(instrument);

            software soft = new software
            {
                pk_software_id       = softwareTable.Count() + 1,
                software_name        = newScore.Header.Encoding.Software,
                encoding_date        = newScore.Header.Encoding.EncodingDate,
                fk_used_for_encoding = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1
            };

            addedby added = new addedby
            {
                id              = addedTable.Count() + 1,
                fk_user_id      = GetUserIdByLogin(login),
                fk_partiture_id = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1,
                added_on        = DateTime.Now
            };

            partituresTable.InsertOnSubmit(partiture);
            softwareTable.InsertOnSubmit(soft);
            addedTable.InsertOnSubmit(added);
            db.SubmitChanges();
        }
Beispiel #2
0
        public void insertNewPartitureXml(string path, string login, int originalVersionId)
        {
            MusicXmlParser parser    = new MusicXmlParser();
            Score          newScore  = parser.GetScore(path);
            partiture      partiture = new partiture
            {
                pk_partiture_id = partituresTable.Count() + 1,
                work_number     = newScore.MovementNumber.ToString(),
                title           = newScore.MovementTitle,
                tempo           = newScore.Parts.FirstOrDefault <Part>().Measures.FirstOrDefault <Measure>().Attributes.Divisions.ToString(),
                meter           = newScore.Parts.FirstOrDefault <Part>().Measures.FirstOrDefault <Measure>().Attributes.Time.Beats.ToString() + "/" + newScore.Parts.FirstOrDefault <Part>().Measures.FirstOrDefault <Measure>().Attributes.Time.Mode,
                note_length     = "1/4",
                part_key        = keyFromFifths(newScore.Parts.FirstOrDefault <Part>().Measures.FirstOrDefault().Attributes.Key.Fifths),
                filepath        = path
            };

            if (originalVersionId == 0)
            {
                partiture.version_of = partituresTable.Count() + 1;
            }
            else
            {
                partiture.version_of = originalVersionId;
            }

            creators creators = new creators();

            creators.pk_creators_id = creatorsTable.Count() + 1;
            creators.composer       = newScore.Identification.Composer;
            creators.poet           = (newScore.Identification.Poet != string.Empty) ? newScore.Identification.Poet : newScore.Identification.Lyricist;
            System.Diagnostics.Debug.Print(creators.composer + creators.poet);
            creators.authors_of = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1;

            if (newScore.Instrument != null)
            {
                if (newScore.Instrument.Name != string.Empty)
                {
                    instruments instrument = new instruments
                    {
                        pk_instrument_id = instrumentsTable.Count() + 1,
                        instrument_name  = newScore.Instrument.Name,
                        fk_part_in       = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1
                    };
                    instrumentsTable.InsertOnSubmit(instrument);
                }
            }
            else
            {
                instruments instrument = new instruments
                {
                    pk_instrument_id = instrumentsTable.Count() + 1,
                    instrument_name  = string.Empty,
                    fk_part_in       = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1
                };
                instrumentsTable.InsertOnSubmit(instrument);
            }

            software soft = new software
            {
                pk_software_id       = softwareTable.Count() + 1,
                software_name        = newScore.Identification.Encoding.Software,
                encoding_date        = newScore.Identification.Encoding.EncodingDate,
                fk_used_for_encoding = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1
            };

            addedby added = new addedby
            {
                id              = addedTable.Count() + 1,
                fk_user_id      = GetUserIdByLogin(login),
                fk_partiture_id = (partituresTable.Count() > 0) ? partituresTable.Count() + 1 : 1,
                added_on        = DateTime.Now
            };

            partituresTable.InsertOnSubmit(partiture);
            creatorsTable.InsertOnSubmit(creators);
            softwareTable.InsertOnSubmit(soft);
            addedTable.InsertOnSubmit(added);

            db.SubmitChanges();
        }
Beispiel #3
0
 partial void Deletecreators(creators instance);
Beispiel #4
0
 partial void Updatecreators(creators instance);
Beispiel #5
0
 partial void Insertcreators(creators instance);
Beispiel #6
0
 private void detach_creators(creators entity)
 {
     this.SendPropertyChanging();
     entity.partiture = null;
 }
Beispiel #7
0
 private void attach_creators(creators entity)
 {
     this.SendPropertyChanging();
     entity.partiture = this;
 }