예제 #1
0
        public static string GetSongName(DownloadSettings downSetting, SongResult songResult)
        {
            if (downSetting.EnableUserSetting)
            {
                return(downSetting.UserName.Replace("%ARTIST%", songResult.ArtistName)
                       .Replace("%INDEX%", songResult.TrackNum.ToString()).Replace("%SONG%", songResult.SongName)
                       .Replace("%DISC%", songResult.Disc.ToString()));
            }
            switch (downSetting.NameSelect)
            {
            case 0:
                return(songResult.SongName);

            case 1:
                if (string.IsNullOrEmpty(songResult.ArtistName))
                {
                    return(songResult.SongName);
                }
                return(songResult.ArtistName + " - " + songResult.SongName);

            case 2:
                if (string.IsNullOrEmpty(songResult.ArtistName))
                {
                    return(songResult.SongName);
                }
                return(songResult.SongName + " - " + songResult.ArtistName);

            default:
                if (songResult.TrackNum < 0)
                {
                    return(songResult.SongName);
                }
                return(songResult.TrackNum.ToString().PadLeft(2, '0') + " - " + songResult.SongName);
            }
        }
예제 #2
0
        public static string GetSongPath(DownloadSettings downSetting, SongResult songResult)
        {
            if (downSetting.EnableUserSetting)
            {
                var path = downSetting.UserFolder.Replace("%ARTIST%", songResult.ArtistName)
                           .Replace("%INDEX%", songResult.TrackNum.ToString()).Replace("%SONG%", songResult.SongName)
                           .Replace("%DISC%", songResult.Disc.ToString());
                if (!string.IsNullOrEmpty(songResult.Year) && songResult.Year.Length >= 4)
                {
                    path = path.Replace("%YEAR%", songResult.Year.Substring(0, 4));
                }
                return(path);
            }
            switch (downSetting.FolderSelect)
            {
            case 0:
                return("");

            case 1:
                return(songResult.ArtistName);

            case 2:
                return(songResult.AlbumName);

            default:
                return(songResult.ArtistName + "/" + songResult.AlbumName);
            }
        }
예제 #3
0
        /// <summary>
        /// constructor
        /// </summary>
        public DownloadTilesImpl()
        {
            this.downloadPool = new Queue<Thread>(MAX_DOWNLOAD_THREADS);

            DownloadSettings temp = new DownloadSettings();
            this.downloadurl = temp.PossibleRenderers[0].Url;
            this.renderer = temp.PossibleRenderers[0].Name;
        }
예제 #4
0
        /// <summary>
        ///     Downloads an AssetBundle or returns a cached AssetBundle if it has already been downloaded.
        ///     Remember to call <see cref="UnloadBundle(UnityEngine.AssetBundle,bool)" /> for every bundle you download once you
        ///     are done with it.
        /// </summary>
        /// <param name="bundleName">Name of the bundle to download.</param>
        /// <param name="downloadSettings">
        ///     Tell the function to use a previously downloaded version of the bundle if available.
        ///     Important!  If the bundle is currently "active" (it has not been unloaded) then the active bundle will be used
        ///     regardless of this setting.  If it's important that a new version is downloaded then be sure it isn't active.
        /// </param>
        public async Task <AssetBundle> GetBundle(string bundleName, DownloadSettings downloadSettings)
        {
            var completionSource = new TaskCompletionSource <AssetBundle>();
            var onComplete       = new Action <AssetBundle>(bundle => completionSource.SetResult(bundle));

            GetBundle(bundleName, onComplete, downloadSettings);
            return(await completionSource.Task);
        }
        public ExtractManagerService(DownloadSettings settings, IConfiguration configuration)
        {
            _settings = settings;
            var    optionsBuilder = new DbContextOptionsBuilder <DownloadContext>();
            string datapath       = Path.Combine(settings.DownloadFolder, "database.db");

            optionsBuilder.UseSqlite("Data Source=" + datapath);

            _context = new DownloadContext(optionsBuilder.Options);
        }
예제 #6
0
        public MoveManagerService(IConfiguration configuration, DownloadSettings settings)
        {
            var    optionsBuilder = new DbContextOptionsBuilder <DownloadContext>();
            string datapath       = Path.Combine(settings.DownloadFolder, "database.db");

            optionsBuilder.UseSqlite("Data Source=" + datapath);

            _context  = new DownloadContext(optionsBuilder.Options);
            _settings = DownloadSettings.Load();
        }
예제 #7
0
        /// <summary>
        /// Dowload track
        /// </summary>
        /// <param name="trackName">The name of the trac without extension</param>
        /// <param name="defaultExtension">The default audio extension in the format .{extension} (example: .mp3)</param>
        public DownloadTrackWindow(string trackName, string defaultExtension)
        {
            InitializeComponent();
            _isInFileMode     = true;
            _defaultExtension = defaultExtension;
            SelectedPath      = Path.Combine(AnyListenSettings.Instance.Config.DownloadSettings.DownloadFolder,
                                             trackName + defaultExtension);
            CheckIfFileExists();

            DownloadSettings = AnyListenSettings.Instance.Config.DownloadSettings;
            OnPropertyChanged("DownloadSettings");
        }
예제 #8
0
        /// <summary>
        /// Download tracks
        /// </summary>
        public DownloadTrackWindow()
        {
            InitializeComponent();

            _isInFileMode = false;
            SelectedPath  = AnyListenSettings.Instance.Config.DownloadSettings.DownloadFolder;
            CanAccept     = true;

            DownloadSettings = AnyListenSettings.Instance.Config.DownloadSettings;
            OnPropertyChanged("DownloadSettings");
            Title = Application.Current.Resources["DownloadTracks"].ToString();
        }
예제 #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <DownloadContext>();

            services.AddSingleton(DownloadSettings.Load());
            services.AddSingleton <AccountHelper>();
            services.AddSingleton <IHostedService, DownloadManagerService>();
            services.AddSingleton <IHostedService, AccountManagerService>();
            services.AddSingleton <IHostedService, ExtractManagerService>();
            services.AddSingleton <IHostedService, MoveManagerService>();

            services.AddControllersWithViews();
        }
예제 #10
0
 public Downloader()
 {
     downloadQueueLock      = new object();
     downloadQueueFilePath  = Path.Combine(Environment.AppDataDirectory, DOWNLOAD_LIST_FILE_NAME);
     downloadQueue          = DownloadQueueStorage.LoadDownloadQueue(downloadQueueFilePath);
     eventQueue             = new BlockingCollection <EventArgs>();
     downloadTaskResetEvent = new AutoResetEvent(false);
     localization           = null;
     httpClient             = null;
     downloadSettings       = null;
     isInOfflineMode        = false;
     isShuttingDown         = false;
     StartEventPublisherTask();
     downloadTask = StartDownloadTask();
 }
예제 #11
0
        private HttpClient CreateNewHttpClient(NetworkSettings networkSettings, DownloadSettings downloadSettings)
        {
            WebRequestHandler webRequestHandler = new WebRequestHandler
            {
                Proxy             = NetworkUtils.CreateProxy(networkSettings),
                UseProxy          = true,
                AllowAutoRedirect = false,
                UseCookies        = false,
                ReadWriteTimeout  = downloadSettings.Timeout * 1000
            };
            HttpClient result = new HttpClient(webRequestHandler);

            result.Timeout = Timeout.InfiniteTimeSpan;
            return(result);
        }
예제 #12
0
 public void Configure(Language currentLanguage, NetworkSettings networkSettings, DownloadSettings downloadSettings)
 {
     localization          = currentLanguage.DownloadManager;
     this.downloadSettings = downloadSettings;
     if (networkSettings.OfflineMode)
     {
         if (!isInOfflineMode)
         {
             isInOfflineMode = true;
             SwitchToOfflineMode();
         }
     }
     else
     {
         httpClient      = CreateNewHttpClient(networkSettings, downloadSettings);
         isInOfflineMode = false;
         ResumeDownloadTask();
     }
 }
예제 #13
0
        private void InitChildren(Settings parent, Dictionary<string, string> loadFrom)
        {
            string val = null;

                if(loadFrom.TryGetValue("Libraries", out val)) {
                    try {
                        _Libraries = ToStringArray(val);
                        for(int i = 0; i < _Libraries.Length; i++) { _Libraries[i] = _Libraries[i].Trim(); }
                    } catch { } // ignore invalid values
                }
            Download = new DownloadSettings(parent, loadFrom);

                if(loadFrom.TryGetValue("LastTVDBUpdateCheck", out val)) {
                    try {
                        DateTime date;
                        if(DateTime.TryParseExact(val, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeLocal, out date)) _LastTVDBUpdateCheck = date;
                    } catch { } // ignore invalid values
                }
        }
예제 #14
0
        public override sealed void SetStandardValues()
        {
            SoundOutDeviceID          = SoundOutManager.DefaultDevicePlaceholder;
            DisableNotificationInGame = true;
            ShowMagicArrowBelowCursor = true;
            WaveSourceBits            = 16;
            SampleRate = -1;
            var language = Languages.FirstOrDefault(x => x.Code == Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName);

            Language          = language == null ? "zh" : language.Code;
            Notification      = NotificationType.Top;
            ApplicationDesign = new ApplicationDesign();
            ApplicationDesign.SetStandard();
            NotificationShowTime        = 5000;
            RememberTrackImportPlaylist = false;
            PlaylistToImportTrack       = null;
            LoadAlbumCoverFromInternet  = true;
            DownloadAlbumCoverQuality   = ImageQuality.Maximum;
            SaveCoverLocal     = true;
            TrimTrackname      = true;
            ShowArtistAndTitle = true;
            SoundOutMode       = WasapiOut.IsSupportedOnCurrentPlatform ? SoundOutMode.WASAPI : SoundOutMode.DirectSound;
            Latency            = 100;
            IsCrossfadeEnabled = false;
            CrossfadeDuration  = 4;
            UseThinHeaders     = true;
            MinimizeToTray     = false;
            ShowNotificationIfMinimizeToTray = true;
            Downloader            = new DownloadManager();
            TabControlTransition  = TransitionType.Left;
            ShowProgressInTaskbar = true;
            DownloadSettings      = new DownloadSettings();
            DownloadSettings.SetDefault();
            CheckForAnyListenUpdates = true;
            CheckForYoutubeDlUpdates = true;
            Passwords       = new List <PasswordEntry>();
            FileNameFormat  = 1;
            DownloadBitrate = 1;
            LastUpdateTime  = DateTime.MinValue;
            DownLrc         = false;
            UseXunlei       = true;
        }
예제 #15
0
 private bool load(DownloadSettings setting)
 {
     return(Settings.Instance.Load <bool>(setting.ToString(), def: false));
 }
예제 #16
0
 private void save(DownloadSettings setting, bool value)
 {
     Settings.Instance.Save <bool>(setting.ToString(), value);
 }
예제 #17
0
 public IActionResult Index(DownloadSettings settings)
 {
     settings.Save();
     return(View(_settings));
 }
예제 #18
0
        protected void btnDownload_Click(object sender, System.EventArgs e)
        {
            Timer1.Enabled = true;

            //Label1.Text = "Refreshed at " +
            //DateTime.Now.ToString();
            bool blnServiceStarted;
            bool blnNoError;

            try
            {
                objCommonMethods = new CommonMethods();
                objCController   = new CController();
                objIController   = (CController)objCController;

                objCMWException  = new CMWException();
                objCommonMethods = new CommonMethods();

                objIController.SetFilePath(strProjectDBPath);
                Shared.udtNetworkType = objIController.GetNetworkType(strProjectDBPath);
                ResgistrySettings RegSettings;
                RegSettings = objIController.GetRegistrySettings();

                Shared.ProjectDBPath   = strProjectDBPath;
                Shared.ApplicationPath = RegSettings.InstallationPath;
                objDownloadSettings    = new DownloadSettings();

                //start downloader Service
                blnServiceStarted = objCommonMethods.StartDownloaderService();
                //Communication Type
                objDownloadSettings.TCP       = true;
                objDownloadSettings.ipAddress = "159.99.185.100";
                //Port number
                objDownloadSettings.portNumber = Constants.portNumber;
                //Gateway type
                objDownloadSettings.enumDownloadGateway = GateWay.E3NGA;
                //NetworkType
                objDownloadSettings.enumNetworkType = Shared.udtNetworkType;
                //Node type
                objDownloadSettings.enumBoardTypeID = BoardTypeID.ILI_S_E3;
                //Node Number
                objDownloadSettings.NodeNumber = 2;
                //Firmware path
                objDownloadSettings.FirmwarePath = "";
                //7100 network card
                objDownloadSettings.Do7100CardDownload = false;
                //RPT card
                objDownloadSettings.DoRPTDownload = false;
                //LCD-SLP load
                objDownloadSettings.DoLCDSLPDownload = false;
                //LCD-SLP Graphics
                objDownloadSettings.DoLCDSLPGraphicsDownload = false;
                //Project Path
                objDownloadSettings.ProjectPath = Shared.ProjectDBPath;
                //Level 4 Password
                objDownloadSettings.L4Password = "******";
                //Download Type
                objDownloadSettings.DownloadTypes = (int)DownloadTypes.CAMOnly | (int)DownloadTypes.ConfigOnly | (int)DownloadTypes.LabelsOnly;
                //Installer ID
                objDownloadSettings.InstallerID = "1234";
                //Virtual Switch
                objDownloadSettings.LoadVirtualSwitch = false;
                //Site Specific key
                objDownloadSettings.SiteSpecificKey = 1234;
                //Application path
                objDownloadSettings.ApplicationPath = Shared.ApplicationPath;
                OnCommandCompleted          = new DelegateCommandCompleted(Query_OnCommandCompleted);
                objCallback                 = new CallbackClass();
                objCallback.OnHostToClient += new RemoteCallback(Status_Changed);
                //call back delegate
                RemoteCallback wire = new RemoteCallback(objCallback.HandleToClient);
                //Parameters to be passed between the client and CAMWorksDownloader service.
                CallbackEventArgs objCallBckArgs = new CallbackEventArgs();
                objCallBckArgs.CallBack = wire;
                objCallBckArgs.IsError  = false;

                objCallBckArgs.Finished = false;

                objCallBckArgs.CommandId = CommandName.ConfigDownload;

                objCallBckArgs.State = 0;

                objCallBckArgs.Sender = GetType().ToString();

                objCallBckArgs.Parameters = objDownloadSettings;

                blnNoError = objIController.DownloadConfigData(objCallBckArgs);

                if (!blnNoError)
                {
                    arListStatus.Add(objCMWException.GetExceptions(objCMWException.LastException, ""));

                    // IsDownloadSuucessful = false;

                    OnCommandCompleted();
                }

                //objCMWException = null;

                objCallBckArgs = null;

                objDownloadSettings = null;
            }
            catch (Exception Ex)
            {
            }
        }
        /// <summary>
        ///     Downloads an AssetBundle or returns a cached AssetBundle if it has already been downloaded.
        ///     Remember to call <see cref="UnloadBundle(UnityEngine.AssetBundle,bool)" /> for every bundle you download once you
        ///     are done with it.
        ///     <param name="bundleName">Name of the bundle to download.</param>
        ///     <param name="onComplete">Action to perform when the bundle has been successfully downloaded.</param>
        ///     <param name="downloadSettings">
        ///         Tell the function to use a previously downloaded version of the bundle if available.
        ///         Important!  If the bundle is currently "active" (it has not been unloaded) then the active bundle will be used
        ///         regardless of this setting.  If it's important that a new version is downloaded then be sure it isn't active.
        ///     </param>
        /// </summary>
        public void GetBundle(string bundleName, Action <AssetBundle> onComplete, DownloadSettings downloadSettings)
        {
            AssetBundleContainer active;

            if (activeBundles.TryGetValue(bundleName, out active))
            {
                active.References++;
                onComplete(active.AssetBundle);
                return;
            }

            DownloadInProgressContainer inProgress;

            if (downloadsInProgress.TryGetValue(bundleName, out inProgress))
            {
                inProgress.References++;
                inProgress.OnComplete += onComplete;
                return;
            }

            downloadsInProgress.Add(bundleName, new DownloadInProgressContainer(onComplete));

            var mainBundle = new AssetBundleDownloadCommand
            {
                BundleName = bundleName,
                Hash       = downloadSettings == DownloadSettings.UseCacheIfAvailable ? manifest.GetAssetBundleHash(bundleName) : default(Hash128),
                OnComplete = bundle => OnDownloadComplete(bundleName, bundle)
            };

            var dependencies           = manifest.GetDirectDependencies(bundleName);
            var dependenciesToDownload = new List <string>();

            for (int i = 0; i < dependencies.Length; i++)
            {
                if (activeBundles.TryGetValue(dependencies[i], out active))
                {
                    active.References++;
                }
                else
                {
                    dependenciesToDownload.Add(dependencies[i]);
                }
            }

            if (dependenciesToDownload.Count > 0)
            {
                var dependencyCount = dependenciesToDownload.Count;
                Action <AssetBundle> onDependenciesComplete = dependency => {
                    if (--dependencyCount == 0)
                    {
                        handler.Handle(mainBundle);
                    }
                };

                for (int i = 0; i < dependenciesToDownload.Count; i++)
                {
                    var dependencyName = dependenciesToDownload[i];
                    GetBundle(dependencyName, onDependenciesComplete);
                }
            }
            else
            {
                handler.Handle(mainBundle);
            }
        }
예제 #20
0
        private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!_isInFileMode)
            {
                return;
            }
            if (string.IsNullOrEmpty(SelectedPath))
            {
                return;
            }
            var selectedPath = new FileInfo(SelectedPath);

            SelectedPath =
                Path.Combine(selectedPath.DirectoryName,
                             Path.GetFileNameWithoutExtension(selectedPath.FullName) + DownloadSettings.GetExtension(_defaultExtension));

            CheckIfFileExists();
        }
예제 #21
0
        protected void btnDownload_Click(object sender, System.EventArgs e)
        {
            Timer1.Enabled = true;

            //Label1.Text = "Refreshed at " +
            //DateTime.Now.ToString();
            bool blnServiceStarted;
            bool blnNoError;
            try
            {
                objCommonMethods = new CommonMethods();
                objCController = new CController();
                objIController = (CController)objCController;

                objCMWException = new CMWException();
                objCommonMethods = new CommonMethods();

                objIController.SetFilePath(strProjectDBPath);
                Shared.udtNetworkType = objIController.GetNetworkType(strProjectDBPath);
                ResgistrySettings RegSettings;
                RegSettings = objIController.GetRegistrySettings();

                Shared.ProjectDBPath = strProjectDBPath;
                Shared.ApplicationPath = RegSettings.InstallationPath;
                objDownloadSettings = new DownloadSettings();

                //start downloader Service
                blnServiceStarted = objCommonMethods.StartDownloaderService();
                //Communication Type
                objDownloadSettings.TCP = true;
                objDownloadSettings.ipAddress = "159.99.185.100";
                //Port number
                objDownloadSettings.portNumber = Constants.portNumber;
                //Gateway type
                objDownloadSettings.enumDownloadGateway = GateWay.E3NGA;
                //NetworkType
                objDownloadSettings.enumNetworkType = Shared.udtNetworkType;
                //Node type
                objDownloadSettings.enumBoardTypeID = BoardTypeID.ILI_S_E3;
                //Node Number
                objDownloadSettings.NodeNumber = 2;
                //Firmware path
                objDownloadSettings.FirmwarePath = "";
                //7100 network card
                objDownloadSettings.Do7100CardDownload = false;
                //RPT card
                objDownloadSettings.DoRPTDownload = false;
                //LCD-SLP load
                objDownloadSettings.DoLCDSLPDownload = false;
                //LCD-SLP Graphics
                objDownloadSettings.DoLCDSLPGraphicsDownload = false;
                //Project Path
                objDownloadSettings.ProjectPath = Shared.ProjectDBPath;
                //Level 4 Password
                objDownloadSettings.L4Password = "******";
                //Download Type
                objDownloadSettings.DownloadTypes = (int)DownloadTypes.CAMOnly | (int)DownloadTypes.ConfigOnly | (int)DownloadTypes.LabelsOnly;
                //Installer ID
                objDownloadSettings.InstallerID = "1234";
                //Virtual Switch
                objDownloadSettings.LoadVirtualSwitch = false;
                //Site Specific key
                objDownloadSettings.SiteSpecificKey = 1234;
                //Application path
                objDownloadSettings.ApplicationPath = Shared.ApplicationPath;
                OnCommandCompleted = new DelegateCommandCompleted(Query_OnCommandCompleted);
                objCallback = new CallbackClass();
                objCallback.OnHostToClient += new RemoteCallback(Status_Changed);
                //call back delegate
                RemoteCallback wire = new RemoteCallback(objCallback.HandleToClient);
                //Parameters to be passed between the client and CAMWorksDownloader service.
                CallbackEventArgs objCallBckArgs = new CallbackEventArgs();
                objCallBckArgs.CallBack = wire;
                objCallBckArgs.IsError = false;

                objCallBckArgs.Finished = false;

                objCallBckArgs.CommandId = CommandName.ConfigDownload;

                objCallBckArgs.State = 0;

                objCallBckArgs.Sender = GetType().ToString();

                objCallBckArgs.Parameters = objDownloadSettings;

                blnNoError = objIController.DownloadConfigData(objCallBckArgs);

                if (!blnNoError)
                {

                    arListStatus.Add(objCMWException.GetExceptions(objCMWException.LastException, ""));

                    // IsDownloadSuucessful = false;

                    OnCommandCompleted();

                }

                //objCMWException = null;

                objCallBckArgs = null;

                objDownloadSettings = null;

            }
            catch (Exception Ex)
            {

            }
        }
예제 #22
0
 public ItemController(DownloadContext context, DownloadSettings settings)
 {
     _context  = context;
     _settings = settings;
 }
예제 #23
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="settings"></param>
        public void SetDownloadSettings(DownloadSettings settings)
        {
            //this.downloadSetting = settings;

            this.renderer = settings.Renderer.Name;
            this.downloadurl = settings.Renderer.Url;

            this.KillAllThreads();
            this.StartDownload();
        }
예제 #24
0
 /// <summary>
 /// Конструктор
 /// </summary>
 public ServerSettings()
 {
     Connection = new ConnectionSettings();
     Download   = new DownloadSettings();
     Upload     = new UploadSettings();
 }
예제 #25
0
        /// <summary>
        ///     Downloads an AssetBundle or returns a cached AssetBundle if it has already been downloaded.
        ///     Remember to call <see cref="UnloadBundle(UnityEngine.AssetBundle,bool)" /> for every bundle you download once you
        ///     are done with it.
        /// </summary>
        /// <param name="bundleName">Name of the bundle to download.</param>
        /// <param name="onComplete">Action to perform when the bundle has been successfully downloaded.</param>
        /// <param name="downloadSettings">
        ///     Tell the function to use a previously downloaded version of the bundle if available.
        ///     Important!  If the bundle is currently "active" (it has not been unloaded) then the active bundle will be used
        ///     regardless of this setting.  If it's important that a new version is downloaded then be sure it isn't active.
        /// </param>
        public void GetBundle(string bundleName, Action <AssetBundle> onComplete, DownloadSettings downloadSettings)
        {
            if (Initialized == false)
            {
                Debug.LogError("AssetBundleManager must be initialized before you can get a bundle.");
                onComplete(null);
                return;
            }

            if (useHash)
            {
                bundleName = GetHashedBundleName(bundleName);
            }

            AssetBundleContainer active;

            if (activeBundles.TryGetValue(bundleName, out active))
            {
                active.References++;
                onComplete(active.AssetBundle);
                return;
            }

            DownloadInProgressContainer inProgress;

            if (downloadsInProgress.TryGetValue(bundleName, out inProgress))
            {
                inProgress.References++;
                inProgress.OnComplete += onComplete;
                return;
            }

            downloadsInProgress.Add(bundleName, new DownloadInProgressContainer(onComplete));

            var mainBundle = new AssetBundleDownloadCommand {
                BundleName = bundleName,
                Hash       = downloadSettings == DownloadSettings.UseCacheIfAvailable ? Manifest.GetAssetBundleHash(bundleName) : default(Hash128),
                OnComplete = bundle => OnDownloadComplete(bundleName, bundle)
            };

            var dependencies           = Manifest.GetDirectDependencies(bundleName);
            var dependenciesToDownload = new List <string>();

            for (int i = 0; i < dependencies.Length; i++)
            {
                if (activeBundles.TryGetValue(dependencies[i], out active))
                {
                    active.References++;
                }
                else
                {
                    dependenciesToDownload.Add(dependencies[i]);
                }
            }

            if (dependenciesToDownload.Count > 0)
            {
                var dependencyCount = dependenciesToDownload.Count;
                Action <AssetBundle> onDependenciesComplete = dependency => {
                    if (--dependencyCount == 0)
                    {
                        handler.Handle(mainBundle);
                    }
                };

                for (int i = 0; i < dependenciesToDownload.Count; i++)
                {
                    var dependencyName = dependenciesToDownload[i];
                    if (useHash)
                    {
                        dependencyName = GetUnhashedBundleName(dependencyName);
                    }
                    GetBundle(dependencyName, onDependenciesComplete);
                }
            }
            else
            {
                handler.Handle(mainBundle);
            }
        }
예제 #26
0
 public SettingsController(DownloadContext context)
 {
     _context  = context;
     _settings = DownloadSettings.Load();;
 }
예제 #27
0
        public AccountManagerService(IConfiguration configuration, AccountHelper account, DownloadSettings settings)
        {
            Console.WriteLine("Erstelle AccountManager");
            var    optionsBuilder = new DbContextOptionsBuilder <DownloadContext>();
            string datapath       = Path.Combine(settings.DownloadFolder, "database.db");

            optionsBuilder.UseSqlite("Data Source=" + datapath);

            _context = new DownloadContext(optionsBuilder.Options);
            _context.Database.Migrate();

            try
            {
                System.IO.File.WriteAllText(System.IO.Path.Combine(settings.LogFolder, "test.txt"), "Huhu, hier bin ich");
            } catch (Exception ex)
            {
                Console.WriteLine("Fehler beim erstellen der Datei!");
                Console.WriteLine(ex.Message);
            }

            _account = account;
        }
예제 #28
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            CheckQuery(stoppingToken);

            while (!stoppingToken.IsCancellationRequested)
            {
                await Task.Delay(TimeSpan.FromSeconds(_settings.IntervalDownload), stoppingToken);

                if (stoppingToken.IsCancellationRequested)
                {
                    break;
                }

                if (_isDownloading)
                {
                    continue;
                }

                _isDownloading = true;
                List <DownloadGroup> groups = new List <DownloadGroup>();
                try
                {
                    _settings = DownloadSettings.Load();
                    groups    = _context.Groups.Where(g => g.IsTemp == false).ToList();
                }
                catch (Exception e)
                {
                    Log("Load Error: " + e.Message);
                }

                bool flagDownload = false;

                foreach (DownloadGroup group in groups)
                {
                    if (!_context.Items.Any(i => i.DownloadGroupID == group.ID && i.State == DownloadItem.States.Waiting))
                    {
                        Log("No Items in " + group.Name);
                        continue;
                    }
                    Log("Checked Group found item: " + group.Name);

                    IEnumerable <DownloadItem> _items = _context.Items.Where(i => i.DownloadGroupID == group.ID && i.State == DownloadItem.States.Waiting).OrderBy(i => i.Name);

                    foreach (DownloadItem _item in _items)
                    {
                        IDownloader downloader = DownloadHelper.GetDownloader(_item);
                        if (downloader == null)
                        {
                            Log("Download Interface Error - " + _item.ID.ToString() + " - " + _item.Hoster);
                            _item.State = DownloadItem.States.Error;
                            queryUpdate.Add(_item);
                            queryAdd.Add(new DownloadError(1, _item, new Exception("No DownloadInterface for " + _item.Hoster)));
                            await SocketHandler.Instance.SendIDError(_item);

                            continue;
                        }

                        if (downloader.IsFree)
                        {
                            flagDownload = true;
                            StartDownload(group, _item, new AccountProfile(new AccountModel()));
                            break;
                        }
                        else
                        {
                            AccountProfile profile = await _account.GetFreeProfile(_item);

                            if (profile != null)
                            {
                                flagDownload = true;
                                StartDownload(group, _item, profile);
                                break;
                            }
                            else
                            {
                                Log("No Account for hoster: " + downloader.Identifier);
                                _item.State = DownloadItem.States.Error;

                                queryUpdate.Add(_item);
                                queryAdd.Add(new DownloadError(2, _item, new Exception("No Account for " + downloader.Identifier)));

                                await SocketHandler.Instance.SendIDError(_item);

                                continue;
                            }
                        }
                    }

                    if (flagDownload)
                    {
                        break;
                    }
                }

                if (!flagDownload)
                {
                    _isDownloading = false;
                }
            }
        }