Skip to content

Commit 9a0c502

Browse files
committed
Sample: Oracle, MySQL, PostgreSQL
1 parent f751f18 commit 9a0c502

364 files changed

Lines changed: 127669 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Samples/MySQL/Console/App.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
5+
</startup>
6+
<connectionStrings>
7+
<add name="ConnectionString" connectionString="Server=127.0.0.1;Database=wftemp;Uid=root;Pwd=1;" />
8+
</connectionStrings>
9+
</configuration>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{C3B4C5DF-BB68-4F1C-8E3B-BB5443648CED}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>Console</RootNamespace>
11+
<AssemblyName>Console</AssemblyName>
12+
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="MySql.Data">
37+
<HintPath>..\packages\MySql.Data.6.9.5\lib\net45\MySql.Data.dll</HintPath>
38+
</Reference>
39+
<Reference Include="OptimaJet.Workflow.Core">
40+
<HintPath>..\packages\WorkflowEngine.NET-Core.1.4.3.1\lib\net40\OptimaJet.Workflow.Core.dll</HintPath>
41+
</Reference>
42+
<Reference Include="OptimaJet.Workflow.MySQL">
43+
<HintPath>..\packages\WorkflowEngine.NET-ProviderForMySQL.1.4.3.0\lib\net45\OptimaJet.Workflow.MySQL.dll</HintPath>
44+
</Reference>
45+
<Reference Include="ServiceStack.Text">
46+
<HintPath>..\packages\ServiceStack.Text.Signed.4.0.36\lib\net40\ServiceStack.Text.dll</HintPath>
47+
</Reference>
48+
<Reference Include="System" />
49+
<Reference Include="System.configuration" />
50+
<Reference Include="System.Core" />
51+
<Reference Include="System.Xml.Linq" />
52+
<Reference Include="System.Data.DataSetExtensions" />
53+
<Reference Include="Microsoft.CSharp" />
54+
<Reference Include="System.Data" />
55+
<Reference Include="System.Xml" />
56+
</ItemGroup>
57+
<ItemGroup>
58+
<Compile Include="Program.cs" />
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
<Compile Include="WorkflowInit.cs" />
61+
</ItemGroup>
62+
<ItemGroup>
63+
<None Include="App.config" />
64+
<None Include="packages.config" />
65+
</ItemGroup>
66+
<ItemGroup />
67+
<ItemGroup>
68+
<Content Include="SQL\CreatePersistenceObjects.sql" />
69+
<Content Include="SQL\DropPersistenceObjects.sql" />
70+
</ItemGroup>
71+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
72+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
73+
Other similar extension points exist, see Microsoft.Common.targets.
74+
<Target Name="BeforeBuild">
75+
</Target>
76+
<Target Name="AfterBuild">
77+
</Target>
78+
-->
79+
</Project>

Samples/MySQL/Console/Program.cs

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
using OptimaJet.Workflow.Core.Runtime;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
9+
namespace WorkflowApp
10+
{
11+
class Program
12+
{
13+
static string schemeCode = "SimpleWF";
14+
static Guid? processId = null;
15+
static void Main(string[] args)
16+
{
17+
Console.WriteLine("Operation:");
18+
Console.WriteLine("0 - CreateInstance");
19+
Console.WriteLine("1 - GetAvailableCommands");
20+
Console.WriteLine("2 - ExecuteCommand");
21+
Console.WriteLine("3 - GetAvailableState");
22+
Console.WriteLine("4 - SetState");
23+
Console.WriteLine("5 - DeleteProcess");
24+
Console.WriteLine("9 - Exit");
25+
26+
Console.WriteLine("The process isn't created.");
27+
CreateInstance();
28+
29+
do
30+
{
31+
if (processId.HasValue)
32+
{
33+
Console.WriteLine("ProcessId = '{0}'. CurrentState: {1}, CurrentActivity: {2}",
34+
processId,
35+
WorkflowInit.Runtime.GetCurrentStateName(processId.Value),
36+
WorkflowInit.Runtime.GetCurrentActivityName(processId.Value));
37+
}
38+
39+
Console.Write("Enter code of operation:");
40+
char operation = Console.ReadLine().FirstOrDefault();
41+
42+
switch (operation)
43+
{
44+
case '0':
45+
CreateInstance();
46+
break;
47+
case '1':
48+
GetAvailableCommands();
49+
break;
50+
case '2':
51+
ExecuteCommand();
52+
break;
53+
case '3':
54+
GetAvailableState();
55+
break;
56+
case '4':
57+
SetState();
58+
break;
59+
case '5':
60+
DeleteProcess();
61+
break;
62+
case '9':
63+
return;
64+
default:
65+
Console.WriteLine("Unknown code. Please, repeat.");
66+
break;
67+
}
68+
69+
Console.WriteLine();
70+
} while (true);
71+
}
72+
73+
private static void CreateInstance()
74+
{
75+
processId = Guid.NewGuid();
76+
try
77+
{
78+
WorkflowApp.WorkflowInit.Runtime.CreateInstance(schemeCode, processId.Value);
79+
Console.WriteLine("CreateInstance - OK.", processId);
80+
}
81+
catch (Exception ex)
82+
{
83+
Console.WriteLine("CreateInstance - Exception: {0}", ex.Message);
84+
processId = null;
85+
}
86+
}
87+
88+
private static void GetAvailableCommands()
89+
{
90+
if (processId == null)
91+
{
92+
Console.WriteLine("The process isn't created. Please, create process instance.");
93+
return;
94+
}
95+
96+
var commands = WorkflowInit.Runtime.GetAvailableCommands(processId.Value, string.Empty);
97+
98+
Console.WriteLine("Available commands:");
99+
if (commands.Count() == 0)
100+
{
101+
Console.WriteLine("Not found!");
102+
}
103+
else
104+
{
105+
foreach (var command in commands)
106+
{
107+
Console.WriteLine("- {0} (LocalizedName:{1}, Classifier:{2})", command.CommandName, command.LocalizedName, command.Classifier);
108+
}
109+
}
110+
}
111+
112+
private static void ExecuteCommand()
113+
{
114+
if (processId == null)
115+
{
116+
Console.WriteLine("The process isn't created. Please, create process instance.");
117+
return;
118+
}
119+
120+
WorkflowCommand command = null;
121+
122+
do
123+
{
124+
GetAvailableCommands();
125+
Console.Write("Enter command:");
126+
var commandName = Console.ReadLine().ToLower().Trim();
127+
if (commandName == string.Empty)
128+
return;
129+
130+
command = WorkflowInit.Runtime.GetAvailableCommands(processId.Value, string.Empty)
131+
.Where(c => c.CommandName.Trim().ToLower() == commandName).FirstOrDefault();
132+
if (command == null)
133+
Console.WriteLine("The command isn't found.");
134+
} while (command == null);
135+
136+
WorkflowInit.Runtime.ExecuteCommand(processId.Value, string.Empty, string.Empty, command);
137+
Console.WriteLine("ExecuteCommand - OK.", processId);
138+
}
139+
140+
private static void GetAvailableState()
141+
{
142+
if (processId == null)
143+
{
144+
Console.WriteLine("The process isn't created. Please, create process instance.");
145+
return;
146+
}
147+
148+
var states = WorkflowInit.Runtime.GetAvailableStateToSet(processId.Value, Thread.CurrentThread.CurrentCulture);
149+
Console.WriteLine("Available state to set:");
150+
151+
if (states.Count() == 0)
152+
{
153+
Console.WriteLine("Not found!");
154+
}
155+
else
156+
{
157+
foreach (var state in states)
158+
{
159+
Console.WriteLine("- {0}", state.Name);
160+
}
161+
}
162+
}
163+
164+
private static void SetState()
165+
{
166+
if (processId == null)
167+
{
168+
Console.WriteLine("The process isn't created. Please, create process instance.");
169+
return;
170+
}
171+
172+
string stateName = string.Empty;
173+
WorkflowState state;
174+
do
175+
{
176+
GetAvailableState();
177+
Console.Write("Enter state:");
178+
stateName = Console.ReadLine().ToLower().Trim();
179+
if (stateName == string.Empty)
180+
return;
181+
182+
state = WorkflowInit.Runtime.GetAvailableStateToSet(processId.Value, Thread.CurrentThread.CurrentCulture)
183+
.Where(c => c.Name.Trim().ToLower() == stateName).FirstOrDefault();
184+
if (state == null)
185+
Console.WriteLine("The state isn't found.");
186+
else
187+
break;
188+
} while (true);
189+
190+
if (state != null)
191+
{
192+
WorkflowInit.Runtime.SetState(processId.Value, string.Empty, string.Empty, state.Name, new Dictionary<string, object>());
193+
Console.WriteLine("SetState - OK.", processId);
194+
}
195+
}
196+
197+
private static void DeleteProcess()
198+
{
199+
if (processId == null)
200+
{
201+
Console.WriteLine("The process isn't created. Please, create process instance.");
202+
return;
203+
}
204+
205+
WorkflowInit.Runtime.PersistenceProvider.DeleteProcess(processId.Value);
206+
Console.WriteLine("DeleteProcess - OK.", processId);
207+
processId = null;
208+
}
209+
}
210+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("Console")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("Console")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("d61467c5-5179-4c21-a40a-a0e4842381dc")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

0 commit comments

Comments
 (0)