本文介绍了Perl脚本转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Perl中有一个小脚本,需要将其转换为C#.我想在我的C#Windows Form应用程序中使用它.是否知道是否有将Perl转换为C#的程序? 提前谢谢! ----------------------
Hi, I got a small script in Perl that needs to be converted to C#. I want to use it in my C# Windows Form application. Does any know if there is an program to convert Perl to C# ? Thanks in advance! ----------------------
use MIME::Base64; use strict; use SOAP::Lite; # Instance my $SNC_HOST = "website"; my $base64; my $buf; # upload and attach a file on the local disk, base 64 encode it into a string first open(FILE, "c:/number_test.xls") or die "$!"; while (read(FILE, $buf, 60*57)) { $base64 .= encode_base64($buf); } # call the sub routine to attach attach_incident(); sub attach_incident { # target the ecc_queue table my $soap = SOAP::Lite->proxy("$SNC_HOST/ecc_queue.do?SOAP"); my $method = SOAP::Data->name(''insert'')->attr({xmlns => ''website''}); # set the ecc_queue parameters my @params = (SOAP::Data->name(agent => ''AttachmentCreator'')); push(@params, SOAP::Data->name(topic => ''AttachmentCreator'') ); # identify the file name and its mime type push(@params, SOAP::Data->name(name => ''number_test.xls:application/vnd.ms-excel'') ); # attach to the incident, specifying its sys_id push(@params, SOAP::Data->name(source => ''incident:dd90c5d70a0a0b39000aac5aee704ae8'') ); # set the payload to be the base 64 encoded string representation of the file push(@params, SOAP::Data->name(payload => $base64) ); # invoke the web service my $result = $soap->call($method => @params); print_fault($result); print_result($result); } sub print_result { my ($result) = @_; if ($result->body && $result->body->{''insertResponse''}) { my %keyHash = %{ $result->body->{''insertResponse''} }; foreach my $k (keys %keyHash) { print "name=$k value=$keyHash{$k}\n"; } } } sub print_fault { my ($result) = @_; if ($result->fault) { print "faultcode=" . $result->fault->{''faultcode''} . "\n"; print "faultstring=" . $result->fault->{''faultstring''} . "\n"; print "detail=" . $result->fault->{''detail''} . "\n"; } } # use the itil user for basic auth credentials sub SOAP::Transport::HTTP::Client::get_basic_credentials { return ''itil'' => ''itil''; }推荐答案
SNC_HOST ="website"; my SNC_HOST = "website"; my
base64; 我的 base64; my
buf; #上传文件并将其附加到本地磁盘上,以64为基数首先将其编码为字符串 打开(FILE,"c:/number_test.xls")或死于" buf; # upload and attach a file on the local disk, base 64 encode it into a string first open(FILE, "c:/number_test.xls") or die "
更多推荐
Perl脚本转换为C#
发布评论