* style.css:
* Web.csproj: * Web.config: * Catalog.xml: * Global.asax.cs: * TestBinding.cs: * IProvider.cs: * yavscModel.csproj: * WFManager.cs: * BasketController.cs: * WorkFlowController.cs: * ITCPNpgsqlProvider.cs: * IContentProvider.cs: * WorkFlowProvider.csproj: * NpgsqlContentProvider.cs: * Provider.cs: * ITContentProvider.csproj: * FrontOfficeApiController.cs: * ProviderCollection.cs: * WorkflowConfiguration.cs: * BlogProvidersConfigurationSection.cs: * IITContent.cs: Estimate creation
This commit is contained in:
parent
fa93ce7fee
commit
bba917dcc0
21 changed files with 375 additions and 85 deletions
|
|
@ -5,58 +5,73 @@ using System.Configuration;
|
|||
using System.Collections.Specialized;
|
||||
using yavscModel.WorkFlow;
|
||||
using System.Web.Mvc;
|
||||
using System.Configuration.Provider;
|
||||
|
||||
namespace WorkFlowProvider
|
||||
{
|
||||
public class NpgsqlContentProvider: IContentProvider
|
||||
public class NpgsqlContentProvider: ProviderBase, IContentProvider
|
||||
{
|
||||
public IWFOrder CreateOrder ()
|
||||
public Estimate GetEstimate (long estimid)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
public IWFOrder ImapctOrder (string orderid, FormCollection col)
|
||||
|
||||
public void SetTitle (long estid, string newTitle)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
using (NpgsqlConnection cnx = CreateConnection ()) {
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText =
|
||||
"update estimate set title = @tit where _id = @estid";
|
||||
cmd.Parameters.Add ("@tit", newTitle);
|
||||
cmd.Parameters.Add ("@estid", estid);
|
||||
cnx.Open ();
|
||||
cmd.ExecuteNonQuery ();
|
||||
cnx.Close ();
|
||||
}
|
||||
}
|
||||
}
|
||||
public bool[] IsFinalStatus {
|
||||
|
||||
public long Write (long estid, string desc, decimal ucost, int count, long productid)
|
||||
{
|
||||
using (NpgsqlConnection cnx = CreateConnection ()) {
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText =
|
||||
"insert into writtings (description, estimid) VALUES (@dscr,@estid) returning _id";
|
||||
cmd.Parameters.Add ("@dscr", desc);
|
||||
// cmd.Parameters.Add ("@prdid", productid);
|
||||
// cmd.Parameters.Add("@ucost", ucost);
|
||||
// cmd.Parameters.Add("@mult", count);
|
||||
cmd.Parameters.Add("@estid", estid);
|
||||
cnx.Open ();
|
||||
|
||||
long res = (long) cmd.ExecuteScalar ();
|
||||
cnx.Close ();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDesc (long writid, string newDesc)
|
||||
{
|
||||
using (NpgsqlConnection cnx = CreateConnection ()) {
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText =
|
||||
"update writtings set description = @dscr where _id = @writid";
|
||||
cmd.Parameters.Add ("@tit", newDesc);
|
||||
cmd.Parameters.Add ("@writid", writid);
|
||||
cnx.Open ();
|
||||
cmd.ExecuteNonQuery ();
|
||||
cnx.Close ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool[] FinalStatuses {
|
||||
get {
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
|
||||
string applicationName=null;
|
||||
|
||||
public string ApplicationName {
|
||||
get {
|
||||
return applicationName;
|
||||
}
|
||||
}
|
||||
|
||||
string cnxstr = null;
|
||||
|
||||
public NpgsqlContentProvider ()
|
||||
{
|
||||
Initialize("NpgsqlYavscContentProvider",ConfigurationManager.AppSettings);
|
||||
}
|
||||
|
||||
public void Initialize (string name, NameValueCollection config)
|
||||
{
|
||||
cnxstr = ConfigurationManager.ConnectionStrings [config ["connectionStringName"]].ConnectionString;
|
||||
applicationName = config["applicationName"] ?? "/";
|
||||
}
|
||||
|
||||
protected NpgsqlConnection CreateConnection ()
|
||||
{
|
||||
return new NpgsqlConnection (cnxstr);
|
||||
}
|
||||
|
||||
#region IDisposable implementation
|
||||
public void Dispose ()
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
public string Order (IWFOrder c)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
|
|
@ -78,11 +93,57 @@ namespace WorkFlowProvider
|
|||
}
|
||||
}
|
||||
|
||||
#region IITContentProvider implementation
|
||||
#region IDisposable implementation
|
||||
public void Dispose ()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
public long CreateEstimate (string client, string title)
|
||||
{
|
||||
using (NpgsqlConnection cnx = CreateConnection ()) {
|
||||
using (NpgsqlCommand cmd = cnx.CreateCommand ()) {
|
||||
cmd.CommandText =
|
||||
"insert into estimate (title,username,applicationname) " +
|
||||
"values (@tit,@un,@app) returning _id";
|
||||
cmd.Parameters.Add ("@tit", title);
|
||||
cmd.Parameters.Add ("@un", client);
|
||||
cmd.Parameters.Add("@app", ApplicationName);
|
||||
cnx.Open ();
|
||||
long res = (long)cmd.ExecuteScalar ();
|
||||
cnx.Close ();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string applicationName=null;
|
||||
|
||||
public string ApplicationName {
|
||||
get {
|
||||
return applicationName;
|
||||
}
|
||||
set {
|
||||
applicationName = value;
|
||||
}
|
||||
}
|
||||
|
||||
string cnxstr = null;
|
||||
|
||||
public override void Initialize (string name, NameValueCollection config)
|
||||
{
|
||||
if ( string.IsNullOrWhiteSpace(config ["connectionStringName"]))
|
||||
throw new ConfigurationErrorsException ("No name for Npgsql connection string found");
|
||||
|
||||
cnxstr = ConfigurationManager.ConnectionStrings [config ["connectionStringName"]].ConnectionString;
|
||||
applicationName = config["applicationName"] ?? "/";
|
||||
}
|
||||
|
||||
protected NpgsqlConnection CreateConnection ()
|
||||
{
|
||||
return new NpgsqlConnection (cnxstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue