Exemple #1
0
        private bool LoadSeanse(string directory)
        {
            bool   result    = false;
            Seanse newSeanse = null;

            try
            {
                SeanseAdding.Invoke(this, directory);
                newSeanse = new Seanse(directory, IoCContainer.Settings.Configuration);
                Seanses.Add(newSeanse);
                result = true;
            }
            catch (Seanse.LogFileNotFoundException e)
            {
                logger.LogMessage(e.FileName + " не найден", LogLevel.Warning);
            }
            catch (Exception e)
            {
                logger.LogMessage(e.ToString() + " " + e.Message, LogLevel.Error);
            }
            finally
            {
                SeanseAdded.Invoke(this, newSeanse);
            }
            return(result);
        }
Exemple #2
0
 public void AddSeansesFromVentursFile(List <string> files)
 {
     LoadingStarted.Invoke(this);
     foreach (string file in files)
     {
         List <Channel> channels = GetChannelsFromVentursFile(file);
         Parallel.ForEach(channels, channelInfo =>
         {
             string pathPartToPaste  = Path.GetDirectoryName(file);
             string pathPartToDelete = channelInfo.Directory.Substring(0, channelInfo.Directory.IndexOf("riClient") + 8);
             string channelDirectory = channelInfo.Directory.Replace(pathPartToDelete, pathPartToPaste).ToLower();
             Seanse currentSeanse    = Seanses.FirstOrDefault(x => x.Directory.FullName.ToLower() == channelDirectory);
             if (currentSeanse == null)
             {
                 lock (Seanses)
                 {
                     LoadSeanse(channelDirectory);
                 }
             }
             if (currentSeanse != null)
             {
                 currentSeanse.ChannelInfo = channelInfo;
             }
         });
     }
     LoadingEnded(this);
 }
Exemple #3
0
 private void RemoveExcessSeanses(List <string> files)
 {
     lock (Seanses)
     {
         // Пути из файла last.lf
         List <string> ventursDirs = new List <string>();
         foreach (string file in files)
         {
             List <Channel> channels         = GetChannelsFromVentursFile(file);
             string         pathPartToPaste  = Path.GetDirectoryName(file);
             string         pathPartToDelete = channels[0].Directory.Substring(0, channels[0].Directory.IndexOf("riClient") + 8);
             string         channelDirectory = channels[0].Directory.Replace(pathPartToDelete, pathPartToPaste).ToLower();
             ventursDirs.AddRange(channels.Where(x => x.Trakt == "slew" || x.Trakt == "link11").Select(x => x.Directory.Replace(pathPartToDelete, pathPartToPaste).ToLower()).ToList());
         }
         // Список сеансов, не содержащихся в last.lf
         List <Seanse> seansesToRemove = new List <Seanse>();
         foreach (Seanse seanse in Seanses)
         {
             if (!ventursDirs.Contains(seanse.Directory.FullName.ToLower()))
             {
                 seansesToRemove.Add(seanse);
             }
         }
         foreach (Seanse seanseToRemove in seansesToRemove)
         {
             if (Seanses.Remove(seanseToRemove))
             {
                 SeanseRemoved.Invoke(this, seanseToRemove);
             }
         }
     }
 }
Exemple #4
0
 private void SeanseManager_SeanseRemoved(object sender, Seanse seanse)
 {
     window.Dispatcher.BeginInvoke((ThreadStart) delegate()
     {
         Seanses.Remove(seanse);
     });
 }
Exemple #5
0
 public void RemoveSeanse(Seanse seanse)
 {
     lock (Seanses)
     {
         if (Seanses.Remove(seanse))
         {
             SeanseRemoved(this, seanse);
         }
     }
 }
Exemple #6
0
 public void RemoveAllSeanses()
 {
     lock (Seanses)
     {
         while (Seanses.Any())
         {
             Seanse removedSeanse = Seanses[0];
             Seanses.RemoveAt(0);
             SeanseRemoved(this, removedSeanse);
         }
     }
 }
Exemple #7
0
 private void SeanseManager_SeanseAdded(object sender, Seanse newSeanse)
 {
     if (newSeanse != null)
     {
         newSeanse.WorkingStart += Seanse_WorkingStart;
         newSeanse.ActiveStart  += Seanse_ActiveStart;
         newSeanse.WorkingEnd   += Seanse_WorkingEnd;
         newSeanse.ActiveEnd    += newSeanse_ActiveEnd;
         window.Dispatcher.BeginInvoke((ThreadStart) delegate()
         {
             Seanses.Add(newSeanse);
             SelectedSeanse = newSeanse;
         });
     }
 }
Exemple #8
0
        public void AddAllSeansesFromFolder(string path)
        {
            lock (Seanses)
            {
                DirectoryInfo   di        = new DirectoryInfo(path);
                DirectoryInfo[] childDirs = di.GetDirectories();

                List <string> dirsInStock = Seanses.Select(x => x.Directory.FullName.ToLower()).ToList();
                LoadingStarted.Invoke(this);
                Parallel.ForEach(childDirs, directory =>
                {
                    if (!dirsInStock.Contains(directory.FullName.ToLower()))
                    {
                        LoadSeanse(directory.FullName);
                    }
                });
                LoadingEnded.Invoke(this);
            }
        }