Exemple #1
0
        private static void AddSongToFluro(Fluro.RootObject newsong, List <Elvanto.File> files)
        {
            List <string> chordchartids = new List <string>();
            List <string> videoids      = new List <string>();

            // add files
            // first search to see if it already exists
            foreach (Elvanto.File file in files)
            {
                if (file.type == "Video")
                {
                    if (file.content.Left(7) == "<iframe")
                    {
                        videoids.Add(FindVideoFromIFrame(file.content));
                    }
                    else
                    {
                        videoids.Add(AddVideoToFluro(file.content));
                    }
                }
                else
                {
                    // add new sheet
                    //download existing file
                    HttpClient dlclient = new HttpClient();

                    HttpResponseMessage response = new HttpResponseMessage();
                    if (file.content.Left(7) == "<iframe")
                    {
                        videoids.Add(FindVideoFromIFrame(file.content));
                    }
                    else
                    {
                        response = dlclient.GetAsync(file.content).Result;
                        if (response.IsSuccessStatusCode)
                        {
                            chordchartids.Add(Util.UploadFiletoFluro(response, file, FluroCreativeRealm, FluroFileUploadURI));
                        }
                    }
                }
            }

            //Add SheetMusic to Song
            newsong.data.sheetMusic = new List <SheetMusic>();
            foreach (string sheetid in chordchartids)
            {
                SheetMusic sheet = new SheetMusic
                {
                    _id = sheetid
                };
                newsong.data.sheetMusic.Add(sheet);
            }
            newsong.data.videos = new List <object>();
            foreach (string videoid in videoids)
            {
                newsong.data.videos.Add(videoid);
            }


            newsong.realms = new List <Realm>();
            Realm creative = new Realm
            {
                _id = FluroCreativeRealm
            };

            newsong.realms.Add(creative);
            newsong.definition = "song";
            Util.UploadToFluroReturnJson(FluroSongURI, "POST", JsonConvert.SerializeObject(newsong));
        }
Exemple #2
0
        static void MigrateSongs()
        {
            string stringFullOfJson = Util.UploadToElvantoReturnJson(ElvantoSongURI, "POST", "{\"files\": true}");

            Fluro.Realm realm = new Fluro.Realm
            {
                _id = FluroCreativeRealm
            };



            SongRootObject rootobj = JsonConvert.DeserializeObject <SongRootObject>(stringFullOfJson);


            foreach (Song song in rootobj.songs.song)
            {
                logger.Info($"{song.id} {song.title}");
                Fluro.RootObject newsong = new Fluro.RootObject
                {
                    title  = song.title,
                    realms = new List <Fluro.Realm>()
                };
                newsong.realms.Add(realm);
                newsong.data = new Fluro.Data
                {
                    artist = song.artist,
                    album  = song.album,
                    ccli   = song.number
                };
                if (song.status == "0")
                {
                    newsong.status = "archived";
                }
                else
                {
                    newsong.status = "active";
                }

                List <Elvanto.File> elvantofiles = new List <Elvanto.File>();

                string filesstring = song.files.ToString();

                if (filesstring.Length >= 3)
                {
                    List <Elvanto.File> files = Util.GetFirstInstance <List <Elvanto.File> >("file", filesstring);
                    foreach (Elvanto.File file in files)
                    {
                        elvantofiles.Add(file);
                    }
                }



                string arrangementresult = Util.UploadToElvantoReturnJson(ElvantoSongArrangementURI, "POST", "{\"song_id\": \"" + song.id + "\",    \"files\": true}");

                var rootArrangement = JsonConvert.DeserializeObject <Elvanto.Arrangement.ArrangementRootObject>(arrangementresult);
                newsong.data.lyrics = new List <object>();
                foreach (Elvanto.Arrangement.Arrangement arrangement in rootArrangement.arrangements.arrangement)
                {
                    newsong.data.lyrics.Add(arrangement.lyrics);
                    if (arrangement.files.ToString().Length > 2)
                    {
                        ProcessIndividualArrangementFiles(arrangement.id, elvantofiles);
                        foreach (Elvanto.File flz in elvantofiles)
                        {
                            logger.Info($"{flz.title} {flz.content}");
                        }
                    }
                }

                AddSongToFluro(newsong, elvantofiles);
            }
        }