internal ExecutionCommandViewItem(ExecutionCommand command)
 {
     Command = command;
     var priceFormat = Command.Instrument.PriceFormat;
     ImageIndex = 0;
     SubItems[0].Text = Command.DateTime.ToString();
     SubItems.AddRange(new[]
     {
         Command.Type.ToString(), string.Empty, string.Empty,
         Command.Side.ToString(), Command.OrdType.ToString(), Command.Price.ToString(priceFormat),
         Command.StopPx.ToString(priceFormat), Command.Qty.ToString(), string.Empty, string.Empty,
         string.Empty, string.Empty, string.Empty, Command.Text
     });
 }
Example #2
0
 public Order OnExecutionCommand(ExecutionCommand command)
 {
     var order = this.orders[command.OrderId];
     if (order == null)
     {
         order = new Order(command);
         this.orders[command.OrderId] = order;
         order.Instrument = command.Instrument;
         order.Provider = command.Provider;
         order.Portfolio = command.Portfolio;
         if (command.Type == ExecutionCommandType.Send)
             order.Status = OrderStatus.PendingNew;
     }
     order.OnExecutionCommand(command);
     return order;
 }
        public override void Send(ExecutionCommand command)
        {
            if (IsDisconnected)
            {
                Connect();
            }
            switch (command.Type)
            {
            case ExecutionCommandType.Send:
                DoSend(command);
                break;

            case ExecutionCommandType.Cancel:
                Cancel(command.Order);
                break;

            case ExecutionCommandType.Replace:
                Replace(command);
                break;
            }
        }
        public DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command)
        {
            var pec       = (NativeExecutionCommand)command;
            var startInfo = new DebuggerStartInfo();

            var cmd = pec.Command;

            RunCv2Pdb(ref cmd);

            startInfo.Command          = cmd;
            startInfo.Arguments        = pec.Arguments;
            startInfo.WorkingDirectory = pec.WorkingDirectory;
            if (pec.EnvironmentVariables.Count > 0)
            {
                foreach (KeyValuePair <string, string> val in pec.EnvironmentVariables)
                {
                    startInfo.EnvironmentVariables[val.Key] = val.Value;
                }
            }
            return(startInfo);
        }
Example #5
0
        public void Customize(ExecutionCommand command, object configurationData)
        {
            CustomArgsExecutionModeData data = (CustomArgsExecutionModeData)configurationData;

            // Customize the command

            ProcessExecutionCommand cmd = (ProcessExecutionCommand)command;

            if (!string.IsNullOrEmpty(data.Arguments))
            {
                cmd.Arguments = data.Arguments;
            }
            if (!string.IsNullOrEmpty(data.WorkingDirectory))
            {
                cmd.WorkingDirectory = data.WorkingDirectory;
            }
            foreach (KeyValuePair <string, string> var in data.EnvironmentVariables)
            {
                cmd.EnvironmentVariables [var.Key] = var.Value;
            }
        }
Example #6
0
        private void SetOrderId(ExecutionCommand cmd)
        {
            if (string.IsNullOrEmpty(cmd.ProviderOrderId))
            {
                var nextId = _idGen.Next().ToString();
                cmd.Order.ClOrderId = nextId;
                cmd.ClOrderId       = nextId;
            }

            cmd.ProviderOrderId       = Interlocked.Increment(ref localId).ToString($"D{LocalIdLength}");
            cmd.Order.ProviderOrderId = cmd.ProviderOrderId;

            var dateTime = DateTime.Now;

            if (DateTime.Today != trader.TradingDay)
            {
                dateTime = trader.TradingDay.Add(dateTime.TimeOfDay);
            }
            cmd.Order.TransactTime = dateTime;
            cmd.TransactTime       = dateTime;
        }
        public override DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand cmd)
        {
            var godotCmd         = (GodotExecutionCommand)cmd;
            var godotProjectPath = godotCmd.GodotProjectPath;

            int attachPort = 23685; // Default if not modified

            // Try read the debugger agent port from the 'project.godot' file
            if (File.Exists(godotProjectPath))
            {
                // [mono] "debugger_agent/port"
                var regex = new Regex(@"debugger_agent/port=([0-9]+)");
                foreach (string line in File.ReadAllLines(godotProjectPath))
                {
                    var match = regex.Match(line);

                    if (match.Success)
                    {
                        attachPort = int.Parse(match.Groups[1].Value);
                        break;
                    }
                }
            }

            SoftDebuggerRemoteArgs args;

            if (godotCmd.ExecutionType != ExecutionType.Attach)
            {
                args = new SoftDebuggerListenArgs("Godot", IPAddress.Loopback, 0);
            }
            else
            {
                args = new SoftDebuggerConnectArgs("Godot", IPAddress.Loopback, attachPort);
            }

            return(new GodotDebuggerStartInfo(godotCmd, args)
            {
                WorkingDirectory = godotCmd.WorkingDirectory
            });
        }
Example #8
0
        public override void OnSendCommand(ExecutionCommand command)
        {
            Order order;

            OrderInfo orderInfo = new OrderInfo(command);

            for (int i = 0; i < command.Qty; i++)
            {
                if (command.Side == OrderSide.Buy)
                {
                    order = BuyOrder(command.Instrument, 1, "VWAP Buy");
                }
                else
                {
                    order = SellOrder(command.Instrument, 1, "VWAP Sell");
                }

                orderTable[order] = orderInfo;

                Send(order);
            }
        }
Example #9
0
        public override void OnSendCommand(ExecutionCommand command)
        {
            Order order = command.Order;

            // Create ExecNew report.
            ExecutionReport report = new ExecutionReport();

            report.DateTime   = framework.Clock.DateTime;
            report.Order      = order;
            report.Instrument = order.Instrument;
            report.OrdQty     = order.Qty;
            report.ExecType   = ExecType.ExecNew;
            report.OrdStatus  = OrderStatus.New;
            report.OrdType    = order.Type;
            report.Side       = order.Side;

            // Send report to BuySide strategy.
            EmitExecutionReport(report);

            // Create new order processor.
            new OrderProcessor(this, command);
        }
        private void CmdNewQuote(ExecutionCommand command)
        {
            string altSymbol;
            string altExchange;
            string apiSymbol;
            string apiExchange;
            double apiTickSize;
            string apiProductID;

            GetApi_Symbol_Exchange_TickSize(command.Instrument, this.id,
                                            out altSymbol, out altExchange,
                                            out apiSymbol, out apiExchange,
                                            out apiTickSize,
                                            out apiProductID);

            Order bidOrder;
            Order askOrder;

            QuoteField field = ToQuoteStruct(command, apiSymbol, apiExchange, out askOrder, out bidOrder);

            quoteMap.DoQuoteSend(field, command, askOrder, bidOrder);
        }
        public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
        {
            var dotNetCoreCommand = (DotNetCoreExecutionCommand)command;

            // ApplicationURL is passed to ASP.NET Core server via ASPNETCORE_URLS enviorment variable
            var envVariables = dotNetCoreCommand.EnvironmentVariables.ToDictionary((arg) => arg.Key, (arg) => arg.Value);

            envVariables ["ASPNETCORE_URLS"] = dotNetCoreCommand.ApplicationURL;

            var process = Runtime.ProcessService.StartConsoleProcess(
                dotNetCoreCommand.Command,
                dotNetCoreCommand.Arguments,
                dotNetCoreCommand.WorkingDirectory,
                console,
                envVariables);

            if (dotNetCoreCommand.LaunchBrowser)
            {
                LaunchBrowser(dotNetCoreCommand.ApplicationURL, dotNetCoreCommand.LaunchURL, process.Task).Ignore();
            }
            return(process);
        }
Example #12
0
        public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console, bool allowPrompt, bool forcePrompt)
        {
            if ((PromptForParameters || forcePrompt) && allowPrompt)
            {
                CommandExecutionContext ctx        = new CommandExecutionContext(Project, command);
                CustomExecutionMode     customMode = ExecutionModeCommandService.ShowParamtersDialog(ctx, Mode, this);
                if (customMode == null)
                {
                    return(new CancelledProcessAsyncOperation());
                }
                else
                {
                    return(customMode.Execute(command, console, false, false));
                }
            }
            if (commandData != null)
            {
                foreach (KeyValuePair <string, object> cmdData in commandData)
                {
                    ExecutionCommandCustomizer cc = ExecutionModeCommandService.GetExecutionCommandCustomizer(cmdData.Key);
                    if (cc != null)
                    {
                        cc.Customize(command, cmdData.Value);
                    }
                }
            }
            ParameterizedExecutionHandler cmode = Mode.ExecutionHandler as ParameterizedExecutionHandler;

            if (cmode != null)
            {
                CommandExecutionContext ctx = new CommandExecutionContext(Project, command);
                return(cmode.Execute(command, console, ctx, Data));
            }
            else
            {
                return(Mode.ExecutionHandler.Execute(command, console));
            }
        }
        public static ExecutionCommand SetColorPalette(this ExecutionCommand action, Palette palette)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            switch (action.Mode)
            {
            case null:
            case Mode.Music:
                action.Mode = Mode.Music;
                if (action.MusicOptions == null)
                {
                    action.MusicOptions = new ModeOptionsMusicCommand();
                }
                action.MusicOptions.Palette = palette;
                break;

            default: throw new InvalidOperationException("Only the 'music' mode supports color palettes!");
            }
            return(action);
        }
        private void Replace(ExecutionCommand command)
        {
            Order order = command.Order;

            order.SetOrderStatus(OrderStatus.PendingReplace);
            if (_reports[order.Id] != null && IsDone(_reports[order.Id].ordStatus))
            {
                ReplaceReject(order, "Order already done");
                return;
            }
            ExecutionReport report = new ExecutionReport(command);

            report.DateTime    = framework.Clock.DateTime;
            report.ExecType    = ExecType.ExecReplace;
            report.OrdStatus   = OrderStatus.Replaced;
            report.CumQty      = order.CumQty;
            report.LastQty     = 0.0;
            report.LeavesQty   = command.Qty - order.CumQty;
            report.LastPx      = 0.0;
            report.AvgPx       = 0.0;
            _reports[order.Id] = new SimulatorExecutionReport(report);
            EmitExecutionReport(report, Queued);
        }
Example #15
0
        static DebuggerEngine GetFactoryForCommand(ExecutionCommand cmd)
        {
            DebuggerEngine supportedEngine = null;

            // Get the default engine for the command if available,
            // or the first engine that supports the command otherwise

            foreach (DebuggerEngine factory in GetDebuggerEngines())
            {
                if (factory.CanDebugCommand(cmd))
                {
                    if (factory.IsDefaultDebugger(cmd))
                    {
                        return(factory);
                    }
                    if (supportedEngine == null)
                    {
                        supportedEngine = factory;
                    }
                }
            }
            return(supportedEngine);
        }
Example #16
0
        public override bool CanDebugCommand(ExecutionCommand cmd)
        {
            if (!(cmd is NativeExecutionCommand nativeCmd))
            {
                return(false);
            }

            string file = FindFile(nativeCmd.Command);

            if (!File.Exists(file))
            {
                // The provided file is not guaranteed to exist. If it doesn't
                // we assume we can execute it because otherwise the run command
                // in the IDE will be disabled, and that's not good because that
                // command will build the project if the exec doesn't yet exist.
                return(true);
            }

            file = Path.GetFullPath(file);
            DateTime currentTime = File.GetLastWriteTime(file);

            if (fileCheckCache.TryGetValue(file, out var data))
            {
                if (data.LastCheck == currentTime)
                {
                    return(data.IsExe);
                }
            }
            data.LastCheck = currentTime;
            try {
                data.IsExe = IsExecutable(file);
            } catch {
                data.IsExe = false;
            }
            fileCheckCache [file] = data;
            return(data.IsExe);
        }
Example #17
0
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            if (!CurrentExecutionTargetIsCoreClr(context.ExecutionTarget))
            {
                base.DoExecute(monitor, context, configuration);
                return;
            }

            var config = GetConfiguration(configuration) as DotNetProjectConfiguration;

            monitor.Log.WriteLine(GettextCatalog.GetString("Running {0} ...", Name));

            IConsole console = CreateConsole(config, context);
            var      aggregatedOperationMonitor = new AggregatedOperationMonitor(monitor);

            try {
                try {
                    ExecutionCommand executionCommand = CreateExecutionCommand(configuration, config);
                    if (context.ExecutionTarget != null)
                    {
                        executionCommand.Target = context.ExecutionTarget;
                    }

                    IProcessAsyncOperation asyncOp = Execute(executionCommand, console);
                    aggregatedOperationMonitor.AddOperation(asyncOp);
                    asyncOp.WaitForCompleted();

                    monitor.Log.WriteLine(GettextCatalog.GetString("The application exited with code: {0}", asyncOp.ExitCode));
                } finally {
                    console.Dispose();
                    aggregatedOperationMonitor.Dispose();
                }
            } catch (Exception ex) {
                LoggingService.LogError(string.Format("Cannot execute \"{0}\"", Name), ex);
                monitor.ReportError(GettextCatalog.GetString("Cannot execute \"{0}\"", Name), ex);
            }
        }
        public DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command)
        {
            var cmd = (AspNetExecutionCommand)command;

            var runtime   = (MonoTargetRuntime)cmd.TargetRuntime;
            var startInfo = new SoftDebuggerStartInfo(runtime.Prefix, runtime.EnvironmentVariables)
            {
                WorkingDirectory = cmd.BaseDirectory,
                Arguments        = cmd.XspParameters.GetXspParameters().Trim(),
            };

            var xspName = AspNetExecutionHandler.GetXspName(cmd);

            FilePath fxDir   = GetFxDir(runtime, cmd.ClrVersion);
            FilePath xspPath = fxDir.Combine(xspName).ChangeExtension(".exe");

            //no idea why xsp is sometimes relocated to a "winhack" dir on Windows
            if (MonoDevelop.Core.Platform.IsWindows && !File.Exists(xspPath))
            {
                var winhack = fxDir.Combine("winhack");
                if (Directory.Exists(winhack))
                {
                    xspPath = winhack.Combine(xspName).ChangeExtension(".exe");
                }
            }

            if (!File.Exists(xspPath))
            {
                throw new UserException(GettextCatalog.GetString(
                                            "The \"{0}\" web server cannot be started. Please ensure that it is installed.", xspName), null);
            }

            startInfo.Command = xspPath;
            SoftDebuggerEngine.SetUserAssemblyNames(startInfo, cmd.UserAssemblyPaths);

            return(startInfo);
        }
Example #19
0
        public ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
        {
            var cmd = command as MeadowExecutionCommand;
            MeadowDeviceExecutionTarget target;
            //get a ref to the new execution target
            //target = (cmd.Target as MeadowDeviceExecutionTarget);
            Task deployTask;
            var  cts = new CancellationTokenSource();

            if (MeadowProject.DeploymentTargetsManager.Count == 1)
            {
                target     = MeadowProject.DeploymentTargetsManager.GetTargetList()[0];
                deployTask = DeployApp(target, cmd.OutputDirectory, cts);
                return(new ProcessAsyncOperation(deployTask, cts));
            }
            else if (MeadowProject.DeploymentTargetsManager.Count > 1) //If there is more than one meadow, then open a list box
            {
                var tcs        = new TaskCompletionSource <ResponseType>();
                var meadowList = new MeadowSelect(MeadowProject.DeploymentTargetsManager);

                meadowList.Response += (o, args) =>
                {
                    tcs.SetResult(args.ResponseId);
                };
                meadowList.Run(); //Blocks
                target = meadowList.GetSelection();
                meadowList.HideAll();
                meadowList.Destroy();
                if (tcs.Task.Result == ResponseType.Ok && target != null)
                {
                    deployTask = DeployApp(target, cmd.OutputDirectory, cts);
                    return(new ProcessAsyncOperation(deployTask, cts));
                }
            }

            return(null);
        }
Example #20
0
        protected async override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
        {
            ProjectConfiguration conf = (ProjectConfiguration)GetConfiguration(configuration);

            monitor.Log.WriteLine(GettextCatalog.GetString("Running {0} ...", FileName));

            OperationConsole console = conf.ExternalConsole
                                ? context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput, monitor.CancellationToken)
                                                                                   : context.ConsoleFactory.CreateConsole(
                OperationConsoleFactory.CreateConsoleOptions.Default.WithTitle(Path.GetFileName(FileName)), monitor.CancellationToken);

            try {
                try {
                    ExecutionCommand executionCommand = CreateExecutionCommand(configuration, conf);

                    if (!context.ExecutionHandler.CanExecute(executionCommand))
                    {
                        monitor.ReportError(GettextCatalog.GetString("Can not execute \"{0}\". The selected execution mode is not supported for .NET projects.", FileName), null);
                        return;
                    }

                    ProcessAsyncOperation asyncOp = context.ExecutionHandler.Execute(executionCommand, console);
                    var stopper = monitor.CancellationToken.Register(asyncOp.Cancel);

                    await asyncOp.Task;

                    stopper.Dispose();

                    monitor.Log.WriteLine(GettextCatalog.GetString("The application exited with code: {0}", asyncOp.ExitCode));
                } finally {
                    console.Dispose();
                }
            } catch (Exception ex) {
                LoggingService.LogError(string.Format("Cannot execute \"{0}\"", FileName), ex);
                monitor.ReportError(GettextCatalog.GetString("Cannot execute \"{0}\"", FileName), ex);
            }
        }
        public override ProcessAsyncOperation Execute(ExecutionCommand command, OperationConsole console)
        {
            var ceCmd    = (CryEngineGameExecutionCommand)command;
            var ceTarget = ceCmd.Target as CryEngineExecutionTarget;

            var launcherPath     = ceTarget != null ? ceTarget.LauncherPath : ceCmd.CryEngineParameters.LauncherPath;
            var workingDirectory = Path.GetDirectoryName(launcherPath);

            var arguments = $"-project {ceCmd.CryEngineParameters.ProjectPath}";

            if (ceCmd.CryEngineParameters.CommandArguments != null)
            {
                arguments += " " + ceCmd.CryEngineParameters.CommandArguments;
            }

            if (ceTarget != null && ceTarget.CommandArguments != null)
            {
                arguments += " " + ceTarget.CommandArguments;
            }

            var nativeCmd = new NativeExecutionCommand(launcherPath, arguments, workingDirectory);

            return(base.Execute(nativeCmd, console));
        }
        public static ExecutionCommand SetModeType(this ExecutionCommand action, int modeType)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            switch (action.Mode)
            {
            case null:
            case Mode.Ambient:
                action.Mode = Mode.Ambient;
                if (action.AmbientOptions == null)
                {
                    action.AmbientOptions = new ModeOptionsAmbientCommand();
                }

                action.AmbientOptions.AmbientModeType = modeType;
                break;

            default: throw new InvalidOperationException("Only the 'ambient' mode supports an mode type!");
            }
            return(action);
        }
        internal protected override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            ProjectConfiguration conf = (ProjectConfiguration)GetConfiguration(configuration);

            monitor.Log.WriteLine(GettextCatalog.GetString("Running {0} ...", FileName));

            IConsole console = conf.ExternalConsole
                                ? context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput)
                                : context.ConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);

            AggregatedOperationMonitor aggregatedOperationMonitor = new AggregatedOperationMonitor(monitor);

            try {
                try {
                    ExecutionCommand executionCommand = CreateExecutionCommand(configuration, conf);

                    if (!context.ExecutionHandler.CanExecute(executionCommand))
                    {
                        monitor.ReportError(GettextCatalog.GetString("Can not execute \"{0}\". The selected execution mode is not supported for .NET projects.", FileName), null);
                        return;
                    }

                    IProcessAsyncOperation asyncOp = context.ExecutionHandler.Execute(executionCommand, console);
                    aggregatedOperationMonitor.AddOperation(asyncOp);
                    asyncOp.WaitForCompleted();

                    monitor.Log.WriteLine(GettextCatalog.GetString("The application exited with code: {0}", asyncOp.ExitCode));
                } finally {
                    console.Dispose();
                    aggregatedOperationMonitor.Dispose();
                }
            } catch (Exception ex) {
                LoggingService.LogError(string.Format("Cannot execute \"{0}\"", FileName), ex);
                monitor.ReportError(GettextCatalog.GetString("Cannot execute \"{0}\"", FileName), ex);
            }
        }
Example #24
0
        private void CmdNewOrderList(ExecutionCommand command)
        {
            // 先查出所有的单子
            List <Order> orders = command.Order.GetSameTimeOrderList();

            OrderField[] fields = new OrderField[orders.Count];
            for (int i = 0; i < orders.Count; ++i)
            {
                string altSymbol;
                string altExchange;
                string apiSymbol;
                string apiExchange;
                double apiTickSize;

                GetApi_Symbol_Exchange_TickSize(orders[i].Instrument, this.id,
                                                out altSymbol, out altExchange,
                                                out apiSymbol, out apiExchange,
                                                out apiTickSize);

                ToOrderStruct(ref fields[i], orders[i], apiSymbol, apiExchange);
            }

            orderMap.DoOrderSend(ref fields, orders);
        }
Example #25
0
 public bool CanExecute(ExecutionCommand command)
 {
     return(command is AspNetCoreExecutionCommand);
 }
Example #26
0
 internal static string GetOrderId(ExecutionCommand order)
 {
     return(order.ClOrderId);
 }
 public override bool CanDebugCommand(ExecutionCommand cmd)
 {
     return(cmd is DotNetCoreExecutionCommand && !Platform.IsWindows);
 }
        public override DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand c)
        {
            var dotNetCommand = DotNetCoreExecutionHandler.ConvertCommand((DotNetCoreExecutionCommand)c);

            return(base.CreateDebuggerStartInfo(dotNetCommand));
        }
Example #29
0
 public override bool CanExecute(ExecutionCommand command)
 {
     return(command is PythonExecutionCommand);
 }
Example #30
0
        public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console)
        {
            var config = ((PythonExecutionCommand)command).Configuration;

            return(config.Runtime.GetExecutionHandler().Execute(command, console));
        }
 public OnExecutionCommand(ExecutionCommand command)
 {
     this.command = command;
 }
 public bool CanExecute(ExecutionCommand command)
 {
     return(command is MicroFrameworkExecutionCommand);
 }
 public void Send(ExecutionCommand command)
 {
     throw new System.NotImplementedException();
 }
 private void ProcessExecutionCommand(ExecutionCommand executionCommand)
 {
     Order order = this.orderFactory.OnExecutionCommand(executionCommand);
     if (executionCommand.Type == ExecutionCommandType.Send)
         this.AddOrder(order);
     this.lastUpdatedOrderList.Add((OrderViewItem)this.allOrders[(object)order]);
     if (executionCommand.Order != this.reportedOrder)
         return;
     this.ltvReports.Items.Add((ListViewItem)new ExecutionCommandViewItem(executionCommand));
 }
Example #35
0
 private void DispatcherExecutionCommand(object sender, ExecutionCommand command)
 {
     OrderManagerQueue.Enqueue(command);
 }
 public IProcessAsyncOperation Execute(ExecutionCommand command, IConsole console)
 {
     return(DebuggingService.GetExecutionHandler().Execute(command, console));
 }
Example #37
0
 internal void OnExecutionCommand(ExecutionCommand command) => OnEvent(command);