protected override OperationInformation GetOperationInformationForCashWithdrawal(int idUserGroup, string label, string labelWork, string operationMethodKeyword)
        {
            string placeLabel     = string.Empty;
            string placeKeyword   = string.Empty;
            string operationLabel = string.Empty;

            //recherche dans operation_detail le mot clef du lieu
            var operationDetail = _referentialService.OperationDetailService.FindKeywordPlace(idUserGroup, labelWork);

            if (operationDetail != null)
            {
                placeLabel   = operationDetail.GMapAddress.gMapLocality.Label;
                placeKeyword = operationDetail.KeywordPlace;
            }

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = "RETRAIT DAB",
                OperationKeyword = operationMethodKeyword,
                PlaceLabel       = placeLabel,
                PlaceKeyword     = placeKeyword
            };

            return(operationInformation);
        }
        protected override OperationInformation GetOperationInformationForFrais(string label, string labelWork, string operationMethodKeyword)
        {
            //rechercher libellé apres mot clef frais
            int    index          = labelWork.IndexOf(operationMethodKeyword) + operationMethodKeyword.Length;
            string operationLabel = labelWork.Substring(index);

            operationLabel = operationLabel.Trim();

            //Arret du label dès le 1er chiffre
            int indexPlace = -1;

            for (int i = 0; i < operationLabel.Length; i++)
            {
                char c = Convert.ToChar(operationLabel.Substring(i, 1));
                if (Char.IsNumber(c))
                {
                    operationLabel = operationLabel.Substring(0, i);
                    indexPlace     = i;
                    break;
                }
            }

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = FileHelper.GetOperationLabelFromOperationLabelWork(label, operationLabel),
                OperationKeyword = $"{operationMethodKeyword}{operationLabel}"
            };

            return(operationInformation);
        }
        protected override OperationInformation GetOperationInformationForCardPayment(int idUserGroup, string label, string labelWork, string operationMethodKeyword)
        {
            string placeLabel   = string.Empty;
            string placeKeyword = string.Empty;
            //string operationLabel = string.Empty;

            //recherche position de 'paiement par carte' et enlever la date devant (format ddMM)
            int    idx            = labelWork.IndexOf(operationMethodKeyword) - 4;
            string operationLabel = labelWork.Substring(0, idx);

            operationLabel = FileHelper.ExcludeNumbers(operationLabel);

            var labelOperation = string.Empty;
            //recherche dans operation_detail le mot clef du lieu
            var operationDetail = _referentialService.OperationDetailService.FindKeywordPlace(idUserGroup, operationLabel);

            if (operationDetail != null)
            {
                placeLabel   = operationDetail.GMapAddress.gMapLocality.Label;
                placeKeyword = operationDetail.KeywordPlace;
                //on enleve tout apres le mot clef de la localisation
                idx            = operationLabel.IndexOf(operationDetail.KeywordPlace);
                operationLabel = operationLabel.Substring(0, idx).ToUpper();
            }

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = FileHelper.GetOperationLabelFromOperationLabelWork(label, operationLabel),
                OperationKeyword = operationLabel,// FileHelper.ExcludeForbiddenChars(operationLabel.Replace(" ", "").ToUpper()),
                PlaceLabel       = placeLabel,
                PlaceKeyword     = placeKeyword
            };

            return(operationInformation);
        }
        protected override OperationInformation GetOperationInformationForPrelevement(string label, string labelWork, string operationMethodKeyword)
        {
            //rechercher libellé apres mot clef prelevement
            var    index          = labelWork.IndexOf(operationMethodKeyword);
            string operationLabel = labelWork.Substring(index + operationMethodKeyword.Length);

            //fin du label est au 1er chiffre trouvé
            for (int i = 0; i < operationLabel.Length; i++)
            {
                char c = Convert.ToChar(operationLabel.Substring(i, 1));
                if (Char.IsNumber(c))
                {
                    operationLabel = operationLabel.Substring(0, i);
                    break;
                }
            }

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = FileHelper.GetOperationLabelFromOperationLabelWork(label, operationLabel),
                OperationKeyword = $"{operationMethodKeyword}{operationLabel}"
            };

            return(operationInformation);
        }
        // >>
        public void OrderModified(string symbol, int operationID, int orderTicket, int orderNewTicket, bool operationResult, string operationResultMessage)
        {
            TracerHelper.Trace(symbol);
            try
            {
                OperationInformation operation = base.GetOperationById(operationID);

                if (operation != null)
                {
                    ModifyOrderResponseMessage message;
                    lock (this)
                    {
                        message = new ModifyOrderResponseMessage(_accountInfo, orderTicket.ToString(), orderNewTicket.ToString(), operationResult);
                        message.OperationResultMessage = operationResultMessage;
                    }

                    base.CompleteOperation(operationID, message);
                }

                lock (this)
                {
                    _pendingOrdersInformations.Add(orderTicket.ToString());
                }
            }
            catch (Exception ex)
            {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the
                // entire package (MT4 included) down with a bad error.
                SystemMonitor.Error(ex.Message);
            }
        }
Ejemplo n.º 6
0
        public string MainControls(OperationInformation operationInformation)
        {
            _OperationInformation = operationInformation;
            if (!InTheMap(_OperationInformation.FirstLocationX, _OperationInformation.FirstLocationY))
            {
                return("First location is NOT valid !!!");
            }

            RobotStatus robotStatus = new RobotStatus
            {
                CurrentLocationX = _OperationInformation.FirstLocationX,
                CurrentLocationY = _OperationInformation.FirstLocationY,
                CurrentDirection = _OperationInformation.FirstDirection
            };
            int step = 0;

            foreach (char operation in _OperationInformation.MovementDirectives)
            {
                step++;
                robotStatus = NextMove(operation, robotStatus);
                if (robotStatus == null)
                {
                    return(string.Format("{0}. step operation invalid !!!", step));
                }
            }


            return(string.Format("{0} {1} {2}", robotStatus.CurrentLocationX, robotStatus.CurrentLocationY, robotStatus.CurrentDirection));
        }
Ejemplo n.º 7
0
            internal void AddToInfoEntry(string operationNumber, string vehicleName)
            {
                OperationInformation oi = GetInfoEntry(operationNumber, true);

                oi.AddVehicleName(vehicleName);

                Save();
            }
Ejemplo n.º 8
0
            internal void RemoveFromInfoEntry(string operationNumber, string vehicleName)
            {
                OperationInformation oi = GetInfoEntry(operationNumber, true);

                oi.RemoveVehicleName(vehicleName);

                Save();
            }
        protected override OperationInformation GetOperationInformationForEmissionCheque(string label, string labelWork, string operationMethodKeyword)
        {
            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = "EMISSION CHEQUE",
                OperationKeyword = operationMethodKeyword
            };

            return(operationInformation);
        }
        protected override OperationInformation GetOperationInformationForEmissionCheque(string label, string labelWork, string operationMethodKeyword)
        {
            //TODO (pas d'exemples)

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel = "EMISSION CHEQUE"
            };

            return(operationInformation);
        }
        // >>
        public void OrderClosed(string symbol, int operationID, int orderTicket, int orderNewTicket, decimal closingPrice, int orderCloseTime, bool operationResult, string operationResultMessage)
        {
            TracerHelper.Trace(symbol);

            try
            {
                OperationInformation operation = base.GetOperationById(operationID);

                string orderNewTicketString = orderNewTicket.ToString();
                if (orderNewTicket < 1)
                {// Anything below 1 (0, -1 etc) is considered empty.
                    orderNewTicketString = string.Empty;
                }

                DateTime?closeTime = GeneralHelper.GenerateDateTimeSecondsFrom1970(orderCloseTime);

                if (closeTime.HasValue == false)
                {
                    if (operation != null)
                    {
                        base.CompleteOperation(operationID, new ResponseMessage(false, "Failed to convert order close time."));
                    }
                    SystemMonitor.Error("Failed to convert order close time.");
                    return;
                }

                if (operation != null)
                {
                    CloseOrderVolumeResponseMessage message;
                    lock (this)
                    {
                        message = new CloseOrderVolumeResponseMessage(_accountInfo, orderTicket.ToString(), orderNewTicketString, closingPrice, closeTime.Value, operationResult);
                        message.OperationResultMessage = operationResultMessage;
                    }

                    base.CompleteOperation(operationID, message);
                }
                else
                {
                    SystemMonitor.Error("Failed to finish order close operation as expected.");
                }

                // Do an update of this order.
                lock (this)
                {
                    _pendingOrdersInformations.Add(orderTicket.ToString());
                }
            }
            catch (Exception ex)
            {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the
                // entire package (MT4 included) down with a bad error.
                SystemMonitor.Error(ex.Message);
            }
        }
        protected override OperationInformation GetOperationInformationForFrais(string label, string labelWork, string operationMethodKeyword)
        {
            string operationLabel = string.Empty;

            //TODO (pas d'exemples)

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = FileHelper.GetOperationLabelFromOperationLabelWork(label, operationLabel),
                OperationKeyword = operationLabel // FileHelper.ExcludeForbiddenChars(operationLabel.Replace(" ", "").ToUpper())
            };

            return(operationInformation);
        }
        protected override OperationInformation GetOperationInformationForCashWithdrawal(int idUser, string label, string labelWork, string operationMethodKeyword)
        {
            //  Le lieu est du debut jusqu'au mot clef
            //  lieu est a mettre dans place
            var index          = labelWork.IndexOf(operationMethodKeyword);
            var operationPlace = labelWork.Substring(0, index);

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = "RETRAIT DAB",
                OperationKeyword = operationMethodKeyword,
                PlaceLabel       = FileHelper.GetOperationLabelFromOperationLabelWork(label, operationPlace),
                PlaceKeyword     = FileHelper.ExcludeNumbers(operationPlace)
            };

            return(operationInformation);
        }
Ejemplo n.º 14
0
            private void Load()
            {
                if (!File.Exists(FilePath))
                {
                    return;
                }

                foreach (string line in File.ReadAllLines(FilePath))
                {
                    string[] tokens = line.Split(new string[] { ";" }, System.StringSplitOptions.RemoveEmptyEntries);

                    OperationInformation entry = new OperationInformation();
                    entry.OperationNumber = tokens[0];
                    entry.ManuallyDeployedVehicleNames.AddRange(tokens.Skip(1));

                    _information[entry.OperationNumber] = entry;
                }
            }
        protected override OperationInformation GetOperationInformationForPrelevement(string label, string labelWork, string operationMethodKeyword)
        {
            string operationLabel = string.Empty;

            //rechercher libellé avant mot clef 'Prelevmnt'
            int index = labelWork.IndexOf(operationMethodKeyword); //accountStatementImportFile.LabelOperation.ToUpper().IndexOf("PRELEVMNT");

            operationLabel = labelWork.Substring(0, index);        // accountStatementImportFile.LabelOperation.Substring(0,index);
            //operationLabel = operationLabel.ToUpper();
            operationLabel = operationLabel.Trim();

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = FileHelper.GetOperationLabelFromOperationLabelWork(label, operationLabel), //operationLabel,
                OperationKeyword = operationLabel                                                             //FileHelper.ExcludeForbiddenChars(operationLabel.Replace(" ", "").ToUpper())
            };

            return(operationInformation);
        }
Ejemplo n.º 16
0
        protected ResponseMessage Receive(RequestMessage message)
        {
            TracerHelper.TraceEntry(message.GetType().Name);

            try
            {
                OperationInformation info = new OperationInformation();
                info.Request = message;

                if (message.PerformSynchronous)
                {
                    ResponseMessage result;
                    if (_stub.PerformOperation <ResponseMessage>(info, null, true, out result))
                    {// Operation performed successfully.
                        TracerHelper.Trace("Operation [" + message.GetType().Name + "] performed successfully.");
                        return(result);
                    }
                    else
                    {
                        TracerHelper.TraceOperationError("Operation [" + message.GetType().Name + "] timed out.");
                    }
                }
                else
                {
                    _stub.PlaceOperation(info, true);

                    if (message.RequestResponse)
                    {
                        return(new ResponseMessage(true));
                    }

                    return(null);
                }
            }
            catch (Exception ex)
            {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the
                // entire package (MT4 included) down with a bad error.
                SystemMonitor.Error(ex.Message);
            }

            return(null);
        }
Ejemplo n.º 17
0
        public bool StartOperation(OperationInformation operationInformation)
        {
            DataHistoryOperation operation = (DataHistoryOperation)operationInformation;

            bool result = true;

            _messageLoopOperator.Invoke(delegate()
            {// Placing the request on the stolen main application thread, since we need the requestMessage pump for this to work properly.
                MbtHistMgr historyClient = _historyClient;
                if (historyClient == null)
                {
                    result = false;
                    return;
                }

                if (operation.Request.IsMinuteBased == false && operation.Request.IsDayBased == false)
                {
                    result = false;
                    return;
                }

                int?time = GetConvertedTime(operation);

                if (operation.Request.IsDayBased)
                {
                    MbtHistDayBar histBar;
                    histBar = historyClient.CreateHistDayBar();
                    histBar.Clear();
                    histBar.SendRequest(operation.Symbol, Int32.Parse(operation.Id), time.Value,
                                        new DateTime(0), new DateTime(0), operation.Request.MaxValuesRetrieved.HasValue ? operation.Request.MaxValuesRetrieved.Value : int.MaxValue, true);
                }
                else if (operation.Request.IsMinuteBased)
                {
                    MbtHistMinBar histBar = historyClient.CreateHistMinBar();
                    histBar.Clear();
                    histBar.SendRequest(operation.Symbol, Int32.Parse(operation.Id), time.Value,
                                        new DateTime(0), new DateTime(0), operation.Request.MaxValuesRetrieved.HasValue ? operation.Request.MaxValuesRetrieved.Value : int.MaxValue, true);
                }
            });

            return(result);
        }
        public bool StartOperation(OperationInformation operationInformation)
        {
            DataHistoryOperation operation = (DataHistoryOperation)operationInformation;

            bool result = true;
            _messageLoopOperator.Invoke(delegate()
            {// Placing the request on the stolen main application thread, since we need the requestMessage pump for this to work properly.
                MbtHistMgr historyClient = _historyClient;
                if (historyClient == null)
                {
                    result = false;
                    return;
                }

                if (operation.Request.IsMinuteBased == false && operation.Request.IsDayBased == false)
                {
                    result = false;
                    return;
                }

                int? time = GetConvertedTime(operation);

                if (operation.Request.IsDayBased)
                {
                    MbtHistDayBar histBar;
                    histBar = historyClient.CreateHistDayBar();
                    histBar.Clear();
                    histBar.SendRequest(operation.Symbol, Int32.Parse(operation.Id), time.Value,
                        new DateTime(0), new DateTime(0), operation.Request.MaxValuesRetrieved.HasValue ? operation.Request.MaxValuesRetrieved.Value : int.MaxValue, true);
                }
                else if (operation.Request.IsMinuteBased)
                {
                    MbtHistMinBar histBar = historyClient.CreateHistMinBar();
                    histBar.Clear();
                    histBar.SendRequest(operation.Symbol, Int32.Parse(operation.Id), time.Value,
                        new DateTime(0), new DateTime(0), operation.Request.MaxValuesRetrieved.HasValue ? operation.Request.MaxValuesRetrieved.Value : int.MaxValue, true);
                }
            });

            return result;
        }
        protected override OperationInformation GetOperationInformationForVirement(string label, string labelWork, string operationMethodKeyword)
        {
            string operationLabel = string.Empty;

            //rechercher libellé avant mot clef virement en votre faveur
            int index = labelWork.IndexOf(operationMethodKeyword); // accountStatementImportFile.LabelOperation.ToUpper().IndexOf("VIREMENT EN VOTRE FAVEUR");

            operationLabel = labelWork.Substring(0, index);        // accountStatementImportFile.LabelOperation.Substring(0,index);
            //label s'arrete au premier chiffre trouvé
            index          = FileHelper.IndexFirstNumeric(operationLabel);
            operationLabel = index == -1 ? operationLabel : operationLabel.Substring(0, index);
            //operationLabel = FileHelper.ExcludeNumbers(operationLabel);
            //operationLabel = FileHelper.ExcludeForbiddenChars(operationLabel);
            //operationLabel = operationLabel.ToUpper();
            operationLabel = operationLabel.Trim();

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = FileHelper.GetOperationLabelFromOperationLabelWork(label, operationLabel), //operationLabel,
                OperationKeyword = operationLabel                                                             // FileHelper.ExcludeForbiddenChars(operationLabel.Replace(" ", "").ToUpper())
            };

            return(operationInformation);
        }
Ejemplo n.º 20
0
        private void UpdateManuallyDeployedVehicles()
        {
            // Create binding source for manually deployed vehicles and add sort description so they sort automatically
            _manuallyDeployedVehicles = new ObservableCollection <ResourceViewModel>();

            if (_operation == null)
            {
                return;
            }

            ICollectionView mdvdv = CollectionViewSource.GetDefaultView(ManuallyDeployedVehicles);

            mdvdv.SortDescriptions.Add(new SortDescription("VehicleName", ListSortDirection.Ascending));

            OperationInformation entry = _operationLibrary.GetInfoEntry(_operation.OperationNumber);

            if (entry != null)
            {
                foreach (string vehicleName in entry.ManuallyDeployedVehicleNames)
                {
                    AddManuallyDeployedVehicle(vehicleName);
                }
            }
        }
        public override List <AccountStatementImportFile> ImportFile(StreamReader reader, AccountStatementImport accountStatementImport, User user)
        {
            reader.DiscardBufferedData();
            reader.BaseStream.Seek(0, SeekOrigin.Begin);

            List <AccountStatementImportFile> accountStatementImportFiles = new List <AccountStatementImportFile>();
            int currentLineNumber = 0;

            while (!reader.EndOfStream)
            {
                var line = reader.ReadLine();

                var values = line.Split(';');
                AccountStatementImportFile asif = _asifService.InitForImport(user.IdUserGroup);
                asif.Id             = currentLineNumber;
                asif.IdImport       = accountStatementImport.Id;
                asif.DateImport     = DateTime.Now;
                asif.Reference      = null;
                asif.LabelOperation = values[2].ToString();

                asif.LabelOperationWork = _asifService.GetOperationLabelWork(asif.LabelOperation);
                //asif.LabelOperationWork = asif.LabelOperationWork.ToString().Replace(" ", "");
                if (values[3].ToString() != string.Empty)
                {
                    asif.AmountOperation = -double.Parse(values[3].Replace(",", ".").ToString(), CultureInfo.InvariantCulture);
                    asif.IdMovement      = (int)EnumMovement.Debit;
                }
                else if (values[4].ToString() != string.Empty)
                {
                    asif.AmountOperation = double.Parse(values[4].Replace(",", ".").ToString(), CultureInfo.InvariantCulture);
                    asif.IdMovement      = (int)EnumMovement.Credit;
                }

                asif.DateIntegration = Convert.ToDateTime(values[1].ToString());
                asif.Account         = _referentialService.AccountService.GetByNumber(values[0].ToString());
                asif.IdAccount       = asif.Account.Id;

                OperationMethod operationMethod = _referentialService.OperationMethodService.GetOperationMethodByFileLabel(asif.LabelOperationWork, EnumBankFamily.CreditAgricole);
                asif.IdOperationMethod = operationMethod.Id;

                //Date Operation
                switch (asif.IdOperationMethod)
                {
                case (int)EnumOperationMethod.PaiementCarte:
                    asif.DateOperation = GetDateOperationByFileLabel(asif.LabelOperationWork, asif.DateIntegration.Value, EnumOperationMethod.PaiementCarte);
                    break;

                case (int)EnumOperationMethod.RetraitCarte:
                    asif.DateOperation = GetDateOperationByFileLabel(asif.LabelOperationWork, asif.DateIntegration.Value, EnumOperationMethod.RetraitCarte);
                    break;
                }

                //Determination de operationDetail (operation+addresse) à partir des keywords
                OperationDetail operationDetail = _asifService.GetOperationDetail(user.Id, asif);
                if (operationDetail != null)
                {
                    asif.IdOperation           = operationDetail.Operation.Id;
                    asif.IdOperationType       = operationDetail.Operation.IdOperationType;
                    asif.IdOperationTypeFamily = operationDetail.Operation.OperationType.IdOperationTypeFamily;
                    asif.IdOperationDetail     = operationDetail.Id;
                    asif.OperationLabelTemp    = operationDetail.Operation.Label;
                    asif.OperationKeywordTemp  = operationDetail.KeywordOperation;
                    asif.PlaceLabelTemp        = operationDetail.KeywordPlace;
                    asif.PlaceKeywordTemp      = operationDetail.KeywordPlace;
                }
                else
                {
                    //Determination de operationDetail (operation+addresse) à partir du label brut
                    OperationType operationType = _referentialService.OperationTypeService.GetUnknown(user.IdUserGroup);
                    asif.IdOperationType       = operationType.Id;
                    asif.IdOperationTypeFamily = operationType.IdOperationTypeFamily;

                    //rechercher les labels et keyword sur libellé brut
                    OperationInformation operationInformation = GetOperationInformationByParsingLabel(user.Id, asif.LabelOperation, asif.LabelOperationWork, operationMethod);
                    if (operationInformation != null)
                    {
                        //asif.IdOperation = operationInformation.IdOperation;
                        asif.OperationLabelTemp   = operationInformation.OperationLabel;
                        asif.OperationKeywordTemp = operationInformation.OperationKeyword;
                        asif.PlaceKeywordTemp     = operationInformation.PlaceKeyword;
                        asif.PlaceLabelTemp       = operationInformation.PlaceLabel;
                    }
                }

                accountStatementImportFiles.Add(asif);
            }


            return(accountStatementImportFiles);
        }
        // >>
        public void OrderOpened(string symbol, int operationID, int orderTicket, decimal openingPrice,
                                int orderOpenTime, bool operationResult, string operationResultMessage)
        {
            TracerHelper.Trace(symbol);

            try
            {
                OperationInformation operation = base.GetOperationById(operationID);

                DateTime?time = GeneralHelper.GenerateDateTimeSecondsFrom1970(orderOpenTime);
                if (time.HasValue == false)
                {
                    if (operation != null)
                    {
                        base.CompleteOperation(operationID, new ResponseMessage(false, "Failed to convert time for order."));
                    }

                    SystemMonitor.Error("Failed to convert time for order.");
                    return;
                }

                string orderId = orderTicket.ToString();
                if (orderTicket < 0)
                {// The system needs orderId empty to recognize the result as failure.
                    orderId         = string.Empty;
                    operationResult = false;
                }

                if (operation != null)
                {
                    ResponseMessage message = null;

                    lock (this)
                    {
                        if (operation.Request is SubmitOrderMessage)
                        {
                            message = new SubmitOrderResponseMessage(_accountInfo, orderId, true);
                            message.OperationResultMessage = operationResultMessage;
                            message.OperationResult        = operationResult;
                        }
                        else if (operation.Request is ExecuteMarketOrderMessage)
                        {
                            OrderInfo info = new OrderInfo(orderId, CreateSymbol(symbol), OrderTypeEnum.UNKNOWN, OrderStateEnum.Executed, int.MinValue);
                            info.OpenTime  = time;
                            info.OpenPrice = openingPrice;

                            message = new ExecuteMarketOrderResponseMessage(_accountInfo, info, operationResult);
                            message.OperationResultMessage = operationResultMessage;
                        }
                        else
                        {
                            SystemMonitor.Error("Failed to establish placed order request type.");
                            message = new ResponseMessage(false);
                        }
                    }

                    base.CompleteOperation(operationID, message);
                }

                if (string.IsNullOrEmpty(orderId) == false)
                {
                    // Do an update of this order.
                    lock (this)
                    {
                        _pendingOrdersInformations.Add(orderId);
                    }
                }
            }
            catch (Exception ex)
            {// Make sure we handle any possible unexpected exceptions, as otherwise
                // they bring the entire package (MT4 included) down with a bad error.
                SystemMonitor.Error(ex.Message);
            }
        }
Ejemplo n.º 23
0
 void NotificationManager_BeforePerforming(OperationInformation operationInformation)
 {
 }
        protected override OperationInformation GetOperationInformationForCardPayment(int idUserGroup, string label, string labelWork, string operationMethodKeyword)
        {
            string operationLabel = string.Empty;
            string operationPlace = string.Empty;

            string fileLabelTmp = labelWork;
            //Rechercher mot clef 'DONT FRAIS' et si present Enlever tout apres 'DONT FRAIS'
            int pos = fileLabelTmp.IndexOf("DONTFRAIS");

            if (pos != -1)
            {
                fileLabelTmp = fileLabelTmp.Substring(0, pos);
                fileLabelTmp = fileLabelTmp.Trim();
            }

            //Recherche du debut du label par le mot cle: CB****
            pos = fileLabelTmp.IndexOf("CB****");

            fileLabelTmp = fileLabelTmp.Substring(pos + "CB****".Length);

            //retrait des chiffres situé apres CB ou SC
            for (int i = 0; i < fileLabelTmp.Length; i++)
            {
                char c = Convert.ToChar(fileLabelTmp.Substring(i, 1));
                if (!Char.IsNumber(c))
                {
                    fileLabelTmp = fileLabelTmp.Substring(i);
                    break;
                }
            }

            //Arret du label dès le 1er chiffre
            int indexPlace = -1;

            for (int i = 0; i < fileLabelTmp.Length; i++)
            {
                char c = Convert.ToChar(fileLabelTmp.Substring(i, 1));
                if (Char.IsNumber(c))
                {
                    operationLabel = fileLabelTmp.Substring(0, i);
                    indexPlace     = i;
                    break;
                }
            }

            if (indexPlace == -1)
            {
                operationLabel = fileLabelTmp;
            }
            else
            {
                //determination du lieu à partir de l'indexPlace
                operationPlace = fileLabelTmp.Substring(indexPlace);
                //suppression des chiffres si > 2
                var countNumber = operationPlace.Count(Char.IsDigit);
                operationPlace = countNumber > 2 ? FileHelper.ExcludeNumbers(operationPlace) : operationPlace;
            }

            OperationInformation operationInformation = new OperationInformation
            {
                OperationLabel   = FileHelper.GetOperationLabelFromOperationLabelWork(label, operationLabel),
                OperationKeyword = operationLabel, //FileHelper.ExcludeForbiddenChars(operationLabel.Replace(" ", "").ToUpper()),
                PlaceLabel       = FileHelper.GetOperationLabelFromOperationLabelWork(label, operationPlace),
                PlaceKeyword     = FileHelper.ExcludeNumbers(operationPlace)
            };

            return(operationInformation);
        }
Ejemplo n.º 25
0
        bool OrderExecutionSourceStub.IImplementation.CloseOrCancelOrder(AccountInfo accountInfo, string orderId,
                                                                         string orderTag, decimal?allowedSlippage, decimal?desiredPrice, out decimal closingPrice,
                                                                         out DateTime closingTime, out string modifiedId, out string operationResultMessage)
        {
            operationResultMessage = string.Empty;

            closingPrice = 0;
            closingTime  = DateTime.MinValue;
            modifiedId   = orderId;

            string operationResultMessageLocal = string.Empty;

            OperationInformation operation = null;

            GeneralHelper.GenericReturnDelegate <string> operationDelegate = delegate()
            {
                operationResultMessageLocal = "Operation not supported.";
                operation = null;

                MbtAccount pAcct = GetAccountByInfo(accountInfo);

                if (pAcct == null)
                {
                    operationResultMessageLocal = "Failed to retrieve account.";
                    SystemMonitor.OperationWarning(operationResultMessageLocal);
                    return(null);
                }

                string message = string.Empty;
                lock (this)
                {// Make sure to keep the entire package here locked, since the order operation get placed after the submit
                    // so we need to make sure we shall catch the responce in OnSubmit() too.
                    if (_orderClient.Cancel(orderTag, ref message) == false)
                    {// Error requestMessage.
                        operationResultMessageLocal = message;
                        return(null);
                    }

                    operation = new CancelOrderOperation()
                    {
                        Id = message
                    };
                    // The message, or operation Id is the order token (further stored in OrderInfo.id)
                    _operationStub.RegisterOperation(operation, false);
                }

                return(message);
            };

            object result;

            if (_messageLoopOperator.Invoke(operationDelegate, TimeSpan.FromSeconds(8), out result) == false)
            {// Timed out.
                operationResultMessage = "Timeout submiting order cancelation.";
                return(false);
            }

            if (string.IsNullOrEmpty((string)result))
            {// Operation error.
                operationResultMessage = operationResultMessageLocal;
                return(false);
            }

            // Return the ID of the submitted order.
            return(true);
        }
            private void Load()
            {
                if (!File.Exists(FilePath))
                {
                    return;
                }

                foreach (string line in File.ReadAllLines(FilePath))
                {
                    string[] tokens = line.Split(new string[] { ";" }, System.StringSplitOptions.RemoveEmptyEntries);

                    OperationInformation entry = new OperationInformation();
                    entry.OperationNumber = tokens[0];
                    entry.ManuallyDeployedVehicleNames.AddRange(tokens.Skip(1));

                    _information[entry.OperationNumber] = entry;
                }
            }