返回首页

您好,

我在Perl脚本,需要转换到C#。我想在我的C#Windows窗体应用程序中使用它。任何不知道如果有一个程序转换的Perl C#

在此先感谢!

----------------------

use MIME::Base64;

use strict;

use SOAP::Lite;

 

# Instance

my $SNC_HOST = "http://website.com";

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 => 'http://website.com'});

 

  # 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';

}
:7762422 |会员

回答

评论会员:spsathees 时间:2012/02/07
#!/usr/bin/perl -w

use strict;

my %next;

BEGIN {

    @next{'0'..'9','A'..'Z'}= ('1'..'9','A'..'Z','0');

}

sub inc36 {

    my $add= "";

    my $dig;

    while(  not $dig= $next{chop($_[0])}  ) {

        $add .= $dig;

        if(  ! length($_[0])  ) {

            $dig= '1';

            last;

        }

    }

    $_[0] .= $dig . $add;

}

while(  <DATA>  ) {

    for(  split " "  ) {

        print "$_ + 1 = ";

        inc36( $_ );

        print $_,$/;

    }

}
评论会员:RaisKazi 时间:2012/02/07
尝试下面的代码:
方法一:
在按钮的Click事件服务器端调用:

lblCessCategory.Text = CessDetail" ";
。lblCessCategory.Text = lblCessCategory.Text ds.Tables [0]行[I]"CessCategoryName"]的ToString()

lblCessCategory.Text lblCessCategory.Text ="";
lblCessCategory.Text = lblCessCategory.Text"LT输入类型="按钮的ID ='btnID'gt的;";

lblCessCategory.Text lblCessCategory.Text ="";

lblCessCategory.Text = lblCessCategory.Text"<输入类型='文本'ID ='txtID'gt;";
lblCessCategory.Text = lblCessCategory.Text"NBS​​P;";
把一个标签。aspx页。标签的ID将lblCessCategory。

方法2:
作为最后的解决办法由shobhna告诉你可以调用JavaScript函数