Exemple #1
0
        public void PropertyGetFetch_TransferType()
        {
            TransferOption      oOptions      = new TransferOption();
            const TransferTypes expectedValue = TransferTypes.Unsupervised;

            oOptions.TransferType = expectedValue;
            Assert.IsTrue(oOptions.ChangeList.ValueExists("TransferType", (int)expectedValue), "TransferType value get fetch failed");
        }
        public void PropertyGetFetch_TransferType()
        {
            MenuEntry           oMenuEntry    = new MenuEntry();
            const TransferTypes expectedValue = TransferTypes.Supervised;

            oMenuEntry.TransferType = expectedValue;
            Assert.IsTrue(oMenuEntry.ChangeList.ValueExists("TransferType", (int)expectedValue), "TransferType value get fetch failed");
        }
Exemple #3
0
 /// <summary>
 /// Returns Transfer
 /// </summary>
 public static Transfer Get(int id, TransferTypes type)
 {
     Type transferType = TransferFactory.GetTransferType(type);
     using (ISession session = Settings.SessionFactory.OpenSession())
     {
         return (Transfer)session.Load(transferType, id);
     }
 }
Exemple #4
0
        public void PropertyGetFetch_TransferType()
        {
            Contact             oContact      = new Contact();
            const TransferTypes expectedValue = TransferTypes.Supervised;

            oContact.TransferType = expectedValue;
            Assert.IsTrue(oContact.ChangeList.ValueExists("TransferType", (int)expectedValue), "TransferType value get fetch failed");
        }
Exemple #5
0
        public void InitiateTransfer(ICall call, TransferTypes transferType, string address)
        {
            // Here, we're only supporting one transfer type. In a real implementation,
            // that flag would indicate the type of transfer that should be performed.

            SwitchClient.Request(new InteractionTransferMessage {
                InteractionId = new Guid(call.Id),
                TargetAddress = address,
            });
        }
Exemple #6
0
        public Manager(AppLogger appLogger)
        {
            _logger = appLogger.Logger;

            SourceDatabase = new DatabaseFacade
            {
                DataSource = "localhost"
            };

            TransferType = TransferTypes.SchemaAndData;
        }
 public static string GetTransferTypeDescription(TransferTypes type)
 {
     if (type == TransferTypes.STORETOSTORE)
     {
         return("SHOP TO SHOP");
     }
     else if (type == TransferTypes.JORET)
     {
         return("REFURB");
     }
     return(type.ToString());
 }
Exemple #8
0
 public static Type GetTransferType(TransferTypes type)
 {
     switch (type)
     {
         case TransferTypes.Single:
             return typeof(SingleTransfer);
         case TransferTypes.Periodical:
             return typeof(PeriodicalTransfer);
         case TransferTypes.Percentage:
             return typeof(PercentageTransfer);
         default:
             throw new NotSupportedException("Transfer Type is not supported");
     }
 }
        internal FuelReportDetail(
            long id,
            long fuelReportId,
            double rob,
            string robUOM,
            double consumption,
            double? receive,
            ReceiveTypes? receiveType,
            double? transfer,
            TransferTypes? transferType,
            double? correction,
            CorrectionTypes? correctionType,
            decimal? correctionPrice,
            string correctionPriceCurrencyISOCode,
            long? correctionPriceCurrencyId,
            long fuelTypeId,
            long measuringUnitId,
            long tankId)
            : this()
        {
            //Id = id;
            FuelReportId = fuelReportId;

            //No validation performed due to unavailability of such validation.
            Consumption = consumption;
            Correction = correction;
            CorrectionPrice = correctionPrice;
            CorrectionPriceCurrencyISOCode = correctionPriceCurrencyISOCode;
            CorrectionType = correctionType;
            Receive = receive;
            ROB = rob;
            ROBUOM = robUOM;
            Transfer = transfer;
            ReceiveType = receiveType;
            TransferType = transferType;
            CorrectionPriceCurrencyId = correctionPriceCurrencyId;
            GoodId = fuelTypeId;
            MeasuringUnitId = measuringUnitId;
            TankId = tankId;
        }
Exemple #10
0
        public void RequestToSendFeatureReport(byte[] commands)
        {
            _transferType       = TransferTypes.Control;
            _transferInProgress = true;
            //  If the device hasn't been detected, was removed, or timed out on a previous attempt
            //  to access it, look for the device.

            if (!_deviceHandleObtained)
            {
                _deviceHandleObtained = FindTheHid();
            }

            if (_deviceHandleObtained)
            {
                if ((_myHid.Capabilities.FeatureReportByteLength > 0))
                {
                    //  The HID has a Feature report.
                    //  Set the size of the Feature report buffer.

                    var outFeatureReportBuffer = new Byte[_myHid.Capabilities.FeatureReportByteLength];
                    //  Store the report ID in the buffer.
                    outFeatureReportBuffer[0] = 0;

                    TransferCommandsToBuffer(outFeatureReportBuffer, commands);
                    //  Store the report data following the report ID.
                    //  Use the data in the combo boxes on the form.
                    //  Write a report to the device

                    Boolean success = _myHid.SendFeatureReport(_hidHandle, outFeatureReportBuffer);

                    if (!success)
                    {
                        CloseCommunications();
                    }
                }
            }
            _transferInProgress = false;
        }
Exemple #11
0
 public void CancelTransfer(ICall originalCall, ICall targetCall, TransferTypes transferType)
 {
 }
Exemple #12
0
		/// <summary>
		/// Request to get an Input report retrieved using interrupt transfers.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// 
		private void cmdGetInputReportInterrupt_Click(object sender, EventArgs e)
		{
			try
			{
				if (_transferInProgress)
				{
					DisplayTransferInProgressMessage();
				}
				else
				{
					//  Don't allow another transfer request until this one completes.
					//  Move the focus away from the button to prevent the focus from 
					//  switching to the next control in the tab order on disabling the button.

					fraInterruptTransfers.Focus();
					cmdGetInputReportInterrupt.Enabled = false;
					_transferType = TransferTypes.Interrupt;
					RequestToGetInputReport();
				}
			}
			catch (Exception ex)
			{
				DisplayException(Name, ex);
				throw;
			}
		}
Exemple #13
0
 public bool SetType(TransferTypes type)
 {
     Connect();
     return (new TypeRequest(type)).Execute(ref _socket).Success;
 }
 //===================================================================================
 /// <summary>
 ///     BR_FR6
 /// </summary>
 private void validateTransferType(double? transfer, TransferTypes? transferType)
 {
     //This business rule must be checked for non EndOfVoyage, EndOfMonth, EndOfYear FuelReports.
     if (FuelReport.FuelReportType != FuelReportTypes.EndOfVoyage &&
         FuelReport.FuelReportType != FuelReportTypes.EndOfMonth &&
         FuelReport.FuelReportType != FuelReportTypes.EndOfYear)
     {
         //fuelReportDetail.Transfer > 0 : will be checked in BR_FR8
         if (transfer.HasValue &&
             !(
                 transferType.HasValue &&
                 Enum.IsDefined(typeof(TransferTypes), transferType.Value)
             )
         )
             throw new BusinessRuleException("BR_FR6", string.Format("The TransferType for '{0}' is not specified.", this.Good.Code));
     }
 }
Exemple #15
0
		/// <summary>
		/// Start doing periodic transfers.
		/// </summary>

		private void PeriodicTransfersStart()
		{
			// Don't allow changing the transfer type while transfers are in progress.

			if (radFeature.Checked)
			{
				radInputOutputControl.Enabled = false;
				radInputOutputInterrupt.Enabled = false;
			}
			else if (radInputOutputControl.Checked)
			{
				radFeature.Enabled = false;
				radInputOutputInterrupt.Enabled = false;
			}
			else if (radInputOutputInterrupt.Checked)
			{
				radFeature.Enabled = false;
				radInputOutputControl.Enabled = false;
			}

			//  Change the command button's text.

			cmdPeriodicTransfers.Text = "Stop";

			//  Enable the timer event to trigger a set of transfers.

			_periodicTransfers.Start();

			cmdPeriodicTransfers.Enabled = true;

			if (radInputOutputInterrupt.Checked)
			{
				_transferType = TransferTypes.Interrupt;
				_reportType = ReportTypes.Output;
			}
			else if (radInputOutputControl.Checked)
			{
				_transferType = TransferTypes.Control;
				_reportType = ReportTypes.Output;
			}
			else if (radFeature.Checked)
			{
				_transferType = TransferTypes.Control;
				_reportType = ReportTypes.Feature;
			}
			_periodicTransfersRequested = true;
			PeriodicTransfers();
		}
Exemple #16
0
 public static string GetTransferTypeDisplayName(TransferTypes transferType)
 {
     return(transferType.GetAttribute <DisplayAttribute>()?.Name ?? transferType.ToString());
 }
        private void validateValues(
            double rob,
            double consumption,
            double? receive,
            ReceiveTypes? receiveType,
            double? transfer,
            TransferTypes? transferType,
            double? correction,
            CorrectionTypes? correctionType,
            decimal? correctionPrice,
            long? correctionPriceCurrencyId,
            //ReferenceType? transferReferenceType,
            //long? transferReferenceEntityId,
            //ReferenceType? receiveReferenceType,
            //long? receiveReferenceEntityId,
            //ReferenceType? correctionReferenceType,
            //long? correctionReferenceEntityId,
            Reference transferReference,
            Reference receiveReference,
            Reference correctionReference,
            FuelReportDetail relevantFuelReportDetailOfTheDayBefore,
            bool isDetailOfFirstFuelReport,
            ICurrencyDomainService currencyDomainService)
        {
            refineValues(ref rob, ref consumption, ref receive, ref receiveType, ref transfer, ref transferType, ref correction, ref correctionType, ref correctionPrice, ref correctionPriceCurrencyId, ref transferReference, ref receiveReference, ref correctionReference);

            //BR_FR3
            validateConsumptionAndROBAvailability(consumption, rob);

            //BR_FR4
            validateNotNegativeConsumptionAndROB(consumption, rob);

            //BR_FR5
            validateReceiveType(receive, receiveType);

            //BR_FR6
            validateTransferType(transfer, transferType);

            //BR_FR7
            validateCorrectionType(correction, correctionType, correctionPriceCurrencyId,
                                                         correctionPrice, currencyDomainService);

            //validatePositiveCorrectionTypeCurrencyAndPriceValues(correction, correctionType, correctionPriceCurrencyId,
            //                                             correctionPrice, currencyDomainService);

            //BR_FR8
            validateNotNegativeReceiveTransferCorrection(receive, transfer, correction);

            //BR_FR9
            //This is already implemented via BR_FR5, BR_FR6, BR_FR7.

            //BR_FR34
            validateValuesForEndOfVoyageEndOfMonthEndOfYearFuelReport(
                rob,
                consumption,
                receive,
                receiveType,
                transfer,
                transferType,
                correction,
                correctionType,
                correctionPrice,
                correctionPriceCurrencyId);

            if (relevantFuelReportDetailOfTheDayBefore == null)
            {
                if (isDetailOfFirstFuelReport)
                {
                    //NOTE: No need to validate ROB for Details of the First Fuel Report in the system.
                }
                else
                {
                    //NOTE: The Detail of Yesterday Fuel Report is not found.
                    throw new ObjectNotFound(string.Format("RelevantFuelReportDetailOfTheDayBefore for '{0}'", this.Good.Code));
                }
            }
            else
            {
                //The Detail for Yesterday Report has been found.
                double? robOfTheDayBefore = relevantFuelReportDetailOfTheDayBefore.ROB;
                //double? receiveOfTheDayBefore = relevantFuelReportDetailOfTheDayBefore.Receive;
                //double? correctionOfTheDayBefore = relevantFuelReportDetailOfTheDayBefore.Correction;
                //CorrectionTypes? correctionTypeOfTheDayBefore = relevantFuelReportDetailOfTheDayBefore.CorrectionType;
                //double? transferOfTheDayBefore = relevantFuelReportDetailOfTheDayBefore.Transfer;

                //BR_FR10
                validateROB(
                    rob,
                    consumption,
                    receive,
                    correction,
                    correctionType,
                    transfer,
                    robOfTheDayBefore);
            }
        }
Exemple #18
0
 public void CompleteTransfer(ICall originalCall, ICall targetCall, TransferTypes transferType)
 {
 }
 public ApiTransferType GetTransferType(int id)
 {
     return(TransferTypes.Where(x => x.Id == id).FirstOrDefault());
 }
        private static void refineValues(ref double rob, ref double consumption, ref double? receive, ref ReceiveTypes? receiveType, ref double? transfer, ref TransferTypes? transferType, ref double? correction, ref CorrectionTypes? correctionType, ref decimal? correctionPrice, ref long? correctionPriceCurrencyId, ref Reference transferReference, ref Reference receiveReference, ref Reference correctionReference)
        {
            //Values refinement.
            //rob = !rob.HasValue || rob == 0 ? null : rob;
            //consumption = !consumption.HasValue || consumption == 0 ? null : consumption;
            receive = !receive.HasValue || receive == 0 ? null : receive;
            transfer = !transfer.HasValue || transfer == 0 ? null : transfer;
            correction = !correction.HasValue || correction == 0 ? null : correction;
            correctionPrice = !correctionPrice.HasValue || correctionPrice == 0 ? null : correctionPrice;
            correctionPriceCurrencyId = !correctionPriceCurrencyId.HasValue || correctionPriceCurrencyId == 0 ? null : correctionPriceCurrencyId;

            if (!receive.HasValue)
            {
                receiveType = null;
                receiveReference = Reference.Empty;
            }

            if (!transfer.HasValue)
            {
                transferType = null;
                transferReference = Reference.Empty;
            }

            if (!correction.HasValue)
            {
                correctionType = null;
                correctionPrice = null;
                correctionPriceCurrencyId = null;
                correctionReference = Reference.Empty;
            }
        }
		/// <summary>
		/// Request to send an Output report using a control transfer.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		/// 
		private void cmdSendOutputReportControl_Click(object sender, EventArgs e)
		{
			try
			{
				if (_transferInProgress)
				{
					DisplayTransferInProgressMessage();
				}
				else
				{
					//  Don't allow another transfer request until this one completes.
					//  Move the focus away from the button to prevent the focus from 
					//  switching to the next control in the tab order on disabling the button.

					_transferType = TransferTypes.Control;
					RequestToSendOutputReport();
				}
			}
			catch (Exception ex)
			{
				DisplayException(Name, ex);
				throw;
			}
		}
Exemple #22
0
        //===================================================================================
        public FuelReportDetail UpdateFuelReportDetail(
            long fuelReportDetailId,
            double rob,
            double consumption,
            double? receive,
            ReceiveTypes? receiveType,
            double? transfer,
            TransferTypes? transferType,
            double? correction,
            CorrectionTypes? correctionType,
            decimal? correctionPrice,
            long? currencyId,
            Reference transferReference,
            Reference receiveReference,
            Reference correctionReference,
            IFuelReportDomainService fuelReportDomainService,
            ICurrencyDomainService currencyDomainService)
        {
            this.CheckToBeOperational();

            //BR_FR1
            validateToBeOpenOrSubmitRejected();

            FuelReportDetail updatingFuelReportDetail = FuelReportDetails.FirstOrDefault(c => c.Id == fuelReportDetailId);

            if (updatingFuelReportDetail == null) throw new ObjectNotFound("FuelReportDetail", fuelReportDetailId);

            validatePreviousFuelReportsToBeFinalApproved(fuelReportDomainService);

            //IOrderedEnumerable<FuelReport> fuelReportsOfYesterday =
            //    fuelReportDomainService
            //        .GetYesterdayFuelReports(this)
            //            .OrderBy(fr => fr.ReportDate);//The ordering is used to find the last report in previous day.

            //FuelReport previousFuelReport = null;

            //bool isTheFirstReport = false;

            //if (fuelReportsOfYesterday.Count() == 0)
            //{
            //    //If nothing found for previous day...

            //    isTheFirstReport = isCurrentFuelReportTheFirstOne(fuelReportDomainService);
            //}
            //else
            //{
            //    //Retrieve the last Fuel Report of yesterday.
            //    previousFuelReport = fuelReportsOfYesterday.LastOrDefault();
            //}

            //FuelReportDetail fuelReportDetailOfYesterdayForRelevantGood = null;

            //if (!isTheFirstReport)
            //{
            //    //TODO: The validation of fuel types against Yesterday valid fuel types must be revised.
            //    fuelReportDetailOfYesterdayForRelevantGood =
            //        previousFuelReport.FuelReportDetails.FirstOrDefault(c => c.GoodId == updatingFuelReportDetail.GoodId);

            //    if (fuelReportDetailOfYesterdayForRelevantGood == null)
            //        //Because current Fuel Report is not the first one,
            //        //its relevant Fuel Report Detail of yesterday must be found.
            //        throw new ObjectNotFound("FuelReportDetailOfYesterdayForRelevantGood");
            //}

            bool isTheFirstReport = isCurrentFuelReportTheFirstOne(fuelReportDomainService);

            FuelReport previousFuelReport = getYesterdayLastFuelReport(fuelReportDomainService);

            validateFuelReportOfTheDayBefore(previousFuelReport, isTheFirstReport);

            FuelReportDetail fuelReportDetailOfYesterdayForRelevantGood =
                getGoodRelevantFuelReportDetailOfYesterday(
                    updatingFuelReportDetail.GoodId,
                    isTheFirstReport,
                    previousFuelReport);

            if (this.State == States.Open)
            {
                updatingFuelReportDetail.Update(rob, consumption, receive, receiveType, transfer, transferType,
                                                correction, correctionType, correctionPrice, currencyId,
                                                transferReference,
                                                receiveReference,
                                                correctionReference,
                                                fuelReportDetailOfYesterdayForRelevantGood,
                                                isTheFirstReport,
                                                currencyDomainService);
            }
            else if (this.State == States.SubmitRejected)
            {
                updatingFuelReportDetail.Update(rob, consumption, fuelReportDetailOfYesterdayForRelevantGood, isTheFirstReport, currencyDomainService);
            }
            else
            {
                throw new InvalidOperation("UpdateFuelReportDetail", "The Fuel Report is in an invalid state.");
            }

            return updatingFuelReportDetail;
        }
        //================================================================================
        public FuelReportDetail UpdateFuelReportDetail(
            long fuelReportId,
            long fuelReportDetailId,
            double rob,
            double consumption,
            double? receive,
            ReceiveTypes? receiveType,
            double? transfer,
            TransferTypes? transferType,
            double? correction,
            CorrectionTypes? correctionType,
            decimal? correctionPrice,
            long? currencyId,
            Reference transferReference,
            Reference receiveReference,
            Reference correctionReference)
        {
            var currentFuelReport = GetById(fuelReportId);

            var result = currentFuelReport.UpdateFuelReportDetail(
                fuelReportDetailId,
                rob,
                consumption,
                receive,
                receiveType,
                transfer,
                transferType,
                correction,
                correctionType,
                correctionPrice,
                currencyId,
                transferReference,
                receiveReference,
                correctionReference,
                fuelReportDomainService,
                currencyDomainService);

            try
            {
                this.unitOfWorkScope.Commit();
            }
            catch (OptimisticConcurrencyException ex)
            {
                throw new ConcurencyException("UpdateFuelReportDetail");
            }
            //            catch (Exception ex)
            //            {
            //                throw new UnHandleException(ex);
            //            }

            return result;
        }
        public FuelReportDetail CreateFuelReportDetail(long fuelReportId,
            double rob,
            string robUOM,
            double consumption,
            double? receive,
            ReceiveTypes? receiveType,
            double? transfer,
            TransferTypes? transferType,
            double? correction,
            CorrectionTypes? correctionType,
            decimal? correctionPrice,
            string correctionPriceCurrencyISOCode,
            long? correctionPriceCurrencyId,
            long fuelTypeId,
            long measuringUnitId,
            long tankId)
        {
            var fuelReportDetail = new FuelReportDetail(
                0,
                fuelReportId,
                rob,
                robUOM,
                consumption,
                receive,
                receiveType,
                transfer,
                transferType,
                correction,
                correctionType,
                correctionPrice,
                correctionPriceCurrencyISOCode,
                correctionPriceCurrencyId,
                fuelTypeId,
                measuringUnitId,
                tankId);

            return fuelReportDetail;
        }
 //===================================================================================
 /// <summary>
 /// BR_FR34
 /// </summary>
 private void validateValuesForEndOfVoyageEndOfMonthEndOfYearFuelReport(
     double? rob,
     double? consumption,
     double? receive,
     ReceiveTypes? receiveType,
     double? transfer,
     TransferTypes? transferType,
     double? correction,
     CorrectionTypes? correctionType,
     decimal? correctionPrice,
     long? correctionPriceCurrencyId)
 {
     if (FuelReport.FuelReportType == FuelReportTypes.EndOfVoyage ||
         FuelReport.FuelReportType == FuelReportTypes.EndOfMonth ||
         FuelReport.FuelReportType == FuelReportTypes.EndOfYear)
     {
         if (!rob.HasValue ||
             !consumption.HasValue ||
             receive.HasValue ||
             receiveType.HasValue ||
             transfer.HasValue ||
             transferType.HasValue ||
             correction.HasValue ||
             correctionType.HasValue ||
             correctionPrice.HasValue ||
             correctionPriceCurrencyId.HasValue)
         {
             throw new BusinessRuleException("BR_FR34",
                                             string.Format("BR_FR34 : Values assignment for '{0}' is invalid against EndOfVoyage, EndOfMonth or EndOfYear Fuel Report.", this.Good.Code));
         }
     }
 }
        internal void Update(
            double rob,
            double consumption,
            double? receive,
            ReceiveTypes? receiveType,
            double? transfer,
            TransferTypes? transferType,
            double? correction,
            CorrectionTypes? correctionType,
            decimal? correctionPrice,
            long? correctionPriceCurrencyId,
            Reference transferReference,
            Reference receiveReference,
            Reference correctionReference,
            FuelReportDetail relevantFuelReportDetailOfTheDayBefore,
            bool isDetailOfFirstFuelReport,
            ICurrencyDomainService currencyDomainService)
        {
            validateValues(rob, consumption, receive, receiveType, transfer, transferType, correction, correctionType,
                correctionPrice, correctionPriceCurrencyId,
                transferReference,
                receiveReference,
                correctionReference,
                relevantFuelReportDetailOfTheDayBefore, isDetailOfFirstFuelReport, currencyDomainService);

            refineValues(ref rob, ref consumption, ref receive, ref receiveType, ref transfer, ref transferType, ref correction, ref correctionType, ref correctionPrice, ref correctionPriceCurrencyId, ref transferReference, ref receiveReference, ref correctionReference);

            ROB = rob;
            Consumption = consumption;
            Receive = receive;
            ReceiveType = receiveType;
            Transfer = transfer;
            TransferType = transferType;
            Correction = correction;
            CorrectionPrice = correctionPrice;
            CorrectionType = correctionType;
            CorrectionPriceCurrencyId = correctionPriceCurrencyId;

            TransferReference = transferReference;
            ReceiveReference = receiveReference;
            CorrectionReference = correctionReference;
        }