Skip to content

Commit

Permalink
BREAKING CHANGES: Version 3.0 see notes in Release page
Browse files Browse the repository at this point in the history
  • Loading branch information
geoperez committed Oct 29, 2020
1 parent daf83f0 commit b8ea19d
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 175 deletions.
13 changes: 0 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@ Please visit the [Tubular GitHub Page](http://unosquare.github.io/tubular) to le
PM> Install-Package Tubular.ServerSide
```

## Global Settings

You can access global settings by using the static object `TubularDefaultSettings` and setup common behavior in Tubular. The settings included are:

<table>
<tr><th>Setting</th><th>Default value</th><th>Notes</th></tr>
<tr><th>AdjustTimezoneOffset</th><td><i>True</i></td><td>Determines if the DateTime from a Response should adjust the timezone offset send by within the Request.</td></tr>
</table>

## Building C# Library

To build the solution you need VS2017 with .NET Core support.

## Sample

You can check out the <a href="http://unosquare.github.io/tubular" target="_blank">Tubular GitHub Page</a> to get a few examples. We still need to work on more samples and better documentation, but we feel what we have now will get you up to speed very quickly :).
Expand Down
6 changes: 2 additions & 4 deletions src/Unosquare.Tubular.AspNetCoreSample/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ public void Configure(IApplicationBuilder app)
app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());

app.UseAuthorization();
app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.9" />
<PackageReference Include="Unosquare.Swan.AspNetCore" Version="1.2.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.6.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.8.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
</ItemGroup>

</Project>
14 changes: 9 additions & 5 deletions src/Unosquare.Tubular.AspNetCoreSample/web.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>

<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->

<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_HTTPS_PORT" value="44333" />
<environmentVariable name="COMPLUS_ForceENC" value="1" />
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EmbedIO" Version="3.4.2" />
<PackageReference Include="EmbedIO" Version="3.4.3" />
</ItemGroup>

</Project>
70 changes: 19 additions & 51 deletions src/Unosquare.Tubular/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ public static GridDataResponse CreateGridDataResponse(
if (request.Columns.Any() != true)
throw new ArgumentOutOfRangeException(nameof(request), "Missing column information");

// Remove this in future versions.
AdjustFilters(request);

var response = new GridDataResponse
{
Counter = request.Counter,
Expand Down Expand Up @@ -142,19 +139,6 @@ public static GridDataResponse CreateGridDataResponse(
return response;
}

private static void AdjustFilters(GridDataRequest request)
{
if (request.Search != null)
request.SearchText = request.Search.Text;

foreach (var column in request.Columns.Where(x => x.Filter != null))
{
column.FilterArgument = column.Filter.Argument;
column.FilterOperator = column.Filter.Operator;
column.FilterText = column.Filter.Text;
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Dictionary<GridColumn, PropertyInfo> MapColumnsToProperties(
IReadOnlyCollection<GridColumn> columns,
Expand Down Expand Up @@ -187,10 +171,9 @@ private static List<List<object>> CreateGridPayload(
{
if (column.Value is DateTime time)
{
if (column.Key.DataType == DataType.DateTimeUtc || !TubularDefaultSettings.AdjustTimezoneOffset)
payloadItem.Add(time);
else
payloadItem.Add(time.AddMinutes(-timezoneOffset));
payloadItem.Add(column.Key.DataType == DataType.DateTimeUtc
? time
: time.AddMinutes(-timezoneOffset));
}
else
{
Expand Down Expand Up @@ -338,7 +321,7 @@ private static IQueryable FilterResponse(GridDataRequest request, IQueryable sub

// Perform Searching
var searchLambda = new StringBuilder();
var searchParamArgs = new List<object>();
var searchParamArgs = new List<object?>();

if (!string.IsNullOrWhiteSpace(request.SearchText))
{
Expand Down Expand Up @@ -369,7 +352,7 @@ private static IQueryable FilterResponse(GridDataRequest request, IQueryable sub
private static void FilterColumn(
GridColumn column,
StringBuilder searchLambda,
ICollection<object> searchParamArgs,
ICollection<object?> searchParamArgs,
bool isDbQuery)
{
switch (column.FilterOperator)
Expand All @@ -379,7 +362,7 @@ private static void FilterColumn(

if (string.IsNullOrWhiteSpace(column.FilterText)) return;

if (column.DataType == DataType.Date)
if (column.DataType == DataType.Date || column.DataType == DataType.DateTime || column.DataType == DataType.DateTimeUtc)
{
searchLambda.AppendFormat(
column.FilterOperator == CompareOperators.Equals
Expand All @@ -404,27 +387,12 @@ private static void FilterColumn(
break;
case DataType.DateTime:
case DataType.DateTimeUtc:
searchParamArgs.Add(DateTime.Parse(column.FilterText).ToString(DateFormat));
break;
case DataType.Date:
if (TubularDefaultSettings.AdjustTimezoneOffset)
{
searchParamArgs.Add(DateTime.Parse(column.FilterText).Date.ToUniversalTime()
.ToString(DateTimeFormat));
searchParamArgs.Add(
DateTime.Parse(column.FilterText)
.Date.ToUniversalTime()
.AddDays(1)
.AddMinutes(-1).ToString(DateTimeFormat));
}
else
{
searchParamArgs.Add(
DateTime.Parse(column.FilterText).Date.ToString(DateTimeFormat));
searchParamArgs.Add(DateTime.Parse(column.FilterText)
.Date.AddDays(1)
.AddMinutes(-1).ToString(DateTimeFormat));
}
searchParamArgs.Add(
DateTime.Parse(column.FilterText).Date.ToString(DateTimeFormat));
searchParamArgs.Add(DateTime.Parse(column.FilterText)
.Date.AddDays(1)
.AddMinutes(-1).ToString(DateTimeFormat));

break;
case DataType.Boolean:
Expand All @@ -443,7 +411,7 @@ private static void FilterColumn(
: "({0} != null && {0}.ToLowerInvariant().Contains(@{1})) &&", column.Name,
searchParamArgs.Count);

searchParamArgs.Add(column.FilterText.ToLowerInvariant());
searchParamArgs.Add(column.FilterText?.ToLowerInvariant());
break;
case CompareOperators.StartsWith:
searchLambda.AppendFormat(
Expand All @@ -452,7 +420,7 @@ private static void FilterColumn(
: "({0} != null && {0}.ToLowerInvariant().StartsWith(@{1})) &&", column.Name,
searchParamArgs.Count);

searchParamArgs.Add(column.FilterText.ToLowerInvariant());
searchParamArgs.Add(column.FilterText?.ToLowerInvariant());
break;
case CompareOperators.EndsWith:
searchLambda.AppendFormat(
Expand All @@ -461,7 +429,7 @@ private static void FilterColumn(
: "({0} != null && {0}.ToLowerInvariant().EndsWith(@{1})) &&", column.Name,
searchParamArgs.Count);

searchParamArgs.Add(column.FilterText.ToLowerInvariant());
searchParamArgs.Add(column.FilterText?.ToLowerInvariant());
break;
case CompareOperators.NotContains:
searchLambda.AppendFormat(
Expand All @@ -470,7 +438,7 @@ private static void FilterColumn(
: "({0} != null && {0}.ToLowerInvariant().Contains(@{1}) == false) &&", column.Name,
searchParamArgs.Count);

searchParamArgs.Add(column.FilterText.ToLowerInvariant());
searchParamArgs.Add(column.FilterText?.ToLowerInvariant());
break;
case CompareOperators.NotStartsWith:
searchLambda.AppendFormat(
Expand All @@ -479,7 +447,7 @@ private static void FilterColumn(
: "({0} != null && {0}.ToLowerInvariant().StartsWith(@{1}) == false) &&", column.Name,
searchParamArgs.Count);

searchParamArgs.Add(column.FilterText.ToLowerInvariant());
searchParamArgs.Add(column.FilterText?.ToLowerInvariant());
break;
case CompareOperators.NotEndsWith:
searchLambda.AppendFormat(
Expand All @@ -488,7 +456,7 @@ private static void FilterColumn(
: "({0} != null && {0}.ToLowerInvariant().EndsWith(@{1}) == false) &&", column.Name,
searchParamArgs.Count);

searchParamArgs.Add(column.FilterText.ToLowerInvariant());
searchParamArgs.Add(column.FilterText?.ToLowerInvariant());
break;
case CompareOperators.Gte:
case CompareOperators.Gt:
Expand Down Expand Up @@ -548,10 +516,10 @@ private static void GetSearchFilter(
bool isDbQuery,
string searchValue,
StringBuilder searchLambda,
List<object> searchParamArgs)
List<object?> searchParamArgs)
{
var filter = new StringBuilder();
var values = new List<object>();
var values = new List<object?>();

if (request.Columns.Any(x => x.Searchable))
filter.Append("(");
Expand Down
49 changes: 0 additions & 49 deletions src/Unosquare.Tubular/Filter.cs

This file was deleted.

10 changes: 1 addition & 9 deletions src/Unosquare.Tubular/GridColumn.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Unosquare.Tubular
namespace Unosquare.Tubular
{
/// <summary>
/// Represents a Tubular Grid column.
Expand Down Expand Up @@ -35,12 +33,6 @@ public class GridColumn
/// </summary>
public SortDirection SortDirection { get; set; }

/// <summary>
/// Represents the Columns filter.
/// </summary>
[Obsolete("This will be removed in future versions.")]
public Filter? Filter { get; set; }

/// <summary>
/// Set if the column is searchable in free-text search.
/// </summary>
Expand Down
6 changes: 0 additions & 6 deletions src/Unosquare.Tubular/GridDataRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ public class GridDataRequest
/// </summary>
public int Counter { get; set; }

/// <summary>
/// The free-text search.
/// </summary>
[Obsolete("This will be removed in future versions.")]
public Filter? Search { get; set; }

/// <summary>
/// Gets or sets the search text.
/// </summary>
Expand Down
13 changes: 0 additions & 13 deletions src/Unosquare.Tubular/TubularDefaultSettings.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/Unosquare.Tubular/Unosquare.Tubular.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Copyright>Unosquare 2016-2020</Copyright>
<AssemblyTitle>Unosquare Tubular</AssemblyTitle>
<VersionPrefix>2.2.0</VersionPrefix>
<VersionPrefix>3.0.0</VersionPrefix>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Unosquare.Tubular</AssemblyName>
Expand All @@ -16,6 +16,6 @@
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.20" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.5" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions test/Unosquare.Tubular.Tests/CompareOperatorsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void DecimalNumberFilterTest()
[Test]
public void DateTimeEqualFilterTest()
{
var filter = DateTime.Now.Date.ToString(CultureInfo.InvariantCulture);
var filter = "2020-04-15T05:00:00.000Z";

var filterCount = DataSource.Where(x => x.Date.ToString(CultureInfo.InvariantCulture) == filter);

Expand All @@ -137,7 +137,7 @@ public void DateTimeEqualFilterTest()
{
Take = PageSize,
Skip = 0,
Columns = Thing.GetColumnsWithDateFilter(filter, CompareOperators.Equals, DataType.DateTime)
Columns = Thing.GetColumnsWithDateFilter(filter, CompareOperators.Equals, DataType.Date)
};

var response = request.CreateGridDataResponse(DataSource);
Expand Down
Loading

0 comments on commit b8ea19d

Please sign in to comment.