Skip to content

Commit b507a90

Browse files
committed
FIXES
1 parent 6b60250 commit b507a90

33 files changed

+296
-134
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ Wlog.Clients/bin/
2020
Wlog.Clients/obj/
2121
WLog.Loggers/obj/
2222
WLog.Loggers/bin/
23+
Wlog.TestApp/obj/

Wlog.Library/BLL/Classes/LogMessage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class LogMessage
1818
public DateTime SourceDate { get; set; }
1919
public string Message { get; set; }
2020
public string Level { get; set; }
21-
public string ApplicationKey { get; private set; }
21+
public string ApplicationKey { get; set; }
2222
public string Stacktrace { get; set; }
2323
/// <summary>
2424
/// JSON string field to store custom attributes

Wlog.Library/BLL/Classes/LogsSearchSettings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Wlog.Library.BLL.Classes
1414
{
1515
public class LogsSearchSettings:SearchSettingsBase
1616
{
17-
public string SearchMessage { get; set; }
17+
public string SearchMessage { get; set; }
1818
public List<Guid> Applications { get; set; }
1919
public string OrderBy { get; set; }
2020
public SortDirection SortDirection { get; set; }

Wlog.Library/BLL/DataBase/NHibernateContext.cs

+5-15
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,14 @@ public static Configuration GetConfiguration()
3333

3434
Configuration cfg = new Configuration();
3535

36-
//if (System.Configuration.ConfigurationManager.AppSettings["_override_connectionstring"] != null)
37-
//{
38-
// cfg.SetProperty("_override_connectionstring", System.Configuration.ConfigurationManager.AppSettings["_override_connectionstring"]);
39-
//}
4036

4137

42-
//if (System.Configuration.ConfigurationManager.AppSettings["_override_connectionstring"] != null)
43-
//{
44-
// cfg.SetProperty("_override_connectionstring", System.Configuration.ConfigurationManager.AppSettings["_override_connectionstring"]);
45-
//}
38+
ModelMapper mapper = new ModelMapper();
39+
mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
4640

47-
48-
//ModelMapper mapper = new ModelMapper();
49-
//mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
50-
51-
//HbmMapping domainMapping =
52-
// mapper.CompileMappingForAllExplicitlyAddedEntities();
53-
//cfg.AddMapping(domainMapping);
41+
HbmMapping domainMapping =
42+
mapper.CompileMappingForAllExplicitlyAddedEntities();
43+
cfg.AddMapping(domainMapping);
5444
cfg.Configure();
5545

5646
return cfg;

Wlog.Library/BLL/Helpers/InfoHelper.cs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static string GetAssemblyAttribute<T>(Func<T, string> value, Assembly a)
3939

4040
public static AssemblyMetadata GetAssemblyMetadata(Assembly assembly)
4141
{
42+
if (assembly == null) return null;
4243
logger.Debug("[ih] entering GetAssemblyMetadata");
4344
AssemblyMetadata aa = new AssemblyMetadata();
4445
aa.Title = GetAssemblyAttribute<AssemblyTitleAttribute>(a => (a != null) ? a.Title : String.Empty, assembly);

Wlog.Library/BLL/Index/LuceneIndexManager.cs

+32-10
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public int UncommittedFiles
7373
public bool Autocommit { get; set; }
7474

7575

76+
private object reopen="";
7677

7778
public bool IsDirty
7879
{
@@ -98,11 +99,14 @@ public LuceneIndexManager(string name, string path, LuceneConfigurationSettings
9899

99100
private void Init()
100101
{
101-
//TODO: [LOW] use factory or DI to setup analyzer, query parse, and other tuning attribute.
102-
logger.Debug("[IndexManager] init");
103-
analyzer = new StandardAnalyzer(global::Lucene.Net.Util.Version.LUCENE_30);
104-
InitIndex();
105-
parser = new QueryParser(global::Lucene.Net.Util.Version.LUCENE_30, "", analyzer);
102+
lock (reopen)
103+
{
104+
//TODO: [LOW] use factory or DI to setup analyzer, query parse, and other tuning attribute.
105+
logger.Debug("[IndexManager] init");
106+
analyzer = new StandardAnalyzer(global::Lucene.Net.Util.Version.LUCENE_30);
107+
InitIndex();
108+
parser = new QueryParser(global::Lucene.Net.Util.Version.LUCENE_30, "", analyzer);
109+
}
106110
}
107111

108112
private void InitIndex()
@@ -113,9 +117,22 @@ private void InitIndex()
113117
logger.Debug("[IndexManager] Opening {0}", Path);
114118
luceneIndexDirectory = settings.GetLuceneIndexDirectory(Path);
115119
logger.Debug("[IndexManager] Creating IndexWriter");
116-
writer = new IndexWriter(luceneIndexDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
120+
if (writer == null)
121+
{
122+
writer = new IndexWriter(luceneIndexDirectory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
123+
}
124+
else
125+
{
126+
writer.Commit();
127+
}
117128
logger.Debug("[IndexManager] Creating IndexReader");
118-
reader = IndexReader.Open(luceneIndexDirectory, true);
129+
if (reader != null)
130+
{
131+
reader.Close();
132+
}
133+
134+
reader = IndexReader.Open(luceneIndexDirectory, true);
135+
119136
logger.Debug("[IndexManager] Creating IndexSearcher");
120137
searcher = new IndexSearcher(reader);
121138
}
@@ -278,11 +295,15 @@ public IPagedList<Document> Query(Query query, Sort field, int start, int size)
278295

279296
private void ReopenIndex()
280297
{
298+
lock (reopen)
299+
{
281300

282-
logger.Debug("[IndexManager] Reopen index");
301+
logger.Debug("[IndexManager] Reopen index");
283302

284-
DisposeIndex();
285-
InitIndex();
303+
// DisposeIndex();
304+
305+
InitIndex();
306+
}
286307
}
287308

288309
public void Dispose()
@@ -306,6 +327,7 @@ public void DisposeIndex()
306327
{
307328
writer.Commit();
308329
writer.Dispose();
330+
309331
}
310332
catch (Exception err)
311333
{

Wlog.Web/Areas/HelpPage/Views/Help/Index.cshtml

+11-17
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,29 @@
55
@model Collection<ApiDescription>
66

77
@{
8-
ViewBag.Title = "ASP.NET Web API Help Page";
8+
ViewBag.Title = "HubLink Api docs";
99

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

14-
<header>
15-
<div class="content-wrapper">
16-
<div class="float-left">
17-
<h1>@ViewBag.Title</h1>
18-
</div>
14+
15+
16+
<div class="row">
17+
<div class="col-lg-12">
18+
<h1 class="page-header"><i class="fa fa-link fa-fw" aria-hidden="true"></i> &nbsp; API</h1>
1919
</div>
20-
</header>
21-
<div id="body">
22-
<section class="featured">
23-
<div class="content-wrapper">
24-
<h2>Introduction</h2>
25-
<p>
26-
Provide a general description of your APIs here.
27-
</p>
28-
</div>
29-
</section>
20+
<!-- /.col-lg-12 -->
21+
</div>
22+
23+
3024
<section class="content-wrapper main-content clear-fix">
3125
@foreach (var group in apiGroups)
3226
{
3327
@Html.DisplayFor(m => group, "ApiGroup")
3428
}
3529
</section>
36-
</div>
30+
3731

3832
@section Scripts {
3933
<link type="text/css" href="~/Areas/HelpPage/HelpPage.css" rel="stylesheet" />

Wlog.Web/Code/API/LogController.cs

+16
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
//******************************************************************************
99
using NLog;
1010
using System;
11+
using System.Collections.Generic;
1112
using System.Web.Http;
1213
using Wlog.BLL.Classes;
1314
using Wlog.Library.BLL.Reporitories;
1415
using Wlog.Library.Scheduler;
1516
using Wlog.Web.Resources;
17+
using System.Linq;
1618

1719
namespace Wlog.Web.Code.API
1820
{
@@ -51,8 +53,22 @@ private void SaveSingle(LogMessage value)
5153
{
5254
if (value == null) throw new Exception(Labels.LogMessageNull);
5355

56+
IEnumerable<string> headerValues;
57+
var appKey = "";
58+
var globalKey = false;
59+
if (Request.Headers.TryGetValues("X-ApplicationKey",out headerValues))
60+
{
61+
appKey= headerValues.FirstOrDefault();
62+
globalKey=appKey != null;
63+
}
64+
65+
5466
if (LogQueue.Current.MaxQueueSize > LogQueue.Current.Count)
5567
{
68+
if (globalKey)
69+
{
70+
value.SetApplication( appKey);
71+
}
5672
LogQueue.Current.Enqueue(value);
5773
}
5874
else

Wlog.Web/Content/sb-admin-2.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ body {
1515
#page-wrapper {
1616
padding: 0 15px;
1717
min-height: 568px;
18-
/*background-color: #fff;*/
18+
background-color: #fff;
1919
}
2020

2121
@media(min-width:768px) {

Wlog.Web/Controllers/InstallController.cs

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ public JsonResult Validate(string connectionString, string driver, string dialec
118118
{
119119

120120
var basePath = this.HttpContext.Server.MapPath("~/App_Data/Index/");
121+
if (!Directory.Exists(basePath))
122+
{
123+
Directory.CreateDirectory(basePath);
124+
}
121125
var rdm = DateTime.Now.ToString("yyyyMMddHHmmss");
122126
var testFile = System.IO.Path.Combine(basePath, rdm + "testfile.txt");
123127
System.IO.File.WriteAllText(testFile, "xxx");

Wlog.Web/Controllers/PrivateController.cs

+36
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,42 @@ public ActionResult DeleteUser(UserData user)
270270
return View(user);
271271
}
272272

273+
#region Logs
274+
public JsonResult Search(Guid? applicationId, string sortOrder, string sortBy, string serchMessage, int page, int pageSize)
275+
{
276+
277+
_logger.Debug("[Private]: Search");
278+
//TDOD: CHECK USER
279+
var result = new JsonResult();
280+
281+
LogsSearchSettings lss = new LogsSearchSettings();
282+
if (applicationId.HasValue)
283+
{
284+
lss.Applications = new List<Guid>();
285+
lss.Applications.Add(applicationId.Value);
286+
}
287+
lss.OrderBy = sortBy;
288+
lss.PageNumber = page;
289+
lss.PageSize = pageSize;
290+
lss.FullTextQuery = serchMessage??"";
291+
lss.SortDirection = ("ASC".Equals(sortOrder, StringComparison.InvariantCultureIgnoreCase)) ? SortDirection.ASC : SortDirection.DESC;
292+
293+
IPagedList list = RepositoryContext.Current.Logs.SearchLogindex(applicationId.Value, lss);
294+
295+
result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
296+
297+
result.Data = new
298+
{
299+
draw = Request["draw"],
300+
recordsTotal = list.TotalItemCount,
301+
recordsFiltered = list.TotalItemCount,
302+
data = list
303+
};
304+
return result;
305+
}
306+
307+
#endregion
308+
273309
#region Application
274310
// Get /Private/ListApps
275311
[AuthorizeRoles(Constants.Roles.Admin, Constants.Roles.ReadLog)]

Wlog.Web/Global.asax.cs

+2-12
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,12 @@ protected void Application_Start()
4646

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

49-
_logger.Info("Apply schema changes");
50-
SystemDataInitialisation.Instance.ApplySchemaChanges();
51-
52-
_logger.Info("Setup info config");
53-
54-
InfoPageConfigurator.Configure(c =>
55-
{
56-
c.ApplicationName = "Wlog";
57-
58-
});
49+
5950

6051

6152
if (installed)
6253
{
63-
//TODO: move this in installation process
64-
54+
6555

6656
_logger.Info("Apply schema changes");
6757
RepositoryContext.Current.System.ApplySchemaChanges();

Wlog.Web/Images/HubLinkLogo.png

5.04 KB
Loading

Wlog.Web/Images/HubLinkLogopng.png

5.23 KB
Loading

Wlog.Web/Views/Account/Login.cshtml

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
<div class="panel-heading">
1414
<div class="panel-title text-center">
1515

16-
<h1 class="title"> WLOG</h1>
16+
<h1 class="title">
17+
<img src="~/Images/HubLinkLogo.png" height="50"/> </h1>
1718

1819
</div>
1920
</div>

Wlog.Web/Views/Install/Install.cshtml

+4-1
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@
4848
<div class="container">
4949

5050
<div class="page-title">
51-
<h1>wlog: install</h1>
51+
<img src="~/Images/HubLinkLogo.png" height="30" style="margin-top:30px"/>
52+
<h1>Install</h1>
5253
<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>
5354

5455
</div>
5556

57+
<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>
58+
5659
<div class="row marketing">
5760
<div class="panel panel-default">
5861

Wlog.Web/Views/Private/BackgroundJobs.cshtml

+8-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
}
77

88

9-
<div class="page-header">
10-
<h1><i class="fa fa-cogs" aria-hidden="true"></i> &nbsp; Background Jobs Management </h1>
11-
</div>
9+
<div class="row">
10+
<div class="col-lg-12">
11+
<h1 class="page-header"><i class="fa fa-cogs" aria-hidden="true"></i> &nbsp; Background Jobs Management </h1>
12+
</div>
13+
<!-- /.col-lg-12 -->
14+
</div>
15+
16+
1217

1318
<div class="row">
1419

Wlog.Web/Views/Private/DeleteApp.cshtml

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
ViewBag.Title = "Delete App";
55
Layout = "~/Views/Shared/_LayoutInternal.cshtml";
66
}
7-
<div class="page-header">
8-
<h1><i class="fa fa-cog" aria-hidden="true"></i> &nbsp; Delete Application: <i>@Model.ApplicationName</i></h1>
7+
8+
9+
<div class="row">
10+
<div class="col-lg-12">
11+
<h1 class="page-header"><i class="fa fa-cog" aria-hidden="true"></i> &nbsp; Delete Application: <i>@Model.ApplicationName</i></h1>
912
</div>
13+
<!-- /.col-lg-12 -->
14+
</div>
1015
<div class="row">
1116
<h3>Are you sure you want to delete this?</h3>
1217

Wlog.Web/Views/Private/DeleteUser.cshtml

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44
Layout = "~/Views/Shared/_LayoutInternal.cshtml";
55
}
66

7-
<div class="page-header">
8-
<h1><i class="fa fa-user" aria-hidden="true"></i> &nbsp; Delete User: <i>@Model.Username</i></h1>
7+
8+
9+
10+
<div class="row">
11+
<div class="col-lg-12">
12+
<h1 class="page-header"><i class="fa fa-user" aria-hidden="true"></i> &nbsp; Delete User: <i>@Model.Username</i></h1>
13+
</div>
14+
<!-- /.col-lg-12 -->
915
</div>
16+
1017
<div class="row">
1118

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

88+
</div>

0 commit comments

Comments
 (0)