Esempio n. 1
0
		public IScore FromXml(MindTouch.Xml.XDoc aXml)
		{
            XScore xscore = new XScore(aXml);
            JScore js = new JScore();
            js["codageParIntervalle"] = xscore.GetCodageParIntervalle();
            js["codageMelodiqueRISM"] = xscore.GetCodageMelodiqueRISM();
            js["verses"] = xscore.GetText();
            js["title"] = xscore.MovementTitle;
            js["composer"] = xscore.Identification.Composer;
            return js;
		}
		public void ConvertLilyToCodeMustBeOk()
		{
			XDoc doc = XDocFactory.From(File.OpenRead(@"G:\test.xml"), MimeType.XML);
			string lily = "c' d' e' f' dis'";
			XScore score = new XScore(doc);
			string codage = score.GetCodageMelodiqueRISM();
			string codage2 = score.GetCodageParIntervalle();
			string code = Context.Current.Instance.IndexController.LilyToCodageMelodiqueRISM(lily);
			string code2 = Context.Current.Instance.IndexController.LilyToCodageParIntervalles(lily);
		}
Esempio n. 3
0
		private Yield AttachMusicXmlHelper(IScore aScore, XDoc aMusicXmlDoc, bool overwriteMusicXmlValues, Result<IScore> aResult)
		{
			XScore musicXml = new XScore(aMusicXmlDoc);
			bool hasNotes = false;
			foreach (var p in musicXml.Parts)
			{
				foreach (var m in p.Measures)
				{
					if (m.Notes.Count() > 0)
					{
						hasNotes = true;
						break;
					}
				}
				if(hasNotes)
					break;
			}

			if(!hasNotes)
			{
				aResult.Return(aScore);
				yield break;
			}


			if (overwriteMusicXmlValues)
			{
				aScore.CodageMelodiqueRISM = musicXml.GetCodageMelodiqueRISM();
				aScore.CodageParIntervalles = musicXml.GetCodageParIntervalle();
				//aScore.Title = musicXml.MovementTitle;
				//aScore.Composer = musicXml.Identification.Composer;
				aScore.Verses = musicXml.GetText();
			}

			Result<IScore> result = new Result<IScore>();
			if (aScore.Id != null)
			{
				yield return Update(aScore.Id, aScore.Rev, aScore, result);
			}
			else
			{
				yield return Insert(aScore, result);
			}

			using(TemporaryFile inputFile = new TemporaryFile(".xml",false))
			using(TemporaryFile outputFile = new TemporaryFile(".png",false))
			{
				theLogger.Info("Saving xdoc to " + inputFile.Path);
				File.Delete(inputFile.Path);
				aMusicXmlDoc.Save(inputFile.Path);
				theLogger.Info("XDoc saved");
				theLogger.Info("Getting Converter and converting");
				//yield return Context.Current.Instance.SourceController.Exists("bla", new Result<bool>());
				IList<string> pngsFilePath = Context.Current.Instance.ConverterFactory.GetConverter(MimeType.PNG).Convert(inputFile.Path, outputFile.Path);
				int i = 1;
				foreach (string pngFile in pngsFilePath)
				{
					using(Stream pngStream = File.OpenRead(pngFile))
					{
						yield return AddAttachment(result.Value.Id, pngStream,pngStream.Length, "$partition" + i + ".png", new Result<bool>());
					}
					File.Delete(pngFile);
					i++;
				}
			}
			//attach music xml to the created /updated score
			using(Stream stream = new MemoryStream(aMusicXmlDoc.ToBytes()))
			{
				yield return AddAttachment(result.Value.Id, stream,stream.Length, "$musicxml.xml", new Result<bool>());
			}
			aResult.Return(result.Value);
		}
Esempio n. 4
0
		public Result<IScore> AttachMusicXml(IScore aScore, MindTouch.Xml.XDoc aMusicXmlDoc, bool overwriteMusicXmlValues, Result<IScore> aResult)
        {
            if (!overwriteMusicXmlValues)
            {
				XScore musicXml = new XScore(aMusicXmlDoc);
				aScore.CodageMelodiqueRISM = musicXml.GetCodageMelodiqueRISM();
				aScore.CodageParIntervalles = musicXml.GetCodageParIntervalle();
				aScore.Title = musicXml.MovementTitle;
				aScore.Composer = musicXml.Identification.Composer;
				aScore.Verses = musicXml.GetText();
            }
            score = aScore;
			attachment = new MemoryStream(aMusicXmlDoc.ToBytes());
            aResult.Return(score);
            return aResult;
        }