Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9619


Ignore:
Timestamp:
06/12/13 16:34:04 (11 years ago)
Author:
spimming
Message:

#1888:

  • Added new BillingService methods
  • Disabled proxy generation and lazy loading!
  • Extended see method with additional test data
  • Added properties to order and invoice model
  • initial commit of BillingEngine module
Location:
branches/OaaS
Files:
5 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/App.config

    r9579 r9619  
    55    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    66  </configSections>
     7  <appSettings>
     8    <add key="BillingEngineInterval" value ="00:01:00"/>
     9  </appSettings>
    710  <connectionStrings>
    811    <add name="BillingContext" connectionString="ADJUST_ME" providerName="System.Data.SqlClient" />
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/DDLScript.sql

    r9602 r9619  
    1515    [UserId] [bigint] not null,
    1616    [OrderId] [bigint] not null,
     17    [InvoiceDate] [datetime] not null,
    1718    [Due] [datetime] not null,
    1819    [StatusValue] [int] not null,
     20    [Total] [float] not null,
     21    [Tax] [float] not null,
    1922    [InvoiceDocument] [nvarchar](max) null,
    2023    primary key ([InvoiceId])
     
    3639    [ActiveSince] [datetime] null,
    3740    [ActiveUntil] [datetime] null,
     41    [LastBillableDay] [datetime] null,
     42    [NextBillableDay] [datetime] null,
    3843    primary key ([OrderId])
    3944);
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing.Test/Program.cs

    r9602 r9619  
    11using System;
    22using System.Data.Entity.Infrastructure;
     3using System.Diagnostics;
    34using System.IO;
     5using System.Threading;
    46using HeuristicLab.Services.Optimization.Billing.DataAccess;
    57using HeuristicLab.Services.Optimization.Billing.Model;
     
    79namespace HeuristicLab.Services.Optimization.Billing.Test {
    810  class Program {
     11    private static BillingEngine.BillingEngine billingEngine;
     12    private static Thread billingEngineThread;
     13
    914    static void Main(string[] args) {
    1015      string ddlScript;
     
    2530      }
    2631
     32      // Start BillingEngine Service:
     33      Trace.WriteLine("Starting BillingEngine ...");
     34      try {
     35        billingEngine = new BillingEngine.BillingEngine();
     36        billingEngineThread = new Thread(billingEngine.Run);
     37        billingEngineThread.IsBackground = true; //dont keep app alive
     38        billingEngineThread.Start();
     39      }
     40      catch (Exception e) {
     41        Trace.WriteLine("Error during BillingEngine startup: " + e.Message);
     42      }
     43
    2744      Console.WriteLine("Press any key to exit...");
    2845      Console.ReadKey();
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/App.config

    r9577 r9619  
    88    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    99  </configSections>
     10  <appSettings>
     11    <add key="BillingEngineInterval" value ="00:01:00"/>
     12  </appSettings>
    1013  <entityFramework>
    1114    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/BillingService.cs

    r9602 r9619  
    2929    }
    3030
     31    public IList<Product> GetProductByName(string productName) {
     32      //TODO: Authentication
     33      //TODO: Enable Transaction
     34      return BillingDao.FindProdcutBy(prod => prod.Name == productName).ToList();
     35    }
     36
    3137    #endregion
    3238
     
    4248      //TODO: Authentication
    4349      //TODO: Enable Transaction
    44       return BillingDao.FindOrderBy(order => order.State == state).ToList();
     50      return BillingDao.FindOrderBy(order => order.StateValue == (int)state).ToList();
    4551    }
    4652
     
    5056      User user = GetUser(userName);
    5157      return BillingDao.FindOrderBy(order => order.User == user).ToList();
     58    }
     59
     60    public void UpdateOrder(Order order) {
     61      throw new System.NotImplementedException();
    5262    }
    5363
     
    7989    }
    8090
     91    public IList<UsageRecord> GetUsageRecords(string username, System.DateTime from, System.DateTime to) {
     92      throw new System.NotImplementedException();
     93    }
     94
    8195    #endregion
    8296
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/Business/MockupBillingService.cs

    r9602 r9619  
    118118      return null;
    119119    }
     120
     121    #region IOptimizationBilling Members
     122
     123
     124    public IList<Model.Product> GetProductByName(string productName) {
     125      throw new NotImplementedException();
     126    }
     127
     128    public void UpdateOrder(Model.Order order) {
     129      throw new NotImplementedException();
     130    }
     131
     132    public IList<Model.UsageRecord> GetUsageRecords(string username, DateTime from, DateTime to) {
     133      throw new NotImplementedException();
     134    }
     135
     136    #endregion
    120137  }
    121138}
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingContext.cs

    r9602 r9619  
    2828    public BillingContext(string connectionString)
    2929      : base(connectionString) {
    30 
     30      this.Configuration.LazyLoadingEnabled = false;
     31      this.Configuration.ProxyCreationEnabled = false;
    3132    }
    3233
     
    9697      protected override void Seed(BillingContext context) {
    9798        Product p1 = new Product() {
    98           Name = "Optimization-as-a-Service - Experiment execution",
     99          Name = "OaaS BAsic Service Charge",
    99100          Description = "Create and run your experiments within HeuristicLab Hive",
    100           ProductId = 1,
    101           Price = 10.0,
     101          Price = 20.0,
    102102          ProductType = "Optimization Service"
    103103        };
     104
     105        Product p2 = new Product() {
     106          Name = "Oaas Usage Charges",
     107          Description = "Charges for OaaS based on usage data",
     108          Price = 0.0,
     109          ProductType = "Optimization Service"
     110        };
     111
     112        Product p3 = new Product() {
     113          Name = "Oaas Support Package",
     114          Description = "Charges for OaaS based on usage data",
     115          Price = 50.0,
     116          ProductType = "Optimization Service"
     117        };
     118
    104119        p1 = context.Products.Add(p1);
     120        p2 = context.Products.Add(p2);
     121        p3 = context.Products.Add(p3);
    105122
    106123        User u1 = new Model.User() { Name = "spimming" };
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/DataAccess/BillingDao.cs

    r9602 r9619  
    22using System;
    33using System.Collections.Generic;
     4using System.Data.Entity;
    45using System.Linq;
    56using System.Linq.Expressions;
     
    105106    public IEnumerable<Order> FindOrderBy(Expression<Func<Order, bool>> predicate) {
    106107      using (var context = CreateContext()) {
    107         var orders = context.Orders.Where(predicate).ToList();
     108        var orders = context.Orders
     109          .Include(o => o.OrderLines)
     110          .Include(o => o.User)
     111          .Include(o => o.Invoices)
     112          .Include(o => o.OrderLines.Select(ol => ol.Product))
     113          .Where(predicate).ToList();
    108114        return orders;
    109115      }
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/HeuristicLab.Services.Optimization.Billing.csproj

    r9602 r9619  
    4040    <Reference Include="System.Core" />
    4141    <Reference Include="System.Data.Entity" />
     42    <Reference Include="System.Drawing" />
    4243    <Reference Include="System.ServiceModel" />
     44    <Reference Include="System.Windows.Forms" />
    4345    <Reference Include="System.Xml.Linq" />
    4446    <Reference Include="System.Data.DataSetExtensions" />
     
    4850  </ItemGroup>
    4951  <ItemGroup>
     52    <Compile Include="BillingEngine\BillingEngine.cs" />
     53    <Compile Include="BillingEngine\PlainTextInvoiceFormattingEngine.cs" />
    5054    <Compile Include="Business\BillingService.cs" />
    5155    <Compile Include="Business\BillingServiceProvider.cs" />
     
    5458    <Compile Include="Interfaces\IEntity.cs" />
    5559    <Compile Include="Interfaces\IGenericDao.cs" />
     60    <Compile Include="Interfaces\IInvoiceFormattingEngine.cs" />
    5661    <Compile Include="Interfaces\IOptimizationBilling.cs" />
    5762    <Compile Include="Business\MockupBillingService.cs" />
     
    6368    <None Include="packages.config" />
    6469  </ItemGroup>
    65   <ItemGroup />
     70  <ItemGroup>
     71    <Content Include="BillingEngine\InvoiceTemplate.txt">
     72      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     73    </Content>
     74  </ItemGroup>
    6675  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    6776  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/Interfaces/IOptimizationBilling.cs

    r9586 r9619  
    1 using System.Collections.Generic;
     1using System;
     2using System.Collections.Generic;
    23using System.Net.Security;
    34using System.ServiceModel;
     
    910    [OperationContract]
    1011    IList<Product> GetProducts();
     12    IList<Product> GetProductByName(string productName);
    1113
    1214    // payment methods via enumeration
     
    1820    IList<Order> GetOrdersByState(OrderState state);
    1921    IList<Order> GetOrders(string userName);
     22    void UpdateOrder(Order order);
     23
     24    IList<Invoice> GetInvoices(string userName);
    2025
    2126    User GetUser(string userName);
     
    2328
    2429    IList<UsageRecord> GetUsageRecords(string userName);
    25     IList<Invoice> GetInvoices(string userName);
     30    IList<UsageRecord> GetUsageRecords(string username, DateTime from, DateTime to);
     31
    2632  }
    2733}
  • branches/OaaS/HeuristicLab.Services.Optimization.Billing/Model/Model.cs

    r9602 r9619  
    9292    public DateTime? ActiveSince { get; set; }
    9393    public DateTime? ActiveUntil { get; set; }
     94    public DateTime? LastBillableDay { get; set; }
     95    public DateTime? NextBillableDay { get; set; }
    9496
    9597    public virtual User User { get; set; }
     
    130132    public long UserId { get; set; }
    131133    public long OrderId { get; set; }
     134    public DateTime InvoiceDate { get; set; }
    132135    public DateTime Due { get; set; }
    133136    public int StatusValue { get; set; }
     137    public double Total { get; set; }
     138    public double Tax { get; set; }
    134139    public string InvoiceDocument { get; set; }
    135140
Note: See TracChangeset for help on using the changeset viewer.