예제 #1
0
파일: Startup.cs 프로젝트: decluga/ZapadCRM
        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);
        }
예제 #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();
            }
        }
예제 #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();
        }
예제 #4
0
파일: Session.cs 프로젝트: decluga/ZapadCRM
        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));
        }
예제 #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);
        }
예제 #6
0
파일: Startup.cs 프로젝트: decluga/ZapadCRM
        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);
        }
예제 #7
0
        /// <summary>
        /// Возвращает время, когда истечет период действия сессии
        /// </summary>
        /// <returns></returns>
        public static DateTime GetTimeOutdateOfSession()
        {
            var config = SelfHostConfigRetriever.GetHostConfig();

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