public bool Install()
        {
            using (var p = new Process())
            {
                p.StartInfo.CreateNoWindow = true;
                var msiExec = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "msiexec.exe");
                p.StartInfo.Arguments = $"/i {InstallInfo.MsiPath} /qn /l*v {InstallInfo.LogPathInstall}";
                p.StartInfo.FileName  = msiExec;
                p.Start();
                var result = p.WaitForExit(Config.WaitTimeInSeconds);
                InstallInfo.ExitCode = (ExitCode)p.ExitCode;
                if (result)
                {
                    if (ExitCodeHelper.IsSuccess(InstallInfo.ExitCode))
                    {
                        Trace.WriteLine($"The install of product:{InstallInfo.ProductName} ({InstallInfo.ProductCode}) succeeded with ExitCode:{InstallInfo.ExitCode}. LogFile:'{InstallInfo.LogPathInstall}'");
                        InstallInfo.IsInstalled = true;
                        return(true);
                    }
                    else
                    {
                        Trace.WriteLine($"The install of product:{InstallInfo.ProductName} ({InstallInfo.ProductCode}) failed with exitcode:{InstallInfo.ExitCode}. LogFile:'{InstallInfo.LogPathInstall}'");
                        return(false);
                    }
                }
                else
                {
                    Trace.WriteLine($"The install of product:{InstallInfo.ProductName} ({InstallInfo.ProductCode}) timed out. LogFile:'{InstallInfo.LogPathInstall}'");
                }

                return(result);
            }
        }
Exemple #2
0
        private static async Task <int> HandleAlbumOptions(AlbumOptions options)
        {
            var handler = await DefaultOptionsHandler.CreateAsync(options).ConfigureAwait(false);

            var client = handler.GetCurrentMuzlanClient();

            var authResponse = await client.Auth.Authenticate().ConfigureAwait(false);

            if (!authResponse.HasResult)
            {
                return(ExitCodeHelper.Set(ExitCode.AuthenticationFailure));
            }

            if (!string.IsNullOrEmpty(options.Url))
            {
                // TODO: parse album or artist url

                return(ExitCodeHelper.Set(ExitCode.ParserError));
            }
            else if (string.IsNullOrEmpty(options.Album))
            {
                var artistResponse = await RateLimitHelper.BypassRateLimitAsync(
                    handler,
                    (client) => client.Albums.FindAlbums(options.Artist ?? string.Empty)).ConfigureAwait(false);

                if (artistResponse.HasResult)
                {
                    var json = await JsonHelper.SerializeAsync(artistResponse.Result, handler.PrettyPrint).ConfigureAwait(false);

                    Console.WriteLine(json);
                }

                return(ExitCodeHelper.Set(artistResponse));
            }
            else
            {
                var albumResponse = await RateLimitHelper.BypassRateLimitAsync(
                    handler,
                    (client) => client.Albums.GetTracks(options.Artist ?? string.Empty, options.Album ?? string.Empty))
                                    .ConfigureAwait(false);

                if (albumResponse.HasResult)
                {
                    var json = await JsonHelper.SerializeAsync(albumResponse.Result, handler.PrettyPrint).ConfigureAwait(false);

                    Console.WriteLine(json);
                }

                return(ExitCodeHelper.Set(albumResponse));
            }
        }
Exemple #3
0
        public static async Task <int> Main(string[] args)
        {
            var verbs = LoadVerbs();

            await Parser.Default.ParseArguments(args, verbs)
            .MapResult
            <AlbumOptions, AuthOptions, DownloadOptions, MetaOptions, SearchOptions, SitemapOptions, Task>(
                HandleAlbumOptions,
                HandleAuthOptions,
                HandleDownloadOptions,
                HandleMetaOptions,
                HandleSearchOptions,
                HandleSitemapOptions,
                _ => ExitCodeHelper.SetAsync(ExitCode.ParserError)).ConfigureAwait(false);

            return(Environment.ExitCode);
        }