Пример #1
0
        public List <TransactionNumber> NumberOfTransactionPurchase()
        {
            try
            {
                PBSDBUtility ABS_IDB = new PBSDBUtility();

                var NumberOfTransaction = new List <TransactionNumber>();

                DataTable dataTable = ABS_IDB.GetDataByProc("sp_GetMonthlyPurchaseAmountAndQuantityForDashboard");
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    TransactionNumber _objNumberOfTrans = new TransactionNumber
                    {
                        MonthName           = dataRow["month"].ToString(),
                        NumberOfTransaction = int.Parse(dataRow["total"].ToString()),
                        TotalAmount         = decimal.Parse(dataRow["totalAmount"].ToString())
                    };
                    NumberOfTransaction.Add(_objNumberOfTrans);
                }
                return(NumberOfTransaction);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #2
0
        public bool SetExport(MNIBDBDataContext ctx)
        {
            //ResetExport();

            if (Product == null)
            {
                // MessageBox.Show("Please elect Product");
                return(false);
            }


            List <ExportDetail> srdetails;

            if (SourceTransaction == "Sales Order")
            {
                if (CurrentHarvester == null && Barcode == null)
                {
                    MessageBox.Show("Please Enter Harvester or Barcode if items already Recieved.");
                    return(false);
                }
                if (CurrentHarvester != null)
                {
                    srdetails = ctx.ExportDetails.Where(x => x.ReceiptNumber.StartsWith(CurrentHarvester.Intials) &&
                                                        x.ReceiptNumber.Contains(Product.ProductId) &&
                                                        x.ReceiptNumber.Contains(ExportDate.ToString("yyyyMMdd"))).ToList();
                }
                else
                {
                    srdetails = ctx.ExportDetails.Where(x => x.ReceiptNumber.Contains(Barcode)).ToList();
                }
            }
            else
            {
                if (string.IsNullOrEmpty(TransactionNumber))
                {
                    // MessageBox.Show("Please Enter ExportNumber");
                    return(false);
                }
                srdetails = ctx.ExportDetails.Where(x => x.ReceiptNumber.Contains(TransactionNumber.ToString()) &&
                                                    x.ReceiptNumber.Contains(Barcode)).ToList();
            }

            //if (sr.ExportId == Export?.ExportId) return true;
            if (srdetails.Any()) //
            {
                // if (!VeifyBoxWeight()) return false;

                //ctx.ExportDetails.Where(x => x.ExportId == sr.ExportId).OrderByDescending(x => x.ExportDetailId).ToList().ForEach(x => ExportDetails.Add(x));

                srdetails.ForEach(x => ExportDetails.Add(x));
                var sr = ctx.Exports.FirstOrDefault(x => x.ExportId == srdetails.First().ExportId);
                Export = sr;
                // TotalWeight = (float) sr.TotalWeight;
                // OnPropertyChanged(nameof(TotalWeight));
                return(true);
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        /// Do this before processing the Client Trigger.
        /// </summary>
        /// <param name="trigger">Trigger message.</param>
        public override void BeforeProcessTrigger(Object trigger)
        {
            // call the base implementation
            base.BeforeProcessTrigger(trigger);

            // get the next transaction number - needed to sort the
            // transactions correctly
            _transactionNumber = TransactionNumber.GetNextTransactionNumber();
        }
Пример #4
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            // Inputs
            var transactionNumber     = TransactionNumber.Get(context);
            var retryNumber           = RetryNumber.Get(context);
            var initRetryNumber       = InitRetryNumber.Get(context);
            var continuousRetryNumber = ContinuousRetryNumber.Get(context);
            var isQueueItem           = IsQueueItem.Get(context);
            var folders          = Folders.Get(context);
            var customParameters = CustomParameters.Get(context);
            var result           = true;

            ///////////////////////////

            // Create SystemReserved entity
            var sysRes = new SystemReserved(transactionNumber, retryNumber, initRetryNumber, continuousRetryNumber, folders, isQueueItem, "", customParameters);

            // If argument has value, check if it was correctly assigned
            if (sysRes.TransactionNumber != transactionNumber)
            {
                result = false;
            }
            if (sysRes.RetryNumber != retryNumber)
            {
                result = false;
            }
            if (sysRes.InitRetryNumber != initRetryNumber)
            {
                result = false;
            }
            if (sysRes.ContinuousRetryNumber != continuousRetryNumber)
            {
                result = false;
            }
            if (sysRes.IsQueueItem != isQueueItem)
            {
                result = false;
            }
            if (folders != null && sysRes.Folders != folders)
            {
                result = false;
            }
            if (customParameters != null && sysRes.CustomParameters != customParameters)
            {
                result = false;
            }

            ///////////////////////////

            // Outputs
            return((ctx) => {
                SystemReserved.Set(ctx, sysRes);
                Result.Set(ctx, result);
            });
        }
Пример #5
0
        public void CalculateNumberTest()
        {
            var localPaymentBasePoint =
                new ECKeyPair("034f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa", false);
            var remotePaymentBasePoint =
                new ECKeyPair("032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991", false);

            ulong obscured = TransactionNumber.CalculateObscured(42, localPaymentBasePoint, remotePaymentBasePoint);
            ulong actual   = TransactionNumber.CalculateNumber(obscured, localPaymentBasePoint, remotePaymentBasePoint);

            Assert.Equal(actual, (ulong)42);
        }
Пример #6
0
        public List <TransactionNumber> NumberOfTransaction()
        {
            try
            {
                PBSDBUtility ABS_IDB = new PBSDBUtility();

                var NumberOfTransaction = new List <TransactionNumber>();

                DataTable dataTable = ABS_IDB.GetDataByProc("sp_GetMonthlySalesAmountAndQuantityForDashboard");
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    //TransactionNumber _objNumberOfTrans = new TransactionNumber
                    //{
                    //    MonthName = dataRow["month"].ToString(),
                    //    NumberOfTransaction = int.Parse(dataRow["total"].ToString()),
                    //    TotalAmount = decimal.Parse(dataRow["totalAmount"].ToString())
                    //};
                    //NumberOfTransaction.Add(_objNumberOfTrans);
                }

                TransactionNumber _objNumberOfTrans = new TransactionNumber
                {
                    MonthName           = "Jan",
                    NumberOfTransaction = 200,
                    TotalAmount         = 2698
                };
                NumberOfTransaction.Add(_objNumberOfTrans);


                _objNumberOfTrans = new TransactionNumber
                {
                    MonthName           = "Feb",
                    NumberOfTransaction = 180,
                    TotalAmount         = 1698
                };
                NumberOfTransaction.Add(_objNumberOfTrans);

                _objNumberOfTrans = new TransactionNumber
                {
                    MonthName           = "Mar",
                    NumberOfTransaction = 210,
                    TotalAmount         = 3698
                };
                NumberOfTransaction.Add(_objNumberOfTrans);

                return(NumberOfTransaction);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #7
0
        public void TransactionNumberTest()
        {
            try
            {
                var field = new TransactionNumber();

                string result, message;
                Assert.IsTrue(field.Check(out result, out message));
            }
            catch (Exception e)
            {
                Assert.Fail(e.ToString());
            }
        }
Пример #8
0
        private void LogTransaction()
        {
            DicomThread dicomThread = (DicomThread)DvtkHighLevelInterface.Common.Threads.Thread.CurrentThread;

            if (dicomThread == null)
            {
                return;
            }

            if (_currentDicomTransaction == null)
            {
                return;
            }

            // get the next transaction number - needed to sort the
            // transactions correctly
            int transactionNumber = TransactionNumber.GetNextTransactionNumber();

            // save the transaction
            ActorsTransaction actorsTransaction = new ActorsTransaction(transactionNumber,
                                                                        ActorName,             // from actor
                                                                        ParentActor.ActorName, // to actor
                                                                        _currentDicomTransaction,
                                                                        dicomThread.Options.ResultsFileNameOnly,
                                                                        dicomThread.Options.ResultsFullFileName,
                                                                        (uint)dicomThread.NrOfErrors,
                                                                        (uint)dicomThread.NrOfWarnings);

            // save the transaction in the Actor log
            ParentActor.ActorsTransactionLog.Add(actorsTransaction);

            // publish the transaction event to any interested parties
            PublishTransactionAvailableEvent(ActorName, actorsTransaction);

            // remove any messages from the dicom thread
            dicomThread.ClearMessages();

            _currentDicomTransaction = null;
        }
Пример #9
0
        private void OnSpendingTransaction(Transaction spendingTx)
        {
            string fundingTxId          = spendingTx.Inputs[0].PrevOut.Hash.ToString();
            uint   fundingTxOutputIndex = spendingTx.Inputs[0].PrevOut.N;
            var    channel = _channelService.Channels.SingleOrDefault(c => c.FundingTransactionId == fundingTxId &&
                                                                      c.FundingOutputIndex == fundingTxOutputIndex);

            if (channel == null)
            {
                return;
            }

            if (spendingTx.Inputs[0].Sequence == 0xFFFFFFFF)
            {
                OnMutualCloseTransaction(channel, spendingTx);
                return;
            }

            var transactionNumber = TransactionNumber.CalculateNumber(spendingTx.Inputs[0].Sequence,
                                                                      channel.LocalCommitmentTxParameters.PaymentBasepoint,
                                                                      channel.RemoteCommitmentTxParameters.PaymentBasepoint);

            if (transactionNumber == channel.RemoteCommitmentTxParameters.TransactionNumber)
            {
                OnCommitmentTransaction(channel, spendingTx);
                return;
            }

            if (transactionNumber < channel.RemoteCommitmentTxParameters.TransactionNumber)
            {
                OnRevokedCommitmentTransaction(channel, spendingTx);
                return;
            }

            if (transactionNumber > channel.RemoteCommitmentTxParameters.TransactionNumber)
            {
                OnNewerCommitmentTransaction(channel, spendingTx);
            }
        }
Пример #10
0
 /// <summary>
 /// Конструктор, заполняющий коллекцию полей Fields
 /// </summary>
 protected MT103(
     TransactionNumber transactionNumber,
     Amount amount,
     BankOperationCode bankOperationCode,
     Sender sender,
     HeadSwiftCode headSwiftCode,
     BranchSwiftCode branchSwiftCode,
     Beneficiary beneficiary,
     PaymentInformation paymentInformation,
     ExpensesDetail expensesDetail,
     SenderToReceiverInformation senderToReceiverInformation)
 {
     Fields.Add(transactionNumber.DefaultOrder, transactionNumber);
     Fields.Add(amount.DefaultOrder, amount);
     Fields.Add(bankOperationCode.DefaultOrder, bankOperationCode);
     Fields.Add(sender.DefaultOrder, sender);
     Fields.Add(headSwiftCode.DefaultOrder, headSwiftCode);
     Fields.Add(branchSwiftCode.DefaultOrder, branchSwiftCode);
     Fields.Add(beneficiary.DefaultOrder, beneficiary);
     Fields.Add(paymentInformation.DefaultOrder, paymentInformation);
     Fields.Add(expensesDetail.DefaultOrder, expensesDetail);
     Fields.Add(senderToReceiverInformation.DefaultOrder, senderToReceiverInformation);
 }
Пример #11
0
        public void PrintTransaction()
        {
            Console.WriteLine("Podaj numer transakcji: ");
            string sTransactionNumber = Console.ReadLine();

            if (Int32.TryParse(sTransactionNumber, out int TransactionNumber) && allTransactions != null)
            {
                bool printed = false;
                foreach (Transaction tr in allTransactions)
                {
                    if (tr.number() == TransactionNumber)
                    {
                        Console.WriteLine("Drukuję potwierdzenie transakcji nr: " + TransactionNumber.ToString());
                        //Console.WriteLine("Transakcja numer: " + tr.number().ToString());
                        Console.WriteLine("Kwota transakcji: " + String.Format("{0:N2}", tr.amount()) + " zł");
                        Console.WriteLine("Data transakcji: " + tr.date());
                        Console.WriteLine("Opis transakcji: " + tr.notes());
                        string fileName    = "PotwierdzenieNr" + TransactionNumber.ToString() + ".txt";
                        string currentPath = System.AppDomain.CurrentDomain.BaseDirectory + "\\Potwierdzenia\\";
                        System.IO.Directory.CreateDirectory(currentPath);
                        System.IO.File.WriteAllText(currentPath + fileName, "Potwierdzenie transakcji z konta numer: " + UserId.ToString());
                        System.IO.File.AppendAllText(currentPath + fileName, "\r\n" + "Transakcja numer: " + tr.number().ToString() + "\r\n" + "Kwota: " + String.Format("{0:N2}", tr.amount()) + " zł" + "\r\n"
                                                     + "Data Transakcji: " + tr.date().ToString() + "\r\n" + tr.notes());
                        printed = true;
                    }
                }
                if (!printed)
                {
                    Console.WriteLine("Błędny numer transackji");
                }
            }
            else
            {
                Console.WriteLine("Błędnie wpisany numer transakcji");
            }
            Console.ReadKey();
        }
Пример #12
0
        public void CalculateLockTimeTest()
        {
            ulong obscured = 0x2bb038521914L ^ 42L;

            Assert.Equal((ulong)542251326, TransactionNumber.CalculateLockTime(obscured));
        }
Пример #13
0
        public void CalculateSequenceTest()
        {
            ulong obscured = 0x2bb038521914L ^ 42L;

            Assert.Equal((ulong)2150346808, TransactionNumber.CalculateSequence(obscured));
        }
Пример #14
0
        private void ProcessTrigger(Hl7Trigger trigger)
        {
            _hl7Mllp = new Hl7Mllp();

            // get the next transaction number - needed to sort the
            // transactions correctly
            int transactionNumber = TransactionNumber.GetNextTransactionNumber();

            System.String message = System.String.Format("HL7 Client thread - connecting to \"{0}\" on port {1}...", _config.ToActorIpAddress, _config.PortNumber);
            _hl7ThreadForHl7Client.LogInformation(message);

            if (_hl7Mllp.Connect(_config.ToActorIpAddress, _config.PortNumber))
            {
                Hl7Message hl7RequestMessage = trigger.Trigger;

                // Set the sending and receiving applications
                hl7RequestMessage.SendingApplication   = _config.FromActorAeTitle;
                hl7RequestMessage.ReceivingApplication = _config.ToActorAeTitle;

                // Add the control id and date/time of message
                hl7RequestMessage.MessageControlId = _messageControlId.ToString();
                _messageControlId++;
                hl7RequestMessage.DateTimeOfMessage = System.DateTime.Now.ToString("yyyyMMddhhmmss", System.Globalization.CultureInfo.InvariantCulture);

                // get initial HL7 message delimiters from the config
                Hl7MessageDelimiters messageDelimiters = _config.MessageDelimiters;

                System.String messageType = hl7RequestMessage.Value(Hl7SegmentEnum.MSH, 9);
                _hl7ThreadForHl7Client.LogInformation(System.String.Format("HL7 Client thread - send message \"{0}\".", messageType));
                _hl7ThreadForHl7Client.LogInformation(hl7RequestMessage.ToString(messageDelimiters));

                if (_hl7Mllp.SendMessage(hl7RequestMessage, messageDelimiters) == true)
                {
                    Hl7Message hl7ResponseMessage = _hl7Mllp.ReceiveMessage(out messageDelimiters);

                    if (hl7ResponseMessage != null)
                    {
                        messageType = hl7ResponseMessage.Value(Hl7SegmentEnum.MSH, 9);
                        _hl7ThreadForHl7Client.LogInformation(System.String.Format("HL7 Client thread - received message \"{0}\".", messageType));
                        _hl7ThreadForHl7Client.LogInformation(hl7ResponseMessage.ToString(messageDelimiters));

                        // Validate the message
                        if (_config.AutoValidate == true)
                        {
                            ValidateMessage(hl7ResponseMessage, messageDelimiters);
                        }

                        // save the transaction
                        Hl7Transaction transaction = new Hl7Transaction(TransactionNameEnum.RAD_1, TransactionDirectionEnum.TransactionSent);
                        transaction.Request  = hl7RequestMessage;
                        transaction.Response = hl7ResponseMessage;

                        ActorsTransaction actorsTransaction = new ActorsTransaction(transactionNumber,
                                                                                    ActorName,             // from actor
                                                                                    ParentActor.ActorName, // to actor
                                                                                    transaction,
                                                                                    _hl7ThreadForHl7Client.Options.ResultsFileNameOnly,
                                                                                    _hl7ThreadForHl7Client.Options.ResultsFullFileName,
                                                                                    (uint)_hl7ThreadForHl7Client.NrErrors,
                                                                                    (uint)_hl7ThreadForHl7Client.NrWarnings);

                        // save the transaction in the Actor log
                        ParentActor.ActorsTransactionLog.Add(actorsTransaction);

                        // publish the transaction event to any interested parties
                        PublishTransactionAvailableEvent(ActorName, actorsTransaction);
                    }
                }

                _hl7Mllp.Stop();

                _hl7ThreadForHl7Client.StopResultsGathering();
                _hl7ThreadForHl7Client.StartResultsGathering();
            }

            if (_awaitCompletion == true)
            {
                _semaphore.Signal();
            }
        }
Пример #15
0
        /// <summary>
        /// Process Hl7 requests and responses.
        /// </summary>
        public void ProcessMessages()
        {
            _hl7Mllp = new Hl7Mllp();

            for (;;)
            {
                System.String message = System.String.Format("Listening for incoming HL7 connection on port {0}...", _config.PortNumber);
                _hl7ThreadForHl7Server.LogInformation(message);

                try
                {
                    // listen for a connection
                    _hl7Mllp.Listen(_config.PortNumber);

                    for (;;)
                    {
                        // accept the connection - only one at a time
                        _hl7Mllp.Accept();

                        // the message delimiters will be filled in by the ReceiveMessage method
                        Hl7MessageDelimiters messageDelimiters = null;

                        // receive an HL7 message
                        Hl7Message hl7RequestMessage = _hl7Mllp.ReceiveMessage(out messageDelimiters);
                        if (hl7RequestMessage != null)
                        {
                            System.String messageType = hl7RequestMessage.Value(Hl7SegmentEnum.MSH, 9);
                            message = System.String.Format("HL7 Server thread - received message \"{0}\".", messageType);
                            _hl7ThreadForHl7Server.LogInformation(message);
                            _hl7ThreadForHl7Server.LogInformation(hl7RequestMessage.ToString(messageDelimiters));

                            // Validate the message
                            if (_config.AutoValidate == true)
                            {
                                ValidateMessage(hl7RequestMessage, messageDelimiters);
                            }

                            // call the message handler to get a response
                            Hl7Message hl7ResponseMessage = MessageHandler(hl7RequestMessage);

                            // copy some fields from the request
                            hl7ResponseMessage.SendingApplication   = hl7RequestMessage.ReceivingApplication;
                            hl7ResponseMessage.SendingFacility      = hl7RequestMessage.ReceivingFacility;
                            hl7ResponseMessage.ReceivingApplication = hl7RequestMessage.SendingApplication;
                            hl7ResponseMessage.ReceivingFacility    = hl7RequestMessage.SendingFacility;
                            hl7ResponseMessage.MessageControlId     = hl7RequestMessage.MessageControlId;

                            // set the date/time of message
                            hl7ResponseMessage.DateTimeOfMessage = System.DateTime.Now.ToString("yyyyMMddhhmmss", System.Globalization.CultureInfo.InvariantCulture);

                            // send the response
                            _hl7Mllp.SendMessage(hl7ResponseMessage, messageDelimiters);

                            messageType = hl7ResponseMessage.Value(Hl7SegmentEnum.MSH, 9);
                            message     = System.String.Format("HL7 Server thread - sent message \"{0}\".", messageType);
                            _hl7ThreadForHl7Server.LogInformation(message);
                            _hl7ThreadForHl7Server.LogInformation(hl7ResponseMessage.ToString(messageDelimiters));

                            // get the next transaction number - needed to sort the
                            // transactions correctly
                            int transactionNumber = TransactionNumber.GetNextTransactionNumber();

                            // save the transaction
                            Hl7Transaction transaction = new Hl7Transaction(TransactionNameEnum.RAD_1, TransactionDirectionEnum.TransactionReceived);
                            transaction.Request  = hl7RequestMessage;
                            transaction.Response = hl7ResponseMessage;

                            _hl7ThreadForHl7Server.LogInformation(String.Format("{0} - received Hl7 event from {1}", ParentActor.ActorName, ActorName));

                            ActorsTransaction actorsTransaction = new ActorsTransaction(transactionNumber,
                                                                                        ActorName,             // from actor
                                                                                        ParentActor.ActorName, // to actor
                                                                                        transaction,
                                                                                        _hl7ThreadForHl7Server.Options.ResultsFileNameOnly,
                                                                                        _hl7ThreadForHl7Server.Options.ResultsFullFileName,
                                                                                        (uint)_hl7ThreadForHl7Server.NrErrors,
                                                                                        (uint)_hl7ThreadForHl7Server.NrWarnings);

                            // save the transaction in the Actor log
                            ParentActor.ActorsTransactionLog.Add(actorsTransaction);

                            // publish the transaction event to any interested parties
                            PublishTransactionAvailableEvent(ActorName, actorsTransaction);
                        }

                        _hl7Mllp.Close();

                        _hl7ThreadForHl7Server.StopResultsGathering();
                        _hl7ThreadForHl7Server.StartResultsGathering();
                    }
                }
                catch
                {
                    // System.Net.Sockets.Socket.Accept() exception thrown when the server is stopped by closing the listen socket.
                    break;
                }
            }
        }