Skip to content

Commit c62b963

Browse files
Merge pull request #17 from budaevb/master
JS ToLocalTime()
2 parents 38cc72e + 6cc8262 commit c62b963

File tree

12 files changed

+56
-19
lines changed

12 files changed

+56
-19
lines changed

Ascon.Pilot.WebClient/src/Ascon.Pilot.Core/Extensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,5 +308,10 @@ public static string ToShortDateString(this DateTime dateTime)
308308
{
309309
return dateTime.ToString("d", DateTimeFormatInfo.CurrentInfo);
310310
}
311+
312+
public static double ToUnixTimeMilliseconds(this DateTime dateTime)
313+
{
314+
return dateTime.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalMilliseconds;
315+
}
311316
}
312317
}

Ascon.Pilot.WebClient/src/Ascon.Pilot.WebClient/Models/DTask.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public string ExecutorRole
115115

116116
public DateTime Created
117117
{
118-
get { return _source.Created.ToLocalTime(); }
118+
get { return _source.Created; }
119119
}
120120

121121
//public IList<Guid> Children
@@ -224,7 +224,7 @@ public DateTime DeadlineDate
224224
if (_source.Attributes.TryGetValue(SystemAttributes.TASK_DEADLINE_DATE, out deadLine))
225225
{
226226
if (deadLine.DateValue != null)
227-
return ((DateTime)deadLine).ToLocalTime();
227+
return deadLine;
228228
}
229229

230230
return DateTime.MaxValue;
@@ -239,7 +239,7 @@ public DateTime DateOfAssignment
239239
if (_source.Attributes.TryGetValue(SystemAttributes.TASK_DATE_OF_ASSIGNMENT, out date))
240240
{
241241
if (date.DateValue != null)
242-
return ((DateTime)date).ToLocalTime();
242+
return date;
243243
}
244244

245245
return Created;
@@ -253,7 +253,7 @@ public DateTime? DateOfCompletion
253253
DValue date;
254254
if (_source.Attributes.TryGetValue(SystemAttributes.TASK_DATE_OF_COMPLETION, out date))
255255
{
256-
return date.DateValue?.ToLocalTime();
256+
return date.DateValue;
257257
}
258258

259259
return null;
@@ -267,7 +267,7 @@ public DateTime? DateOfStart
267267
DValue date;
268268
if (_source.Attributes.TryGetValue(SystemAttributes.TASK_DATE_OF_START, out date))
269269
{
270-
return date.DateValue?.ToLocalTime();
270+
return date.DateValue;
271271
}
272272

273273
return null;
@@ -281,7 +281,7 @@ public DateTime? DateOfRevokation
281281
DValue date;
282282
if (_source.Attributes.TryGetValue(SystemAttributes.TASK_DATE_OF_REVOKATION, out date))
283283
{
284-
return date.DateValue?.ToLocalTime();
284+
return date.DateValue;
285285
}
286286

287287
return null;

Ascon.Pilot.WebClient/src/Ascon.Pilot.WebClient/ViewModels/FilesDetailsViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public FilesDetailsViewModel(Guid objId, long version, IRepository repository, F
5050

5151
Snapshots = new List<DFilesSnapshot>();
5252
Snapshots.Add(obj.ActualFileSnapshot);
53-
foreach (var previousFileSnapshot in obj.PreviousFileSnapshots)
53+
foreach (var previousFileSnapshot in obj.PreviousFileSnapshots.ToArray().Reverse())
5454
{
5555
Snapshots.Add(previousFileSnapshot);
5656
}
@@ -94,7 +94,7 @@ private DFile GetFile(long version, DObject obj)
9494
var file = obj.ActualFileSnapshot.Files.FirstOrDefault();
9595
if (file != null)
9696
{
97-
VersionTime = obj.ActualFileSnapshot.Created.ToLocalTime();
97+
VersionTime = obj.ActualFileSnapshot.Created;
9898
Author = _repository.GetPerson(obj.ActualFileSnapshot.CreatorId).DisplayName;
9999
}
100100
return file;
@@ -108,7 +108,7 @@ private DFile GetFile(long version, DObject obj)
108108
{
109109
if (!string.IsNullOrEmpty(snapshot.Reason))
110110
VersionReason = string.Format("\"{0}\"", snapshot.Reason);
111-
VersionTime = snapshot.Created.ToLocalTime();
111+
VersionTime = snapshot.Created;
112112
Author = GetPersonDisplayName(snapshot.CreatorId);
113113
}
114114
return file;

Ascon.Pilot.WebClient/src/Ascon.Pilot.WebClient/Views/Files/Index.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,6 @@
4242
var ROOT_ID = '@DObject.RootId';
4343
var currentFolderId = '@Model.CurrentFolderId';
4444
</script>
45+
<script type="text/javascript" src="~/js/datetime.js"></script>
4546
<script type="text/javascript" src="@Url.Content("~/js/files.js")" asp-append-version="true"></script>
4647
}

Ascon.Pilot.WebClient/src/Ascon.Pilot.WebClient/Views/Shared/Components/FileDetails/FileDetails.cshtml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ else
3333
</dl>
3434
<br/>
3535
<br/>
36-
<p>Создал(а) @Model.Author @Model.VersionTime</p>
36+
<p>Создал(а) @Model.Author <span class="local-datetime nowrap" data-utc="@Model.VersionTime.ToUnixTimeMilliseconds()">@Model.VersionTime</span></p>
3737
</div>
3838
</div>
3939
</div>
@@ -53,17 +53,19 @@ else
5353
@{
5454
foreach (var snapshot in Model.Snapshots)
5555
{
56-
var snapshotTime = @snapshot.Created;
56+
var snapshotTime = snapshot.Created;
5757
var isActive = "";
5858
var author = Model.GetPersonDisplayName(snapshot.CreatorId);
5959
var reason = "";
6060
if (!string.IsNullOrEmpty(snapshot.Reason))
61+
{
6162
reason = string.Format("\"{0}\"", snapshot.Reason);
62-
if (Model.VersionTime.Equals(snapshotTime.ToLocalTime()))
63+
}
64+
if (Model.VersionTime.Equals(snapshotTime))
6365
{
6466
isActive = "active";
6567
}
66-
<li class="list-group-item @isActive"><a href="@Url.Action("Index", "Files", new {id = Model.Id, version = snapshotTime.Ticks})">Версия @snapshotTime.ToLocalTime() @author @reason </a></li>
68+
<li class="list-group-item @isActive"><a href="@Url.Action("Index", "Files", new {id = Model.Id, version = snapshotTime.Ticks})">Версия <span class="local-datetime nowrap" data-utc="@snapshotTime.ToUnixTimeMilliseconds()">@snapshotTime</span> @author @reason </a></li>
6769
}
6870
}
6971
</ul>
@@ -77,7 +79,7 @@ else
7779
@if (Model.IsActual == false)
7880
{
7981
<div class="row info-note info-panel">
80-
<p>Неактуальная версия от @Model.VersionTime @Model.Author @Model.VersionReason. Перейти к <a href="@Url.Action("Index", "Files", new {id = Model.Id})">актуальной версии</a>
82+
<p>Неактуальная версия от <span class="local-datetime" data-utc="@Model.VersionTime.ToUnixTimeMilliseconds()">@Model.VersionTime</span> @Model.Author @Model.VersionReason. Перейти к <a href="@Url.Action("Index", "Files", new {id = Model.Id})">актуальной версии</a>
8183
</p>
8284
</div>
8385
}

Ascon.Pilot.WebClient/src/Ascon.Pilot.WebClient/Views/Tasks/Index.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@
5757

5858
</div>
5959

60-
<script src="~/js/tasks.js"></script>
60+
<script type="text/javascript" src="~/js/datetime.js"></script>
61+
<script type="text/javascript" src="~/js/tasks.js"></script>

Ascon.Pilot.WebClient/src/Ascon.Pilot.WebClient/Views/Tasks/TaskList.cshtml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
@using Ascon.Pilot.WebClient.Models;
1+
@using Ascon.Pilot.Core
2+
@using Ascon.Pilot.WebClient.Models;
23

34
@model IEnumerable<Ascon.Pilot.WebClient.ViewModels.TaskNode>
45

@@ -45,7 +46,7 @@ else
4546
break;
4647
}
4748
<div class="col-md-6 col-sm-8 col-lg-8 text-title truncate">@node.Title</div>
48-
<div class="col-fix-145 col-float-right hidden-xs" style="font-size:small">Выдано @node.DateOfAssignment.ToString("g")</div>
49+
<div class="col-fix-145 col-float-right hidden-xs" style="font-size:small">Выдано <span class="local-datetime nowrap" data-utc="@node.DateOfAssignment.ToUnixTimeMilliseconds()">@node.DateOfAssignment.ToString("g")</span></div>
4950
</div>
5051
<div class="row">
5152
<div class="col-fix-16"></div>
@@ -57,7 +58,7 @@ else
5758
}
5859
else
5960
{
60-
<div class="col-fix-145 col-float-right hidden-xs" style="font-size:small">Срок @node.DeadlineDate.ToString("g")</div>
61+
<div class="col-fix-145 col-float-right hidden-xs" style="font-size:small">Срок <span class="local-datetime nowrap" data-utc="@node.DeadlineDate.ToUnixTimeMilliseconds()">@node.DeadlineDate.ToString("g")</span></div>
6162
}
6263
</div>
6364
<div class="row">
@@ -68,7 +69,7 @@ else
6869
}
6970
else
7071
{
71-
<div class="col-fix-145 col-float-right hidden-xs" style="font-size:small">Начало @node.DateOfStart?.ToString("g")</div>
72+
<div class="col-fix-145 col-float-right hidden-xs" style="font-size:small">Начало <span class="local-datetime nowrap" data-utc="@node.DateOfStart?.ToUnixTimeMilliseconds()">@node.DateOfStart?.ToString("g")</span></div>
7273
}
7374
</div>
7475
</div>

Ascon.Pilot.WebClient/src/Ascon.Pilot.WebClient/web.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,13 @@
1010
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
1111
</handlers>
1212
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
13+
<rewrite>
14+
<rules>
15+
<rule name="Redirect to document with version">
16+
<match url="^([0-9a-z-]+)/([0-9]+)" />
17+
<action type="Rewrite" url="Files/Index/{R:1}?version={R:2}" />
18+
</rule>
19+
</rules>
20+
</rewrite>
1321
</system.webServer>
1422
</configuration>

Ascon.Pilot.WebClient/src/Ascon.Pilot.WebClient/wwwroot/_references.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// <autosync enabled="true" />
2+
/// <reference path="js/datetime.js" />
23
/// <reference path="js/dropzone.js" />
34
/// <reference path="js/files.js" />
45
/// <reference path="js/site.js" />

Ascon.Pilot.WebClient/src/Ascon.Pilot.WebClient/wwwroot/css/site.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ a.task-node {
464464
margin-top: -20px;
465465
}
466466
}
467+
468+
.nowrap {
469+
white-space: nowrap;
470+
}
467471
/*--------------------------------------Modal preview---------------------------*/
468472

469473
@media (min-width: 992px) {

0 commit comments

Comments
 (0)