Refactor project structure in solution
Replaced "EnvelopeGenerator.WebUI" with "EnvelopeGenerator.Server" and "EnvelopeGenerator.WebUI.Client" with "EnvelopeGenerator.Server.Client". Updated project entries, solution configuration platforms, and nested projects to reflect these changes.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
namespace EnvelopeGenerator.WebUI.Client.Data {
|
||||
public class Adjustment
|
||||
{
|
||||
public static Adjustment CreateBalanceForward(DateTime dt, int random)
|
||||
{
|
||||
var rnd = new DeterministicRandom(random);
|
||||
Adjustment res = new Adjustment();
|
||||
res.currentDateTime = dt;
|
||||
res.currentDescription = "Balance Forward";
|
||||
res.currentAmount = rnd.Random(10, 300) * 10;
|
||||
return res;
|
||||
}
|
||||
public static Adjustment CreatePayment(DateTime dt, int random)
|
||||
{
|
||||
var rnd = new DeterministicRandom(random);
|
||||
Adjustment res = new Adjustment();
|
||||
res.currentDateTime = dt;
|
||||
res.currentDescription = "Payment";
|
||||
res.currentAmount = -rnd.Random(1, 40) * 10;
|
||||
return res;
|
||||
}
|
||||
public static Adjustment CreateCharge(DateTime dt, int random)
|
||||
{
|
||||
var rnd = new DeterministicRandom(random);
|
||||
Adjustment res = new Adjustment();
|
||||
res.currentDateTime = dt;
|
||||
res.currentDescription = rnd.GetRandomItem(bills);
|
||||
res.currentAmount = rnd.Random(10, 50) * 10;
|
||||
return res;
|
||||
}
|
||||
|
||||
DateTime currentDateTime;
|
||||
string currentDescription = "";
|
||||
double currentAmount = 0;
|
||||
static readonly string[] bills = new string[] { "Bill - Insurance", "Bill - Electricity", "Bill - Rent", "Bill - Phone", "Bill - Office Supplies" };
|
||||
public DateTime Date { get { return currentDateTime; } }
|
||||
public string Description { get { return currentDescription; } }
|
||||
public double Amount { get { return currentAmount; } }
|
||||
|
||||
public Adjustment()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using DevExpress.DataAccess.Sql;
|
||||
using DevExpress.DataAccess.Sql.DataApi;
|
||||
|
||||
namespace EnvelopeGenerator.WebUI.Client.Data {
|
||||
public class Customer {
|
||||
static List<Customer> currentCustomers = new List<Customer>();
|
||||
|
||||
public static List<Customer> Customers { get { return currentCustomers; } }
|
||||
static Customer() {
|
||||
try {
|
||||
SqlDataSource ds = new SqlDataSource("NWindConnectionString");
|
||||
SelectQuery query = SelectQueryFluentBuilder
|
||||
.AddTable("Customers")
|
||||
.SelectAllColumns()
|
||||
.Build("Customers");
|
||||
ds.Queries.Add(query);
|
||||
ds.RebuildResultSchema();
|
||||
ds.Fill();
|
||||
ITable src = ds.Result["Customers"];
|
||||
foreach(var row in src) {
|
||||
currentCustomers.Add(new Customer() {
|
||||
CustomerID = row.GetValue<string>("CustomerID"),
|
||||
Address = row.GetValue<string>("Address"),
|
||||
CompanyName = row.GetValue<string>("CompanyName"),
|
||||
ContactName = row.GetValue<string>("ContactName"),
|
||||
ContactTitle = row.GetValue<string>("ContactTitle"),
|
||||
Country = row.GetValue<string>("Country"),
|
||||
City = row.GetValue<string>("City"),
|
||||
Fax = row.GetValue<string>("Fax"),
|
||||
Phone = row.GetValue<string>("Phone"),
|
||||
PostalCode = row.GetValue<string>("PostalCode"),
|
||||
Region = row.GetValue<string>("Region")
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
currentCustomers.Add(new Customer() {
|
||||
Address = "Obere Str. 57",
|
||||
City = "Berlin",
|
||||
CompanyName = "Alfreds Futterkiste",
|
||||
ContactName = "Maria Anders",
|
||||
ContactTitle = "Sales Representative",
|
||||
Country = "Germany",
|
||||
CustomerID = "ALFKI",
|
||||
Fax = "030-0076545",
|
||||
Phone = "030-0074321",
|
||||
PostalCode = "12209"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomerID { get; set; }
|
||||
public string CompanyName { get; set; }
|
||||
public string ContactName { get; set; }
|
||||
public string ContactTitle { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string City { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Region { get; set; }
|
||||
public string Country { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Fax { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
namespace EnvelopeGenerator.WebUI.Client.Data {
|
||||
public class DataItem {
|
||||
static readonly string[] accountType = new string[] { "Energy", "Manufacturing", "Estate", "Food", "Services" };
|
||||
public string CustomerID { get; set; }
|
||||
public string CompanyName { get; set; }
|
||||
public string ContactName { get; set; }
|
||||
public string ContactTitle { get; set; }
|
||||
public string Address { get; set; }
|
||||
public string City { get; set; }
|
||||
public string PostalCode { get; set; }
|
||||
public string Region { get; set; }
|
||||
public string Country { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Fax { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Invoice { get; set; }
|
||||
public string CustomerAccount { get; set; }
|
||||
public string CustomerIdentifiers { get; set; }
|
||||
public DateTime BillingDate { get; set; }
|
||||
public DateTime BillingPeriodStart { get; set; }
|
||||
public DateTime BillingPeriodEnd { get; set; }
|
||||
public string Terms { get; set; }
|
||||
public string TermsID { get; set; }
|
||||
public Adjustment[] Adjustments { get; set; }
|
||||
|
||||
public DataItem(int i) {
|
||||
var rnd = new DeterministicRandom(i);
|
||||
Customer c = rnd.GetRandomItem(Customer.Customers);
|
||||
CustomerID = c.CustomerID;
|
||||
CompanyName = c.CompanyName;
|
||||
ContactName = c.ContactName;
|
||||
ContactTitle = c.ContactTitle;
|
||||
Address = c.Address;
|
||||
City = c.City;
|
||||
PostalCode = c.PostalCode;
|
||||
Region = c.Region;
|
||||
Country = c.Country;
|
||||
Phone = c.Phone;
|
||||
Fax = c.Fax;
|
||||
Email = ContactName.Split(' ')[0].Replace(' ', '.').ToLower() + "@" + CompanyName.Split(' ')[0].ToLower() + ".com";
|
||||
Invoice = string.Format("{0}{1}-{2}", rnd.RandomChar, rnd.Random(100, 1000), rnd.Random(100, 1000));
|
||||
CustomerAccount = rnd.GetRandomItem(accountType);
|
||||
CustomerIdentifiers = string.Format("{0}-{1}", rnd.Random(1000, 10000), rnd.Random(10, 100));
|
||||
BillingPeriodStart = rnd.RandomTime();
|
||||
BillingPeriodEnd = rnd.RandomTime(BillingPeriodStart, 7 * 24, 30 * 24);
|
||||
BillingDate = rnd.RandomTime(BillingPeriodEnd, 7 * 24, 30 * 24);
|
||||
Term currentTerm = rnd.GetRandomItem(Term.Terms);
|
||||
Terms = currentTerm.Name;
|
||||
|
||||
int adjustmentsCount = rnd.Random(6) + 4;
|
||||
Adjustments = new Adjustment[adjustmentsCount];
|
||||
int h = (int)((BillingPeriodEnd - BillingPeriodStart).TotalHours / adjustmentsCount);
|
||||
|
||||
Adjustments[0] = Adjustment.CreateBalanceForward(rnd.RandomTime(BillingPeriodStart, 0, h), rnd.Random(10000));
|
||||
|
||||
int[] items = rnd.RandomList(adjustmentsCount - 1, 2);
|
||||
|
||||
for(int j = 1; j < Adjustments.Length; j++) {
|
||||
DateTime nextDate = rnd.RandomTime(BillingPeriodStart.AddHours(h * j), 0, h);
|
||||
switch(items[j - 1]) {
|
||||
case 0:
|
||||
Adjustments[j] = Adjustment.CreateCharge(nextDate, rnd.Random(10000));
|
||||
break;
|
||||
case 1:
|
||||
Adjustments[j] = Adjustment.CreatePayment(nextDate, rnd.Random(10000));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections;
|
||||
|
||||
namespace EnvelopeGenerator.WebUI.Client.Data {
|
||||
public class DataItemList : IList<DataItem>, IList {
|
||||
readonly int rowCount;
|
||||
|
||||
public DataItem this[int index] { get { return new DataItem(index); } set { } }
|
||||
public int Count { get { return rowCount; } }
|
||||
public bool IsReadOnly { get { return false; } }
|
||||
public bool IsFixedSize { get { return false; } }
|
||||
public object SyncRoot { get { return true; } }
|
||||
public bool IsSynchronized { get { return true; } }
|
||||
object IList.this[int index] { get { return new DataItem(index); } set { } }
|
||||
|
||||
public DataItemList(int rowCount) {
|
||||
this.rowCount = rowCount;
|
||||
}
|
||||
public IEnumerator<DataItem> GetEnumerator() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public int Add(object value) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public bool Contains(object value) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void Clear() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public int IndexOf(object value) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void Insert(int index, object value) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void Remove(object value) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void RemoveAt(int index) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void CopyTo(Array array, int index) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
IEnumerator IEnumerable.GetEnumerator() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public int IndexOf(DataItem item) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void Insert(int index, DataItem item) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void Add(DataItem item) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public bool Contains(DataItem item) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void CopyTo(DataItem[] array, int arrayIndex) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public bool Remove(DataItem item) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
void ICollection<DataItem>.CopyTo(DataItem[] array, int arrayIndex) {
|
||||
CopyTo(array, arrayIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
namespace EnvelopeGenerator.WebUI.Client.Data {
|
||||
class DeterministicRandom {
|
||||
const int randomCount = 10000;
|
||||
static readonly int[] deterministicRandomNumbers;
|
||||
static readonly DateTime time;
|
||||
int rnd;
|
||||
int Next {
|
||||
get {
|
||||
rnd = deterministicRandomNumbers[rnd % randomCount];
|
||||
return rnd;
|
||||
}
|
||||
}
|
||||
public char RandomChar {
|
||||
get {
|
||||
return (char)((int)'A' + Random(0, 26));
|
||||
}
|
||||
}
|
||||
public int[] RandomList(int count, int to) {
|
||||
int[] res = new int[count];
|
||||
for(int i = 0; i < Math.Min(count, to); i++)
|
||||
res[i] = i;
|
||||
for(int i = to; i < count; i++)
|
||||
res[i] = Random(to);
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
int ind = Random(count);
|
||||
int temp = res[ind];
|
||||
res[ind] = res[i];
|
||||
res[i] = temp;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
public int Random(int to) {
|
||||
return Random(0, to);
|
||||
}
|
||||
public int Random(int from, int to) {
|
||||
return Next % Math.Max(1, to - from) + from;
|
||||
}
|
||||
public T GetRandomItem<T>(IList<T> list) {
|
||||
return list[Next % list.Count];
|
||||
}
|
||||
public DateTime RandomTime() {
|
||||
return RandomTime(time, 0, 30 * 24);
|
||||
}
|
||||
public DateTime RandomTime(DateTime from, int fromHours, int toHours) {
|
||||
return from.AddHours(Next % (toHours - fromHours) + fromHours);
|
||||
}
|
||||
|
||||
static DeterministicRandom() {
|
||||
time = DateTime.Now.AddDays(-62);
|
||||
Random currentRandom = new Random(randomCount);
|
||||
deterministicRandomNumbers = new int[randomCount];
|
||||
for(int i = 0; i < randomCount; i++)
|
||||
deterministicRandomNumbers[i] = currentRandom.Next(randomCount);
|
||||
}
|
||||
public DeterministicRandom(int i) {
|
||||
this.rnd = i + (i >> 10) + (i >> 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace EnvelopeGenerator.WebUI.Client.Data {
|
||||
public struct Term {
|
||||
public static readonly Term[] Terms = new Term[] {
|
||||
new Term("Payment seven days after invoice date" ),
|
||||
new Term("Payment ten days after invoice date" ),
|
||||
new Term("End of month" ),
|
||||
new Term("21st of the month following invoice date" ),
|
||||
};
|
||||
readonly string currentName;
|
||||
public string Name { get { return currentName; } }
|
||||
public Term(string currentName) {
|
||||
this.currentName = currentName;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user