How To Go From Step To Step

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
How do you connect the steps that are brought in from PM to CC when you import? Say you have a template that goes and registers to a site, then gets the email confirmation link and then goes to the confirmation link and continues on with the site. When you import a project, the steps are separated out. Does CodeCreator run the steps in order, or do you have to call the second step from the first?
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
834
Баллы
113
Hi Clint,
When template is exported to the CC, there is class Program (Program.cs), in this class you can see queue of steps in which they will be executed.
CC makes first step such step which was created first in PM, second one which was created second, etc. So it ignores connections and make it follow by number of creating.
If there is branch mail processing and it uses macro inside, then you should change this part manually.
And again you can change order of steps in Program.cs.
 
  • Спасибо
Реакции: jen и bigcajones

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Thanks HB, just what I was looking for. I haven't done it in a while, but I noticed the last template that I imported that had email processing, it kept throwing up errors on the regex. I know that you have to add @ in front of the regex, but is there anything else that we need to know to make it work properly?
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
834
Баллы
113
For example you use execution results of some branches in the fields for email authorization (login, password). In this case you should change them manually.
 
  • Спасибо
Реакции: bigcajones

jen

Client
Регистрация
17.09.2011
Сообщения
33
Благодарностей
0
Баллы
6
Hello,

In the "program.cs", I put the following code:

Код:
using System;
using Zennolab.CommandCenter;

namespace youtube
{
    class Program : IZennoCustomCode
    {
        public int ExecuteCode(Instance instance)
        {
            Step1.Execute(instance);
            step2.Execute(instance);
            return 0;
        }
    }
}
that Excecute step1 but don't step2, why?

Thanks for your answers.
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
If you use automatically generated class Step2 then the declaration of Step2 must start with the big letter. :-)

Код:
using System;
using Zennolab.CommandCenter;

namespace NewProject
{
    class Program : IZennoCustomCode
    {
        public int ExecuteCode(Instance instance)
        {
            Step1.Execute(instance);
            Step2.Execute(instance);
            return 0;
        }
    }
}
If you created a new class don't forget that Execute method must be "static" like this:
Код:
public static int Execute(Instance instance)
 
  • Спасибо
Реакции: bigcajones и jen

bigcajones

Client
Регистрация
09.02.2011
Сообщения
1 216
Благодарностей
683
Баллы
113
Okay Shade, how do you carry variables over to next step? When I create a variable in Step1 like string password = ..... and try to use it in Step2, I keep getting an error that says: "The name 'password' does not exist in the current context" in Debug for Step2. Here is a simple one to show you what I am getting.

Код:
namespace CCtest
{
	internal class Step1
	{
		public static int Execute(Instance instance)
		{
			// Executing macros
			string login = instance.RiseMacros("File.GetString", new[] { "\\Resources\\Beboemail.txt", "0", "true" });

			return 0;
And then in Step2 I have this;

Код:
namespace CCtest
{
	internal class Step2
	{
		public static int Execute(Instance instance)
		{
			// Executing macros
			instance.RiseMacros("File.AppendString", new[] { "\\Results\\CCtest.txt", login, "true" });
			return 0;
And I get the error: "The name 'login' does not exist in the current context"

What am I doing wrong here because a lot of templates will take the result of one Step and need them in another?
 

shade

Client
Регистрация
19.11.2010
Сообщения
580
Благодарностей
346
Баллы
63
Okay Shade, how do you carry variables over to next step? When I create a variable in Step1 like string password = ..... and try to use it in Step2, I keep getting an error that says: "The name 'password' does not exist in the current context" in Debug for Step2. Here is a simple one to show you what I am getting.

Код:
namespace CCtest
{
    internal class Step1
    {
        public static int Execute(Instance instance)
        {
            // Executing macros
            string login = instance.RiseMacros("File.GetString", new[] { "\\Resources\\Beboemail.txt", "0", "true" });

            return 0;
And then in Step2 I have this;

Код:
namespace CCtest
{
    internal class Step2
    {
        public static int Execute(Instance instance)
        {
            // Executing macros
            instance.RiseMacros("File.AppendString", new[] { "\\Results\\CCtest.txt", login, "true" });
            return 0;
And I get the error: "The name 'login' does not exist in the current context"

What am I doing wrong here because a lot of templates will take the result of one Step and need them in another?
Hi bigcajones.

There are many ways.
First: You can use static variables of class
Step1
JavaScript:
internal class Step1
    {
        // this is static variable of class
        public static string login;
        
        /// <summary>
        /// Еxecute Step1
        /// </summary>
        public static int Execute(Instance instance)
        {
            // set value to static variable
            login = instance.RiseMacros("Person.HumanLogin", new [] { "[Eng|4][RndNum|1970|1990]" });
            
            return 0;
        }
    }
Step2
JavaScript:
internal class Step2
    {
        public static int Execute(Instance instance)
        {
            // go to google.com
            Tab tb = instance.MainTab;
            if ((tb.IsVoid) || (tb.IsNull)) return -1;
            if (tb.IsBusy) tb.WaitDownloading();
tb.Navigate("http://www.google.com/");
            if (tb.IsBusy) tb.WaitDownloading();

            HtmlElement he;
            // search field
            he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildByName("q");
            if (he.IsVoid) return -1;
            
            // set value for Html element from static variable of Step1
            he.SetValue(Step1.login, true);
            
            return 0;
        }
    }
Or use static auto property
Step1
JavaScript:
internal class Step1
    {
        // this is static auto property of class
        public static string login {get; set;}
        
        /// <summary>
        /// Еxecute Step1
        /// </summary>
        public static int Execute(Instance instance)
        {
            // set value to static variable
            login = instance.RiseMacros("Person.HumanLogin", new [] { "[Eng|4][RndNum|1970|1990]" });
            
            return 0;
        }
    }
Step2
JavaScript:
public static int Execute(Instance instance)
        {
            // go to google.com
            Tab tb = instance.MainTab;
            if ((tb.IsVoid) || (tb.IsNull)) return -1;
            if (tb.IsBusy) tb.WaitDownloading();
tb.Navigate("http://www.google.com/");
            if (tb.IsBusy) tb.WaitDownloading();

            HtmlElement he;
            // search field
            he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByTag("form", 0).FindChildByName("q");
            if (he.IsVoid) return -1;
            
            // set value for Html element from static auto property of Step1
            he.SetValue(Step1.login, true);
            
            return 0;
        }
But I think it would be better to create a special class for storing your variables.
My examples for you:
example1 - static variable
example2 - static auto property
example3 - special class with static auto property
And more, Do not forget that all variables and methods must be static and public.
 

Вложения

  • Спасибо
Реакции: bigcajones

Кто просматривает тему: (Всего: 2, Пользователи: 0, Гости: 2)