Esempio n. 1
0
        public void Configuration(IAppBuilder appBuilder)
        {
            // Регистрируем и конфигурируем SignalR
            appBuilder.Map("/signalr", map => {
                map.UseCors(CorsOptions.AllowAll);
                map.MapSignalR();
            });

            HttpConfiguration selfHostConfig = new HttpConfiguration();

            selfHostConfig.Routes.MapHttpRoute(name: "DefaultApiRoute", routeTemplate: "api/{controller}", defaults: null);
            //selfHostConfig.Routes.MapHttpRoute(name: "DefaultApiWithId", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional });
            selfHostConfig.Routes.MapHttpRoute(name: "DefaultApiWithAction", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional });

            var config = SelfHostConfigRetriever.GetHostConfig();

            if (config.GetElementByName("authentication").Value == "yes")
            {
                HttpListener listener = (HttpListener)appBuilder.Properties["System.Net.HttpListener"];
                listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication;
            }

            selfHostConfig.MessageHandlers.Add(new MessageLoggingHandler());
            selfHostConfig.Services.Add(typeof(IExceptionLogger), new TraceExceptionLogger());

            SessionSet.Create(Settings.Default.msSessionLifiTime);

            WebApiSync.Create(Settings.Default.WebApiSyncUrls, "" /*/Settings.Default.CertificateToZoneThumbprint/*/, Settings.Default.msPingZoneInterval,
                              Settings.Default.PingRequestsCount, Settings.Default.NoPingNotifyInterval.TotalMilliseconds);
            appBuilder.UseWebApi(selfHostConfig);
        }
Esempio n. 2
0
        protected override void OnStart(string[] args)
        {
            EventLog eventLog = new EventLog();

            eventLog.Source = WinServiceName;
            if (IsDebug == false)
            {
                eventLog.WriteEntry("Инициализация началась", EventLogEntryType.Information);
            }
            try
            {
                var config  = SelfHostConfigRetriever.GetHostConfig();
                var siteUrl = config.GetElementByName("url").Value;
                WebApp.Start <Startup>(url: siteUrl);

                if (WinService.IsDebug == false)
                {
                    eventLog.WriteEntry("Инициализация завершена", EventLogEntryType.Information);
                }
            }
            catch (Exception e)
            {
                eventLog.WriteEntry("Ошибка при запуске: " + e.ExceptionToXElement().ToString(), EventLogEntryType.Error);
                this.Stop();
            }
        }
Esempio n. 3
0
        static SessionStore()
        {
            var  config             = SelfHostConfigRetriever.GetHostConfig();
            long flushTimerInterval = Convert.ToInt64(config.GetElementByName("sessionInterval").Value);

            timer          = new Timer(flushTimerInterval);
            timer.Elapsed += timer_Elapsed;
            timer.Start();
        }
Esempio n. 4
0
        public Session(DateTime lifeTime, string ipAdress)
        {
            this.IsAuthentificated = false;
            SetIpAdress(ipAdress);
            ExpirationTime = lifeTime;

            var config = SelfHostConfigRetriever.GetHostConfig();

            LastQueries = new Queue <string>(Convert.ToInt32(config.GetElementByName("sizeQueueOfLastQueries").Value));
        }
Esempio n. 5
0
        public static void AddQueryToLastQueries(Guid guid, string url)
        {
            var config = SelfHostConfigRetriever.GetHostConfig();

            if (sessions[guid].LastQueries.Count == Convert.ToInt32(config.GetElementByName("sizeQueueOfLastQueries").Value))
            {
                sessions[guid].LastQueries.Dequeue();
            }

            sessions[guid].LastQueries.Enqueue(url);
        }
Esempio n. 6
0
        public void Configuration(IAppBuilder appBuilder)
        {
            HttpConfiguration selfHostConfig = new HttpConfiguration();

            selfHostConfig.Routes.MapHttpRoute(name: "DefaultApiRoute", routeTemplate: "api/{controller}", defaults: null);
            //selfHostConfig.Routes.MapHttpRoute(name: "DefaultApiWithId", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional });
            selfHostConfig.Routes.MapHttpRoute(name: "DefaultApiWithAction", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional });

            var config = SelfHostConfigRetriever.GetHostConfig();

            if (config.GetElementByName("authentication").Value == "yes")
            {
                HttpListener listener = (HttpListener)appBuilder.Properties["System.Net.HttpListener"];
                listener.AuthenticationSchemes = AuthenticationSchemes.IntegratedWindowsAuthentication;
            }

            selfHostConfig.MessageHandlers.Add(new MessageLoggingHandler());
            selfHostConfig.Services.Add(typeof(IExceptionLogger), new TraceExceptionLogger());

            appBuilder.UseWebApi(selfHostConfig);
        }
Esempio n. 7
0
        /// <summary>
        /// Возвращает время, когда истечет период действия сессии
        /// </summary>
        /// <returns></returns>
        public static DateTime GetTimeOutdateOfSession()
        {
            var config = SelfHostConfigRetriever.GetHostConfig();

            return(DateTime.Now.AddSeconds(Convert.ToInt64(config.GetElementByName("dateOfOutdateSessions").Value)));
        }