Ejemplo n.º 1
0
	public static void Exit () {
		//if (ExitCode==ExitCodes.CrashError) { ExitCode=ExitCodes.ExitError; }
		if (ExitCode==ExitCodes.ExitError)  { ExitCode=ExitCodes.NoError; }
		if (Log.ErrorHasBeenLogged) { if (ExitCode==ExitCodes.NoError) { ExitCode=ExitCodes.LoggedError; } }
		String exitcode = ""; if (ExitCode!=ExitCodes.NoError) { exitcode = " ["+ExitCode+"]"; }
		Log.TRACE( "RunTime: " + DT.GetSpanString(DateTime.Now-App.InitDT) + exitcode );
		if (ExitOnExit) { Environment.Exit(Environment.ExitCode); }
	}
Ejemplo n.º 2
0
	public static void Run (Action<List<String>> fx, String[] args) {
		try {
			ExitCode=ExitCodes.InitError;  App.Init();
			ExitCode=ExitCodes.FxError;    fx(args.ToList());
			ExitCode=ExitCodes.ExitError;  App.Exit();
		} catch (Exception ex) {
			App.Crash(ex);
		}
	}
Ejemplo n.º 3
0
	public static void Crash (Exception ex) {
		try {
			App.CrashReport(ex);
			App.Exit();
			if (ThrowOnCrash) { throw ex; }
		} catch (Exception crashex) {
			ExitCode=ExitCodes.CrashError;
			Log.ERROR("Unhandled Exception After App Crashed");
			Log.EX(crashex);
		}
	}
        private static void HandleError(Exception exc, ExitCodes exitCode, string message)
	    {
			var typeLoadExc = exc as ReflectionTypeLoadException;

			if (typeLoadExc != null)
				Log.Error(String.Join("; ", typeLoadExc.LoaderExceptions.Select(e => e.Message)), typeLoadExc);
			else
				Log.Error(exc);

	        MessageBox.Show(message, "Startup Error", MessageBoxButton.OK, MessageBoxImage.Error);
            Application.Current.Shutdown((int)exitCode);
	    }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a new <see cref="MuPDFDocument"/> from data bytes accessible through the specified pointer.
        /// </summary>
        /// <param name="context">The context that will own this document.</param>
        /// <param name="dataAddress">A pointer to the data bytes that make up the document.</param>
        /// <param name="dataLength">The number of bytes to read from the specified address.</param>
        /// <param name="fileType">The type of the document to read.</param>
        /// <param name="dataHolder">An <see cref="IDisposable"/> that will be disposed when the <see cref="MuPDFDocument"/> is disposed.</param>
        public MuPDFDocument(MuPDFContext context, IntPtr dataAddress, long dataLength, InputFileTypes fileType, ref IDisposable dataHolder)
        {
            bool isImage = fileType == InputFileTypes.BMP || fileType == InputFileTypes.GIF || fileType == InputFileTypes.JPEG || fileType == InputFileTypes.PAM || fileType == InputFileTypes.PNG || fileType == InputFileTypes.PNM || fileType == InputFileTypes.TIFF;

            this.OwnerContext = context;

            float xRes = 0;
            float yRes = 0;

            ExitCodes result = (ExitCodes)NativeMethods.CreateDocumentFromStream(context.NativeContext, dataAddress, (ulong)dataLength, FileTypeMagics[(int)fileType], isImage ? 1 : 0, ref NativeDocument, ref NativeStream, ref PageCount, ref xRes, ref yRes);

            if (xRes > 72)
            {
                this.ImageXRes = xRes;
            }
            else
            {
                this.ImageXRes = 72;
            }

            if (yRes > 72)
            {
                this.ImageYRes = yRes;
            }
            else
            {
                this.ImageYRes = 72;
            }

            this.DataHolder = dataHolder;

            switch (result)
            {
            case ExitCodes.EXIT_SUCCESS:
                break;

            case ExitCodes.ERR_CANNOT_OPEN_STREAM:
                throw new MuPDFException("Cannot open data stream", result);

            case ExitCodes.ERR_CANNOT_OPEN_FILE:
                throw new MuPDFException("Cannot open document", result);

            case ExitCodes.ERR_CANNOT_COUNT_PAGES:
                throw new MuPDFException("Cannot count pages", result);

            default:
                throw new MuPDFException("Unknown error", result);
            }

            Pages        = new MuPDFPageCollection(context, this, PageCount);
            DisplayLists = new MuPDFDisplayList[PageCount];
        }
Ejemplo n.º 6
0
        public override async Task <int> InvokeAsync(InvocationContext context)
        {
            // validate options

            // resolve targets
            this.logger.LogDebug("Input targets: {targets}", this.Targets);

            var files = this.fileMatcher.ExpandMatches(this.fileSystem.Directory.GetCurrentDirectory(), this.Targets);

            this.WriteHeader <RenameResult>();
            this.Write("Looking for targets...");

            using var dryRun = new DryRun(this.DryRun, this.dryRunLogger);

            var(renames, failed) = await this.ProcessFiles(files, dryRun);

            int success = 0, unchanged = 0, fail = 0;

            if (renames.Any())
            {
                if (failed)
                {
                    fail = renames.Length;
                }
                else
                {
                    foreach (var result in renames)
                    {
                        if (result.Reason is not null)
                        {
                            fail++;
                        }
                        else if (result.OldName == result.NewName)
                        {
                            unchanged++;
                        }
                        else
                        {
                            success++;
                        }
                    }
                }
            }
            else
            {
                this.WriteFooter($"No files matched targets: {this.Targets.FormatInlineList()}");
            }

            this.WriteFooter($"{renames.Length} files, {success} renamed, {unchanged} unchanged, {fail} failed");

            return(ExitCodes.Get(!failed));
        }
Ejemplo n.º 7
0
 public static void Shutdown(ExitCodes code)
 {
     Current.Dispatcher.Invoke(() =>
     {
         if (code == ExitCodes.Updating)
         {
             var dlgdc = new Dialogs.DownloadToolUpdateDialogDataContext((Current as App).UpdateDownloadInfo);
             var dlg   = new Dialogs.DownloadToolUpdateDialog(dlgdc);
             dlg.ShowDialog();
         }
         Current.Shutdown((int)code);
     });
 }
Ejemplo n.º 8
0
        public static Image <Bgr, byte> GetImageFromScanner()
        {
            Process scannerManager = new Process();
            string  scanFilePattrn = @"^\d{8}_SC\d{4}";

            string[] files;
            string   lastAddedFilePath;

            ExitCodes.ExitCode exCode = ExitCodes.ExitCode.ERROR_FILE_NOT_FOUND;

            try
            {
                scannerManager.StartInfo.Arguments = ScanDirectory;

                scannerManager.StartInfo.FileName  = Path.Combine(Environment.CurrentDirectory, @"..\..\..\ScannerManager\bin\Debug\ScannerManager.exe");
                scannerManager.EnableRaisingEvents = true;

                scannerManager.Start();
                scannerManager.WaitForExit();

                exCode = (ExitCodes.ExitCode)scannerManager.ExitCode;

                switch (exCode)
                {
                case ExitCodes.ExitCode.SUCCESS:
                {
                    files = Directory.GetFiles(ScanDirectory);
                    files = files.Where(x => Regex.IsMatch(Path.GetFileName(x), scanFilePattrn)).ToArray();

                    lastAddedFilePath = files.OrderByDescending(x => Path.GetFileName(x)).First();

                    if (string.IsNullOrEmpty(lastAddedFilePath))
                    {
                        throw new Exception("Scanned file not found!");
                    }
                    FilePath = lastAddedFilePath;
                    return(new Image <Bgr, byte>(FilePath));
                }

                case ExitCodes.ExitCode.ERROR_CANCELLED:
                { return(null); }

                default:
                { throw new Exception(ExitCodes.ExitMessage(exCode)); }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 9
0
        public static void Main(string[] args)
        {
            ExitCodes exitCode = ExitCodes.Success;

            try
            {
                CommandLine.DisplayBanner();
                var commandLine = new CommandLine(new Arguments(args));
                if (commandLine.Valid())
                {
                    // Create common configuration context
                    string connectionString = BuildConnectionString(commandLine);
                    Console.WriteLine("Using database connection string " + connectionString);
                    string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    var    context      = new CommonExtractionContext
                    {
                        CompanyName       = commandLine.CompanyName,
                        SccmConnection    = connectionString,
                        StartDate         = commandLine.StartDate,
                        EndtDate          = commandLine.EndDate,
                        BaseWorkDirectory = assemblyPath,
                        PluginsDirectory  = Path.Combine(assemblyPath, "Plugins")
                    };

                    // Create DataExtractor Plugin Factory
                    var factory = new DataExtractorFactory(context.PluginsDirectory);

                    int commandExecutionTimeout = SqlCommandExecutionTimeout();
                    var queryExecutor           = new SqlQueryExecutor(context.SccmConnection, commandExecutionTimeout);

                    // Create Data Extractor and build package
                    var    extractor = new DataExtractor(factory, queryExecutor);
                    string zipPath   = extractor.BuildPackage(context);

                    if (extractor.Succeded())
                    {
                        string uploadurl = ConfigurationManager.AppSettings["fileUploadUrl"].Replace(
                            "[SERVERNAME]", commandLine.UploadServerName);

                        FileUploader.UploadFile(uploadurl, zipPath);
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayError(ex);
                exitCode = ExitCodes.Error;
            }

            Environment.Exit((int)exitCode);
        }
Ejemplo n.º 10
0
        public bool Run(out ExitCodes exitCode)
        {
            try
            {
                Run(Arguments.CompcArgs);

                exitCode = ExitCode == 0 ? 0 : ExitCodes.ErrorRunningCompiler;
                return(false);
            }
            catch (Exception e)
            {
                return(ErrorHelper.ErrorRunningCompiler(out exitCode, e));
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Create a new <see cref="MuPDFMultiThreadedPageRenderer"/> from a specified display list using the specified number of threads.
        /// </summary>
        /// <param name="context">The context that owns the document from which the display list was extracted.</param>
        /// <param name="displayList">The display list to render.</param>
        /// <param name="threadCount">The number of threads to use in the rendering. This must be factorisable using only powers of 2, 3, 5 or 7. Otherwise, the biggest number smaller than <paramref name="threadCount"/> that satisfies this condition is used.</param>
        /// <param name="pageBounds">The bounds of the page being rendererd.</param>
        /// <param name="clipToPageBounds">A boolean value indicating whether the rendered image should be clipped to the original page's bounds. This can be relevant if the page has been "cropped" by altering its mediabox, but otherwise leaving the contents untouched.</param>
        /// <param name="imageXRes">If the document is an image, the horizontal resolution of the image. Otherwise, 72.</param>
        /// <param name="imageYRes">If the document is an image, the vertical resolution of the image. Otherwise, 72.</param>
        internal MuPDFMultiThreadedPageRenderer(MuPDFContext context, MuPDFDisplayList displayList, int threadCount, Rectangle pageBounds, bool clipToPageBounds, double imageXRes, double imageYRes)
        {
            threadCount = Utils.GetAcceptableNumber(threadCount);

            this.ThreadCount      = threadCount;
            this.DisplayList      = displayList;
            this.PageBounds       = pageBounds;
            this.ClipToPageBounds = clipToPageBounds;

            this.ImageXRes = imageXRes;
            this.ImageYRes = imageYRes;

            IntPtr[] contexts       = new IntPtr[threadCount];
            GCHandle contextsHandle = GCHandle.Alloc(contexts, GCHandleType.Pinned);

            try
            {
                ExitCodes result = (ExitCodes)NativeMethods.CloneContext(context.NativeContext, threadCount, contextsHandle.AddrOfPinnedObject());

                switch (result)
                {
                case ExitCodes.EXIT_SUCCESS:
                    break;

                case ExitCodes.ERR_CANNOT_INIT_MUTEX:
                    throw new MuPDFException("Cannot initalize mutex objects", result);

                case ExitCodes.ERR_CANNOT_CREATE_CONTEXT:
                    throw new MuPDFException("Cannot create master context", result);

                case ExitCodes.ERR_CANNOT_CLONE_CONTEXT:
                    throw new MuPDFException("Cannot create context clones", result);

                default:
                    throw new MuPDFException("Unknown error", result);
                }

                Contexts         = new MuPDFContext[threadCount];
                RenderingThreads = new RenderingThread[threadCount];
                for (int i = 0; i < threadCount; i++)
                {
                    Contexts[i]         = new MuPDFContext(contexts[i]);
                    RenderingThreads[i] = new RenderingThread();
                }
            }
            finally
            {
                contextsHandle.Free();
            }
        }
Ejemplo n.º 12
0
        private bool LoadProjectFile(XmlDocument xmlDoc, out ExitCodes exitCode)
        {
            try
            {
                xmlDoc.Load(ProjectPath);

                exitCode = 0;
                return(false);
            }
            catch (Exception e)
            {
                return(ErrorHelper.ErrorLoadingProjectFile(out exitCode, e));
            }
        }
Ejemplo n.º 13
0
        public static void ExitProgram(ExitCodes exitCode, string format, params object[] args)
        {
            #if DEBUG
            Console.WriteLine("Program.ExitProgram");
            #endif
            Debug.PrintMessage(format, args);

            if (!Variables.os_is_unix && exitCode != ExitCodes.EXIT_OK)
            {
                Debug.PrintMessage("Press RETURN. Program will exit.");
                Console.ReadLine();
            }

            Application.Quit();
        }
Ejemplo n.º 14
0
        private static void Exit(ExitCodes exitCode)
        {
            LogManager.Shutdown();

            if (exitCode != ExitCodes.Normal)
            {
                System.Console.WriteLine("Press enter to exit...");

                System.Threading.Thread.Sleep(1000);

                // Please note that ReadLine silently succeeds if there is no console, KeyAvailable does not.
                System.Console.ReadLine();
            }

            Environment.Exit((int)exitCode);
        }
Ejemplo n.º 15
0
        private static void HandleError(Exception exc, ExitCodes exitCode, string message)
        {
            var typeLoadExc = exc as ReflectionTypeLoadException;

            if (typeLoadExc != null)
            {
                Log.Error(string.Join("; ", typeLoadExc.LoaderExceptions.Select(e => e.Message)), typeLoadExc);
            }
            else
            {
                Log.Error(exc);
            }

            MessageBox.Show(message, "Startup Error", MessageBoxButton.OK, MessageBoxImage.Error);
            Application.Current.Shutdown((int)exitCode);
        }
Ejemplo n.º 16
0
        private static void HandleError(Exception exc, ExitCodes exitCode, string message, string additionalInfo = null)
        {
            if (additionalInfo != null)
            {
                Log.Error(additionalInfo, exc);
            }
            else
            {
                Log.Error(exc);
            }



            MessageBox.Show(message, "Startup Error", MessageBoxButton.OK, MessageBoxImage.Error);
            Application.Current.Shutdown((int)exitCode);
        }
Ejemplo n.º 17
0
        private static void CleanExit(ExitCodes code)
        {
            Cleanup();

            // Clear a line for neatness.
            Console.WriteLine();

            if (code != ExitCodes.Success)
            {
                // Write out our reson.
                Console.WriteLine(string.Format("Exiting due to error: {0}", Regex.Replace(code.ToString(), @"(\B[A-Z]+?(?=[A-Z][^A-Z])|\B[A-Z]+?(?=[^A-Z]))", " $1")));
            }

            // Exit.
            Environment.Exit((int)code);
        }
Ejemplo n.º 18
0
        public bool Parse(xml data, out ExitCodes exitCode)
        {
            try
            {
                // <output><movie>
                var group    = data[G.Output];
                var elements = group?.GetElementsByTagName(E.Movie);
                ParseOutputOptions(elements);

                // <build><option>
                group    = data[G.Build];
                elements = group?.GetElementsByTagName(E.Option);
                ParseBuildOptions(elements);

                // <classpaths><class>
                group    = data[G.Classpaths];
                elements = group?.GetElementsByTagName(E.Class);
                ParseClasspaths(elements);

                // <includeLibraries><element>
                group    = data[G.IncludeLibraries];
                elements = group?.GetElementsByTagName(E.Element);
                ParseIncludeLibraries(elements);

                // <libraryPaths><element>
                group    = data[G.LibraryPaths];
                elements = group?.GetElementsByTagName(E.Element);
                ParseLibraryPaths(elements);

                // <externalLibraryPaths><element>
                group    = data[G.ExternalLibraryPaths];
                elements = group?.GetElementsByTagName(E.Element);
                ParseExternalLibraryPaths(elements);

                // <externalLibraryPaths><element>
                group    = data[G.RslPaths];
                elements = group?.GetElementsByTagName(E.Element);
                ParseRslPaths(elements);

                exitCode = 0;
                return(false);
            }
            catch (FormatException e)
            {
                return(ErrorHelper.ErrorParsingProjectFile(out exitCode, e));
            }
        }
Ejemplo n.º 19
0
        private static bool CheckNonBuildSyntax(string[] args, out ExitCodes exitCode)
        {
            if (args.Length > 0)
            {
                string key = args[0];

                if (key.Length > 0 && key[0] == '-')
                {
                    switch (key.Substring(1).ToLower())
                    {
                    case Argument.Help:
                    case Argument.HelpAlias:
                        ShowHelp();

                        exitCode = ExitCodes.NoError;
                        return(true);

                    case Argument.Info:
                    case Argument.InfoAlias:
                        if (args.Length == 1)
                        {
                            return(ErrorHelper.ValueExpected(out exitCode, Argument.Info));
                        }

                        if (!byte.TryParse(args[1], out byte code) || !Enum.IsDefined(typeof(ExitCodes), code))
                        {
                            return(ErrorHelper.IncorrectArgumentValue(out exitCode, Argument.Info, args[1]));
                        }

                        WriteLine($"ExitCode ({code}): {nameof(ExitCodes)}.{(ExitCodes) code}");

                        exitCode = ExitCodes.NoError;
                        return(true);

                    case Argument.Version:
                    case Argument.VersionAlias:
                        DisplayVersion();

                        exitCode = ExitCodes.NoError;
                        return(true);
                    }
                }
            }

            exitCode = 0;
            return(false);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Render (part of) a page to the specified destination.
        /// </summary>
        /// <param name="pageNumber">The number of the page to render (starting at 0).</param>
        /// <param name="region">The region of the page to render in page units.</param>
        /// <param name="zoom">The scale at which the page will be rendered. This will determine the size in pixel of the image.</param>
        /// <param name="pixelFormat">The format of the pixel data.</param>
        /// <param name="destination">The address of the buffer where the pixel data will be written. There must be enough space available to write the values for all the pixels, otherwise this will fail catastrophically!</param>
        /// <param name="includeAnnotations">If this is <see langword="true" />, annotations (e.g. signatures) are included in the display list that is generated. Otherwise, only the page contents are included.</param>
        public void Render(int pageNumber, Rectangle region, double zoom, PixelFormats pixelFormat, IntPtr destination, bool includeAnnotations = true)
        {
            if (DisplayLists[pageNumber] == null)
            {
                DisplayLists[pageNumber] = new MuPDFDisplayList(this.OwnerContext, this.Pages[pageNumber], includeAnnotations);
            }

            if (zoom < 0.000001 | zoom * region.Width <= 0.001 || zoom * region.Height <= 0.001)
            {
                throw new ArgumentOutOfRangeException(nameof(zoom), zoom, "The zoom factor is too small!");
            }

            if (this.ImageXRes != 72 || this.ImageYRes != 72)
            {
                zoom  *= Math.Sqrt(this.ImageXRes * this.ImageYRes) / 72;
                region = new Rectangle(region.X0 * 72 / this.ImageXRes, region.Y0 * 72 / this.ImageYRes, region.X1 * 72 / this.ImageXRes, region.Y1 * 72 / this.ImageYRes);
            }

            float fzoom = (float)zoom;

            ExitCodes result = (ExitCodes)NativeMethods.RenderSubDisplayList(OwnerContext.NativeContext, DisplayLists[pageNumber].NativeDisplayList, region.X0, region.Y0, region.X1, region.Y1, fzoom, (int)pixelFormat, destination, IntPtr.Zero);

            switch (result)
            {
            case ExitCodes.EXIT_SUCCESS:
                break;

            case ExitCodes.ERR_CANNOT_RENDER:
                throw new MuPDFException("Cannot render page", result);

            default:
                throw new MuPDFException("Unknown error", result);
            }

            RoundedRectangle roundedRegion = region.Round(fzoom);
            RoundedSize      roundedSize   = new RoundedSize(roundedRegion.Width, roundedRegion.Height);

            if (pixelFormat == PixelFormats.RGBA || pixelFormat == PixelFormats.BGRA)
            {
                Utils.UnpremultiplyAlpha(destination, roundedSize);
            }

            if (this.ClipToPageBounds && !Pages[pageNumber].Bounds.Contains(DisplayLists[pageNumber].Bounds.Intersect(region)))
            {
                Utils.ClipImage(destination, roundedSize, region, Pages[pageNumber].Bounds, pixelFormat);
            }
        }
Ejemplo n.º 21
0
        /// <inheritdoc/>
        public async Task <int> ExecuteCommandAsync(IEnumerable <string> commandLineArguments)
        {
            _logger.LogInformation("Executing command '{CommandLineArguments}'.", commandLineArguments);

            using (IServiceScope serviceScope = _serviceScopeFactory.CreateScope())
            {
                IServiceProvider provider     = serviceScope.ServiceProvider;
                ICliContext      cliContext   = provider.GetRequiredService <ICliContext>();
                Guid             cliContextId = cliContext.Id;

                _logger.LogDebug("New scope created with CliContext {CliContextId}.", cliContextId);

                CommandInput input = CommandInputResolver.Parse(commandLineArguments, _rootSchemaAccessor.RootSchema.GetCommandNames());
                ((CliContext)cliContext).Input = input;

                try
                {
                    // Execute middleware pipeline
                    await RunPipelineAsync(provider, cliContext);
                }
                catch (Exception ex)
                {
                    _logger.LogDebug("Exception occured. Trying to find exception handler.");

                    IEnumerable <ICliExceptionHandler> exceptionHandlers = provider.GetServices <ICliExceptionHandler>();
                    foreach (ICliExceptionHandler handler in exceptionHandlers)
                    {
                        if (handler.HandleException(ex))
                        {
                            _logger.LogDebug(ex, "Exception handled by {ExceptionHandlerType}.", handler.GetType().FullName);

                            return(ExitCodes.FromException(ex));
                        }
                    }

                    _logger.LogCritical(ex, "Unhandled exception during command execution.");

                    throw;
                }
                finally
                {
                    _logger.LogDebug("Disposed scope with CliContext {CliContextId}.", cliContextId);
                }

                return(cliContext.ExitCode ?? ExitCodes.Error);
            }
        }
Ejemplo n.º 22
0
        static EventLogEntryType ExitCodeToEventLogEntryType(ExitCodes ExitCode)
        {
            // Tailor behavior of this one to my taste.  Windows event log should only have red exclamation marks for major / program errors.
            if ((ExitCode & ExitCodes.FetchFailedOrEmpty) == ExitCodes.FetchFailedOrEmpty && ExitCode <= ExitCodes.FetchFailedOrEmpty)
            {
                return(EventLogEntryType.Warning);
            }

            if (ExitCode >= ExitCodes.FailureCodesStart)
            {
                return(EventLogEntryType.Error);
            }
            if (ExitCode >= ExitCodes.WarningCodesStart)
            {
                return(EventLogEntryType.Warning);
            }
            return(EventLogEntryType.Information);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Create a new <see cref="MuPDFContext"/> instance with the specified cache store size.
        /// </summary>
        /// <param name="storeSize">The maximum size in bytes of the resource cache store. The default value is 256 MiB.</param>
        public MuPDFContext(long storeSize = 256 << 20)
        {
            ExitCodes result = (ExitCodes)NativeMethods.CreateContext((ulong)storeSize, ref NativeContext);

            switch (result)
            {
            case ExitCodes.EXIT_SUCCESS:
                break;

            case ExitCodes.ERR_CANNOT_CREATE_CONTEXT:
                throw new MuPDFException("Cannot create MuPDF context", result);

            case ExitCodes.ERR_CANNOT_REGISTER_HANDLERS:
                throw new MuPDFException("Cannot register document handlers", result);

            default:
                throw new MuPDFException("Unknown error", result);
            }
        }
Ejemplo n.º 24
0
        private static int MainInner(string[] args)
        {
            try
            {
                var parser = BuildCommandLine();
                exitCode = (ExitCodes)parser.Invoke(args);
            }
            catch (GitException ex)
            {
                Console.Error.WriteLine($"ERROR: {ex.Message}");
                exitCode = ex.ErrorCode switch
                {
                    GitException.ErrorCodes.ObjectNotFound when ex.iSShallowClone => ExitCodes.ShallowClone,
                                                                   _ => ExitCodes.InternalError,
                };
            }

            return((int)exitCode);
        }
Ejemplo n.º 25
0
        static void _PrintHelpAndExit(IEnumerable<Option> options, string headertext, string examples, ExitCodes exitCode)
        {
            var maxLongCommandLength =
                options.Max(o => o.LongOption.Length);

            var atLeastOneValueNeeded =
                options.Where(o => o.NeedsValue).Count() > 0;

            var valuePlaceholder = atLeastOneValueNeeded ? new string(' ', 10) : "";

            if (string.IsNullOrWhiteSpace(headertext) == false)
            {
                Console.WriteLine(_TrimAllLines(headertext));
                Console.WriteLine();
            }

            Console.WriteLine("Usage:");
            foreach (var option in options)
            {
                var longOption =
                    string.IsNullOrWhiteSpace(option.LongOption) ? "" : $" --{option.LongOption + new string(' ', maxLongCommandLength - option.LongOption.Length)}";

                var value =
                    option.NeedsValue ? $" <{option.ShortOption}_value>" : valuePlaceholder;

                var description =
                    (option.Mandatory ? " MANDATORY" : "")
                    + (string.IsNullOrWhiteSpace(option.Description) ? "" : $" {option.Description}");
                if (string.IsNullOrWhiteSpace(description) == false)
                    description = $" :{description}";

                Console.WriteLine($"-{option.ShortOption}{longOption}{value}{description}");
            }

            if (string.IsNullOrWhiteSpace(examples) == false)
            {
                Console.WriteLine();
                Console.WriteLine("Examples:");
                Console.WriteLine(_TrimAllLines(examples));
            }

            Environment.Exit((int)exitCode);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Save (part of) a page to an image file in the specified format.
        /// </summary>
        /// <param name="pageNumber">The number of the page to render (starting at 0).</param>
        /// <param name="region">The region of the page to render in page units.</param>
        /// <param name="zoom">The scale at which the page will be rendered. This will determine the size in pixel of the image.</param>
        /// <param name="pixelFormat">The format of the pixel data.</param>
        /// <param name="fileName">The path to the output file.</param>
        /// <param name="fileType">The output format of the file.</param>
        /// <param name="includeAnnotations">If this is <see langword="true" />, annotations (e.g. signatures) are included in the display list that is generated. Otherwise, only the page contents are included.</param>
        public void SaveImage(int pageNumber, Rectangle region, double zoom, PixelFormats pixelFormat, string fileName, RasterOutputFileTypes fileType, bool includeAnnotations = true)
        {
            if (pixelFormat == PixelFormats.RGBA && fileType == RasterOutputFileTypes.PNM)
            {
                throw new ArgumentException("Cannot save an image with alpha channel in PNM format!", nameof(fileType));
            }

            if (DisplayLists[pageNumber] == null)
            {
                DisplayLists[pageNumber] = new MuPDFDisplayList(this.OwnerContext, this.Pages[pageNumber], includeAnnotations);
            }

            if (zoom < 0.000001 | zoom * region.Width <= 0.001 || zoom * region.Height <= 0.001)
            {
                throw new ArgumentOutOfRangeException(nameof(zoom), zoom, "The zoom factor is too small!");
            }

            if (this.ImageXRes != 72 || this.ImageYRes != 72)
            {
                zoom  *= Math.Sqrt(this.ImageXRes * this.ImageYRes) / 72;
                region = new Rectangle(region.X0 * 72 / this.ImageXRes, region.Y0 * 72 / this.ImageYRes, region.X1 * 72 / this.ImageXRes, region.Y1 * 72 / this.ImageYRes);
            }

            float fzoom = (float)zoom;

            ExitCodes result = (ExitCodes)NativeMethods.SaveImage(OwnerContext.NativeContext, DisplayLists[pageNumber].NativeDisplayList, region.X0, region.Y0, region.X1, region.Y1, fzoom, (int)pixelFormat, fileName, (int)fileType);

            switch (result)
            {
            case ExitCodes.EXIT_SUCCESS:
                break;

            case ExitCodes.ERR_CANNOT_RENDER:
                throw new MuPDFException("Cannot render page", result);

            case ExitCodes.ERR_CANNOT_SAVE:
                throw new MuPDFException("Cannot save to the output file", result);

            default:
                throw new MuPDFException("Unknown error", result);
            }
        }
Ejemplo n.º 27
0
        public void calcStats()
        {
            Dictionary <object, ITranslatable> texts = fileManager.GetFullDictionary();
            TroubleType trouble;

            foreach (ITranslatable text in texts.Values)
            {
                if (text.Troublesome(out trouble))
                {
                    troubleDict[trouble]++;
                }
            }

            if (troubleDict[TroubleType.duplicate] > 0)
            {
                result |= ExitCodes.duplicates;
            }
            if (troubleDict[TroubleType.absence] > 0)
            {
                result |= ExitCodes.absence;
            }
        }
Ejemplo n.º 28
0
        public static void Exit(ExitCodes reason)
        {
            if (Exiting != null)
            {
                EventHandler <EventArgs>[] delegates = (EventHandler <EventArgs>[])Exiting.GetInvocationList();
                if (delegates != null)
                {
                    EventArgs e = new EventArgs();
                    for (int i = 0; i < delegates.Length; i++)
                    {
                        try
                        {
                            delegates[i].Invoke(null, e);
                        }
                        catch
                        {
                        }
                    }
                }
            }

            Environment.Exit((int)reason);
        }
Ejemplo n.º 29
0
        private static void OutputError(ExitCodes errorCode, bool outputMessage, string extraMessage = null)
        {
            if (errorCode != ExitCodes.OK)
            {
                if (outputMessage)
                {
                    Console.Write($"Error {errorCode}");
                }
                else
                {
                    Console.Write($"{errorCode}");
                }

                if (outputMessage)
                {
                    var exitCodeDisplayName = errorCode.GetAttribute <DisplayAttribute>();

                    if (!string.IsNullOrEmpty(exitCodeDisplayName.Name))
                    {
                        Console.Write($": { exitCodeDisplayName.Name }");
                    }

                    if (string.IsNullOrEmpty(extraMessage))
                    {
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine($" ({ extraMessage })");
                    }
                }
                else
                {
                    Console.WriteLine("");
                }
            }
        }
Ejemplo n.º 30
0
        public int Execute(CommandLineApplication cmd)
        {
            bool   delaySign       = _delaySign.HasValue();
            bool   force           = _force.HasValue();
            string keyFile         = _keyFile.Value;
            string assemblyFile    = _assemblyFile.Value;
            string outAssemblyFile = !string.IsNullOrEmpty(_outAssemblyFile.Value)
                ? _outAssemblyFile.Value
                : null;

            try
            {
                if (File.Exists(outAssemblyFile) && !force)
                {
                    throw new FileAlreadyExistsException(outAssemblyFile);
                }

                if (delaySign)
                {
                    StrongNamePublicKey publicKey = _keyLoader.LoadPublicKey(keyFile);
                    _signer.DelaySignAssembly(assemblyFile, publicKey, outAssemblyFile);
                }
                else
                {
                    StrongNameKey key = _keyLoader.LoadKey(keyFile);
                    _signer.SignAssembly(assemblyFile, key, outAssemblyFile);
                }
            }
            catch (Exception error)
            {
                cmd.Error.WriteLine("ERROR: {0}", error.Message);
                return(ExitCodes.FromException(error));
            }

            cmd.Out.WriteLine("Assembly '{0}' successfully signed.", outAssemblyFile);
            return(ExitCodes.Success);
        }
Ejemplo n.º 31
0
        private static void Exit(ExitCodes exitCode, StartupContext startupArgs)
        {
            LogManager.Shutdown();

            if (exitCode != ExitCodes.Normal)
            {
                System.Console.WriteLine("Press enter to exit...");

                System.Threading.Thread.Sleep(1000);

                if (exitCode == ExitCodes.NonRecoverableFailure)
                {
                    if (startupArgs?.ExitImmediately == true)
                    {
                        System.Console.WriteLine("Non-recoverable failure, but set to exit immediately");

                        Environment.Exit((int)exitCode);
                    }

                    System.Console.WriteLine("Non-recoverable failure, waiting for user intervention...");
                    for (int i = 0; i < 3600; i++)
                    {
                        System.Threading.Thread.Sleep(1000);

                        if (!System.Console.IsInputRedirected && System.Console.KeyAvailable)
                        {
                            break;
                        }
                    }
                }

                // Please note that ReadLine silently succeeds if there is no console, KeyAvailable does not.
                System.Console.ReadLine();
            }

            Environment.Exit((int)exitCode);
        }
Ejemplo n.º 32
0
 public override void Shutdown(ExitCodes code)
 {
     // Do nothing.
 }
Ejemplo n.º 33
0
        static async Task RunOptionsAndReturnExitCodeAsync(Options o)
        {
            #region parse verbosity option

            switch (o.Verbosity)
            {
            // quiet
            case "q":
            case "quiet":
                verbosityLevel = VerbosityLevel.Quiet;
                break;

            // minimal
            case "m":
            case "minimal":
                verbosityLevel = VerbosityLevel.Minimal;
                break;

            // normal
            case "n":
            case "normal":
                verbosityLevel = VerbosityLevel.Normal;
                break;

            // detailed
            case "d":
            case "detailed":
                verbosityLevel = VerbosityLevel.Detailed;
                break;

            // diagnostic
            case "diag":
            case "diagnostic":
                verbosityLevel = VerbosityLevel.Diagnostic;
                break;

            default:
                throw new ArgumentException("Invalid option for Verbosity");
            }

            #endregion

            Console.WriteLine(headerInfo);
            Console.WriteLine(copyrightInfo);
            Console.WriteLine();

            #region target processing

            // if a target name was specified, try to be smart and set the platform accordingly (in case it wasn't specified)
            if (string.IsNullOrEmpty(o.Platform) &&
                !string.IsNullOrEmpty(o.TargetName))
            {
                // easiest one: ESP32
                if (o.TargetName.Contains("ESP32"))
                {
                    o.Platform = "esp32";
                }
                else if (
                    o.TargetName.Contains("ST") ||
                    o.TargetName.Contains("MBN_QUAIL") ||
                    o.TargetName.Contains("NETDUINO3") ||
                    o.TargetName.Contains("GHI FEZ") ||
                    o.TargetName.Contains("IngenuityMicro") ||
                    o.TargetName.Contains("ORGPAL")
                    )
                {
                    // candidates for STM32
                    o.Platform = "stm32";
                }
                else if (
                    o.TargetName.Contains("TI_CC1352")
                    )
                {
                    // candidates for TI CC13x2
                    o.Platform = "cc13x2";
                }
                else
                {
                    // other supported platforms will go here
                    // in case a wacky target is entered by the user, the package name will be checked against Bintray repo
                }
            }

            #endregion

            #region platform specific options

            // if an option was specified and has an obvious platform, try to be smart and set the platform accordingly (in case it wasn't specified)
            if (string.IsNullOrEmpty(o.Platform))
            {
                // JTAG related
                if (
                    o.ListJtagDevices ||
                    !string.IsNullOrEmpty(o.JtagDeviceId) ||
                    o.HexFile.Any() ||
                    o.BinFile.Any())
                {
                    o.Platform = "stm32";
                }
                // DFU related
                else if (
                    o.ListDevicesInDfuMode ||
                    !string.IsNullOrEmpty(o.DfuDeviceId) ||
                    !string.IsNullOrEmpty(o.DfuFile))
                {
                    o.Platform = "stm32";
                }
                // ESP32 related
                else if (
                    !string.IsNullOrEmpty(o.SerialPort) ||
                    (o.BaudRate != 921600) ||
                    (o.Esp32FlashMode != "dio") ||
                    (o.Esp32FlashFrequency != 40))
                {
                    o.Platform = "esp32";
                }
            }

            #endregion


            #region ESP32 platform options

            if (o.Platform == "esp32")
            {
                // COM port is mandatory for ESP32
                if (string.IsNullOrEmpty(o.SerialPort))
                {
                    _exitCode = ExitCodes.E6001;
                    return;
                }

                EspTool espTool;

                try
                {
                    espTool = new EspTool(
                        o.SerialPort,
                        o.BaudRate,
                        o.Esp32FlashMode,
                        o.Esp32FlashFrequency);
                }
                catch (Exception)
                {
                    _exitCode = ExitCodes.E4005;
                    return;
                }

                EspTool.DeviceInfo esp32Device;

                if (espTool.ComPortAvailable)
                {
                    try
                    {
                        esp32Device = espTool.TestChip();
                    }
                    catch (EspToolExecutionException ex)
                    {
                        _exitCode     = ExitCodes.E4000;
                        _extraMessage = ex.Message;

                        return;
                    }
                }
                else
                {
                    // couldn't open COM port
                    // done here, this command has no further processing
                    _exitCode = ExitCodes.E6000;

                    return;
                }

                if (verbosityLevel >= VerbosityLevel.Normal)
                {
                    Console.WriteLine($"Connected to ESP32 { esp32Device.ChipName } with MAC address { esp32Device.MacAddress }");
                    Console.WriteLine($"features { esp32Device.Features }");

                    string flashSize = esp32Device.FlashSize >= 0x10000 ? $"{ esp32Device.FlashSize / 0x100000 }MB" : $"{ esp32Device.FlashSize / 0x400 }kB";

                    Console.WriteLine($"Flash information: manufacturer 0x{ esp32Device.FlashManufacturerId } device 0x{ esp32Device.FlashDeviceModelId } size { flashSize }");
                }

                // set verbosity
                espTool.Verbosity = verbosityLevel;

                // backup requested
                if (!string.IsNullOrEmpty(o.BackupPath) ||
                    !string.IsNullOrEmpty(o.BackupFile))
                {
                    try
                    {
                        // backup path specified, backup deployment
                        _exitCode = Esp32Operations.BackupFlash(espTool, esp32Device, o.BackupPath, o.BackupFile, verbosityLevel);
                        if (_exitCode != ExitCodes.OK)
                        {
                            // done here
                            return;
                        }
                    }
                    catch (ReadEsp32FlashException ex)
                    {
                        _exitCode     = ExitCodes.E4004;
                        _extraMessage = ex.Message;

                        // done here
                        return;
                    }
                }

                // update operation requested?
                if (o.Update)
                {
                    try
                    {
                        // write flash
                        _exitCode = await Esp32Operations.UpdateFirmwareAsync(
                            espTool,
                            esp32Device,
                            o.TargetName,
                            true,
                            o.FwVersion,
                            o.Stable,
                            o.DeploymentImage,
                            null,
                            verbosityLevel);

                        if (_exitCode != ExitCodes.OK)
                        {
                            // done here
                            return;
                        }

                        // done here
                        _exitCode = ExitCodes.OK;
                        return;
                    }
                    catch (ReadEsp32FlashException ex)
                    {
                        _exitCode     = ExitCodes.E4004;
                        _extraMessage = ex.Message;
                    }
                    catch (WriteEsp32FlashException ex)
                    {
                        _exitCode     = ExitCodes.E4003;
                        _extraMessage = ex.Message;
                    }
                    catch (EspToolExecutionException ex)
                    {
                        _exitCode     = ExitCodes.E4000;
                        _extraMessage = ex.Message;
                    }
                }

                // it's OK to deploy after update
                if (o.Deploy)
                {
                    // need to take care of flash address
                    string appFlashAddress = null;

                    if (o.FlashAddress.Any())
                    {
                        // take the first address, it should be the only one valid
                        appFlashAddress = o.FlashAddress.ElementAt(0);
                    }
                    else
                    {
                        _exitCode = ExitCodes.E9009;
                        return;
                    }

                    // this to flash a deployment image without updating the firmware
                    try
                    {
                        // write flash
                        _exitCode = await Esp32Operations.UpdateFirmwareAsync(
                            espTool,
                            esp32Device,
                            null,
                            false,
                            null,
                            false,
                            o.DeploymentImage,
                            appFlashAddress,
                            verbosityLevel);

                        if (_exitCode != ExitCodes.OK)
                        {
                            // done here
                            return;
                        }

                        // done here
                        _exitCode = ExitCodes.OK;
                        return;
                    }
                    catch (ReadEsp32FlashException ex)
                    {
                        _exitCode     = ExitCodes.E4004;
                        _extraMessage = ex.Message;
                    }
                    catch (WriteEsp32FlashException ex)
                    {
                        _exitCode     = ExitCodes.E4003;
                        _extraMessage = ex.Message;
                    }
                    catch (EspToolExecutionException ex)
                    {
                        _exitCode     = ExitCodes.E4000;
                        _extraMessage = ex.Message;
                    }
                }

                // done here
                return;
            }

            #endregion

            #region STM32 platform options

            if (o.Platform == "stm32")
            {
                if (o.ListDevicesInDfuMode)
                {
                    var connecteDevices = StmDfuDevice.ListDfuDevices();

                    if (connecteDevices.Count == 0)
                    {
                        Console.WriteLine("No DFU devices found");
                    }
                    else
                    {
                        Console.WriteLine("-- Connected DFU devices --");

                        foreach (string deviceId in connecteDevices)
                        {
                            Console.WriteLine(deviceId);
                        }

                        Console.WriteLine("---------------------------");
                    }

                    // done here, this command has no further processing
                    _exitCode = ExitCodes.OK;

                    return;
                }

                if (o.ListJtagDevices)
                {
                    try
                    {
                        var connecteDevices = StmJtagDevice.ListDevices();

                        if (connecteDevices.Count == 0)
                        {
                            Console.WriteLine("No JTAG devices found");
                        }
                        else
                        {
                            Console.WriteLine("-- Connected JTAG devices --");

                            foreach (string deviceId in connecteDevices)
                            {
                                Console.WriteLine(deviceId);
                            }

                            Console.WriteLine("---------------------------");
                        }

                        // done here, this command has no further processing
                        _exitCode = ExitCodes.OK;
                    }
                    catch (Exception ex)
                    {
                        // exception with
                        _exitCode     = ExitCodes.E5000;
                        _extraMessage = ex.Message;
                    }

                    return;
                }

                if (!string.IsNullOrEmpty(o.DfuFile))
                {
                    // there is a DFU file argument, so follow DFU path
                    var dfuDevice = new StmDfuDevice(o.DfuDeviceId);

                    if (!dfuDevice.DevicePresent)
                    {
                        // no DFU device found

                        // done here, this command has no further processing
                        _exitCode = ExitCodes.E1000;

                        return;
                    }

                    if (verbosityLevel >= VerbosityLevel.Normal)
                    {
                        Console.WriteLine($"Connected to DFU device with ID { dfuDevice.DeviceId }");
                    }

                    // set verbosity
                    dfuDevice.Verbosity = verbosityLevel;

                    // get mass erase option
                    dfuDevice.DoMassErase = o.MassErase;

                    try
                    {
                        dfuDevice.FlashDfuFile(o.DfuFile);

                        // done here, this command has no further processing
                        _exitCode = ExitCodes.OK;

                        return;
                    }
                    catch (DfuFileDoesNotExistException)
                    {
                        // DFU file doesn't exist
                        _exitCode = ExitCodes.E1002;
                    }
                    catch (Exception ex)
                    {
                        // exception with DFU operation
                        _exitCode     = ExitCodes.E1003;
                        _extraMessage = ex.Message;
                    }
                }
                else if (
                    o.BinFile.Any() &&
                    o.HexFile.Any())
                {
                    // this has to be a JTAG connected device

                    #region STM32 JTAG options

                    try
                    {
                        var jtagDevice = new StmJtagDevice(o.JtagDeviceId);

                        if (!jtagDevice.DevicePresent)
                        {
                            // no JTAG device found

                            // done here, this command has no further processing
                            _exitCode = ExitCodes.E5001;

                            return;
                        }

                        if (verbosityLevel >= VerbosityLevel.Normal)
                        {
                            Console.WriteLine($"Connected to JTAG device with ID { jtagDevice.DeviceId }");
                        }

                        // set verbosity
                        jtagDevice.Verbosity = verbosityLevel;

                        // get mass erase option
                        jtagDevice.DoMassErase = o.MassErase;

                        if (o.HexFile.Any())
                        {
                            _exitCode = jtagDevice.FlashHexFiles(o.HexFile);

                            // done here
                            return;
                        }

                        if (o.BinFile.Any())
                        {
                            _exitCode = jtagDevice.FlashBinFiles(o.BinFile, o.FlashAddress);

                            // done here
                            return;
                        }
                    }
                    catch (CantConnectToJtagDeviceException)
                    {
                        // done here, this command has no further processing
                        _exitCode = ExitCodes.E5002;
                    }

                    #endregion
                }
                else if (!string.IsNullOrEmpty(o.TargetName))
                {
                    // update operation requested?
                    if (o.Update)
                    {
                        // this to update the device with fw from Bintray

                        // need to take care of flash address
                        string appFlashAddress = null;

                        if (o.FlashAddress.Any())
                        {
                            // take the first address, it should be the only one valid
                            appFlashAddress = o.FlashAddress.ElementAt(0);
                        }

                        _exitCode = await Stm32Operations.UpdateFirmwareAsync(
                            o.TargetName,
                            o.FwVersion,
                            o.Stable,
                            true,
                            o.DeploymentImage,
                            appFlashAddress,
                            o.DfuDeviceId,
                            o.JtagDeviceId,
                            verbosityLevel);

                        if (_exitCode != ExitCodes.OK)
                        {
                            // done here
                            return;
                        }
                    }

                    // it's OK to deploy after update
                    if (o.Deploy)
                    {
                        // this to flash a deployment image without updating the firmware

                        // need to take care of flash address
                        string appFlashAddress = null;

                        if (o.FlashAddress.Any())
                        {
                            // take the first address, it should be the only one valid
                            appFlashAddress = o.FlashAddress.ElementAt(0);
                        }
                        else
                        {
                            _exitCode = ExitCodes.E9009;
                            return;
                        }

                        _exitCode = await Stm32Operations.UpdateFirmwareAsync(
                            o.TargetName,
                            null,
                            false,
                            false,
                            o.DeploymentImage,
                            appFlashAddress,
                            o.DfuDeviceId,
                            o.JtagDeviceId,
                            verbosityLevel);

                        if (_exitCode != ExitCodes.OK)
                        {
                            // done here
                            return;
                        }
                    }

                    // reset MCU requested?
                    if (o.ResetMcu)
                    {
                        _exitCode = Stm32Operations.ResetMcu(
                            o.JtagDeviceId,
                            verbosityLevel);

                        if (_exitCode != ExitCodes.OK)
                        {
                            // done here
                            return;
                        }
                    }
                }
            }

            #endregion


            #region TI CC13x2 platform options

            if (o.Platform == "cc13x2")
            {
                if (!string.IsNullOrEmpty(o.TargetName))
                {
                    // update operation requested?
                    if (o.Update)
                    {
                        // this to update the device with fw from Bintray

                        // need to take care of flash address
                        string appFlashAddress = null;

                        if (o.FlashAddress.Any())
                        {
                            // take the first address, it should be the only one valid
                            appFlashAddress = o.FlashAddress.ElementAt(0);
                        }

                        _exitCode = await CC13x26x2Operations.UpdateFirmwareAsync(
                            o.TargetName,
                            o.FwVersion,
                            o.Stable,
                            true,
                            o.DeploymentImage,
                            appFlashAddress,
                            verbosityLevel);

                        if (_exitCode != ExitCodes.OK)
                        {
                            // done here
                            return;
                        }
                    }

                    // it's OK to deploy after update
                    if (o.Deploy)
                    {
                        // this to flash a deployment image without updating the firmware

                        // need to take care of flash address
                        string appFlashAddress = null;

                        if (o.FlashAddress.Any())
                        {
                            // take the first address, it should be the only one valid
                            appFlashAddress = o.FlashAddress.ElementAt(0);
                        }
                        else
                        {
                            _exitCode = ExitCodes.E9009;
                            return;
                        }

                        _exitCode = await CC13x26x2Operations.UpdateFirmwareAsync(
                            o.TargetName,
                            null,
                            false,
                            false,
                            o.DeploymentImage,
                            appFlashAddress,
                            verbosityLevel);

                        if (_exitCode != ExitCodes.OK)
                        {
                            // done here
                            return;
                        }
                    }

                    // reset MCU requested?
                    if (o.ResetMcu)
                    {
                        // can't reset CC13x2 device without configuration file
                        // would require to specify the exact target name and then had to try parsing that
                        _exitCode = ExitCodes.E9000;

                        // done here
                        return;
                    }
                }

                if (o.TIInstallXdsDrivers)
                {
                    _exitCode = CC13x26x2Operations.InstallXds110Drivers(verbosityLevel);

                    if (_exitCode != ExitCodes.OK)
                    {
                        // done here
                        return;
                    }
                }
            }

            #endregion
        }
Ejemplo n.º 34
0
 static Task HandleErrorsAsync(IEnumerable <Error> errors)
 {
     _exitCode = ExitCodes.E9000;
     return(Task.CompletedTask);
 }
 //--------------------------------------------------
 void ReportErrorAndExit(string errmsg, ExitCodes exitcode)
 {
     MessageBox.Show(errmsg,
         System.Reflection.Assembly.GetExecutingAssembly().GetName().Name,
         MessageBoxButton.OK, MessageBoxImage.Error);
     Environment.Exit((int)exitcode);
 }
Ejemplo n.º 36
0
 private void DisplayHelpAndExit(ExitCodes code)
 {
     Console.Error.WriteLine("Usage: {0} -t [bank type] [file name]", AppDomain.CurrentDomain.FriendlyName);
     ListSupportedConverters();
     Environment.Exit((int)code);
 }
Ejemplo n.º 37
0
 public override string FinalMessage(ExitCodes existingExitFlags)
 {
     // note this is the only case where we return a success code but don't emit SuccessMessage
     return(Switches.HelpMessage);
 }
Ejemplo n.º 38
0
        void usage(ExitCodes res = ExitCodes.Success)
        {
            Console.WriteLine ("Usage: [-c|--config] [-h|--help] <path/to/winjs/home> fileToExecute");
            Console.WriteLine (
                @"If the environment variable WINJSHOME is not set then -c
                and the fullpath to the location of the winjs configuration
                file is required."
            );

            Environment.Exit ((int) res);
        }
Ejemplo n.º 39
0
 public ConsoleException(string message, ExitCodes exitCode)
     : base(message)
 {
     ExitCode = exitCode;
 }
 //--------------------------------------------------
 static void ReportErrorAndExit(string errmsg, ExitCodes exitcode)
 {
     PrintAppInfoAndUsage();
     Console.ForegroundColor = ConsoleColor.Red;
     Console.WriteLine(errmsg);
     Environment.Exit((int)exitcode);
 }
Ejemplo n.º 41
0
 public TfsCommandResult(ExitCodes exitCode, string output)
     : this((int)exitCode, output)
 {
 }