简体   繁体   English

VB.NET应用程序中的脚本自动化

[英]Scripting Automation within VB.NET application

The software company I work for offers data conversion as a service for new clients who have previously used other similar software. 我工作的软件公司为之前使用过其他类似软件的新客户提供数据转换服务。 I've written a VB.NET application to automate common conversion operations, and have separate logic between known vendors. 我编写了一个VB.NET应用程序来自动执行常见的转换操作,并在已知供应商之间使用单独的逻辑。 A particular file layout has become rather common, but due to the nature of how this particular competitor's application stores information, certain fields mean one thing for one client, and another for a different client. 特定的文件布局已变得相当普遍,但由于此特定竞争对手的应用程序如何存储信息的性质,某些字段对于一个客户端来说意味着一件事,而对于另一个客户端则意味着另一件事件。

Certain elements within this vendor's format change every time, so I've written the application to account for that. 此供应商格式中的某些元素每次都会更改,因此我已编写应用程序来解释此问题。 Because some data fields mean different things to different vendors, I have to change my mapping code every time. 由于某些数据字段对不同的供应商意味着不同的东西,我每次都必须更改我的映射代码。 This wasn't an issue when I had one of these every six months or so, but these are becoming much more common and I would much rather find a way to further automate this process. 当我每六个月左右使用其中一个时,这不是问题,但这些变得越来越普遍,我宁愿找到一种方法来进一步自动化这个过程。

I was thinking of implementing a simple interpreted scripting language that would allow me to save the conversion settings for the client in a text file, so I'm not having to feed the settings into my app every time I run it. 我正在考虑实现一种简单的解释脚本语言,它允许我在文本文件中保存客户端的转换设置,所以每次运行时我都不必将设置提供给我的应用程序。 My goal is to have the time spent in implementing this pay off in faster conversions in the long run. 我的目标是从长远来看,在更快的转换中花费时间来实现这种回报。

This is the example I had in my head: 这是我头脑中的例子:

# this is a comment
RECORD INCLUDE(source[Class] != 'I' && source[Category] != 99);

FIELDMAP
  destination[name] == source[name];
  desintation[address] == source[mailingaddress1];
  ...
END FIELDMAP

BEGIN
  # logic goes here
END

I don't want to make this more complicated than it needs to be. 我不想让它变得比它需要的更复杂。 I admit that I've never even looked into scripting and am kinda clueless as to where to start or what other considerations need to be made. 我承认我从来没有考虑过编写脚本,而且对于从哪里开始或者需要做出哪些其他考虑因素都是无能为力的。

Are there already scripting libraries for .NET that will do most of what I want? 是否已经有.NET的脚本库可以完成我想要的大部分工作? Is scripting the wrong way to go about this? 编写错误的脚本是为了解决这个问题吗? I really don't want to reinvent the wheel if there is a better way. 如果有更好的方法,我真的不想重新发明轮子。

Thank you for any help. 感谢您的任何帮助。 :) :)

IronPython (one of the the DLR languages Jake referred to) is a .NET implementation of the Python scripting language. IronPython (Jake提到的DLR语言之一)是Python脚本语言的.NET实现。 It allows you to access .NET code (including framework classes and class you've written) and would be an excellent choice for this sort of task. 它允许您访问.NET代码(包括您编写的框架类和类),并且是这类任务的绝佳选择。

It doesn't have any real dependencies (other than the .NET Framework) and you won't need to learn much learn much Python-specific syntax in order to get the job done. 它没有任何真正的依赖(除了.NET Framework),你不需要学习太多了解Python特定的语法来完成工作。

(If you decide to go with IronPython, I recommend using Notepad++ as your editor.) (如果您决定使用IronPython,我建议您使用Notepad ++作为编辑器。)

Rather than write a custom language, you could embed any of the DLR languages (IronPython, IronRuby, or JScript), or you can use compiler services to compile VB.NET from your application. 您可以嵌入任何DLR语言 (IronPython,IronRuby或JScript),也可以使用编译器服务从应用程序编译VB.NET,而不是编写自定义语言。

Another idea ... if you only need to change the mappings between variable names, maybe you could just come up with a little XML file that would define the mappings. 另一个想法......如果你只需要改变变量名之间的映射,也许你可以想出一个定义映射的小XML文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM