Visual Web Ripper Logo Visual Web Ripper Logo
Welcome Guest Search | Active Topics | Log In | Register

Tag as favorite
How to set transformation script
assaf
#1 Posted : Sunday, March 06, 2011 9:13:11 AM
Groups: Registered
Joined: 3/2/2011
Posts: 11
Location: Israel

I would like to manipulate the input transformation script for a form FormField element using API.

here is what I've got so far:

Code:

public void setScript(WrProject project,WrContent content)
        {

            WrScript script = new WrScript();
            //set up new script....???
            content.TranformationScript.IsEnabled = true;
            content.TranformationScript.ScriptType = WrScriptType.InputDataScript;
            content.TranformationScript.ScriptLanguage WebRipperUtils.WrScriptLanguageEnum.Csharp;
            content.TranformationScript.Assign(script);


         
        }


how do i set up a new script?
Sequentum Support
#2 Posted : Monday, March 07, 2011 4:38:48 AM

Groups: Administrators
Joined: 4/10/2010
Posts: 1,239
Location: Sydney, Australia
The property TranformationScript is only there for backward compatibility

You should use:

content.Scripts.GetScript(WrScriptType.ContentTransformation).Assign(script)
assaf
#3 Posted : Sunday, March 13, 2011 11:44:09 AM
Groups: Registered
Joined: 3/2/2011
Posts: 11
Location: Israel
I'm having trouble implementing the WrInputTransformationArguments class.

in other words, I want imitate the
TransformInput(WrInputTransformationArguments args) method and assign its content to a WrScript object.

Code:

            WrScript script = new WrScript();
            script.ScriptType = WrScriptType.InputDataScript;
            script.ScriptLanguage = WebRipperUtils.WrScriptLanguageEnum.Csharp;
            content.Scripts.GetScript(WrScriptType.InputDataScript).Assign(script);
            content.Scripts[0].IsEnabled = true;

       WrInputTransformationArguments trans = new WrInputTransformationArguments (???????)


thanks
Sequentum Support
#4 Posted : Monday, March 14, 2011 2:24:51 AM

Groups: Administrators
Joined: 4/10/2010
Posts: 1,239
Location: Sydney, Australia
I'm not quite sure what you are trying to achieve, but you cannot instantiate WrInputTransformationArguments in a stand-alone application, since it is instantiated with parameters that are extracted/calculated during runtime.
assaf
#5 Posted : Monday, March 14, 2011 2:49:03 AM
Groups: Registered
Joined: 3/2/2011
Posts: 11
Location: Israel

so is that means that I cannot create a transformation scripts dynamically using the API?

is there another way to do it?
Sequentum Support
#6 Posted : Monday, March 14, 2011 9:03:48 PM

Groups: Administrators
Joined: 4/10/2010
Posts: 1,239
Location: Sydney, Australia
You can create and add the script to the project, but you cannot run it independently which is when you would be using WrInputTransformationArguments.
assaf
#7 Posted : Tuesday, March 15, 2011 5:42:10 AM
Groups: Registered
Joined: 3/2/2011
Posts: 11
Location: Israel

It will be great if you can get me started on creating the script. a simple transformation script will do.

I already know how to assign the script to the project element

thanks
Sequentum Support
#8 Posted : Tuesday, March 15, 2011 9:23:50 PM

Groups: Administrators
Joined: 4/10/2010
Posts: 1,239
Location: Sydney, Australia
Code:

WrScript script = content.Scripts.GetScript(WrScriptType.ContentTransformation);
script.IsEnabled = true;
script.ScriptLanguage = WrScriptLanguageEnum.Csharp;
script.Script = "script code";
assaf
#9 Posted : Wednesday, March 16, 2011 2:47:07 AM
Groups: Registered
Joined: 3/2/2011
Posts: 11
Location: Israel
ah... okay

and how do I pass project parameters to the script?
can I just do:
Code:
script.Script = "string s = args.Content ; return s;"

??
like the script is running within the VWR application?
assaf
#10 Posted : Wednesday, March 16, 2011 7:41:57 AM
Groups: Registered
Joined: 3/2/2011
Posts: 11
Location: Israel
I see that I need to write the entire thing in a string.. including the namespace references etc.
something like:
Code:

string s;

s = "using System; using VisualWebRipper.Internal.SimpleHtmlParser; ";
s += " using VisualWebRipper; ";
s += " public class Script{ ";
s += " public static string TransformContent(WrContentTransformationArguments args) ";
s += " { try " ;
s += "  { string test ; test = \" test string \"; return args.Content;} ";
s += "catch(Exception exp){ args.WriteDebug(exp.Message);";
s += "return \"Custom script error\"; } } }";

script.Script = s;


Am I correct?
Sequentum Support
#11 Posted : Thursday, March 17, 2011 5:01:23 AM

Groups: Administrators
Joined: 4/10/2010
Posts: 1,239
Location: Sydney, Australia
Yes, that is correct.
Users browsing this topic
Guest
Tag as favorite
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.4 RC1 | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.106 seconds.