private void onTimer(object sender, ElapsedEventArgs e)
        {
            _synchronizeInvoke.BeginInvoke(new Action(async() =>
            {
                if (isConnected() || _checking)
                {
                    return;
                }

                _checking = true;
                try
                {
                    string token = HostProperties.GetAccessToken(HostName);
                    ConnectionCheckStatus result = await ConnectionChecker.CheckConnectionAsync(HostName, token);
                    if (!isConnected() && result == ConnectionCheckStatus.OK)
                    {
                        // isConnected() check is needed because connection has been probably already restored
                        // while we awaited for a CheckConnectionAsync() result
                        Trace.TraceInformation("[GitLabInstance] ConnectionChecker.CheckConnection() returned OK");
                        onConnectionRestored();
                    }
                }
                finally
                {
                    _checking = false;
                }
            }), null);
        }
Beispiel #2
0
        private void SetExtension(HostProperties props, string extension)
        {
            if (props.ActorSystemConfig.Extensions.Contains(extension))
            {
                return;
            }

            props.ActorSystemConfig.Extensions.Add(extension);
        }
Beispiel #3
0
        private HostProperties FillMissingProps(HostProperties props)
        {
            if (string.IsNullOrEmpty(props.TempDirectory))
            {
                props.TempDirectory = GetSubRootDir(props.Id, TEMP_DIR_NAME);
            }
            if (string.IsNullOrEmpty(props.DataDirectory))
            {
                props.DataDirectory = GetSubRootDir(props.Id, DATA_DIR_NAME);
            }

            SetExtension(props, "Akka.Cluster.Tools.PublishSubscribe.DistributedPubSubExtensionProvider,Akka.Cluster.Tools");

            return(props);
        }
Beispiel #4
0
        public MopHost(HostProperties p, MopLifeService life, IInjectorService injector)
        {
            if (p.DataDirectory is null)
            {
                throw new ArgumentNullException("Data directory is null");
            }
            if (p.TempDirectory is null)
            {
                throw new ArgumentNullException("Temp directory is null");
            }

            Info          = BuildHostInfo(p.Id, p.Name);
            DataDirectory = new DirectoryInfo(p.DataDirectory);
            TempDirectory = new DirectoryInfo(p.TempDirectory);
            _lifeHandler  = life;
            _injector     = injector;
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            HostProperties properties = new HostProperties(
                "nmindcompanionhost",
                "Nmind Companion Host",
                new string[] { "phehpbpffhpnbhgmlmipddaoplhcakcj" },
                new string[] { "*****@*****.**" }
                );

            endpoint = new Endpoint(properties);
            endpoint.LoadHandlers(typeof(DefaultHandlers));
            endpoint.LoadHandlers(typeof(PrinterHandlers));
            endpoint.LoadHandlers(typeof(EpaymentHandlers));
            endpoint.LoadHandlers(typeof(CompanionHandlers));

#if DEBUG
            EnableLog(true);
#else
            EnableLog(false);
#endif

            //endpoint.TestMode = true;
            //endpoint.Test(RequestBuilder.From("{'name':'companion.pause', 'id':'123456789', 'async':true}").Silent(true).Create());
            //endpoint.Test(RequestBuilder.From("{'name':'companion.echo','params':'foo'}").Async(true).Create());

            //endpoint.Test(RequestBuilder.From("{'name':'companion.printers.list','params': null}").Async(true).Create());
            //endpoint.Test(RequestBuilder.From("{'name':'companion.serialPorts.list','params': null}").Async(true).Create());

            //endpoint.Test(RequestBuilder.From("{'name':'companion.epayment.ping','params':{'port' : 'COM4', 'device' : 'ict250', 'protocol' : 'Concert-V2'}}").Async(false).Create());
            //endpoint.Test(RequestBuilder.From("{'name':'companion.epayment.process','params':{'amount' : 50.22, 'port' : 'COM4', 'device' : 'ict250', 'protocol' : 'Concert-V2', 'pos' : 88, 'data' : 'AQUAO'}}").Async(true).Create());
            //endpoint.Test(RequestBuilder.From("{'name':'companion.epayment.test','params':{'payload' : '0100000561519782001001001'}}").Async(false).Create());
            //endpoint.Test(RequestBuilder.From("{'name':'companion.epayment.test','params':{'payload' : '010000056001_5017670200028629   0000000000000000000000000000000000_9782001001001'}}").Async(false).Create());

            //endpoint.Test(RequestBuilder.Route("companion.version").Create());
            //endpoint.Test(RequestBuilder.Route("companion.ping").Create());
            //endpoint.Test(RequestBuilder.Route("companion.location.open").With("filepath", "C:/Users/numer/Downloads/").Delay(1000 *10).Async(true).Silent(true).Create());
            //endpoint.Test(RequestBuilder.Route("companion.exit").Async(true).Create());

            //endpoint.Test(RequestBuilder.From(@"{'name':'companion.printers.test','params':{'printerName':'Microsoft Print to PDF'}}").Create());

            //endpoint.Test(RequestBuilder.From("{'name':'companion.document.print','params':{'printerName':'Brother MFC-7460DN Printer','path':'C:/Users/numer/Downloads/34020_29300.pdf'}}").Create());
            //endpoint.Test(RequestBuilder.From("{'name':'companion.document.print','params':{'printerName':'Brother MFC-7460DN Printer','path':'C:/Users/numer/Downloads/ttt.docx'}}").Create());

            Run(args);
        }
        async private Task <GitLabVersion> getVersionAsync()
        {
            string token = HostProperties.GetAccessToken(HostName);

            using (GitLabTaskRunner client = new GitLabTaskRunner(HostName, token))
            {
                try
                {
                    return((GitLabVersion)(await client.RunAsync(async(gl) => await gl.Version.LoadTaskAsync())));
                }
                catch (GitLabSharpException ex)
                {
                    ExceptionHandlers.Handle("Cannot obtain GitLab server version", ex);
                }
                catch (GitLabRequestException ex)
                {
                    ExceptionHandlers.Handle("Cannot obtain GitLab server version", ex);
                }
                catch (GitLabTaskRunnerCancelled)
                {
                }
                return(null);
            }
        }
Beispiel #7
0
 public static ActorSystem BuildFrom(HostProperties props)
 => new ActorSystemFactory(props).Build();
Beispiel #8
0
 public ActorSystemFactory(HostProperties props)
 {
     _config = props.ActorSystemConfig;
     _id     = props.Id;
 }