Ejemplo n.º 1
0
 public Either <RfcErrorInfo, Unit> AllowStartOfPrograms(IConnectionHandle connectionHandle,
                                                         StartProgramDelegate callback)
 {
     Logger.IfSome(l => l.LogTrace("Setting allow start of programs callback"));
     Api.AllowStartOfPrograms(connectionHandle as ConnectionHandle, callback, out var errorInfo);
     return(ResultOrError(Unit.Default, errorInfo.Code, errorInfo));
 }
Ejemplo n.º 2
0
Archivo: Api.cs Proyecto: fw2568/YaNco
        public static void AllowStartOfPrograms(ConnectionHandle connectionHandle, StartProgramDelegate callback, out
                                                RfcErrorInfo errorInfo)
        {
            var descriptionHandle = new FunctionDescriptionHandle(Interopt.RfcCreateFunctionDesc("RFC_START_PROGRAM", out errorInfo));

            if (descriptionHandle.Ptr == IntPtr.Zero)
            {
                return;
            }

            var paramDesc = new Interopt.RFC_PARAMETER_DESC {
                Name = "COMMAND", Type = RfcType.CHAR, Direction = RfcDirection.Import, NucLength = 512, UcLength = 1024
            };
            var rc = Interopt.RfcAddParameter(descriptionHandle.Ptr, ref paramDesc, out errorInfo);

            if (rc != RfcRc.RFC_OK)
            {
                return;
            }

            rc = Interopt.RfcInstallServerFunction(null, descriptionHandle.Ptr, StartProgramHandler, out errorInfo);
            if (rc != RfcRc.RFC_OK)
            {
                return;
            }

            RegisteredCallbacks.AddOrUpdate(connectionHandle.Ptr, callback, (c, v) => v);
        }
Ejemplo n.º 3
0
        public async Task AllowStartOfPrograms_is_cancelled()
        {
            var rfcRuntimeMock = new Mock <IRfcRuntime>()
                                 .SetupOpenConnection(out var connHandle);

            StartProgramDelegate callback = (c) => RfcErrorInfo.Ok();

            rfcRuntimeMock.Setup(r => r
                                 .AllowStartOfPrograms(connHandle.Object, callback))
            .Returns(Unit.Default);

            var conn = await rfcRuntimeMock.CreateConnection()
                       .Map(c => c.AllowStartOfPrograms(callback));

            rfcRuntimeMock.VerifyAll();
        }
Ejemplo n.º 4
0
 public ConnectionBuilder WithStartProgramCallback(StartProgramDelegate startProgramDelegate)
 {
     _startProgramDelegate = startProgramDelegate;
     return(this);
 }
Ejemplo n.º 5
0
        static async Task Main(string[] args)
        {
            var configurationBuilder =
                new ConfigurationBuilder();

            configurationBuilder.AddInMemoryCollection(new[]
            {
                new KeyValuePair <string, string>("tests:repeats", "10"),
                new KeyValuePair <string, string>("tests:rows", "10")
            });
            configurationBuilder.AddEnvironmentVariables("saprfc");
            configurationBuilder.AddCommandLine(args);
            configurationBuilder.AddUserSecrets <Program>();

            var config = configurationBuilder.Build();

            var settings = new Dictionary <string, string>
            {
                { "ashost", config["saprfc:ashost"] },
                { "sysnr", config["saprfc:sysnr"] },
                { "client", config["saprfc:client"] },
                { "user", config["saprfc:username"] },
                { "passwd", config["saprfc:password"] },
                { "lang", "EN" }
            };

            var rows    = Convert.ToInt32(config["tests:rows"]);
            var repeats = Convert.ToInt32(config["tests:repeats"]);

            Console.WriteLine($"Test rows: {rows}");
            Console.WriteLine($"Test repeats: {repeats}");


            StartProgramDelegate callback = command =>
            {
                var programParts = command.Split(' ');
                var arguments    = command.Replace(programParts[0], "");
                var p            = Process.Start(AppDomain.CurrentDomain.BaseDirectory + @"\" + programParts[0] + ".exe",
                                                 arguments.TrimStart());

                return(RfcErrorInfo.Ok());
            };

            var connectionBuilder = new ConnectionBuilder(settings)
                                    .WithStartProgramCallback(callback)
                                    .ConfigureRuntime(c =>
                                                      c.WithLogger(new SimpleConsoleLogger()));

            using (var context = new RfcContext(connectionBuilder.Build()))
            {
                await context.PingAsync();

                await RunIntegrationTests(context);

                long totalTest1 = 0;
                long totalTest2 = 0;

                for (var run = 0; run < repeats; run++)
                {
                    Console.WriteLine($"starting Test Run {run + 1} of {repeats}\tTest 01");
                    totalTest1 += await RunPerformanceTest01(context, rows);

                    Console.WriteLine($"starting Test Run {run + 1} of {repeats}\tTest 02");
                    totalTest2 += await RunPerformanceTest02(context, rows);

                    GC.Collect();
                }

                Console.WriteLine("Total runtime Test 01: " + totalTest1);
                Console.WriteLine("Total runtime Test 02: " + totalTest2);
                Console.WriteLine("Average runtime Test 01: " + totalTest1 / repeats);
                Console.WriteLine("Average runtime Test 02: " + totalTest2 / repeats);
            }
        }
Ejemplo n.º 6
0
 public static void AllowStartOfPrograms(ConnectionHandle connectionHandle, StartProgramDelegate callback, out
                                         RfcErrorInfo errorInfo)
 {
     throw new NotImplementedException();
 }