protected override int ExecuteArguments(IEnumerable <IArgument> args) { var srcPath = args.Get <Src1Argument>(); var srcType = args.Get <SrcType1Argument>(); var src2Path = args.Get <Src2Argument>(); var src2Type = args.Get <SrcType2Argument>(); var destPath = args.Get <DestArgument>(); var dpi = args.Get <DpiArgument>(); var width = args.Get <LineWidthArgument>(); var margin = args.Get <MarginArgument>(); var parPage = args.Get <ParPageArgument>(); var pdfContext = new PdfContext { FileName = Path.GetFileName(destPath.Argument), OutputPath = Path.GetDirectoryName(destPath.Argument), Dpi = dpi.GetArgumentAsFloat(), IsVisibleSeparateLine = args.Contains <VisibleLineArgument>(), }; var labelContext = new LabelContext { OutlineWidth = width.GetArgumentAsInt(), MarginRatio = margin.GetArgumentAsFloat(), ParPage = parPage.GetArgumentAsInt(), }; try { var toAddressList = CsvReader.Read(CsvResolver.ResolveType(srcType), srcPath.Argument) .Cast <IAddress>(); var fromAddress = CsvReader.Read(CsvResolver.ResolveType(src2Type), src2Path.Argument) .Cast <IAddress>().First(); var labelContents = this.BuildLabelContents(toAddressList, fromAddress); var drawer = new PdfDrawer(pdfContext, labelContext); drawer.Draw(labelContents); this._messenger.Send("PDF の作成を終了しました"); return(0); } catch (Exception ex) { this._messenger.Send("PDF の作成でエラーが発生しました"); this._messenger.Send(ex.Message); return(1); } }
protected override int ExecuteArguments(IEnumerable <IArgument> args) { var srcPathArg = args.Get <Src1Argument>(); var srcTypeArg = args.Get <SrcType1Argument>(); var destPathArg = args.Get <DestArgument>(); var destTypeArg = args.Get <DestTypeArgument>(); var srcType = CsvResolver.ResolveType(srcTypeArg); var destType = CsvResolver.ResolveType(destTypeArg); var srcConvertKind = CsvKindResolver.Resolve(srcType); var destConvertKind = CsvKindResolver.Resolve(destType); try { var converter = ConverterFactory.Create(srcConvertKind, destConvertKind); var records = CsvReader.Read(srcType, srcPathArg.Argument).Cast <ICsvModel>(); var dest = converter.Convert(records); CsvWriter.Write(destType, destPathArg.Argument, dest); this._messenger.Send("CSV 変換が終了しました"); return(0); } catch (Exception ex) { this._messenger.Send("CSV 変換でエラーが発生しました"); this._messenger.Send(ex.Message); this._messenger.Send(ex.StackTrace); return(1); } }