static LogStore() { var config = SelfHostConfigRetriever.GetHostConfig(); long flushTimerInterval = Convert.ToInt64(config.GetElementByName("logInterval").Value); timer = new Timer(flushTimerInterval); timer.Elapsed += timer_Elapsed; timer.Start(); }
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)); }
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); }
protected override void OnStart(string[] args) { EventLog eventLog = new EventLog(); eventLog.Source = WinServiceName; if (IsDebug == false) { eventLog.WriteEntry("Инициализация началась", EventLogEntryType.Information); } try {/* * //Пробуем подключиться...ХЫ * using (zapad_rootEntities db = new zapad_rootEntities()) * { * foreach (sys_EndPoint zulu in db.sys_EndPoint.Where(u => u.ServiceTypeId == Properties.Settings.Default.ServiceTypeId && !u.IsDisabled && !u.IsDebug).OrderBy(u => u.Priority)) * { * string sAdress = zulu.ServiceAddress; * * } * }*/ var config = SelfHostConfigRetriever.GetHostConfig(); var siteUrl = config.GetElementByName("url").Value; eventLog.WriteEntry(siteUrl, EventLogEntryType.Information); var server = WebApp.Start <Startup>(url: siteUrl); // using (var server = WebApp.Start<Startup>(url: siteUrl)) //{ // Thread.Sleep(Timeout.Infinite); // } if (WinService.IsDebug == false) { eventLog.WriteEntry("Инициализация завершена", EventLogEntryType.Information); } } catch (Exception e) { eventLog.WriteEntry("Ошибка при запуске: " + e.ExceptionToXElement().ToString(), EventLogEntryType.Error); this.Stop(); } }
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); }
protected override bool IsAuthorized(HttpActionContext actionContext) { var config = SelfHostConfigRetriever.GetHostConfig(); try { using (var context = new PrincipalContext(ContextType.Domain, config.GetElementByName("domain").Value)) { UserPrincipal user = UserPrincipal.FindByIdentity(context, Thread.CurrentPrincipal.Identity.Name); List <string> userGroupsNames = new List <string>(); if (user != null) { PrincipalSearchResult <Principal> groups = user.GetAuthorizationGroups(); foreach (Principal p in groups) { if (p is GroupPrincipal) { userGroupsNames.Add(p.Name.ToString()); } } var requiredGroups = Groups.Split(new char[] { ',' }); foreach (var requiredGroup in requiredGroups) { if (userGroupsNames.Contains(requiredGroup)) { return(true); } } } return(false); } } catch { return(false); } }
/// <summary> /// Возвращает время, когда истечет период действия сессии /// </summary> /// <returns></returns> public static DateTime GetTimeOutdateOfSession() { var config = SelfHostConfigRetriever.GetHostConfig(); return(DateTime.Now.AddSeconds(Convert.ToInt64(config.GetElementByName("dateOfOutdateSessions").Value))); }