* Yavsc.sln:
* Web.csproj: * TestAPI.csproj: * YavscModel.csproj: * Automate.cs: * TaskOutput.cs: * AssemblyInfo.cs: * Service.cs: * FinalStateException.cs: * FrontOfficeController.cs: * InvalidLetterException.cs: * PriceOnItemCount.cs: * TestAutomate.cs: Tests an Automate * packages.config: using Machine.Specifications
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
2015-07-17 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* Yavsc.sln:
|
||||
|
||||
2015-06-09 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* Yavsc.sln: creates a packaging project
|
||||
|
9
TestAPI/ChangeLog
Normal file
9
TestAPI/ChangeLog
Normal file
@ -0,0 +1,9 @@
|
||||
2015-07-17 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* TestAPI.csproj:
|
||||
* AssemblyInfo.cs:
|
||||
|
||||
* TestAutomate.cs: Tests an Automate
|
||||
|
||||
* packages.config: using Machine.Specifications
|
||||
|
47
TestAPI/Properties/AssemblyInfo.cs
Normal file
47
TestAPI/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,47 @@
|
||||
//
|
||||
// AssemblyInfo.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// Copyright (c) 2015 GNU GPL
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle ("TestAPI")]
|
||||
[assembly: AssemblyDescription ("")]
|
||||
[assembly: AssemblyConfiguration ("")]
|
||||
[assembly: AssemblyCompany ("")]
|
||||
[assembly: AssemblyProduct ("")]
|
||||
[assembly: AssemblyCopyright ("GNU GPL")]
|
||||
[assembly: AssemblyTrademark ("")]
|
||||
[assembly: AssemblyCulture ("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion ("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
||||
|
73
TestAPI/TestAPI.csproj
Normal file
73
TestAPI/TestAPI.csproj
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{42B77C89-BF6D-4DB1-8763-6197F4030A95}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>TestAPI</RootNamespace>
|
||||
<AssemblyName>TestAPI</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Machine.Specifications">
|
||||
<HintPath>..\packages\Machine.Specifications.0.9.3\lib\net45\Machine.Specifications.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Machine.Specifications.Clr4">
|
||||
<HintPath>..\packages\Machine.Specifications.0.9.3\lib\net45\Machine.Specifications.Clr4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Machine.Specifications.Runner.Utility">
|
||||
<HintPath>..\packages\Machine.Specifications.Runner.Utility.0.9.0\lib\net45\Machine.Specifications.Runner.Utility.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Spark">
|
||||
<HintPath>..\packages\Spark.1.7.5.3\lib\NET45\Spark.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Machine.Specifications.Reporting">
|
||||
<HintPath>..\packages\Machine.Specifications.Reporting.0.9.0\lib\net45\Machine.Specifications.Reporting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Machine.Specifications.Reporting.Templates">
|
||||
<HintPath>..\packages\Machine.Specifications.Reporting.0.9.0\lib\net45\Machine.Specifications.Reporting.Templates.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Machine.Specifications.Should">
|
||||
<HintPath>..\packages\Machine.Specifications.Should.0.7.2\lib\net45\Machine.Specifications.Should.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework, Version=2.6.3.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
|
||||
<Package>nunit</Package>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestAutomate.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\yavscModel\YavscModel.csproj">
|
||||
<Project>{68F5B80A-616E-4C3C-91A0-828AA40000BD}</Project>
|
||||
<Name>YavscModel</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
</Project>
|
67
TestAPI/TestAutomate.cs
Normal file
67
TestAPI/TestAutomate.cs
Normal file
@ -0,0 +1,67 @@
|
||||
//
|
||||
// MyClass.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// Copyright (c) 2015 GNU GPL
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
using Machine.Specifications;
|
||||
using Yavsc.Model.WorkFlow;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace TestAPI
|
||||
{
|
||||
[Subject(typeof(Automate<int,int>),"simple automate")]
|
||||
public class CreatingAnAutomate
|
||||
{
|
||||
static Automate<int,int> Subject;
|
||||
/// <summary>
|
||||
/// The context.
|
||||
/// </summary>
|
||||
Establish context = () =>
|
||||
{
|
||||
// ... any mocking, stubbing, or other setup ...
|
||||
Subject = new Automate<int,int>();
|
||||
};
|
||||
|
||||
Because of = () => Subject.AddTransition(0,1,'a');
|
||||
/// <summary>
|
||||
/// The should be in state 0.
|
||||
/// </summary>
|
||||
It should_be_in_state_0 = () => Subject.State.ShouldEqual(0);
|
||||
/// <summary>
|
||||
/// The should not be in state 1.
|
||||
/// </summary>
|
||||
It should_not_be_in_state_1 = () => Subject.State.ShouldNotEqual(1);
|
||||
/// <summary>
|
||||
/// The state of the should not indicate o as final.
|
||||
/// </summary>
|
||||
It should_not_indicate_O_as_final_state = () => Subject.IsInFinalState().ShouldNotEqual(true);
|
||||
|
||||
[Test]
|
||||
public void DoTheTest()
|
||||
{
|
||||
context.Invoke ();
|
||||
of.Invoke ();
|
||||
should_be_in_state_0.Invoke ();
|
||||
should_not_be_in_state_1.Invoke ();
|
||||
should_not_indicate_O_as_final_state.Invoke ();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
8
TestAPI/packages.config
Normal file
8
TestAPI/packages.config
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Machine.Specifications" version="0.9.3" targetFramework="net45" />
|
||||
<package id="Machine.Specifications.Reporting" version="0.9.0" targetFramework="net45" />
|
||||
<package id="Machine.Specifications.Runner.Utility" version="0.9.0" targetFramework="net45" />
|
||||
<package id="Machine.Specifications.Should" version="0.7.2" targetFramework="net45" />
|
||||
<package id="Spark" version="1.7.5.3" targetFramework="net45" />
|
||||
</packages>
|
@ -33,12 +33,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
EndProject
|
||||
Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "pkg", "pkg\pkg.mdproj", "{C6DBD1DC-B619-4DC7-BC92-15693508541E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestAPI", "TestAPI\TestAPI.csproj", "{42B77C89-BF6D-4DB1-8763-6197F4030A95}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{42B77C89-BF6D-4DB1-8763-6197F4030A95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{42B77C89-BF6D-4DB1-8763-6197F4030A95}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{42B77C89-BF6D-4DB1-8763-6197F4030A95}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{42B77C89-BF6D-4DB1-8763-6197F4030A95}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{59E1DF7B-FFA0-4DEB-B5F3-76EBD98D5356}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{59E1DF7B-FFA0-4DEB-B5F3-76EBD98D5356}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{59E1DF7B-FFA0-4DEB-B5F3-76EBD98D5356}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -58,6 +58,19 @@ namespace Yavsc.ApiControllers
|
||||
return CatalogManager.GetCatalog ().GetBrand (brandName).GetProductCategory (prodCategorie);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Authorization denied.
|
||||
/// </summary>
|
||||
public class AuthorizationDenied : HttpRequestException {
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Yavsc.ApiControllers.FrontOfficeController+AuthorizationDenied"/> class.
|
||||
/// </summary>
|
||||
/// <param name="msg">Message.</param>
|
||||
public AuthorizationDenied(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the estimate.
|
||||
/// </summary>
|
||||
@ -68,6 +81,14 @@ namespace Yavsc.ApiControllers
|
||||
public Estimate GetEstimate (long id)
|
||||
{
|
||||
Estimate est = wfmgr.ContentProvider.GetEstimate (id);
|
||||
string username = Membership.GetUser ().UserName;
|
||||
if (est.Client != username)
|
||||
if (!Roles.IsUserInRole("Admin"))
|
||||
if (!Roles.IsUserInRole("FrontOffice"))
|
||||
throw new AuthorizationDenied (
|
||||
string.Format (
|
||||
"Auth denied to eid {1} for:{2}",
|
||||
id, username));
|
||||
return est;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2015-07-17 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* Web.csproj:
|
||||
* FrontOfficeController.cs:
|
||||
|
||||
2015-07-15 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* cldr.js:
|
||||
|
@ -155,7 +155,6 @@
|
||||
<Compile Include="Controllers\BackOfficeController.cs" />
|
||||
<Compile Include="Admin\Export.cs" />
|
||||
<Compile Include="Admin\DataManager.cs" />
|
||||
<Compile Include="Admin\TaskOutput.cs" />
|
||||
<Compile Include="Controllers\FileSystemController.cs" />
|
||||
<Compile Include="CatExts\WebCatalogExtensions.cs" />
|
||||
<Compile Include="Helpers\YavscHelpers.cs" />
|
||||
|
@ -1,3 +1,13 @@
|
||||
2015-07-17 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* YavscModel.csproj:
|
||||
* Automate.cs:
|
||||
* TaskOutput.cs:
|
||||
* Service.cs:
|
||||
* FinalStateException.cs:
|
||||
* InvalidLetterException.cs:
|
||||
* PriceOnItemCount.cs:
|
||||
|
||||
2015-07-15 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* ListItem.cs:
|
||||
|
@ -26,7 +26,7 @@ namespace Yavsc.Model.FrontOffice.Billing
|
||||
/// <summary>
|
||||
/// A set price.
|
||||
/// </summary>
|
||||
public class SetPrice: Price
|
||||
public class PriceOnItemCount: Price
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum count for this setprice.
|
@ -24,7 +24,7 @@ namespace Yavsc.Model.FrontOffice
|
||||
/// Gets or sets the set prices.
|
||||
/// </summary>
|
||||
/// <value>The set prices.</value>
|
||||
public SetPrice[] SetPrices { get; set; }
|
||||
public PriceOnItemCount[] SetPrices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Role names involved in this kind of service
|
||||
|
@ -26,103 +26,75 @@ namespace Yavsc.Model.WorkFlow
|
||||
/// <summary>
|
||||
/// Automate.
|
||||
/// </summary>
|
||||
public class Automate
|
||||
public class Automate<TState,TLetter>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Yavsc.Model.WorkFlow.Automate"/> class.
|
||||
/// Initializes a new instance of the Automate class.
|
||||
/// </summary>
|
||||
public Automate ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private List<IEquatable<long>> eventids =
|
||||
new List<IEquatable<long>>();
|
||||
private List<IEquatable<long>> stateids =
|
||||
new List<IEquatable<long>>();
|
||||
private IEquatable<long> startingstateid ;
|
||||
private List<IEquatable<long>> endingstateids =
|
||||
new List<IEquatable<long>>();
|
||||
private Dictionary<IEquatable<long>,Dictionary<IEquatable<long>,IEquatable<long>>> transitions =
|
||||
new Dictionary<IEquatable<long>, Dictionary<IEquatable<long>, IEquatable<long>>>();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the state of the starting.
|
||||
/// </summary>
|
||||
/// <param name="startingStateId">Starting state identifier.</param>
|
||||
public void SetStartingState(IEquatable<long> startingStateId)
|
||||
{
|
||||
if (endingstateids.Contains (startingStateId))
|
||||
throw new InvalidOperationException ("endingstateids.Contains (startingStateId)");
|
||||
if (!stateids.Contains (startingStateId))
|
||||
stateids.Add (startingStateId);
|
||||
startingstateid = startingStateId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the state of the ending.
|
||||
/// </summary>
|
||||
/// <param name="endingStateId">Ending state identifier.</param>
|
||||
public void SetEndingState(IEquatable<long> endingStateId)
|
||||
{
|
||||
|
||||
if (startingstateid==endingStateId)
|
||||
throw new InvalidOperationException ("startingstateid==endingStateId");
|
||||
if (!stateids.Contains (endingStateId))
|
||||
stateids.Add (endingStateId);
|
||||
if (!endingstateids.Contains (endingStateId))
|
||||
endingstateids.Add (endingStateId);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Adds the transition.
|
||||
/// </summary>
|
||||
/// <param name="startingStateId">Starting state identifier.</param>
|
||||
/// <param name="endingStateId">Ending state identifier.</param>
|
||||
/// <param name="eventId">Event identifier.</param>
|
||||
public void AddTransition(
|
||||
IEquatable<long> startingStateId,
|
||||
IEquatable<long> endingStateId,
|
||||
IEquatable<long> eventId)
|
||||
{
|
||||
if (!stateids.Contains (startingStateId))
|
||||
stateids.Add (startingStateId);
|
||||
if (!stateids.Contains (endingStateId))
|
||||
stateids.Add (endingStateId);
|
||||
|
||||
Dictionary<IEquatable<long>,IEquatable<long>> currentNode = transitions [startingStateId];
|
||||
if (currentNode == null) {
|
||||
transitions.Add(
|
||||
startingStateId,
|
||||
currentNode =
|
||||
new Dictionary<IEquatable<long>, IEquatable<long>> ());
|
||||
}
|
||||
currentNode [eventId] = endingStateId;
|
||||
if (!eventids.Contains (eventId))
|
||||
eventids.Add (eventId);
|
||||
}
|
||||
|
||||
private Dictionary<TState,Dictionary<TLetter,TState>> transitions =
|
||||
new Dictionary<TState,Dictionary<TLetter,TState>>();
|
||||
private List<TLetter> letters = new List<TLetter>();
|
||||
private List<TState> states = new List<TState>();
|
||||
/// <summary>
|
||||
/// Gets or sets the state.
|
||||
/// </summary>
|
||||
/// <value>The state.</value>
|
||||
public IEquatable<long> State { get; set; }
|
||||
public TState State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the starting state.
|
||||
/// </summary>
|
||||
/// <value>The state.</value>
|
||||
public TState StartingState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Adds the transition.
|
||||
/// </summary>
|
||||
/// <param name="start">Start.</param>
|
||||
/// <param name="end">End.</param>
|
||||
/// <param name="letter">Letter.</param>
|
||||
public virtual void AddTransition(
|
||||
TState start,
|
||||
TState end,
|
||||
TLetter letter)
|
||||
{
|
||||
if (!states.Contains (start))
|
||||
states.Add (start);
|
||||
if (!states.Contains (end))
|
||||
states.Add (end);
|
||||
if (!letters.Contains (letter))
|
||||
letters.Add (letter);
|
||||
Dictionary<TLetter,TState> node = null;
|
||||
if (!transitions.ContainsKey(start))
|
||||
transitions.Add(
|
||||
start,
|
||||
node =
|
||||
new Dictionary<TLetter,TState> ());
|
||||
else node = transitions [start];
|
||||
if (node.ContainsKey (letter))
|
||||
throw new NotImplementedException ("Automates indéterministes");
|
||||
node.Add(letter, end);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Move this instance according the specified eventId.
|
||||
/// </summary>
|
||||
/// <param name="eventId">Event identifier.</param>
|
||||
public void Move(IEquatable<long> eventId)
|
||||
public void Aggregate(TLetter eventId)
|
||||
{
|
||||
if (State == null)
|
||||
throw new InvalidOperationException ("Set the current state or reset the automate before");
|
||||
Dictionary<IEquatable<long>,IEquatable<long>> node = transitions [State];
|
||||
if (node == null) // no transition found
|
||||
return;
|
||||
IEquatable<long> nextState = node [eventId];
|
||||
Dictionary<TLetter,TState> node = transitions [State];
|
||||
if (node == null) // no transition found from this state
|
||||
// it is final.
|
||||
throw new FinalStateException();
|
||||
TState nextState = node [eventId];
|
||||
if (nextState == null) // no transition found for this event
|
||||
return;
|
||||
throw new InvalidLetterException(eventId);
|
||||
State = nextState;
|
||||
}
|
||||
|
||||
@ -131,7 +103,7 @@ namespace Yavsc.Model.WorkFlow
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
State = startingstateid;
|
||||
State = StartingState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -139,10 +111,9 @@ namespace Yavsc.Model.WorkFlow
|
||||
/// reset all of its properties
|
||||
/// </summary>
|
||||
public void FactoryReset() {
|
||||
State = null;
|
||||
startingstateid = null;
|
||||
endingstateids.Clear ();
|
||||
eventids.Clear ();
|
||||
State = default(TState);
|
||||
StartingState = default(TState);
|
||||
letters.Clear ();
|
||||
transitions.Clear ();
|
||||
}
|
||||
|
||||
@ -152,7 +123,7 @@ namespace Yavsc.Model.WorkFlow
|
||||
/// <returns><c>true</c> if this instance is in final state; otherwise, <c>false</c>.</returns>
|
||||
public bool IsInFinalState()
|
||||
{
|
||||
return endingstateids.Contains (State);
|
||||
return !transitions.ContainsKey(this.State);
|
||||
}
|
||||
}
|
||||
|
||||
|
32
yavscModel/WorkFlow/FinalStateException.cs
Normal file
32
yavscModel/WorkFlow/FinalStateException.cs
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// Automate.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paulschneider@free.fr>
|
||||
//
|
||||
// Copyright (c) 2015 Paul Schneider
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Yavsc.Model.WorkFlow
|
||||
{
|
||||
public class FinalStateException : Exception
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
42
yavscModel/WorkFlow/InvalidLetterException.cs
Normal file
42
yavscModel/WorkFlow/InvalidLetterException.cs
Normal file
@ -0,0 +1,42 @@
|
||||
//
|
||||
// Automate.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paulschneider@free.fr>
|
||||
//
|
||||
// Copyright (c) 2015 Paul Schneider
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Yavsc.Model.WorkFlow
|
||||
{
|
||||
/// <summary>
|
||||
/// Invalid letter exception.
|
||||
/// </summary>
|
||||
public class InvalidLetterException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Yavsc.Model.WorkFlow.InvalidLetterException"/> class.
|
||||
/// </summary>
|
||||
/// <param name="letter">Letter.</param>
|
||||
public InvalidLetterException(object letter):base(letter.ToString())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.ComponentModel;
|
||||
|
||||
namespace Yavsc.Admin
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Task output.
|
||||
/// </summary>
|
@ -119,7 +119,6 @@
|
||||
<Compile Include="FileSystem\WebFileInfo.cs" />
|
||||
<Compile Include="FrontOffice\CommandStatus.cs" />
|
||||
<Compile Include="FrontOffice\CommandSet.cs" />
|
||||
<Compile Include="FrontOffice\Catalog\Billing\SetPrice.cs" />
|
||||
<Compile Include="FrontOffice\Catalog\Billing\Price.cs" />
|
||||
<Compile Include="OtherWebException.cs" />
|
||||
<Compile Include="WorkFlow\Automate.cs" />
|
||||
@ -160,6 +159,10 @@
|
||||
<Compile Include="ListItem.cs" />
|
||||
<Compile Include="Calendar\BookEdit.cs" />
|
||||
<Compile Include="Calendar\FreeDate.cs" />
|
||||
<Compile Include="FrontOffice\Catalog\Billing\PriceOnItemCount.cs" />
|
||||
<Compile Include="WorkFlow\TaskOutput.cs" />
|
||||
<Compile Include="WorkFlow\FinalStateException.cs" />
|
||||
<Compile Include="WorkFlow\InvalidLetterException.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user