I need to execute workflow from command line that is already created using UI.
Already I have tried to invoke workflow by creating workflow instance.
the code shown below which is i was tried
XmlTextReader reader = new XmlTextReader("Workflow1.xml");
Console.WriteLine("Waiting for Workflow completion..");
WorkflowRuntime runtime = new WorkflowRuntime();
WorkflowInstance instance = runtime.CreateWorkflow(reader);
instance.Start();
but it shows the error message "xml tag is not framed well".
I have fully copied the workflow xaml content and pasted in Workflow1.xml file.
is there any other possibilities to achieve this.
Thanks in Advance.
It looks like you are using Windows Workflow 4, but you are trying to use the Windows Workflow 3 runtime to execute the workflow. I've got a white paper [1] on WF 4 that might be useful, but here's a snippet from that article that might be helpful. It uses the workflowInvoker class to execute the workflow. You can also use WorkflowApplication if you have long running workflows that need bookmarking capabilities.
Activity mathWF;
using (Stream mathXaml = File.OpenRead("Math.xaml"))
{
mathWF = ActivityXamlServices.Load(mathXaml);
}
var outputs = WorkflowInvoker.Invoke(mathWF,
new Dictionary<string, object> {
{ "operand1", 5 },
{ "operand2", 10 },
{ "operation", "add" } });
Assert.AreEqual<int>(15, (int)outputs["result"], "Incorrect result returned");
Developer's Introduction to Windows Workflow
Related
Updating with very useful info using guidance from mrsargent
I am trying to automate following steps in C# (Visual Studio) with following steps:
run and connect to TIA portal
create project
install GSDML device files
add PLC and single device as per GSDML
design application relationship between product and PLC (cpu)
I tried to use OpenNess Demo Application for the same but I am unable to step through the code and there is no option in the Demo GUI to install GSDML files in the same.
I tried to write the following code as per documentation for CAX import of GSDML file but faced errors as described below:
Code:
using
(TiaPortal tiaPortal = new TiaPortal(TiaPortalMode.WithoutUserInterface))
{
Console.WriteLine("TIA Portal has started");
ProjectComposition projects = tiaPortal.Projects;
Console.WriteLine("Opening Project...");
DirectoryInfo dinfo = new DirectoryInfo(#"C:\projects\TestProjects\");
string unixTimestamp = Convert.ToString((int)DateTime.Now.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
string prj_name = "Prj_" + unixTimestamp;
Project project = null;
try
{
project = projects.Create(dinfo, prj_name);
}
catch (Exception)
{
Console.WriteLine(String.Format("Could not open project {0}", projectPath.FullName));
Console.WriteLine("Demo complete hit enter to exit");
Console.ReadLine();
return;
}
CaxProvider caxProvider = project.GetService<CaxProvider>();
if (caxProvider != null)
{
// GETTING ERROR OVER HERE
// {"Error when calling method 'Import' of type 'Siemens.Engineering.Cax.CaxProvider'.\r\n\r\nThe path of the import file 'C:\\Gaurav\\GSDML-xxxxxxxx.xml' with the extension '.xml' is invalid.\r\n"}
caxProvider.Import(
new FileInfo(#"C:\GSDML-xxxx.xml"),
new FileInfo(#"C:\ProjectImport_Log.log"),
CaxImportOptions.MoveToParkingLot
);
}
Console.WriteLine(String.Format("Project {0} is open", project.Path.FullName));
// IterateThroughDevices(project);
project.Close();
Console.WriteLine("Demo complete hit enter to exit");
Console.ReadLine();
}
Following error is observed:
{"Error when calling method 'Import' of type 'Siemens.Engineering.Cax.CaxProvider'.\r\n\r\nThe path of the import file 'C:\GSDML-xxx.xml' with the extension '.xml' is invalid.\r\n"}
Yes this is a difficult thing to do. However it is possible. First you need proper documentation that is a little difficult to find. The manual is very detailed and good found here
You need the import the GSD file as a CAx that is found page 939 of the documentation.
//Access the CaxProvider service
Project project = tiaPortal.Projects.Open(...);
CaxProvider caxProvider = project.GetService<CaxProvider>();
if(caxProvider != null)
{
// Perform Cax export and import operation
}
To create this CAx (an xml document) you need to look starting at page 988 of this manual. It will tell you how to configure. It is far too much to explain and list in this forum but the documentation does a good job of explaining after you read it 5 times ;)
It is probably best to read this entire import/export section in order to get a full understanding of how to do this. Hope this helps!
Specifically, I want to use the onSelectionChange(e) event to show a sidebar depending on what's in the selected cell. The problem is: the project I am working on is a standalone script. So I want to know if there is a way to use the onOpen event (for example) and check if the script is being run from a spreadsheet and somehow 'inject' the trigger.
I was trying something pretty much like in the documentation, but I never got it to fire, I guess because it was a standalone script.
const onSelectionChange = (e) => {
Logger.log(`onSelectionChange triggered: ${e.toString()}`);
const { range } = e;
if (range.getNumRows() === 1 && range.getNumColumns() === 1) {
range.setBackground('green');
}
};
So the actual solution for me was to create a new document with clasp. Using the command:
npx clasp create --type sheets --title "foo" --rootDir ./dist
and then uploading the script to this new project.
For my scheduler task, I want to delete all the existing data from repository before updating it, every time the scheduler runs. I am able to save and add new data from XML File using add().
class FunctionFetcherService {
public function fetchRoomandLesson() {
$path = 'http:abc.dll?type=room&content=xml';
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$roomRepository = $objectManager->get("School\\booking\\Domain\\Repository\\RoomsRepository");
$this->roomRepository->removeAll();
$xml = simplexml_load_file($path);
$json = json_encode($xml);
$xmlArray = json_decode($json, true);
$serialized_array = serialize($xmlArray);
$unserialized_array = unserialize($serialized_array);
An error occurs removeAll() called on Null. I also referred to the already asked question: use removeAll() in scheduler task but it does doe not work.
You create the repository as variable $roomRepository and then try to access it through $this->roomRepository. Changing $this->roomRepository to $roomRepository should fix the error.
You should create an Extbase CommandController as your scheduler task. All registered commands are available in the scheduler as well as CLI commands.
By using CommandControllers you can use the full extbase framework, such as dependency injections and validations.
Please note that CommandController command methods must be suffixed with Command just like the linked example.
I am new to Sahi and I am just trying to take a screenshot on script errors.
I have tried to used their demo and the script the website provides for the task, but the onScriptFailure doesn't seem to trigger. I added the alert box and changed the log in name to trigger a failure. Sorry if i'm missing something obvious.
function onScriptError($e){
_focusWindow();
_takeScreenShot();
_alert("test me");
}
onScriptFailure = onScriptError;
_navigateTo("http://sahi.co.in/demo/training/");
_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_click(_submit("TriggerError"));
I was using Sahi Pro. I actually got the answer from their support department. This is what he had me do:
var onScriptError = function ($e) {
_focusWindow();
_takeScreenShot();
_alert("test me");
}
onScriptFailure = onScriptError;
_navigateTo("http://sahi.co.in/demo/training/");
_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_click(_submit("TriggerError"));
HI You can use the GlobalInclude.sah file which has the code for the error handling.
you can edit this file to make the script behave according to your needs
I want to create a reusable sub processes in jbpm 6, but I cant't see any processes in Called Element pop up. It doesn't load any process information. Please can anyone give me the reason for this situation?
I'm not sure I completely understand your question/issue. However, I have successfully used reusable suprosses in JBPM 6.1.0.Final and eclipse.
These are steps:
Create a resuable subprocess with and ID. Make note the ID for steps 2-5.
Drag and Drop a "Call Activity" Activity to the bpmn
Edit the properties of the "Call Activity" - click on "Call Activity" and go to eclipse properties tab.
Click on "pencil" edit icon:
Enter the reusable subprocess id in edit window and type reusable subprosses id and hit o.k.
You should be able to run you bpmn and see the execution of subprocess.
I've just hitted this error today at work, using 6.1.0.Final. If process id has underscores it will not show in workbench called activity popup. Look at the sources:
Asset<String> processContent = ServletUtil.getProcessSourceContent(p, profile);
Pattern idPattern = Pattern.compile("<\\S*process[^\"]+id=\"([^_\"]+)\"", Pattern.MULTILINE);
Matcher idMatcher = idPattern.matcher(processContent.getAssetContent());
if(idMatcher.find()) {
String pid = idMatcher.group(1);
String pidcontent = ServletUtil.getProcessImageContent(processContent.getAssetLocation(), pid, profile);
if(pid != null && !(packageName.equals(processPackage) && pid.equals(processId))) {
processInfo.put(pid+"|"+processContent.getAssetLocation(), pidcontent != null ? pidcontent : "");
}
}
That regex used to get process id will not match "_". Check that your process id is valid.