Skip to content

Commit

Permalink
FIXES
Browse files Browse the repository at this point in the history
  • Loading branch information
zeppaman committed Apr 1, 2017
1 parent 6b60250 commit b507a90
Show file tree
Hide file tree
Showing 33 changed files with 296 additions and 134 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Wlog.Clients/bin/
Wlog.Clients/obj/
WLog.Loggers/obj/
WLog.Loggers/bin/
Wlog.TestApp/obj/
2 changes: 1 addition & 1 deletion Wlog.Library/BLL/Classes/LogMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class LogMessage
public DateTime SourceDate { get; set; }
public string Message { get; set; }
public string Level { get; set; }
public string ApplicationKey { get; private set; }
public string ApplicationKey { get; set; }
public string Stacktrace { get; set; }
/// <summary>
/// JSON string field to store custom attributes
Expand Down
2 changes: 1 addition & 1 deletion Wlog.Library/BLL/Classes/LogsSearchSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Wlog.Library.BLL.Classes
{
public class LogsSearchSettings:SearchSettingsBase
{
public string SearchMessage { get; set; }
public string SearchMessage { get; set; }
public List<Guid> Applications { get; set; }
public string OrderBy { get; set; }
public SortDirection SortDirection { get; set; }
Expand Down
20 changes: 5 additions & 15 deletions Wlog.Library/BLL/DataBase/NHibernateContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,14 @@ public static Configuration GetConfiguration()

Configuration cfg = new Configuration();

//if (System.Configuration.ConfigurationManager.AppSettings["_override_connectionstring"] != null)
//{
// cfg.SetProperty("_override_connectionstring", System.Configuration.ConfigurationManager.AppSettings["_override_connectionstring"]);
//}


//if (System.Configuration.ConfigurationManager.AppSettings["_override_connectionstring"] != null)
//{
// cfg.SetProperty("_override_connectionstring", System.Configuration.ConfigurationManager.AppSettings["_override_connectionstring"]);
//}
ModelMapper mapper = new ModelMapper();
mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());


//ModelMapper mapper = new ModelMapper();
//mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());

//HbmMapping domainMapping =
// mapper.CompileMappingForAllExplicitlyAddedEntities();
//cfg.AddMapping(domainMapping);
HbmMapping domainMapping =
mapper.CompileMappingForAllExplicitlyAddedEntities();
cfg.AddMapping(domainMapping);
cfg.Configure();

return cfg;
Expand Down
1 change: 1 addition & 0 deletions Wlog.Library/BLL/Helpers/InfoHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static string GetAssemblyAttribute<T>(Func<T, string> value, Assembly a)

public static AssemblyMetadata GetAssemblyMetadata(Assembly assembly)
{
if (assembly == null) return null;
logger.Debug("[ih] entering GetAssemblyMetadata");
AssemblyMetadata aa = new AssemblyMetadata();
aa.Title = GetAssemblyAttribute<AssemblyTitleAttribute>(a => (a != null) ? a.Title : String.Empty, assembly);
Expand Down
42 changes: 32 additions & 10 deletions Wlog.Library/BLL/Index/LuceneIndexManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public int UncommittedFiles
public bool Autocommit { get; set; }


private object reopen="";

public bool IsDirty
{
Expand All @@ -98,11 +99,14 @@ public LuceneIndexManager(string name, string path, LuceneConfigurationSettings

private void Init()
{
//TODO: [LOW] use factory or DI to setup analyzer, query parse, and other tuning attribute.
logger.Debug("[IndexManager] init");
analyzer = new StandardAnalyzer(global::Lucene.Net.Util.Version.LUCENE_30);
InitIndex();
parser = new QueryParser(global::Lucene.Net.Util.Version.LUCENE_30, "", analyzer);
lock (reopen)
{
//TODO: [LOW] use factory or DI to setup analyzer, query parse, and other tuning attribute.
logger.Debug("[IndexManager] init");
analyzer = new StandardAnalyzer(global::Lucene.Net.Util.Version.LUCENE_30);
InitIndex();
parser = new QueryParser(global::Lucene.Net.Util.Version.LUCENE_30, "", analyzer);
}
}

private void InitIndex()
Expand All @@ -113,9 +117,22 @@ private void InitIndex()
logger.Debug("[IndexManager] Opening {0}", Path);
luceneIndexDirectory = settings.GetLuceneIndexDirectory(Path);
logger.Debug("[IndexManager] Creating IndexWriter");
writer = new IndexWriter(luceneIndexDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
if (writer == null)
{
writer = new IndexWriter(luceneIndexDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
}
else
{
writer.Commit();
}
logger.Debug("[IndexManager] Creating IndexReader");
reader = IndexReader.Open(luceneIndexDirectory, true);
if (reader != null)
{
reader.Close();
}

reader = IndexReader.Open(luceneIndexDirectory, true);

logger.Debug("[IndexManager] Creating IndexSearcher");
searcher = new IndexSearcher(reader);
}
Expand Down Expand Up @@ -278,11 +295,15 @@ public IPagedList<Document> Query(Query query, Sort field, int start, int size)

private void ReopenIndex()
{
lock (reopen)
{

logger.Debug("[IndexManager] Reopen index");
logger.Debug("[IndexManager] Reopen index");

DisposeIndex();
InitIndex();
// DisposeIndex();

InitIndex();
}
}

public void Dispose()
Expand All @@ -306,6 +327,7 @@ public void DisposeIndex()
{
writer.Commit();
writer.Dispose();

}
catch (Exception err)
{
Expand Down
28 changes: 11 additions & 17 deletions Wlog.Web/Areas/HelpPage/Views/Help/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,29 @@
@model Collection<ApiDescription>

@{
ViewBag.Title = "ASP.NET Web API Help Page";
ViewBag.Title = "HubLink Api docs";

// Group APIs by controller
ILookup<string, ApiDescription> apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor.ControllerName);
}

<header>
<div class="content-wrapper">
<div class="float-left">
<h1>@ViewBag.Title</h1>
</div>


<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><i class="fa fa-link fa-fw" aria-hidden="true"></i> &nbsp; API</h1>
</div>
</header>
<div id="body">
<section class="featured">
<div class="content-wrapper">
<h2>Introduction</h2>
<p>
Provide a general description of your APIs here.
</p>
</div>
</section>
<!-- /.col-lg-12 -->
</div>


<section class="content-wrapper main-content clear-fix">
@foreach (var group in apiGroups)
{
@Html.DisplayFor(m => group, "ApiGroup")
}
</section>
</div>


@section Scripts {
<link type="text/css" href="~/Areas/HelpPage/HelpPage.css" rel="stylesheet" />
Expand Down
16 changes: 16 additions & 0 deletions Wlog.Web/Code/API/LogController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
//******************************************************************************
using NLog;
using System;
using System.Collections.Generic;
using System.Web.Http;
using Wlog.BLL.Classes;
using Wlog.Library.BLL.Reporitories;
using Wlog.Library.Scheduler;
using Wlog.Web.Resources;
using System.Linq;

namespace Wlog.Web.Code.API
{
Expand Down Expand Up @@ -51,8 +53,22 @@ private void SaveSingle(LogMessage value)
{
if (value == null) throw new Exception(Labels.LogMessageNull);

IEnumerable<string> headerValues;
var appKey = "";
var globalKey = false;
if (Request.Headers.TryGetValues("X-ApplicationKey",out headerValues))
{
appKey= headerValues.FirstOrDefault();
globalKey=appKey != null;
}


if (LogQueue.Current.MaxQueueSize > LogQueue.Current.Count)
{
if (globalKey)
{
value.SetApplication( appKey);
}
LogQueue.Current.Enqueue(value);
}
else
Expand Down
2 changes: 1 addition & 1 deletion Wlog.Web/Content/sb-admin-2.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ body {
#page-wrapper {
padding: 0 15px;
min-height: 568px;
/*background-color: #fff;*/
background-color: #fff;
}

@media(min-width:768px) {
Expand Down
4 changes: 4 additions & 0 deletions Wlog.Web/Controllers/InstallController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public JsonResult Validate(string connectionString, string driver, string dialec
{

var basePath = this.HttpContext.Server.MapPath("~/App_Data/Index/");
if (!Directory.Exists(basePath))
{
Directory.CreateDirectory(basePath);
}
var rdm = DateTime.Now.ToString("yyyyMMddHHmmss");
var testFile = System.IO.Path.Combine(basePath, rdm + "testfile.txt");
System.IO.File.WriteAllText(testFile, "xxx");
Expand Down
36 changes: 36 additions & 0 deletions Wlog.Web/Controllers/PrivateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,42 @@ public ActionResult DeleteUser(UserData user)
return View(user);
}

#region Logs
public JsonResult Search(Guid? applicationId, string sortOrder, string sortBy, string serchMessage, int page, int pageSize)
{

_logger.Debug("[Private]: Search");
//TDOD: CHECK USER
var result = new JsonResult();

LogsSearchSettings lss = new LogsSearchSettings();
if (applicationId.HasValue)
{
lss.Applications = new List<Guid>();
lss.Applications.Add(applicationId.Value);
}
lss.OrderBy = sortBy;
lss.PageNumber = page;
lss.PageSize = pageSize;
lss.FullTextQuery = serchMessage??"";
lss.SortDirection = ("ASC".Equals(sortOrder, StringComparison.InvariantCultureIgnoreCase)) ? SortDirection.ASC : SortDirection.DESC;

IPagedList list = RepositoryContext.Current.Logs.SearchLogindex(applicationId.Value, lss);

result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

result.Data = new
{
draw = Request["draw"],
recordsTotal = list.TotalItemCount,
recordsFiltered = list.TotalItemCount,
data = list
};
return result;
}

#endregion

#region Application
// Get /Private/ListApps
[AuthorizeRoles(Constants.Roles.Admin, Constants.Roles.ReadLog)]
Expand Down
14 changes: 2 additions & 12 deletions Wlog.Web/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,12 @@ protected void Application_Start()

Mapper.Initialize(cfg => cfg.AddProfile(new ApplicationProfile()));

_logger.Info("Apply schema changes");
SystemDataInitialisation.Instance.ApplySchemaChanges();

_logger.Info("Setup info config");

InfoPageConfigurator.Configure(c =>
{
c.ApplicationName = "Wlog";
});



if (installed)
{
//TODO: move this in installation process



_logger.Info("Apply schema changes");
RepositoryContext.Current.System.ApplySchemaChanges();
Expand Down
Binary file added Wlog.Web/Images/HubLinkLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Wlog.Web/Images/HubLinkLogopng.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Wlog.Web/Views/Account/Login.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<div class="panel-heading">
<div class="panel-title text-center">

<h1 class="title"> WLOG</h1>
<h1 class="title">
<img src="~/Images/HubLinkLogo.png" height="50"/> </h1>

</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion Wlog.Web/Views/Install/Install.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@
<div class="container">

<div class="page-title">
<h1>wlog: install</h1>
<img src="~/Images/HubLinkLogo.png" height="30" style="margin-top:30px"/>
<h1>Install</h1>
<p class="lead">We are ready to install this application. Please fill some basic information and start setup. Configuration can be changed at anytime by editing manually web.config file.</p>

</div>

<div class="alert alert-danger" role="alert"><b>PASSWORD:</b> will be set to 123456578 as temporary passoword. Please change it at first login.</div>

<div class="row marketing">
<div class="panel panel-default">

Expand Down
11 changes: 8 additions & 3 deletions Wlog.Web/Views/Private/BackgroundJobs.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
}


<div class="page-header">
<h1><i class="fa fa-cogs" aria-hidden="true"></i> &nbsp; Background Jobs Management </h1>
</div>
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><i class="fa fa-cogs" aria-hidden="true"></i> &nbsp; Background Jobs Management </h1>
</div>
<!-- /.col-lg-12 -->
</div>



<div class="row">

Expand Down
9 changes: 7 additions & 2 deletions Wlog.Web/Views/Private/DeleteApp.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
ViewBag.Title = "Delete App";
Layout = "~/Views/Shared/_LayoutInternal.cshtml";
}
<div class="page-header">
<h1><i class="fa fa-cog" aria-hidden="true"></i> &nbsp; Delete Application: <i>@Model.ApplicationName</i></h1>


<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><i class="fa fa-cog" aria-hidden="true"></i> &nbsp; Delete Application: <i>@Model.ApplicationName</i></h1>
</div>
<!-- /.col-lg-12 -->
</div>
<div class="row">
<h3>Are you sure you want to delete this?</h3>

Expand Down
12 changes: 10 additions & 2 deletions Wlog.Web/Views/Private/DeleteUser.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
Layout = "~/Views/Shared/_LayoutInternal.cshtml";
}

<div class="page-header">
<h1><i class="fa fa-user" aria-hidden="true"></i> &nbsp; Delete User: <i>@Model.Username</i></h1>



<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><i class="fa fa-user" aria-hidden="true"></i> &nbsp; Delete User: <i>@Model.Username</i></h1>
</div>
<!-- /.col-lg-12 -->
</div>

<div class="row">

<h3>Are you sure you want to delete user <i> @Html.DisplayFor(model => model.Username, new { @class = "form-control" }) </i>?</h3>
Expand Down Expand Up @@ -78,3 +85,4 @@
</p>
}

</div>
Loading

0 comments on commit b507a90

Please sign in to comment.