public ServiceBase(IOptions <AppSettings> appSettings)
 {
     _newskiesSettings = appSettings != null && appSettings.Value != null && appSettings.Value.NewskiesSettings != null ?
                         appSettings.Value.NewskiesSettings : throw new ArgumentNullException(nameof(appSettings.Value.NewskiesSettings));
     _navApiEndpoints   = _newskiesSettings.ServiceEndpoints;
     _navApiContractVer = _newskiesSettings.ApiContractVersion;
     _navMsgContractVer = _newskiesSettings.MsgContractVersion;
 }
        /// <summary>
        /// Returns a string representation of this <see cref="SignalROptions"/> instance.
        /// </summary>
        string IOptionsFormatter.Format()
        {
            var options = new JObject
            {
                { nameof(ServiceEndpoints), JArray.FromObject(ServiceEndpoints.Select(e => e.ToString())) },
                { nameof(ServiceTransportType), ServiceTransportType.ToString() },
                { nameof(JsonObjectSerializer), JsonObjectSerializer?.GetType().FullName }
            };

            return(options.ToString(Formatting.Indented));
        }
Beispiel #3
0
        public AggregateController(IMemoryCache memoryCache, IOptions <CacheOptions> cacheOptions, IOptions <ServiceEndpoints> serviceEndpoints)
        {
            _serviceEndpoints = serviceEndpoints.Value;

            if (!bool.TryParse(cacheOptions.Value.UseCache, out bool useCache))
            {
                useCache = true;
            }

            if (!double.TryParse(cacheOptions.Value.ExpireTimeMinutes, out double cacheExpireTime))
            {
                cacheExpireTime = 5; // in minutes, respecting the appsetting
            }

            _cacheManager = new CacheManager(memoryCache, useCache, cacheExpireTime);
        }
Beispiel #4
0
        async Task Invoke(IOwinContext context)
        {
            if (_state == null)
            {
                _state = new State(GetBaseAddress(context));
                await _state.Load(@"c:\data\test\nuspecs", CancellationToken.None);
            }

            try
            {
                switch (context.Request.Path.Value)
                {
                case "/":
                    context.Response.StatusCode = (int)HttpStatusCode.OK;
                    await context.Response.WriteAsync("READY");

                    break;

                case "/debug":
                    await Debug(context);

                    break;

                // basically
                case "/v3/query":
                    await ServiceEndpoints.V3SearchAsync(context, _state.SearcherManager);

                    break;

                case "/v3/autocomplete":
                    await ServiceEndpoints.AutoCompleteAsync(context, _state.SearcherManager);

                    break;

                default:
                    await Lookup(context);

                    break;
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        internal static Uri SelectBaseUri(
            ServiceEndpoints configuredEndpoints,
            Func <ServiceEndpoints, Uri> uriGetter,
            string description,
            Logger errorLogger
            )
        {
            var configuredUri = uriGetter(configuredEndpoints);

            if (configuredUri != null)
            {
                return(configuredUri);
            }
            errorLogger.Error(
                "You have set custom ServiceEndpoints without specifying the {0} base URI; connections may not work properly",
                description);
            return(uriGetter(BaseUris));
        }
        internal Configuration(ConfigurationBuilder builder)
        {
            AutoAliasingOptOut          = builder._autoAliasingOptOut;
            DataSourceFactory           = builder._dataSourceFactory;
            DiagnosticOptOut            = builder._diagnosticOptOut;
            EnableBackgroundUpdating    = builder._enableBackgroundUpdating;
            EvaluationReasons           = builder._evaluationReasons;
            EventProcessorFactory       = builder._eventProcessorFactory;
            HttpConfigurationBuilder    = builder._httpConfigurationBuilder;
            LoggingConfigurationBuilder = builder._loggingConfigurationBuilder;
            MobileKey = builder._mobileKey;
            Offline   = builder._offline;
            PersistenceConfigurationBuilder = builder._persistenceConfigurationBuilder;
            ServiceEndpoints = (builder._serviceEndpointsBuilder ?? Components.ServiceEndpoints()).Build();

            BackgroundModeManager    = builder._backgroundModeManager;
            ConnectivityStateManager = builder._connectivityStateManager;
            DeviceInfo = builder._deviceInfo;
        }
        // Not working because of https://github.com/reactiveui/refit/issues/717
        public static IServiceCollection AddExternalService <TService>(this IServiceCollection services, IConfiguration configuration) where TService : class
        {
            if (serviceEndpoints == null)
            {
                serviceEndpoints = configuration
                                   .GetSection(nameof(ServiceEndpoints))
                                   .Get <ServiceEndpoints>(config => config
                                                           .BindNonPublicProperties = true);
            }

            var serviceName = typeof(TService)
                              .Name.Substring(1)
                              .Replace("Service", string.Empty);

            services
            .AddRefitClient <TService>()
            .ConfigureHttpClient(c => c.BaseAddress = new Uri(serviceEndpoints[serviceName]));

            return(services);
        }
Beispiel #8
0
        protected override void OnStart(string[] args)
        {
            if (args.Length == 0)
            {
                // Retrieve the arguments from the service ImagePath
                args = Environment.GetCommandLineArgs();
            }

            string logSource = "_TransportEventLog";

            if (!EventLog.SourceExists(logSource))
            {
                EventLog.CreateEventSource(logSource, logSource);
            }

            EventLogTraceListener myTraceListener = new EventLogTraceListener(logSource);

            // Add the event log trace listener to the collection.
            Trace.Listeners.Add(myTraceListener);

            if (args.Length > 0)
            {
                if (((ICollection <string>)args).Contains("-debug"))
                {
                    Debug = true;
                }

                if (((ICollection <string>)args).Any(a => a.Contains("-timer")))
                {
                    IEnumerable <string> timerStrings = ((ICollection <string>)args).Where(a => a.Contains("-timer"));
                    if (timerStrings.Count() == 1)
                    {
                        try
                        {
                            string timerString  = timerStrings.First();
                            int    index        = timerString.IndexOf('=');
                            string timerSeconds = timerString.Substring(index + 1);
                            Timer = Convert.ToInt32(timerSeconds);
                        }
                        catch
                        {
                            Timer = 1;
                            EventLog.WriteEntry(SERVICE_NAME, "Error parsing the -timer command line argument.  Setting timer to 1 second.");
                        }
                    }
                }
            }

            EventLog.WriteEntry(SERVICE_NAME, "Starting...");
            Dictionary <string, string> argsMap = new Dictionary <string, string>();

            for (int i = 1; i < args.Length; i++)
            {
                argsMap.Add(args[i - 1], args[i++]);
            }

            // only allow localhost
            string listenAddress = null;

            if (!argsMap.TryGetValue("/P", out listenAddress))
            {
                listenAddress = "http://127.0.0.1:8181/";
                listenAddress = "8181";
            }

            ServiceEndpoints endpoints = new ServiceEndpoints();

            string callbackEndpoint = null;

            if (!argsMap.TryGetValue("/C", out callbackEndpoint))
            {
                callbackEndpoint = "http://localhost:8182/CloverCallback";
            }

            server = new CloverRESTServer("localhost", listenAddress, "http");// "127.0.0.1", listenAddress, "http");
            CloverRESTConnectorListener connectorListener = new CloverRESTConnectorListener();

            Console.WriteLine("callback endpoint: " + callbackEndpoint);
            connectorListener.RestClient   = new RestSharp.RestClient(callbackEndpoint);
            server.ForwardToClientListener = connectorListener;
            server.CloverConnector         = (CloverConnector)CloverConnectorFactory.createICloverConnector(new USBCloverDeviceConfiguration(null, getPOSNameAndVersion(), Debug, Timer));
            server.CloverConnector.AddCloverConnectorListener(connectorListener);
            server.CloverConnector.InitializeConnection();
            StartRESTListener();
            server.OnAfterStart += new ToggleServerHandler(this.OnServerStart);
            server.OnStop       += new ToggleServerHandler(this.OnServerStop);
        }
 internal static bool IsCustomUri(
     ServiceEndpoints configuredEndpoints,
     Func <ServiceEndpoints, Uri> uriGetter
     ) =>
 !uriGetter(BaseUris).Equals(uriGetter(configuredEndpoints));
Beispiel #10
0
 internal ServiceEndpointsBuilder(ServiceEndpoints copyFrom)
 {
     _streamingBaseUri = copyFrom.StreamingBaseUri;
     _pollingBaseUri   = copyFrom.PollingBaseUri;
     _eventsBaseUri    = copyFrom.EventsBaseUri;
 }
Beispiel #11
0
        public static void Main(string[] args)
        {
            string PAT         = string.Empty;
            string accountName = string.Empty;
            string projectName = string.Empty;

            Console.WriteLine("Please enter Account Name");
            accountName = Console.ReadLine();

            Console.WriteLine("Please enter Personel access token");
            PAT = Console.ReadLine();

            Console.WriteLine("Please enter project name");
            projectName = Console.ReadLine();


            Configuration sourceconfig = new Configuration()
            {
                UriString = "https://" + accountName + ".visualstudio.com:", PersonalAccessToken = PAT, Project = projectName
            };

            VstsRestAPI.Configuration vstsAPIConfiguration = new VstsRestAPI.Configuration()
            {
                UriString = "https://" + accountName + ".visualstudio.com:", PersonalAccessToken = PAT, Project = projectName
            };

            Console.WriteLine("Generating templates....");
            Console.WriteLine();


            Dictionary <string, string> queryList = new Dictionary <string, string>();
            ExportQueries objQuery = new ExportQueries(vstsAPIConfiguration);

            //queryList = objQuery.GetQueries(projectName);
            queryList = objQuery.GetQueriesByPath(projectName, string.Empty);

            ExportWidgetsAndCharts objWidgetAndCharts = new ExportWidgetsAndCharts(vstsAPIConfiguration);

            objWidgetAndCharts.GetWidgetsAndCharts(projectName, queryList);
            Console.WriteLine("Queries and widget JSONs are saved into Template folder");
            Console.WriteLine("");


            Teams objTeam = new Teams(vstsAPIConfiguration);

            objTeam.ExportTeams(projectName);
            Console.WriteLine("Teams JSON is saved into Template folder");
            Console.WriteLine("");

            ServiceEndpoints objService = new ServiceEndpoints(vstsAPIConfiguration);

            string serviceEndPoint = string.Empty;

            serviceEndPoint = objService.ExportServiceEndPoints(projectName);
            Console.WriteLine("ServiceEndPoint JSONs are saved into Template folder");
            Console.WriteLine("");

            SourceCode objSourceCode = new SourceCode(vstsAPIConfiguration);

            objSourceCode.ExportSourceCode(projectName);
            Console.WriteLine("ImportSourceCode JSON is saved into Template folder");
            Console.WriteLine("");

            BoardColumns objColumn = new BoardColumns(vstsAPIConfiguration);

            objColumn.ExportBoardColumns(projectName);
            Console.WriteLine("BoardColumn JSON file is saved into Template folder");
            Console.WriteLine("");

            GenerateWIFromSource wiql = new GenerateWIFromSource(sourceconfig, accountName);

            wiql.UpdateWorkItem();
            Console.WriteLine("Work item JSON files are saved into Templates folder");
            Console.WriteLine("");

            BuildDefinitions   objBuild   = new BuildDefinitions(vstsAPIConfiguration, accountName);
            ReleaseDefinitions objRelease = new ReleaseDefinitions(vstsAPIConfiguration, accountName);

            objBuild.ExportBuildDefinitions(projectName);
            objRelease.ExportReleaseDefinitions(projectName, serviceEndPoint);
            Console.WriteLine("Build and Release Definitions are saved into Templates folder");
            Console.WriteLine("");

            CardFieldsAndCardStyles objCards = new CardFieldsAndCardStyles(vstsAPIConfiguration);

            objCards.GetCardFields(projectName);
            objCards.GetCardStyles(projectName);
            Console.WriteLine("CardField and CardStyle JSON files are saved into Templates folder");
            Console.WriteLine("");

            Iterations objIterations = new Iterations(vstsAPIConfiguration, accountName);

            objIterations.GetIterations();
            Console.WriteLine("iterations JSON file is saved into Templates folder");
            Console.WriteLine("");

            PullRequests objPullRequest = new PullRequests(vstsAPIConfiguration);

            objPullRequest.ExportPullRequests(projectName);
            Console.WriteLine("PullReqests and comments JSON files are saved into Templates folder");
            Console.WriteLine("");

            Console.WriteLine("Completed generating templates from " + projectName);
            var wait = Console.ReadLine();
        }
        protected override void OnStart(string[] args)
        {
            string logSource = "_TransportEventLog";
            if (!EventLog.SourceExists(logSource))
                EventLog.CreateEventSource(logSource, logSource);

            EventLogTraceListener myTraceListener = new EventLogTraceListener(logSource);

            // Add the event log trace listener to the collection.
            Trace.Listeners.Add(myTraceListener);

            if (args.Length > 0)
            {
                if (((ICollection<string>)args).Contains("-debug"))
                {
                    Debug = true;
                }

                if (((ICollection<string>)args).Any(a => a.Contains("-timer")))
                {
                    IEnumerable<string> timerStrings = ((ICollection<string>)args).Where(a => a.Contains("-timer"));
                    if (timerStrings.Count() == 1)
                    {
                        try {
                            string timerString = timerStrings.First();
                            int index = timerString.IndexOf('=');
                            string timerSeconds = timerString.Substring(index + 1);
                            Timer = Convert.ToInt32(timerSeconds);
                        } catch (Exception e)
                        {
                            Timer = 1;
                            EventLog.WriteEntry(SERVICE_NAME, "Error parsing the -timer command line argument.  Setting timer to 1 second.");
                        }
                    }
                }
            }

            EventLog.WriteEntry(SERVICE_NAME, "Starting...");
            Dictionary<string, string> argsMap = new Dictionary<string, string>();
            for (int i = 1; i < args.Length; i++)
            {
                argsMap.Add(args[i - 1], args[i++]);
            }

            // only allow localhost
            string listenAddress = null;
            if (!argsMap.TryGetValue("/P", out listenAddress))
            {
                listenAddress = "http://127.0.0.1:8181/";
                listenAddress = "8181";
            }

            ServiceEndpoints endpoints = new ServiceEndpoints();

            string callbackEndpoint = null;
            if (!argsMap.TryGetValue("/C", out callbackEndpoint))
            {
                callbackEndpoint = "http://localhost:8182/CloverCallback";
            }

            server = new CloverRESTServer("localhost", listenAddress, "http");// "127.0.0.1", listenAddress, "http");
            CloverRESTConnectorListener connectorListener = new CloverRESTConnectorListener();
            Console.WriteLine("callback endpoint: " + callbackEndpoint);
            connectorListener.RestClient = new RestSharp.RestClient(callbackEndpoint);
            server.ForwardToClientListener = connectorListener;
            string webSocketEndpoint = null;
            if(argsMap.TryGetValue("/L", out webSocketEndpoint))
            {
                string[] tokens = webSocketEndpoint.Split(new char[]{':'});
                if(tokens.Length != 2) {
                    throw new Exception("Invalid host and port. must be <hostname>:<port>");
                }
                string hostname = tokens[0];
                int port = int.Parse(tokens[1]);
                server.CloverConnector = new CloverConnector(new WebSocketCloverDeviceConfiguration(hostname, port, getPOSNameAndVersion(), Debug, Timer));
            }
            else
            {
                server.CloverConnector = new CloverConnector(new USBCloverDeviceConfiguration(null, getPOSNameAndVersion(), Debug, Timer));
            }
            server.CloverConnector.InitializeConnection();
            server.CloverConnector.AddCloverConnectorListener(connectorListener);
            StartRESTListener();
            server.OnAfterStart += new ToggleServerHandler(this.OnServerStart);
            server.OnStop += new ToggleServerHandler(this.OnServerStop);
        }
Beispiel #13
0
 public void Setup()
 {
     this.serviceEndpoints = new();
 }