123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617 |
- using System;
- using System.Globalization;
- //using System.Diagnostics;
- //using System.Windows.Forms;
- using Wayne.Lib;
- #if _SINP
- using Wayne.ForecourtControl.Nfs;
- #endif
- namespace Wayne.ForecourtControl.Fusion
- {
- /*internal*/
- public class FUSIONFuelling : IFuellingEx
- {
- // Fields
- private decimal amount;
- private long authorizationId;
- private DateTime completionDateTime;
- private int completionReason;
- private int fuelGrade;
- private int fuellingSequenceNumber;
- private int fuelPeriodId;
- private FUSIONManager manager;
- private int nfsFillingType;
- private FUSIONPump nfsPump;
- private INozzle nozzle;
- private PresetType presetType;
- private decimal presetValue;
- private decimal price;
- private PriceGroup priceGroup;
- private decimal quantity;
- private int reservedBy;
- private int authorizedBy;
- private FuellingState state;
- private FuellingType type;
- private ushort _CRC;
- private string signedReceiptLines;
- private string signedReceiptLinesWide;
- private byte reservingDeviceId;
- //FG, OCT-13-10, Add PayType to show outdoor payment type on FM
- private string payType;
- // used for generating Authorization token; it is ok to have one per workstation
- public static int transactionId = 0;
- // Methods
- internal FUSIONFuelling(FUSIONManager manager, FUSIONPump pump)
- {
- this.manager = manager;
- this.nfsPump = pump;
- this.WritableReservedBy = 0;
- this.WritableAuthorizedBy = 0;
- // JDL, AUG-10-10, default to outdoor card payment
- this.type = FuellingType.OptCardPaid;
- }
- internal void Dispose()
- {
- this.manager = null;
- }
- public void ReserveAsync(EventHandler<AsyncCompletedEventArgs> fuellingReserveCompleted, object userToken)
- {
- // call LockFuelSaleTrx
- // this.WritableReservedBy = this.manager.Id;
- this.manager.ifsfManager.LockFuelSaleTrx(((FUSIONPump)(this.Pump)).realId, this.FuellingSequenceNumber, (int)(this.AuthorizationId), fuellingReserveCompleted, userToken, this);
- }
- private void SendFillingRequest(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken, ushort fid)
- {
- throw new NotImplementedException("SendFillingRequest - TODO");
- }
- public void SetAsPaidAsync(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken)
- {
- // call ClearFuelSaleTrx
- Trace.WriteLine(string.Format("SetAsPaidAsync: fuellingSequenceNumber={0}, State={1}", this.fuellingSequenceNumber, State));
- this.manager.ifsfManager.ClearFuelSaleTrx(((FUSIONPump)(this.Pump)).realId, this.FuellingSequenceNumber, (int)(this.AuthorizationId), null, requestCompleted, userToken, this);
- }
- public void SetAsPaidAsync(string note, EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken)
- {
- // call ClearFuelSaleTrx
- Trace.WriteLine(string.Format("SetAsPaidAsync: fuellingSequenceNumber={0}, State={1}", this.fuellingSequenceNumber, State));
- this.manager.ifsfManager.ClearFuelSaleTrx(((FUSIONPump)(this.Pump)).realId, this.FuellingSequenceNumber, (int)(this.AuthorizationId), note, requestCompleted, userToken, this);
- }
- public override string ToString()
- {
- return this.ToString("", CultureInfo.InvariantCulture);
- }
- public string ToString(IFormatProvider provider)
- {
- return this.ToString("", provider);
- }
- public string ToString(string format)
- {
- return this.ToString(format, CultureInfo.InvariantCulture);
- }
- public string ToString(string format, IFormatProvider provider)
- {
- return ("Fuelling, Pump=" + this.nfsPump.Id.ToString(CultureInfo.InvariantCulture) + " SqN=" + this.fuellingSequenceNumber.ToString(CultureInfo.InvariantCulture) + " AuthId=" + this.authorizationId.ToString(CultureInfo.InvariantCulture));
- }
- public void TransferAsync(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken)
- {
- // does nothing on transfer operation but setting fuelling on state Transferred
- Trace.WriteLine(string.Format("TransferAsync: fuellingSequenceNumber={0}, State={1}", this.fuellingSequenceNumber, State));
- if (this.State != FuellingState.Transferred)
- {
- this.WritableState = FuellingState.Transferred;
- this.nfsPump.FireFuellingStateChange(this, this.WritableState);
- }
- if (requestCompleted != null)
- requestCompleted.BeginInvoke(this, new AsyncCompletedEventArgs(true, userToken), null, null);
- }
- public void UndoTransferAsync(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken)
- {
- // does nothing on undotransfer operation but resetting fuelling on state PayableTransaction
- if (this.State == FuellingState.Transferred)
- this.WritableState = FuellingState.PayableTransaction;
- if (requestCompleted != null)
- requestCompleted.BeginInvoke(this, new AsyncCompletedEventArgs(true, userToken), null, null);
- }
- public void UnreserveAsync(EventHandler<AsyncCompletedEventArgs> requestCompleted, object userToken)
- {
- // call UnlockFuelSaleTrx
- //this.WritableReservedBy = 0;
- this.manager.ifsfManager.UnlockFuelSaleTrx(((FUSIONPump)(this.Pump)).realId, this.FuellingSequenceNumber, (int)(this.AuthorizationId), requestCompleted, userToken, this);
- }
- // Properties
- public decimal Amount
- {
- get
- {
- return this.amount;
- }
- }
- public long AuthorizationId
- {
- get
- {
- return this.authorizationId;
- }
- }
- public DateTime CompletionDateTime
- {
- get
- {
- return this.completionDateTime;
- }
- }
- public int CompletionReason
- {
- get
- {
- return this.completionReason;
- }
- }
- private bool Disposed
- {
- get
- {
- return (this.manager == null);
- }
- }
- public int FuelGrade
- {
- get
- {
- return this.fuelGrade;
- }
- }
- public int FuellingSequenceNumber
- {
- get
- {
- return this.fuellingSequenceNumber;
- }
- }
- public int FuelPeriodId
- {
- get
- {
- return this.fuelPeriodId;
- }
- }
- internal int NfsFillingType
- {
- get
- {
- return this.nfsFillingType;
- }
- set
- {
- this.nfsFillingType = value;
- }
- }
- public INozzle Nozzle
- {
- get
- {
- return this.nozzle;
- }
- }
- public PresetType PresetType
- {
- get
- {
- return this.presetType;
- }
- }
- public decimal PresetValue
- {
- get
- {
- return this.presetValue;
- }
- }
- public decimal Price
- {
- get
- {
- return this.price;
- }
- }
- public int PriceGroup
- {
- get
- {
- return (int)this.priceGroup;
- }
- }
- public IPump Pump
- {
- get
- {
- return this.nfsPump;
- }
- }
- public PumpAccumulatorReading PumpAccumulator
- {
- get
- {
- return null;
- }
- }
- public decimal Quantity
- {
- get
- {
- return this.quantity;
- }
- }
- public int ReservedBy
- {
- get
- {
- return this.reservedBy;
- }
- }
- public int AuthorizedBy
- {
- get
- {
- return this.authorizedBy;
- }
- }
- public FuellingState State
- {
- get
- {
- return this.state;
- }
- }
- public FuellingType Type
- {
- get
- {
- return this.type;
- }
- }
- public ushort CRC
- {
- get
- {
- return this._CRC;
- }
- }
- public string SignedReceiptLines
- {
- get
- {
- return this.signedReceiptLines;
- }
- }
- public string SignedReceiptLinesWide
- {
- get
- {
- return this.signedReceiptLinesWide;
- }
- }
- public byte ReservingDeviceId
- {
- get { return reservingDeviceId; }
- }
- internal decimal WritableAmount
- {
- get
- {
- return this.amount;
- }
- set
- {
- this.amount = value;
- }
- }
- internal long WritableAuthorizationId
- {
- get
- {
- return this.authorizationId;
- }
- set
- {
- this.authorizationId = value;
- }
- }
- internal DateTime WritableCompletionDateTime
- {
- get
- {
- return this.completionDateTime;
- }
- set
- {
- this.completionDateTime = value;
- }
- }
- internal int WritableCompletionReason
- {
- get
- {
- return this.completionReason;
- }
- set
- {
- this.completionReason = value;
- }
- }
- internal int WritableFuelGrade
- {
- get
- {
- return this.fuelGrade;
- }
- set
- {
- this.fuelGrade = value;
- }
- }
- internal int WritableFuellingSequenceNumber
- {
- get
- {
- return this.fuellingSequenceNumber;
- }
- set
- {
- this.fuellingSequenceNumber = value;
- }
- }
- internal int WritableFuelPeriodId
- {
- get
- {
- return this.fuelPeriodId;
- }
- set
- {
- this.fuelPeriodId = value;
- }
- }
- internal INozzle WritableNozzle
- {
- get
- {
- return this.nozzle;
- }
- set
- {
- this.nozzle = value;
- }
- }
- internal PresetType WritablePresetType
- {
- get
- {
- return this.presetType;
- }
- set
- {
- this.presetType = value;
- }
- }
- internal decimal WritablePresetValue
- {
- get
- {
- return this.presetValue;
- }
- set
- {
- this.presetValue = value;
- }
- }
- internal decimal WritablePrice
- {
- get
- {
- return this.price;
- }
- set
- {
- this.price = value;
- }
- }
- internal PriceGroup WritablePriceGroup
- {
- get
- {
- return this.priceGroup;
- }
- set
- {
- this.priceGroup = value;
- }
- }
- internal decimal WritableQuantity
- {
- get
- {
- return this.quantity;
- }
- set
- {
- this.quantity = value;
- }
- }
- internal int WritableReservedBy
- {
- get
- {
- return this.reservedBy;
- }
- set
- {
- this.reservedBy = value;
- }
- }
- internal int WritableAuthorizedBy
- {
- get
- {
- return this.authorizedBy;
- }
- set
- {
- this.authorizedBy = value;
- }
- }
- internal FuellingState WritableState
- {
- get
- {
- return this.state;
- }
- set
- {
- this.state = value;
- }
- }
- internal FuellingType WritableType
- {
- get
- {
- return this.type;
- }
- set
- {
- this.type = value;
- }
- }
- internal ushort WritableCRC
- {
- get
- {
- return this._CRC;
- }
- set
- {
- this._CRC = value;
- }
- }
- internal string WritableSignedReceiptLines
- {
- get
- {
- return this.signedReceiptLines;
- }
- set
- {
- this.signedReceiptLines = value;
- }
- }
- //FG, OCT-13-10, Add PayType to show outdoor payment type on FM
- internal string PayType
- {
- get
- {
- return this.payType;
- }
- set
- {
- this.payType = value;
- }
- }
- internal string WritableSignedReceiptLinesWide
- {
- get
- {
- return this.signedReceiptLinesWide;
- }
- set
- {
- this.signedReceiptLinesWide = value;
- }
- }
- internal byte WritableReservingDeviceId
- {
- get { return reservingDeviceId; }
- set { reservingDeviceId = value; }
- }
- public int convertStatus(int status)
- {
- // TODO
- return status;
- }
- #region IFuelling Members
- public byte PriceRevision
- {
- get { return 0; }
- }
- #endregion
- }
- }
|