/// <summary> /// Gets the card indices specified on the command line /// </summary> /// <returns>The indices specified on the command line (defaults to all)</returns> public int[] GetCardIndices() { var sCardIndices = CommandLineParser.GetStringArg(CommandLineArg.CardIndices); var listCardIndices = new List <int>(); if (null != sCardIndices) { var arrayRanges = sCardIndices.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var sRange in arrayRanges) { var arrayEntries = sRange.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries); int nStart; int nEnd; // NOTE: all of the inputs are cardId (1 based) -- converted to 0 based internally switch (arrayEntries.Length) { case 1: if (int.TryParse(arrayEntries[0], out nStart)) { listCardIndices.Add(nStart - 1); } else { CommandLineUtil.ExitWithError("Invalid Card Index: " + sRange); } break; case 2: if (int.TryParse(arrayEntries[0], out nStart) && int.TryParse(arrayEntries[1], out nEnd)) { listCardIndices.AddRange(Enumerable.Range(nStart - 1, (nEnd - nStart) + 1)); } else { CommandLineUtil.ExitWithError("Invalid Card Index Range: " + sRange); } break; default: CommandLineUtil.ExitWithError("Invalid Card Index Range: " + sRange); break; } } return(listCardIndices.ToArray()); } return(null); }
/// <summary> /// Performs the export action /// </summary> /// <returns>true on success, false otherwise</returns> public bool Export() { var zFileCardExporter = CreateExporter(); zFileCardExporter.ProgressReporter = CardMakerInstance.ProgressReporterFactory.CreateReporter( Description, new string[] { ProgressName.LAYOUT, ProgressName.REFERENCE_DATA, ProgressName.CARD }, zFileCardExporter.ExportThread); try { zFileCardExporter.ProgressReporter.StartProcessing(null); return(true); } catch (Exception e) { CommandLineUtil.ExitWithError("Export failed. " + e); return(false); } }
/// <summary> /// Gets the layout indices /// </summary> /// <returns>The layout indices specified on the command line (defaults to all)</returns> protected int[] GetLayoutIndices() { var arrayLayoutNames = CommandLineParser.GetStringArgs(CommandLineArg.LayoutNames); // get the indices of the layouts by name if (null != arrayLayoutNames) { var idx = 0; var dictionaryLayoutNameToLayout = ProjectManager.Instance.LoadedProject.Layout.ToDictionary(layout => layout.Name.ToUpper(), layout => idx++); var listMissingLayout = arrayLayoutNames .Where(sLayoutName => !dictionaryLayoutNameToLayout.ContainsKey(sLayoutName.ToUpper())).ToList(); if (listMissingLayout.Count > 0) { CommandLineUtil.ExitWithError("Invalid layout names specified: " + string.Join(",", listMissingLayout.ToArray())); } return(arrayLayoutNames .Where(sLayoutName => dictionaryLayoutNameToLayout.ContainsKey(sLayoutName.ToUpper())) .Select(sLayoutName => dictionaryLayoutNameToLayout[sLayoutName.ToUpper()]).ToArray()); } // default to all layouts return(Enumerable.Range(0, ProjectManager.Instance.LoadedProject.Layout.Length).ToArray()); }