Beispiel #1
0
        private ArtistsAdminFile LoadArtistsAdminFile()
        {
            string sPathDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
            string sPathRepoFile  = sPathDirectory + "\\Files\\Repository\\ArtistsAdminFile.xml";

            artistsAdminFile = FastSerialisation.Instance().GetSaveStructInCurrentDirectory <ArtistsAdminFile>(sPathRepoFile);
            if (artistsAdminFile == null)
            {
                artistsAdminFile = new ArtistsAdminFile()
                {
                    listArtistAdminItems = new List <ArtistAdminItem>()
                };
            }
            return(artistsAdminFile);
        }
Beispiel #2
0
        public DispoEntityArtists GetEntityArtists(ParamEntityArtists param)
        {
            var artistsAdminFile = LoadArtistsAdminFile();

            Idinc = 0;
            DispoEntityArtists rep = new DispoEntityArtists()
            {
                listEntityArtist = new List <EntityArtist>()
            };

            if (globalLinePayLoad != null && globalLinePayLoad.listLine != null)
            {
                foreach (var v in globalLinePayLoad.listLine)
                {
                    string artist      = v.Artist.Trim();
                    var    artistExist = rep.listEntityArtist.Where(c => c.Name == artist).FirstOrDefault();
                    if (artistExist == null)
                    {
                        artistExist = new EntityArtist()
                        {
                            Id = Idinc++, Name = v.Artist, Source = eSource.EXCEL, Payable = ePayable.GROUP, Pourcent = 0, ListRelationEntityArtist = new List <RelationEntityArtist>(), ParentNames = new List <string>(), IdParamAdmin = -1
                        };
                        rep.listEntityArtist.Add(artistExist);
                    }
                }


                List <EntityArtist> listNewArtist = new List <EntityArtist>();

                foreach (var item in rep.listEntityArtist)
                {
                    string sName = item.Name;
                    sName = sName.Replace("Feat.", ";");
                    sName = sName.Replace("feat.", ";");
                    sName = sName.Replace("Feat", ";");
                    sName = sName.Replace("feat", ";");
                    sName = sName.Replace("&", ";");

                    var listArtiste = sName.Split(';').ToList();
                    int cptOrdre    = 0;
                    foreach (var v in listArtiste)
                    {
                        string newArt   = v.Trim();
                        var    newExist = listNewArtist.Where(c => c.Name == newArt).FirstOrDefault();
                        if (newExist == null)
                        {
                            newExist = new EntityArtist()
                            {
                                Name = newArt, ParentNames = new List <string>(), Id = Idinc++, Source = eSource.ANALYSE_FEAT, ListRelationEntityArtist = new List <RelationEntityArtist>(), IdParamAdmin = -1
                            };
                            listNewArtist.Add(newExist);
                        }
                        item.ListRelationEntityArtist.Add(new RelationEntityArtist()
                        {
                            IdEntity = newExist.Id, Name = newExist.Name, OrdreRelation = cptOrdre, PourcentageFeat = cptOrdre == 0 ? 100 : 0
                        });
                        newExist.ParentNames.Add(item.Name);
                        cptOrdre++;
                    }
                }


                artistsAdminFile = null;

                int IdMax = 0;
                if (artistsAdminFile != null && artistsAdminFile.listArtistAdminItems != null && artistsAdminFile.listArtistAdminItems.Count > 0)
                {
                    var last = artistsAdminFile.listArtistAdminItems.Last();
                    if (last != null)
                    {
                        IdMax = last.IdArtist + 1;
                    }
                }
                else
                {
                    artistsAdminFile = new ArtistsAdminFile()
                    {
                        listArtistAdminItems = new List <ArtistAdminItem>()
                    };
                }

                foreach (var newArt2 in listNewArtist)
                {
                    newArt2.sPbAscci = "";
                    string rawName = newArt2.Name.Trim().ToLower();
                    for (int i = 0; i < rawName.Length; i++)
                    {
                        if (rawName[i] < 32 || rawName[i] > 122)
                        {
                            newArt2.sPbAscci += "Ascci[" + ((int)rawName[i]).ToString() + "]:" + rawName[i];
                            rawName           = rawName.Replace(rawName[i], ' ');
                        }
                    }
                    newArt2.RawName = rawName;
                }


                foreach (var newArt2 in listNewArtist)
                {
                    var listAlias = listNewArtist.Where(c => c.RawName == newArt2.RawName).Select(c => c.Name).ToList();
                    int CptMatch  = 0;

                    if (newArt2.Name == "Devi Reed")
                    {
                    }

                    ArtistAdminItem selectedArtistAdminItems = null;
                    foreach (var vAdmin in artistsAdminFile.listArtistAdminItems)
                    {
                        if (vAdmin.listAlias != null)
                        {
                            foreach (var v in vAdmin.listAlias)
                            {
                                foreach (var v1 in listAlias)
                                {
                                    if (v == v1)
                                    {
                                        CptMatch++;
                                        selectedArtistAdminItems = vAdmin;
                                    }
                                }
                            }
                        }
                    }
                    if (selectedArtistAdminItems == null)
                    {
                        selectedArtistAdminItems = new ArtistAdminItem()
                        {
                            ArtistName = listAlias[0], IdArtist = IdMax++, listAlias = listAlias, LoginArtist = "", PasswordArtist = "", PourcentProdVsArtisteBase = 0
                        };
                        artistsAdminFile.listArtistAdminItems.Add(selectedArtistAdminItems);
                    }
                    newArt2.IdParamAdmin = selectedArtistAdminItems.IdArtist;
                }
                rep.listEntityArtist.AddRange(listNewArtist);
            }
            SaveArtistsAdminFile();
            rep.artistsAdminFile = artistsAdminFile;

            return(rep);
        }