
* jquery-latest.js: * IITContent.cs: * ITContent.csproj: * YavscModel.csproj: * Write.aspx: * jquery.tablesorter.min.js: * AssemblyInfo.cs: * NewEstimateEvenArgs.cs: * jquery.metadata.js: ajax call Write * jquery.tablesorter.js: Estimate table sorting * Catalog.cs: Find a product by reference * NpgsqlContentProvider.cs: Npgsql provider could not get the Postgresql data type "money" * Yavsc.sln: Removing an empty project * MyClass.cs: implements IModule * fortune.csproj: uses Configuration * FrontOfficeApiController.cs: Url: GetEstimate/5 * WorkFlowController.cs: debugging ajax call * RemoveUserQuery.aspx: no more "head" place holder * Estimate.aspx: Ajax call to add a line to estimates * Web.config: using the "Deploy" target * IModule.cs: Install & uninstall using a System.Data.IDbConnection * IContentProvider.cs: refactoring * WorkFlowManager.cs: an event at creating an estimate (NewOrder) * Writting.cs: ProductReference is a string
127 lines
3.7 KiB
C#
127 lines
3.7 KiB
C#
using System;
|
|
using Yavsc.Model.WorkFlow;
|
|
using System.Configuration;
|
|
using Yavsc.Model.WorkFlow.Configuration;
|
|
using System.Collections.Specialized;
|
|
using SalesCatalog.Model;
|
|
|
|
namespace Yavsc.Model.WorkFlow
|
|
{
|
|
/// <summary>
|
|
/// Work flow manager.
|
|
/// It takes orders store them and raise some events for modules
|
|
/// It publishes estimates and invoices
|
|
/// </summary>
|
|
public static class WorkFlowManager
|
|
{
|
|
public static Catalog Catalog { get; set; }
|
|
|
|
|
|
public static void SetTitle (long id, string title)
|
|
{
|
|
ContentProvider.SetTitle (id, title);
|
|
}
|
|
|
|
public static event EventHandler NewOrder;
|
|
|
|
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)
|
|
{
|
|
long estid = ContentProvider.CreateEstimate (client, title);
|
|
if (NewOrder != null)
|
|
NewOrder.Invoke(ContentProvider, new NewEstimateEvenArgs(estid,client,title));
|
|
return estid;
|
|
}
|
|
|
|
public static long Write(long estid, string desc, decimal ucost, int count, string productid)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(productid)) {
|
|
if (Catalog == null)
|
|
Catalog = SalesCatalog.CatalogManager.GetCatalog ();
|
|
if (Catalog == null)
|
|
throw new Exception ("No catalog");
|
|
Product p = Catalog.FindProduct (productid);
|
|
// TODO new EstimateChange Event
|
|
}
|
|
return ContentProvider.Write(estid, desc, ucost, count, productid);
|
|
}
|
|
|
|
public static void SetEstimateStatus(long estid, int status, string username)
|
|
{
|
|
ContentProvider.SetEstimateStatus (estid, status, username);
|
|
}
|
|
|
|
}
|
|
}
|
|
|