De presentatie wordt gedownload. Even geduld aub

De presentatie wordt gedownload. Even geduld aub

NextGenPos Evi Francis Hilde Van Roey Wim Serroyen Ignas Van Tricht

Verwante presentaties


Presentatie over: "NextGenPos Evi Francis Hilde Van Roey Wim Serroyen Ignas Van Tricht"— Transcript van de presentatie:

1 NextGenPos Evi Francis Hilde Van Roey Wim Serroyen Ignas Van Tricht
David Van Effen Liesbeth Vertommen

2 Inleiding Geautomatiseerde applicatie voor kassasysteem
Aankopen samenstellen Flexibiliteit Aanpasbaarheid

3 Context diagram

4 Data flow diagram

5 ERD

6 Use case

7 Het programma

8 Pluggable business rules & Prijsstrategieën

9 [Serializable] public class DiscountSettings { private IDiscountStrategy[] strategies; private static XmlSerializer serializer; [XmlIgnore] public IDiscountStrategy[] Strategies get { return strategies; } set { strategies = value; } } [XmlElement(Type = typeof(DiscountStrategySerializer))] public DiscountStrategySerializer[] XmlStrategies get { if (Strategies == null) return null; else { DiscountStrategySerializer[] dss = new DiscountStrategySerializer[Strategies.Length]; for (int i = 0; i < Strategies.Length; i++) { dss[i] = new DiscountStrategySerializer(strategies[i]); return dss;

10 public class DiscountStrategySerializer : IXmlSerializable {
private IDiscountStrategy strategy; public DiscountStrategySerializer(IDiscountStrategy strategy) { this.strategy = strategy; } public void ReadXml(XmlReader reader) Type type = Type.GetType(reader.GetAttribute("type")); reader.ReadStartElement(); this.strategy = (IDiscountStrategy)new XmlSerializer(type).Deserialize(reader); reader.ReadEndElement(); public void WriteXml(XmlWriter writer) writer.WriteAttributeString("type", strategy.GetType().ToString()); new XmlSerializer(strategy.GetType()).Serialize(writer, strategy);

11 <?xml version="1.0" encoding="utf-8"?>
<DiscountSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <XmlStrategies type="NextGenPOS.Model.Discounts.ItemPriceDiscountStrategy"> <ItemPriceDiscountStrategy> <Description>Bedrag op product</Description> <Product> <ProductID>4</ProductID> <Description>Chef Antons Cajun Seasoning</Description> <Price>22</Price> </Product> <Amount>100</Amount> <Quantity>100</Quantity> </ItemPriceDiscountStrategy> </XmlStrategies> ...

12

13 public class RulesFacade
{ private static RulesFacade instance; private PluggableRules rules; private RulesFacade() rules = new PluggableRules().Deserialize(RulesFacade.RulesFile); } ... public bool IsInvalid(Sale sale) foreach (PaymentTypeRule ptr in rules.Rules) { if (ptr.PaymentType == sale.PaidBy.Type) return ptr.IsInvalid(sale); return false;

14 [System.Xml.Serialization.XmlRoot("PluggableRules")]
public class PluggableRules { private Rule[] rules; public PluggableRules() rules = new Rule[0]; } [System.Xml.Serialization.XmlArray("Rules"), System.Xml.Serialization.XmlArrayItem(typeof(PaymentTypeRule))] public Rule[] Rules get{return rules;} set{rules = value;} public void addRule(Rule r) IList<Rule> ruleList = this.Rules.ToList<Rule>(); ruleList.Add(r); this.Rules = ruleList.ToArray<Rule>();

15 public void Serialize(string path)
{ XmlSerializer serializer = new XmlSerializer(typeof(PluggableRules)); Stream stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.ReadWrite); serializer.Serialize(stream, this); stream.Close(); } public PluggableRules Deserialize(string path) TextReader reader = new StreamReader(path); PluggableRules myRules = (PluggableRules)serializer.Deserialize(reader); reader.Close(); return myRules;

16 <?xml version="1.0"?> <PluggableRules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Rules> <PaymentTypeRule type="NextGenPOS.Model.Rules.PaymentTypeRule"> <MinAmount>0</MinAmount> <MaxAmount>5000</MaxAmount> <PaymentType>Cash</PaymentType> </PaymentTypeRule> <MinAmount>15</MinAmount> <MaxAmount>10000</MaxAmount> <PaymentType>DirectDebit</PaymentType> <MinAmount>50</MinAmount> <MaxAmount>25000</MaxAmount> <PaymentType>CreditCard</PaymentType> </Rules> </PluggableRules>

17 ServiceFactory public class ServiceFactory {
private Hashtable services = new Hashtable(); public ServiceFactory() Add<IAccountingAdapter>(new AccountingAdapter(new AccountingSystemTest())); Add<IInventoryAdapter>(new InventoryAdapter(new InventorySystemTest())); } public void Add<T>(T t) where T : IService services.Add(typeof(T), t); public T GetService<T>() return (T)services[typeof(T)];

18 ServiceFactory public interface IService {}
public interface IAccountingAdapter : IService { /// <summary> /// Verwerkt de boekhoudkundige gegevens voor een sale /// </summary> /// <param name="s"></param> void ReportSale(Sale s); }

19 Model

20 Database Controller public Controller() { string connectionString = server=(local)\\SQLEXPRESS; “ + “database=NEXTGENPOS.MDF;Integrated Security=SSPI"; mySqlConnection = new SqlConnection(connectionString); } // dynamische query opbouwer private DataSet genericSelectQueryFunction(string selectString, string returnSetName) { if (selectString.Equals("") || returnSetName.Equals("")) { return new DataSet(); } SqlCommand mySqlCommand = mySqlConnection.CreateCommand(); mySqlCommand.CommandText = selectString; SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(); mySqlDataAdapter.SelectCommand = mySqlCommand; DataSet myDataSet = new DataSet(); mySqlConnection.Open(); mySqlDataAdapter.Fill(myDataSet, returnSetName); mySqlConnection.Close(); return myDataSet; }

21 public DataSet getProductByName(string name) {
public DataSet getProductByName(string name) { string selectString = "select * from product where description like” + '%" + name + "%'"; return genericSelectQueryFunction(selectString, "product"); }

22 public void saleTransaction(int customerId, DateTime saleDateTime, bool complete,
double amount, int paymentTypeId, int[,] productIdQuantity) { try mySqlConnection.Open(); } catch (Exception ex) Console.WriteLine(ex.Message); SqlTransaction transaction = null; SqlCommand command = new SqlCommand(); int saleId = 0; string insertSaleQueryString = "insert into sale (customer_id,date,complete) values ( “ + customerId + ", '" + saleDateTime + "', '" + complete + "')" + "; select id from sale where id= transaction = mySqlConnection.BeginTransaction(); command.Connection = mySqlConnection; command.CommandText = insertSaleQueryString; command.Transaction = transaction; saleId = (int)command.ExecuteScalar(); if (transaction != null) Console.WriteLine("Transactie rollback"); transaction.Rollback(); mySqlConnection.Close();

23 Datafacade public static DatabaseFacade Instance { get { if (null == instance) instance = new DatabaseFacade(); return instance; } }

24 public IList<Employee> getAllEmployees() {
public IList<Employee> getAllEmployees() { IList<Employee> eList = new List<Employee>(); DataSet employees = control.getAllEmployees(); DataTable myDataTable = employees.Tables["employee"]; foreach (DataRow row in myDataTable.Rows) { Employee emp = new Employee(); emp.EmployeeID = int.Parse(row["id"].ToString()); emp.FirstName = row["firstname"].ToString(); emp.LastName = row["lastname"].ToString(); emp.UserName = row["username"].ToString(); emp.IsManager = row["function_id"]. ToString().TrimEnd().Equals("2"); eList.Add(emp); } return eList; }

25 public Customer getCustomerById(int id) {
public Customer getCustomerById(int id) { DataSet customerDataSet = control.getCustomerById(id); DataTable myDataTable = customerDataSet.Tables["customer"]; if (myDataTable.Rows.Count == 0) { throw new CustomerNotFoundException("Geen klant gevonden met id " + id); } DataRow temp = myDataTable.Rows[0]; return new Customer(int.Parse(temp["id"].ToString()), temp["name"].ToString(), temp["address"].ToString(), temp["city"].ToString(), System.DateTime.Parse(temp["dob"].ToString()); }

26 Stored procedure

27 Kortingen - Strategy

28 Adapters

29 Voorraadbeheersysteem

30 interface IInventoryAdapter
{ bool IsInStock(Product p); //is het item in voorraad? int GetNumberInStock(Product p); //aantal items in voorraad void UpdateStock(Sale s); //werk de stock bij met de //items in de sale } public int GetNumberInStock(Product p) { if (p.Description.Equals("Tofu") || p.Description.Equals("Konbu")) return 0; return ; }

31 Boekhoudsysteem

32 public interface IAccountingAdapter { /// Verwerkt de boekhoudkundige gegevens voor een sale void ReportSale(Sale s); } public class AccountingSystemTest { public void UpdateSales(Sale s) Console.WriteLine("Sale:{0}", s.ToString()); } public void UpdateCommissions(Sale s)

33 Authorization service

34 public interface ICreditAuthorizationAdapter
{ bool isAuthorized(string cardNumber, string customername, double amount); } public class CreditCardAuthorizationServiceTest { public bool isAuthorized(string cardnumber, string customername, double amount) if ((customername.Equals("Antonio Moreno") || customername.Equals("Yang Wang")) && amount > 0) return false; else if ((customername.Equals("Maria Anders") || customername.Equals("Thomas Hardy")) && amount > 1000) return true; }

35 Logger Design Patterns: Chain of Responsibility pattern
Verschillende niveaus (debug/info/fatal) verschillende outputs (console/file/ ) Observer pattern Event logging

36 Observer

37

38 IObservable public interface IObservable {
public interface IObserver { void Notify(object anObject); } public interface IObservable { void Register(IObserver anObserver); void UnRegister(IObserver anObserver);

39 public class ObservableImpl:IObservable {
protected Hashtable _observerContainer=new Hashtable(); public void Register(IObserver anObserver){ _observerContainer.Add(anObserver,anObserver); } public void UnRegister(IObserver anObserver){ _observerContainer.Remove(anObserver); public void NotifyObservers(object anObject) { foreach(IObserver anObserver in _observerContainer.Keys) { anObserver.Notify(anObject);

40 Voorbeeld public IList<SalesLineItem> ItemsPurchased {
get { return itemsPurchased; } set { base.NotifyObservers(itemsPurchased); itemsPurchased = value; }

41 Chain op responsibility

42

43

44 public enum LoggerState
{ FATAL = 1, //Fatale error --> hoogste niveau: stuur een naar de persoon die verantwoordelijke is EXCEPT = 3, //Zware fout --> Exceptions ERROR = 5, = 6, // versturen van een INFO = 7, //Notice (opmerking) : schrijf naar een logbestand OBSERVER = 8, //observer logging DEBUG = 10 //Debugging boodschap: schrijf enkel naar de console } Elk type heeft een waarde (=prioriteit of mask):

45 protected ILogger next;
public ILogger setNext(ILogger l) { next = l; return l; } protected static ILogger l, l3; protected static OBserverLogger l2; static LogManager() { l = new ConsoleLogger(LoggerState.DEBUG); l3 = l.setNext(new LogFileLogger (LoggerState.INFO,"./logs/logFileInfo")); l2 = new OBserverLogger (LoggerState.OBSERVER, "./logs/logFileObserver"); }

46 public void Message(String msg, LoggerState priority)
{ if (priority <= mask) { WriteMessage(msg); } if (next != null) { next.Message(msg, priority); abstract protected void WriteMessage(String msg);

47

48 view Model-view-controller

49 New POSForm() een lijst van de klanten opgehaald een lijst binnengehaald met de gekende producten user met succes is geauthenticeerd, zal er worden nagegaan of deze user admin rechten heeft.

50 Hoe vullen we een component ‘combobox’ met de lijst van onze klanten?
we hebben een klasse Bind de properties id en name de methode override String ToString()

51 Sequence diagram de lijst met klanten, verkregen door de DatabaseFacade omzetten van customer lijst naar een lijst van Bind objecten lijst van bind objecten wordt aan een BindingSource gelinked.

52

53 Sale ticket een ticket geeft een overzicht van sale de producten, subtotalen, kortingen op producten, globale kortingen de velden die in een ticket zijn instelbaar, doormiddel van een XML config bestand Vb. item in xml:

54

55 Sequence diagram: de communicatie tussen het POSForm en de controller, die uiteindelijk met het model Register communiceert

56 Sequence diagram: de communicatie bij aanmaak van een ticket.
Een ticket wordt ingesteld wanneer de methode setFlatList (de lijst van flatLineItems) of setFlatTotal (een flatLineItem) worden aan- geroepen.


Download ppt "NextGenPos Evi Francis Hilde Van Roey Wim Serroyen Ignas Van Tricht"

Verwante presentaties


Ads door Google