IZennoPosterProjectModel
Assembly: ZennoLab.InterfacesLibrary
Full name: ZennoLab.InterfacesLibrary.ProjectModel.IZennoPosterProjectModel
Kind: interface
Represents a model of current project. Performs access to global variables, local variables, tables, profile, lists. Contains methods for sending messages of warnings and errors to program’s log.
The object of the IZennoPosterModel interface get access to major data of ZennoPoster’s project.
Properties
Directory
Property
string Directory { get; }
Gets the directory of the project file.
Example
// get directory of the project
string projectDirectory = project.Directory;Example2
// get directory of the project
$projectDirectory = $project->Directory;Path
Property
string Path { get; }
Gets the directory of the project file with terminating.
Example
// get directory of the project
string projectDirectory = project.Path;Example2
// get directory of the project
$projectDirectory = $project->Path;Variables
Property
ILocalVariables Variables { get; }
Get a collection of local variables that can be accessed name.
Example
// get local variable
ILocalVariable lv = project.Variables["MyLocalVariable"];
// set value
if (lv.Value == "5") lv.Value = "0";Example2
// get local variable
$lv = $project->Variables->get_Item("MyLocalVariable");
// set value
if ($lv->Value == "5") $lv->Value = "0";GlobalVariables
Property
IGlobalVariables GlobalVariables { get; }
Get a collection of global variables that can be accessed by namespace and name.
Example
// get global variable by namespace and name
// variable "gv" object of interface IGlobalVariable
IGlobalVariable gv = project.GlobalVariables["MyNamespase", "VariableName"];
// change value of global variable
gv.Value = "ChangedValue";
// create a new global variable and set value
project.GlobalVariables.SetVariable("MyNamespase", "NewVariableName", "NewValue");Example2
// get global variable by namespace and name
// variable "gv" object of interface IGlobalVariable
$gv = $project->GlobalVariables->get_Item("MyNamespase", "VariableName");
// change value of global variable
$gv->Value = "ChangedValue";
// create a new global variable and set value
$project->GlobalVariables->SetVariable("MyNamespase", "NewVariableName", "NewValue");Lists
Property
ILists Lists { get; }
Get a collection of lists that can be accessed name.
Example
// get list by name "MyList"
var list = project.Lists["MyList"];
// add a new item to list
list.Add("new_list_item");
// get list by name "AnotherList" and get count of item
int count = project.Lists["AnotherList"].Count;Example2
// get list by name "MyList"
$list = $project->Lists->get_Item("MyList");
// add a new item to list
$list->Add("new_list_item");
// get list by name "AnotherList" and get count of item
$count = $project->Lists->get_Item("AnotherList")->Count;Name
Property
string Name { get; }
Gets the name of the project.
Example
// get the name of the current project
string projectName = project.Name;Example2
// get the name of the current project
$projectName = $project->Name;Tables
Property
ITables Tables { get; }
Get a collection of tables that can be accessed name.
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// add a new row
table.AddRow("simple text");
// get table by name "AnotherTable" and get row count
int count = project.Tables["AnoterTable"].RowCount;Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// add a new row
$table->AddRow("simple text");
// get table by name "AnotherTable" and get row count
$count = $project->Tables->get_Item("AnoterTable")->RowCount;GoogleSpreadsheets
Property
IGoogleSpreadsheets GoogleSpreadsheets { get; }
Get a collection of Google spreadsheets that can be accessed name.
Profile
Property
IProfile Profile { get; }
Get a profile of current project.
Example
// set a new email to profile
project.Profile.Email = "myemail@someemail.com";
// get SecretQuestionAnswer1 from profile
string SecretQuestionAnswer1 = project.Profile.SecretQuestionAnswer1;Example2
// set a new email to profile
$project->Profile->Email = "myemail@someemail.com";
// get SecretQuestionAnswer1 from profile
$SecretQuestionAnswer1 = $project->Profile->SecretQuestionAnswer1;ProxyRules
Property
string ProxyRules { get; }
Gets the proxy rules for the current project.
Example
// get the proxy rules of the current project
string proxyRules = project.ProxyRules;Example2
// get the proxy rules of the current project
$proxyRules = $project->ProxyRules;Context
Property
IContext Context { get; }
Gets a context of the current project.
Example
// get shared object with name "ObjectName"
object o = project.Context["ObjectName"];
// set shared object with name "ObjectName"
project.Context["ObjectName"] = "example string or any another object";TaskId
Property
string TaskId { get; }
Gets the id of the task.
Example
// get the id of the current task
String id = project.TaskId;Example2
// get the id of the current task
$id = $project->TaskId;LogOptions
Property
ILogOptions LogOptions { get; }
Gets the options of the execution log of the project.
Example
// get the path to log file
string path = project.LogOptions.LogFile;
// set the path to log file
project.LogOptions.LogFile = "X:\\log.txt";
// enable splitting for log
project.LogOptions.SplitLogByThread = true;
return tmp;LastExecutedActionId
Property
string LastExecutedActionId { get; }
Get an information about last executed action ID.
Example
string id = project.LastExecutedActionId;
return id;Example2
$id = $project->LastExecutedActionId;
return $id;LastExecutedActionElapsedTime
Property
long LastExecutedActionElapsedTime { get; }
Get an information about last executed action elapsed time (ms).
Example
var timeMs = project.LastExecutedActionElapsedTime;
return timeMs;Example2
$timeMs = $project->LastExecutedActionElapsedTime;
return $timeMs;Json
Property
object Json { get; }
Get dynamic object for Json.
Example
project.Json.FromString("{\"Status\": 200}");
return project.Json.Status;Example2
$project->Json->FromString("{\"Status\": 200}");
return $project->Json->Status;Xml
Property
object Xml { get; }
Get dynamic object for Xml.
Example
project.Xml.FromString("<Answer><Status>200</Status></Answer>");
return project.Xml.Answer.Status;Example2
$project->Xml->FromString("<Answer><Status>200</Status></Answer>");
return $project->Xml->Answer->Status;Environment
Property
IProjectEnvironment Environment { get; }
Gets information of the current envirovment.
PluginDirectory
Property
string PluginDirectory { get; }
Gets the directory of the plugin file.
Example
// get directory of the plugin
string pluginDirectory = project.PluginDirectory;Example2
// get directory of the project
$pluginDirectory = $project->PluginDirectory;PluginPath
Property
string PluginPath { get; }
Gets the path of the plugin file with terminating.
Example
// get path of the plugin
string pluginPath = project.PluginPath;Example2
// get path of the plugin
$pluginPath = $project->PluginPath;LastErrorComment
Property
string LastErrorComment { get; }
Get a message from last unsuccessful action.
Returns: A message from last unsuccessful action.
BrowserProfileFolder
Property
string BrowserProfileFolder { get; }
Get path to folder-profile of currently running browser instance. Empty string if folder-profile is not used.
Returns: Path to folder-profile of currently running browser instance. Empty string if folder-profile is not used.
ZennoBrowserProfileId
Property
string ZennoBrowserProfileId { get; }
Get the ProfileId of the current ZennoBrowser profile we are interested in.
Returns: Get the ProfileId of the current ZennoBrowser profile we are interested in.
ZennoBrowserProfileContainerId
Property
string ZennoBrowserProfileContainerId { get; }
Get the ProfileContainerId of the current ZennoBrowser profile folder we are interested in.
Returns: Get the ProfileContainerId of the current ZennoBrowser profile folder we are interested in.
Methods
GetProxy
Method
string GetProxy()
Gets the proxy for the current project.
Example
// get the proxy of the current project
string proxy = project.GetProxy();Example2
// get the proxy of the current project
$proxyRules = $project->GetProxy();SetProxy
Method
void SetProxy(string proxy)
Sets the proxy for the current project.
Parameters
| Type | Name | Description |
|---|---|---|
string | proxy |
Example
// set the proxy of the current project
project.SetProxy(proxy);Example2
// set the proxy of the current project
$project->SetProxy($proxy);SendToLog
Method
void SendToLog(string message, LogType type)
Send a message to the log of ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx A message for send. |
LogType | type | Type of message to be displayed in the log |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female) project.SendToLog("Oh, hell, it is a woman", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Warning);Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female) $project->SendWarningToLog("Oh, hell, it is a woman", ZennoLab::InterfacesLibrary::Enums::Log::LogType->Warning);SendToLog
Method
void SendToLog(string message, LogType type, bool showInPoster)
Send a message to the log of ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx A message for send. |
LogType | type | Type of message to be displayed in the log |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female) project.SendToLog("Oh, hell, it is a woman", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Warning, false);Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female) $project->SendWarningToLog("Oh, hell, it is a woman", ZennoLab::InterfacesLibrary::Enums::Log::LogType->Warning, FALSE);SendToLog
Method
void SendToLog(string message, LogType type, bool showInPoster, LogColor color)
Send a message to the log of ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx A message for send. |
LogType | type | Type of message to be displayed in the log |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
LogColor | color | The background color of a message |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female)
project.SendToLog("Oh, hell, it is a woman",
ZennoLab.InterfacesLibrary.Enums.Log.LogType.Warning,
false,
ZennoLab.InterfacesLibrary.Enums.Log.LogColor.Yellow);Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female)
$project->SendWarningToLog("Oh, hell, it is a woman",
ZennoLab::InterfacesLibrary::Enums::Log::LogType->Warning,
FALSE,
ZennoLab::InterfacesLibrary::Enums::Log::LogColor->Yellow);SendToLog
Method
void SendToLog(string message, string way, LogType type)
Send a message to the log of ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx A message for send. |
string | way | An error “way” for send. The parameter “way” can be line in code, action ID or module. |
LogType | type | Type of message to be displayed in the log |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female) project.SendToLog("Oh, hell, it is a woman", "Own Code C#", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Warning);Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female) $project->SendWarningToLog("Oh, hell, it is a woman", "Own Code PHP", ZennoLab::InterfacesLibrary::Enums::Log::LogType->Warning);SendToLog
Method
void SendToLog(string message, string way, LogType type, bool showInPoster)
Send a message to the log of ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx A message for send. |
string | way | An error “way” for send. The parameter “way” can be line in code, action ID or module. |
LogType | type | Type of message to be displayed in the log |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female) project.SendToLog("Oh, hell, it is a woman", "Own Code C#", ZennoLab.InterfacesLibrary.Enums.Log.LogType.Warning, true);Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female) $project->SendWarningToLog("Oh, hell, it is a woman", "Own Code PHP", ZennoLab::InterfacesLibrary::Enums::Log::LogType->Warning, TRUE);SendToLog
Method
void SendToLog(string message, string way, LogType type, bool showInPoster, LogColor color)
Send a message to the log of ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx A message for send. |
string | way | An error “way” for send. The parameter “way” can be line in code, action ID or module. |
LogType | type | Type of message to be displayed in the log |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
LogColor | color | The background color of a message |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female)
project.SendToLog("Oh, hell, it is a woman",
"Own Code C#",
ZennoLab.InterfacesLibrary.Enums.Log.LogType.Warning,
true,
ZennoLab.InterfacesLibrary.Enums.Log.LogColor.Orange);Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female)
$project->SendWarningToLog("Oh, hell, it is a woman",
"Own Code PHP",
ZennoLab::InterfacesLibrary::Enums::Log::LogType->Warning,
TRUE,
ZennoLab::InterfacesLibrary::Enums::Log::LogColor->Orange);SendWarningToLog
Method
void SendWarningToLog(string message, bool showInPoster)
Send a warning message to the log of ZennoPoster.
The parameter “way” hasn’t restrictions, it should use for specify the location where warning was detected. This parameter can be empty.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx A warning message for send. |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female) project.SendWarningToLog("Oh, hell, it is a woman", "OwnCode C#");Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female) $project->SendWarningToLog("Oh, hell, it is a woman", "OwnCode PHP");SendErrorToLog
Method
void SendErrorToLog(string message, bool showInPoster)
Send an error message to the log of ZennoPoster.
The parameter “way” hasn’t restrictions, it should use for specify the location where error was detected. This parameter can be empty.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx An error message for send. |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
Example
try
{
// get global variable
IGlobalVariable gv = project.GlobalVariables["MyNamespace", "MyGlobalVariable"];
}
catch (Exception e)
{
// send error to log
project.SendErrorToLog(e.Message);
}Example2
try
{
// get global variable
$gv = $project->GlobalVariables->get_Item("MyNamespace", "MyGlobalVariable");
}
catch (Exception $e)
{
// send error to log
$project->SendErrorToLog($e->Message);
}SendInfoToLog
Method
void SendInfoToLog(string message, bool showInPoster)
Send an information to the log of ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | An information for send. |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female) project.SendInfoToLog("It is a woman");Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female) $project->SendInfoToLog("It is a woman");SendWarningToLog
Method
void SendWarningToLog(string message, string way, bool showInPoster)
Send a warning message to the log of ZennoPoster.
The parameter “way” hasn’t restrictions, it should use for specify the location where warning was detected. This parameter can be empty.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx A warning message for send. |
string | way | :http://msdn.microsoft.com/en-us/library/system.string.aspx A warning “way” for send. The parameter “way” can be line in code, action or module. |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female) project.SendWarningToLog("Oh, hell, it is a woman", "OwnCode C#");Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female) $project->SendWarningToLog("Oh, hell, it is a woman", "OwnCode PHP");SendErrorToLog
Method
void SendErrorToLog(string message, string way, bool showInPoster)
Send an error message to the log of ZennoPoster.
The parameter “way” hasn’t restrictions, it should use for specify the location where error was detected. This parameter can be empty.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | :http://msdn.microsoft.com/en-us/library/system.string.aspx An error message for send. |
string | way | An error “way” for send. The parameter “way” can be line in code, action ID or module. |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
Example
try
{
// get global variable
IGlobalVariable gv = project.GlobalVariables["MyNamespace", "MyGlobalVariable"];
}
catch (Exception e)
{
// send error to log
project.SendErrorToLog(e.Message, "first action OwnCode C#");
}Example2
try
{
// get global variable
$gv = $project->GlobalVariables->get_Item("MyNamespace", "MyGlobalVariable");
}
catch (Exception $e)
{
// send error to log
$project->SendErrorToLog($e->Message, "first action OwnCode PHP");
}SendInfoToLog
Method
void SendInfoToLog(string message, string way, bool showInPoster)
Send an information to the log of ZennoPoster.
Parameters
| Type | Name | Description |
|---|---|---|
string | message | An information for send. |
string | way | An information “way” for send. The parameter “way” can be line in code, action ID or module. |
bool | showInPoster | Set true, if needs show this message in ZennoPoster. |
Example
// get gender form profile
ProfileSex gender = project.Profile.Sex;
// send warning
if (gender == ProfileSex.Female) project.SendInfoToLog("It is a woman", "OwnCode C#");Example2
// get gender form profile
$gender = $project->Profile->Sex;
// send warning
if ($gender == ProfileSex::Female) $project->SendInfoToLog("It is a woman", "OwnCode PHP");GetLastError
Method
LastError GetLastError()
Get a last error after project failed.
Returns: An information of last error.
Example
var error = project.GetLastError();
var tmp = "";
if(error != null)
tmp = string.Format("ActionComment: {0}.\r\nActionGroupId: {1}.\r\nActionId: {2}", error.ActionComment, error.ActionGroupId, error.ActionId);
return tmp;ExecuteProject
Method
bool ExecuteProject(string pathToProject, IEnumerable<Tuple<string, string>> varibleMapping, bool mapOnBadExist, bool passProjectContext, bool useBrowser)
Execute ZennoPoster project.
Parameters
| Type | Name | Description |
|---|---|---|
string | pathToProject | The path to project file. |
| “ | IEnumerable<Tuple<string | |
string>> | varibleMapping | Collection of pair variables name in current project and called project. |
bool | mapOnBadExist | Set true, if needs map variables to current project even if execution of called project will be failed. |
bool | passProjectContext | Set true, if needs map context of current project to called project and back. |
bool | useBrowser | Set true, if needs to use browser. |
Example
// set value for variable a1, make sure that source project contains variable "a1"
project.Variables["a1"].Value = "example";
var mapVars = new List<Tuple<string, string>>();
// make sure that called project contains variable "b1"
mapVars.Add(new Tuple<string, string>("a1", "b1"));
return project.ExecuteProject("example.xmlz", mapVars, true, true, true);ExecuteMacro
Method
string ExecuteMacro(string text)
Executes macroses in text and returns result.
Parameters
| Type | Name | Description |
|---|---|---|
string | text | Text with macroses. |
Returns: Text with executed macroses.