示例#1
0
        protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken ct)
        {
            string javaPath = JavaPath.Get(context);

            if (javaPath != null)
            {
                javaPath = Path.Combine(javaPath, "bin", "java.exe");
                if (!File.Exists(javaPath))
                {
                    throw new ArgumentException(Resources.InvalidJavaPath, Resources.JavaPathDisplayName);
                }
            }
            _invoker = new JavaInvoker(javaPath);

            try
            {
                await _invoker.StartJavaService();
            }
            catch (Exception e)
            {
                Trace.TraceError($"Error initializing Java Invoker: {e.ToString()}");
                throw new InvalidOperationException(string.Format(Resources.JavaInitiazeException, e.ToString()));
            }
            ct.ThrowIfCancellationRequested();
            return(ctx =>
            {
                ctx.ScheduleAction(Body, _invoker, OnCompleted, OnFaulted);
            });
        }
示例#2
0
 public MCsettings()
 {
     InitializeComponent();
     JavaPath.SetBinding(TextBox.TextProperty, new Binding("JavaPath")
     {
         Source = setting, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay
     });
     MaxRAM.SetBinding(TextBox.TextProperty, new Binding("MaxRam")
     {
         Source = setting, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, Mode = BindingMode.TwoWay
     });
 }
示例#3
0
        protected override async Task <Action <NativeActivityContext> > ExecuteAsync(NativeActivityContext context, CancellationToken ct)
        {
            string javaPath = JavaPath.Get(context);
            var    javaExec = _javaExeWindows;

#if NETCOREAPP
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                javaExec = _javaExeLinux;
            }
#endif
            if (javaPath != null)
            {
                javaPath = Path.Combine(javaPath, "bin", javaExec);
                if (!File.Exists(javaPath))
                {
                    throw new ArgumentException(Resources.InvalidJavaPath, Resources.JavaPathDisplayName);
                }
            }
            _invoker = new JavaInvoker(javaPath);

            int initTimeout = TimeoutMS.Get(context);
            if (initTimeout < 0)
            {
                throw new ArgumentException(UiPath.Java.Activities.Properties.Resources.TimeoutMSException, "TimeoutMS");
            }

            try
            {
                await _invoker.StartJavaService(initTimeout);
            }
            catch (Exception e)
            {
                Trace.TraceError($"Error initializing Java Invoker: {e}");
                throw new InvalidOperationException(string.Format(Resources.JavaInitiazeException, e.ToString()));
            }
            ct.ThrowIfCancellationRequested();
            return(ctx =>
            {
                ctx.ScheduleAction(Body, _invoker, OnCompleted, OnFaulted);
            });
        }