refactoring
This commit is contained in:
@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace WorkFlowProvider.Configuration
|
||||
{
|
||||
public class WFProvider:ConfigurationElement
|
||||
{
|
||||
[ConfigurationProperty("name", IsKey=true, IsRequired=true)]
|
||||
public string Name {
|
||||
get {
|
||||
return (string) base ["name"];
|
||||
}
|
||||
set { base ["name"] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty("type")]
|
||||
public string Type {
|
||||
get { return (string) this ["type"]; }
|
||||
set {
|
||||
this ["type"] = value;
|
||||
}
|
||||
}
|
||||
[ConfigurationProperty("applicationName")]
|
||||
public string ApplicationName {
|
||||
get {
|
||||
return (string)this ["applicationName"];
|
||||
}
|
||||
set {
|
||||
this ["applicationName"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("connectionStringName")]
|
||||
public string ConnectionStringName {
|
||||
get { return (string)this ["connectionStringName"]; }
|
||||
set { this ["connectionStringName"] = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace WorkFlowProvider.Configuration
|
||||
{
|
||||
public class WFProviderCollection : ConfigurationElementCollection
|
||||
{
|
||||
protected override object GetElementKey (ConfigurationElement element)
|
||||
{
|
||||
return ((WFProvider) element).Name;
|
||||
}
|
||||
protected override ConfigurationElement CreateNewElement ()
|
||||
{
|
||||
return new WFProvider();
|
||||
}
|
||||
public WFProvider GetElement (string name)
|
||||
{
|
||||
return this.BaseGet (name) as WFProvider;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace WorkFlowProvider.Configuration
|
||||
{
|
||||
public class WorkflowConfiguration : ConfigurationSection
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the default provider.
|
||||
/// </summary>
|
||||
/// <value>The default provider.</value>
|
||||
[ConfigurationProperty("defaultProvider")]
|
||||
public string DefaultProvider {
|
||||
get { return (string)base ["defaultProvider"]; }
|
||||
set { base ["defaultProvider"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the providers.
|
||||
/// </summary>
|
||||
/// <value>The providers.</value>
|
||||
[ConfigurationProperty("providers")]
|
||||
[ConfigurationCollection(typeof(WFProvider),
|
||||
AddItemName = "add",
|
||||
ClearItemsName = "clear",
|
||||
RemoveItemName = "remove")]
|
||||
public WFProviderCollection Providers {
|
||||
get {
|
||||
return this["providers"] as WFProviderCollection;
|
||||
}
|
||||
|
||||
set {
|
||||
this["providers"]=value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,99 +0,0 @@
|
||||
using System;
|
||||
using Yavsc.Model.WorkFlow;
|
||||
using System.Configuration;
|
||||
using WorkFlowProvider.Configuration;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace WorkFlowProvider
|
||||
{
|
||||
public static class WFManager
|
||||
{
|
||||
public static Estimate GetEstimate (long estid)
|
||||
{
|
||||
return ContentProvider.GetEstimate (estid);
|
||||
}
|
||||
public static Estimate [] GetEstimates (string client)
|
||||
{
|
||||
return ContentProvider.GetEstimates (client);
|
||||
}
|
||||
public static void UpdateWritting (Writting wr)
|
||||
{
|
||||
ContentProvider.UpdateWritting (wr);
|
||||
}
|
||||
|
||||
public static void DropWritting (long wrid)
|
||||
{
|
||||
ContentProvider.DropWritting (wrid);
|
||||
}
|
||||
public static void DropEstimate (long estid)
|
||||
{
|
||||
ContentProvider.DropEstimate(estid);
|
||||
}
|
||||
static IContentProvider contentProvider;
|
||||
|
||||
public static IContentProvider ContentProvider {
|
||||
get {
|
||||
WorkflowConfiguration c = (WorkflowConfiguration) ConfigurationManager.GetSection ("system.web/workflow");
|
||||
if (c == null)
|
||||
throw new Exception ("No system.web/workflow configuration section found");
|
||||
WFProvider confprov = c.Providers.GetElement (c.DefaultProvider);
|
||||
if (confprov == null)
|
||||
throw new Exception ("Default workflow provider not found (system.web/workflow@defaultProvider)");
|
||||
string clsName = confprov.Type;
|
||||
if (clsName == null)
|
||||
throw new Exception ("Provider type not specified (system.web/workflow@type)");
|
||||
|
||||
if (contentProvider != null)
|
||||
{
|
||||
if (contentProvider.GetType ().Name != clsName)
|
||||
contentProvider = null;
|
||||
}
|
||||
|
||||
if (contentProvider == null)
|
||||
{
|
||||
Type cpt = Type.GetType (clsName);
|
||||
if (cpt == null)
|
||||
throw new Exception (string.Format("Type not found : {0} (wrong name, or missing assembly reference?)",clsName));
|
||||
System.Reflection.ConstructorInfo ci =cpt.GetConstructor (System.Type.EmptyTypes);
|
||||
contentProvider = (IContentProvider)ci.Invoke (System.Type.EmptyTypes);
|
||||
}
|
||||
|
||||
contentProvider.ApplicationName = confprov.ApplicationName;
|
||||
|
||||
NameValueCollection config = new NameValueCollection ();
|
||||
config.Add ("name", confprov.Name);
|
||||
config.Add ("connectionStringName", confprov.ConnectionStringName);
|
||||
config.Add ("applicationName", confprov.ApplicationName);
|
||||
contentProvider.Initialize (confprov.Name, config);
|
||||
|
||||
return contentProvider;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the estimate.
|
||||
/// </summary>
|
||||
/// <returns>The estimate identifier.</returns>
|
||||
/// <param name="title">Title.</param>
|
||||
public static long CreateEstimate(string client, string title)
|
||||
{
|
||||
return ContentProvider.CreateEstimate (client, title);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static long Write(long estid, string desc, decimal ucost, int count, long productid)
|
||||
{
|
||||
return ContentProvider.Write(estid, desc, ucost, count, productid);
|
||||
}
|
||||
|
||||
public static void SetEstimateStatus(long estid, int status, string username)
|
||||
{
|
||||
ContentProvider.SetEstimateStatus (estid, status, username);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,6 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="NpgsqlContentProvider.cs" />
|
||||
<Compile Include="WFManager.cs" />
|
||||
<Compile Include="Configuration\WorkflowConfiguration.cs" />
|
||||
<Compile Include="Configuration\ProviderCollection.cs" />
|
||||
<Compile Include="Configuration\Provider.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
@ -50,7 +46,4 @@
|
||||
<Name>YavscModel</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Configuration\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user