Exemple #1
0
 public PackageInstaller(EnvironmentSettings environmentSettings,
                         IApplicationClientFactory applicationClientFactory, IApplication application,
                         IPackageArchiver packageArchiver, ISqlScriptExecutor scriptExecutor,
                         IServiceUrlBuilder serviceUrlBuilder, IFileSystem fileSystem, ILogger logger)
 {
     environmentSettings.CheckArgumentNull(nameof(environmentSettings));
     applicationClientFactory.CheckArgumentNull(nameof(applicationClientFactory));
     application.CheckArgumentNull(nameof(application));
     packageArchiver.CheckArgumentNull(nameof(packageArchiver));
     scriptExecutor.CheckArgumentNull(nameof(scriptExecutor));
     serviceUrlBuilder.CheckArgumentNull(nameof(serviceUrlBuilder));
     fileSystem.CheckArgumentNull(nameof(fileSystem));
     _environmentSettings      = environmentSettings;
     _applicationClientFactory = applicationClientFactory;
     _application             = application;
     _packageArchiver         = packageArchiver;
     _scriptExecutor          = scriptExecutor;
     _serviceUrlBuilder       = serviceUrlBuilder;
     _fileSystem              = fileSystem;
     _logger                  = logger;
     _applicationClient       = _applicationClientFactory.CreateClient(_environmentSettings);
     _applicationClientForLog = _applicationClientFactory.CreateClient(_environmentSettings);
     _developerModeEnabled    = _environmentSettings.DeveloperModeEnabled.HasValue &&
                                _environmentSettings.DeveloperModeEnabled.Value;
 }
 public PBXConnection(ILogger log, IRegistryConfigurationProvider config, IApplicationClient ac, IClock c)
 {
     _log    = log;
     _config = config;
     _ac     = ac;
     _c      = c;
 }
Exemple #3
0
        public string Execute(string sql, IApplicationClient applicationClient, EnvironmentSettings settings)
        {
            var    scriptData         = "{ \"script\":\"" + sql + "\"}";
            string responseFormServer = applicationClient.ExecutePostRequest(
                settings.IsNetCore ? settings.Uri + ExecuteSqlScriptUrl : settings.Uri + "/0" + ExecuteSqlScriptUrl, scriptData);

            return(CorrectJson(responseFormServer));
        }
        public PMSParser(PBXConfiguration config, ILogger log, IMessageConnectionFactory cf,
                         IApplicationClient ac, IClock c) :
            base(config, log, cf, ac, c)
        {
            var lexer = new PMSByteStreamLexer();

            lexer.EnquireRecieved += EnquireReceived;
            RegisterLexer(lexer);
        }
Exemple #5
0
 protected PBXParser(PBXConfiguration config, ILogger log, IMessageConnectionFactory cf,
                     IApplicationClient ac, IClock c)
 {
     Log                    = log;
     CF                     = cf;
     AC                     = ac;
     C                      = c;
     Transport              = GetConfiguredTransport(log, config);
     Transport.DataArrived += TransportDataArrived;
 }
Exemple #6
0
 public Application(EnvironmentSettings environmentSettings, IApplicationClient applicationClient,
                    IServiceUrlBuilder serviceUrlBuilder)
 {
     environmentSettings.CheckArgumentNull(nameof(environmentSettings));
     applicationClient.CheckArgumentNull(nameof(applicationClient));
     serviceUrlBuilder.CheckArgumentNull(nameof(serviceUrlBuilder));
     _environmentSettings = environmentSettings;
     _applicationClient   = applicationClient;
     _serviceUrlBuilder   = serviceUrlBuilder;
 }
Exemple #7
0
 public ApplicationPackageListProvider(IApplicationClient applicationClient, IJsonConverter jsonConverter,
                                       IServiceUrlBuilder serviceUrlBuilder)
 {
     applicationClient.CheckArgumentNull(nameof(applicationClient));
     jsonConverter.CheckArgumentNull(nameof(jsonConverter));
     serviceUrlBuilder.CheckArgumentNull(nameof(serviceUrlBuilder));
     _applicationClient      = applicationClient;
     _jsonConverter          = jsonConverter;
     _packagesListServiceUrl = serviceUrlBuilder.Build("/rest/CreatioApiGateway/GetPackages");
 }
Exemple #8
0
 public static void TestAdd(int NumUser, int n, ClientContext cc, IApplicationClient ic, Action Completed)
 {
     ic.TestAdd(new TestAddRequest {
         Left = n - 1, Right = n + 1
     }).ContinueWith(t =>
     {
         var r = t.Result;
         Trace.Assert(r.Result == 2 * n);
         Completed();
     });
 }
Exemple #9
0
        private static async Task <bool> HandleLine(IApplicationClient InnerClient, Action <SecureContext> SetSecureContext, bool UseOld, string Line)
        {
            if (Line == "exit")
            {
                await InnerClient.Quit(new QuitRequest());

                return(false);
            }
            if (Line == "shutdown")
            {
                var r = await InnerClient.Shutdown(new ShutdownRequest());

                if (r.OnSuccess)
                {
                    Console.WriteLine("服务器正在关闭。");
                }
                return(false);
            }
            if (Line == "secure")
            {
                await InnerClient.SendMessage(new SendMessageRequest { Content = Line });

                //生成测试用确定Key
                var ServerToken = Enumerable.Range(0, 41).Select(i => (Byte)(i)).ToArray();
                var ClientToken = Enumerable.Range(0, 41).Select(i => (Byte)(40 - i)).ToArray();
                SetSecureContext(new SecureContext {
                    ServerToken = ServerToken, ClientToken = ClientToken
                });
            }
            else if (UseOld)
            {
                var r = await InnerClient.SendMessageAt1(new SendMessageAt1Request { Id = 1, Message = new MessageAt2 {
                                                                                         Title = "", Lines = new List <String> {
                                                                                             Line
                                                                                         }
                                                                                     } });

                if (r.OnTitleTooLong || r.OnLinesTooLong || r.OnLineTooLong)
                {
                    Console.WriteLine("消息过长。");
                }
            }
            else
            {
                var r = await InnerClient.SendMessage(new SendMessageRequest { Content = Line });

                if (r.OnTooLong)
                {
                    Console.WriteLine("消息过长。");
                }
            }
            return(true);
        }
Exemple #10
0
        public HealthCheckCommand(IApplicationClient applicationClient, EnvironmentSettings settings)
            : base(applicationClient, settings)
        {
            _handler = new HttpClientHandler();

            //Skip SSL cert validation
            _handler.ClientCertificateOptions = ClientCertificateOption.Manual;
            _handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, certChail, sslPolicyErrors) => {
                return(true);
            };

            _httpClient             = new HttpClient(_handler);
            _httpClient.BaseAddress = new Uri(RootPath);
        }
Exemple #11
0
        public string Execute(string sql, IApplicationClient applicationClient, EnvironmentSettings settings)
        {
            var scriptData = new {
                script = sql
            };
            string serializedRequestPayload = JsonConvert.SerializeObject(scriptData);
            string endpointUri = settings.IsNetCore
                                ? settings.Uri + ExecuteSqlScriptUrl
                                : settings.Uri + "/0" + ExecuteSqlScriptUrl;
            string responseFormServer = applicationClient.ExecutePostRequest(endpointUri,
                                                                             serializedRequestPayload);

            return(CorrectJson(responseFormServer));
        }
Exemple #12
0
        public static void TestMultiply(int NumUser, int n, ClientContext cc, IApplicationClient ic, Action Completed)
        {
            double v = n;
            var    o = v * 1000001 * 0.5;

            ic.TestMultiply(new TestMultiplyRequest {
                Operand = n
            }).ContinueWith(t =>
            {
                var r = t.Result;
                Trace.Assert(Math.Abs(r.Result - o) < 0.01);
                Completed();
            });
        }
Exemple #13
0
        public static void TestText(int NumUser, int n, ClientContext cc, IApplicationClient ic, Action Completed)
        {
            var    ss = n.ToString();
            String s  = String.Join("", Enumerable.Range(0, 10000 / ss.Length).Select(i => ss).ToArray()).Substring(0, 4096 - 256);

            ic.TestText(new TestTextRequest {
                Text = s
            }).ContinueWith(t =>
            {
                var r = t.Result;
                Trace.Assert(String.Equals(r.Result, s));
                Completed();
            });
        }
Exemple #14
0
        public void ClearRedisDb_FormsCorrectApplicationRequest_WhenApplicationRunsUnderNetCore()
        {
            IApplicationClient applicationClient = Substitute.For <IApplicationClient>();
            var testUri  = "TestUri";
            var settings = new EnvironmentSettings {
                Uri       = testUri,
                IsNetCore = true
            };
            RedisCommand redisCommand      = new RedisCommand(applicationClient, settings);
            var          clearRedisOptions = Substitute.For <ClearRedisOptions>();

            redisCommand.Execute(clearRedisOptions);
            applicationClient.Received(1).ExecutePostRequest(
                testUri + "/ServiceModel/AppInstallerService.svc/ClearRedisDb",
                "{}", Timeout.Infinite);
        }
Exemple #15
0
        public static void TestMessage(int NumUser, int n, ClientContext cc, IApplicationClient ic, Action Completed)
        {
            var s = n.ToString();

            ic.TestMessage(new TestMessageRequest {
                Message = s
            }).ContinueWith(t =>
            {
                //Trace.Assert(r.Success == cc.NumOnline);
                cc.Num -= 1;
                if (cc.Num == 0)
                {
                    Completed();
                }
            });
        }
Exemple #16
0
        public void Delete_FormsCorrectApplicationRequest_WhenApplicationRunsUnderNetFramework()
        {
            IApplicationClient   applicationClient = Substitute.For <IApplicationClient>();
            DeletePackageCommand deleteCommand     = new DeletePackageCommand(applicationClient);
            var deleteOptions = new DeletePkgOptions {
                Login      = "******",
                Password   = "******",
                IsNetCore  = false,
                Maintainer = "Test",
                Uri        = "http://test.domain.com",
                Name       = "TestPackage"
            };

            deleteCommand.Delete(deleteOptions);
            applicationClient.Received(1).ExecutePostRequest(
                deleteOptions.Uri + "/0/ServiceModel/AppInstallerService.svc/DeletePackage",
                "\"TestPackage\"", Arg.Any <int>());
        }
Exemple #17
0
        public void RestartCommand_FormsCorrectApplicationRequest_WhenApplicationRunsUnderNetCoreAndSettingsPickedFromEnvironment()
        {
            IApplicationClient applicationClient = Substitute.For <IApplicationClient>();
            var environmentSettings = new EnvironmentSettings {
                Login      = "******",
                Password   = "******",
                IsNetCore  = true,
                Maintainer = "Test",
                Uri        = "http://test.domain.com"
            };
            RestartCommand restartCommand = new RestartCommand(applicationClient, environmentSettings);
            var            options        = Substitute.For <RestartOptions>();

            restartCommand.Execute(options);
            applicationClient.Received(1).ExecutePostRequest(
                environmentSettings.Uri + "/ServiceModel/AppInstallerService.svc/RestartApp",
                "{}", Timeout.Infinite);
        }
Exemple #18
0
 public FeatureCommand(IApplicationClient applicationClient, EnvironmentSettings settings)
     : base(applicationClient, settings)
 {
 }
Exemple #19
0
 protected RemoteCommand(IApplicationClient applicationClient,
                         EnvironmentSettings environmentSettings)
 {
     ApplicationClient   = applicationClient;
     EnvironmentSettings = environmentSettings;
 }
Exemple #20
0
        public ZFingerDevice CreateZFingerDevice(IApplicationClient client)
        {
            ZFingerDevice ret = new ZFingerDevice(client.SessionId, client.SessionClient, client.FrameClient, client.TransportClient);

            return(ret);
        }
Exemple #21
0
 public RestartCommand(IApplicationClient applicationClient, EnvironmentSettings settings)
     : base(applicationClient, settings)
 {
 }
Exemple #22
0
 public SMDRParser(PBXConfiguration config, ILogger log, IMessageConnectionFactory cf,
                   IApplicationClient ac, IClock c) :
     base(config, log, cf, ac, c)
 {
     RegisterLexer(new CRLFByteSreamLineLexer());
 }
Exemple #23
0
 public static void TestMessageInitializeClientContext(int NumUser, int n, ClientContext cc, IApplicationClient ic, Action Completed)
 {
     ic.TestMessageReceived += e =>
     {
         var Done = false;
         lock (cc.Lockee)
         {
             cc.Sum += Int32.Parse(e.Message);
             cc.Num -= 1;
             Done    = cc.Num == 0;
         }
         if (Done)
         {
             Completed();
         }
     };
     cc.NumOnline = NumUser;
     cc.Num       = NumUser;
 }
Exemple #24
0
 public DeletePackageCommand(IApplicationClient applicationClient)
     : base(applicationClient)
 {
 }
Exemple #25
0
 public SqlScriptCommand(IApplicationClient applicationClient, EnvironmentSettings settings,
                         ISqlScriptExecutor sqlScriptExecutor)
     : base(applicationClient, settings)
 {
     _sqlScriptExecutor = sqlScriptExecutor;
 }
Exemple #26
0
 public static void TestQuit(int NumUser, int n, ClientContext cc, IApplicationClient ic, Action Completed)
 {
     ic.Quit(new QuitRequest {
     }).ContinueWith(t => Completed());
 }
 public DeletePackageCommand(IApplicationClient applicationClient, EnvironmentSettings settings)
     : base(applicationClient, settings)
 {
 }
Exemple #28
0
 public CompileWorkspaceCommand(IApplicationClient applicationClient, EnvironmentSettings settings)
     : base(applicationClient, settings)
 {
 }
Exemple #29
0
 public AssemblyCommand(IApplicationClient applicationClient, EnvironmentSettings settings)
     : base(applicationClient, settings)
 {
 }
 public GenerateModelsCommand(IApplicationClient applicationClient, EnvironmentSettings settings) :
     base(applicationClient, settings)
 {
 }