Permalink
Browse files

Merge branch 'master' into production

  • Loading branch information...
2 parents 50739ae + 09be3fd commit 8c6ba05445a459315135014c4b212b548b1e136b @emiliotorrens committed Mar 27, 2017
View
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+ <solution>
+ <add key="disableSourceControlIntegration" value="true" />
+ </solution>
+</configuration>
View
Binary file not shown.
View
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
+
+ <!-- Enable the restore command to run before builds -->
+ <RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
+
+ <!-- Property that enables building a package from a project -->
+ <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
+
+ <!-- Determines if package restore consent is required to restore packages -->
+ <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
+
+ <!-- Download NuGet.exe if it does not already exist -->
+ <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
+ </PropertyGroup>
+
+ <ItemGroup Condition=" '$(PackageSources)' == '' ">
+ <!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
+ <!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
+ <!--
+ <PackageSource Include="https://www.nuget.org/api/v2/" />
+ <PackageSource Include="https://my-nuget-source/nuget/" />
+ -->
+ </ItemGroup>
+
+ <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
+ <!-- Windows specific commands -->
+ <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
+ <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
+ <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
+ <PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
+ <PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
+ </PropertyGroup>
+
+ <PropertyGroup>
+ <!-- NuGet command -->
+ <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
+ <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
+
+ <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
+ <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
+
+ <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
+
+ <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
+ <NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
+
+ <PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
+ <PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
+
+ <!-- Commands -->
+ <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
+ <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
+
+ <!-- We need to ensure packages are restored prior to assembly resolve -->
+ <BuildDependsOn Condition="$(RestorePackages) == 'true'">
+ RestorePackages;
+ $(BuildDependsOn);
+ </BuildDependsOn>
+
+ <!-- Make the build depend on restore packages -->
+ <BuildDependsOn Condition="$(BuildPackage) == 'true'">
+ $(BuildDependsOn);
+ BuildPackage;
+ </BuildDependsOn>
+ </PropertyGroup>
+
+ <Target Name="CheckPrerequisites">
+ <!-- Raise an error if we're unable to locate nuget.exe -->
+ <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
+ <!--
+ Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
+ This effectively acts as a lock that makes sure that the download operation will only happen once and all
+ parallel builds will have to wait for it to complete.
+ -->
+ <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
+ </Target>
+
+ <Target Name="_DownloadNuGet">
+ <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
+ </Target>
+
+ <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
+ <Exec Command="$(RestoreCommand)"
+ Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
+
+ <Exec Command="$(RestoreCommand)"
+ LogStandardErrorAsError="true"
+ Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
+ </Target>
+
+ <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
+ <Exec Command="$(BuildCommand)"
+ Condition=" '$(OS)' != 'Windows_NT' " />
+
+ <Exec Command="$(BuildCommand)"
+ LogStandardErrorAsError="true"
+ Condition=" '$(OS)' == 'Windows_NT' " />
+ </Target>
+
+ <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
+ <ParameterGroup>
+ <OutputFilename ParameterType="System.String" Required="true" />
+ </ParameterGroup>
+ <Task>
+ <Reference Include="System.Core" />
+ <Using Namespace="System" />
+ <Using Namespace="System.IO" />
+ <Using Namespace="System.Net" />
+ <Using Namespace="Microsoft.Build.Framework" />
+ <Using Namespace="Microsoft.Build.Utilities" />
+ <Code Type="Fragment" Language="cs">
+ <![CDATA[
+ try {
+ OutputFilename = Path.GetFullPath(OutputFilename);
+
+ Log.LogMessage("Downloading latest version of NuGet.exe...");
+ WebClient webClient = new WebClient();
+ webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
+
+ return true;
+ }
+ catch (Exception ex) {
+ Log.LogErrorFromException(ex);
+ return false;
+ }
+ ]]>
+ </Code>
+ </Task>
+ </UsingTask>
+</Project>
@@ -45,9 +45,8 @@
<HintPath>..\packages\MongoDB.Driver.Core.2.3.0\lib\net45\MongoDB.Driver.Core.dll</HintPath>
<Private>True</Private>
</Reference>
- <Reference Include="nunit.framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
- <HintPath>..\packages\NUnit.3.5.0\lib\net45\nunit.framework.dll</HintPath>
- <Private>True</Private>
+ <Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
+ <HintPath>..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
@@ -56,6 +55,8 @@
<Compile Include="AgregationTest.cs" />
<Compile Include="Classes\CountryCollection.cs" />
<Compile Include="Classes\Log.cs" />
+ <Compile Include="FG-148\CurrentyType.cs" />
+ <Compile Include="FG-148\Test.cs" />
<Compile Include="InsertModifyDeleteTest.cs" />
<Compile Include="ConfigTest.cs" />
<Compile Include="FindTest.cs" />
@@ -0,0 +1,102 @@
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using EtoolTech.MongoDB.Mapper;
+using EtoolTech.MongoDB.Mapper.Exceptions;
+using EtoolTech.MongoDB.Mapper.Attributes;
+using MongoDB.Bson.Serialization.Attributes;
+using MongoDB.Driver;
+using MongoDB.Bson.Serialization.IdGenerators;
+using FindByKeyNotFoundException = EtoolTech.MongoDB.Mapper.Exceptions.FindByKeyNotFoundException;
+
+namespace EtoolTech.Orca.BedBank.BlackBox.Core.Data.Mongo
+{
+ [Serializable]
+ [MongoKey(KeyFields = "CurrencyCode")]
+ [MongoMapperIdIncrementable(IncremenalId = false, ChildsIncremenalId = false)]
+ public partial class CurrencyType : MongoMapper<CurrencyType>
+ {
+
+ private static readonly Dictionary<string, object> LocalCache = new Dictionary<string, object>();
+ private object GetFromLocalCache<T>(string objectName, string fieldNames, params object[] values)
+ {
+
+ if (values.Any(value => value == null))
+ {
+ return null;
+ }
+
+ string valueKey = values.Aggregate(String.Empty, (current, value) => current + (value.ToString() + "|"));
+
+ string key = (string.Format("{0}|{1}|{2}", objectName, fieldNames, valueKey));
+ if (!LocalCache.ContainsKey(key))
+ {
+ var queryList = new List<FilterDefinition<T>>();
+ int index = 0;
+ var fields = fieldNames.Split(',');
+ foreach (var value in values)
+ {
+ FilterDefinition<T> query;
+ if (value is long)
+ {
+ query = MongoQuery<T>.Eq(objectName, fields[index], (long)value);
+ }
+ else if (value is int)
+ {
+ query = MongoQuery<T>.Eq(objectName, fields[index], (int)value);
+ }
+ else
+ {
+ query = MongoQuery<T>.Eq(objectName, fields[index], value.ToString());
+ }
+ queryList.Add(query);
+ index++;
+ }
+
+ var cursor = MongoMapperCollection<T>.Instance.Find(Builders<T>.Filter.And(queryList)).ToListAsync().Result;
+
+ object data = null;
+ if (cursor.Any()) data = cursor.First();
+
+ if (!LocalCache.ContainsKey(key)) LocalCache.Add(key, data);
+ }
+ return LocalCache[key];
+ }
+
+ [BsonIgnore]
+ public long _id { get { return base.m_id; } set { base.m_id = value; } }
+ public String CurrencyCode { get; set; }
+ public String Name { get; set; }
+ public String Description { get; set; }
+ public String Simbol { get; set; }
+ public Decimal Value { get; set; }
+ public String SermepaCode { get; set; }
+ public Boolean IsLocalCurrency { get; set; }
+ [BsonElement("lmu")]
+ public string LastModificationUser { get; set; }
+ [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
+ [BsonElement("lmd")]
+ public DateTime LastModificationDateTime { get; set; }
+
+
+ public new void Save()
+ {
+ try
+ {
+ base.Save();
+ }
+ catch (EtoolTech.MongoDB.Mapper.Exceptions.DuplicateKeyException)
+ {
+ throw new DuplicateKeyException();
+ }
+ }
+
+ public new void Delete()
+ {
+ base.Delete();
+ }
+
+
+ }
+
+}
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using EtoolTech.Orca.BedBank.BlackBox.Core.Data.Mongo;
+using MongoDB.Driver;
+
+namespace EtoolTech.MongoDB.Mapper.Test.NUnit
+{
+ public class Test
+ {
+ public void Filter()
+ {
+
+ var Fields = new string[] { "Description" };
+ var OrderBy = new string[] { "lmd","CurrencyCode" };
+
+ string Name = "%";
+ int Skip = 25;
+ int Limit = 25;
+
+ var col = MongoMapperCollection<CurrencyType>.Instance;
+ Fields = MongoMapperHelper.ConvertFieldName("CurrencyType", Fields.ToList()).ToArray();
+
+ OrderBy = MongoMapperHelper.ConvertFieldName("CurrencyType", OrderBy.ToList()).ToArray();
+ var sortList = new List<SortDefinition<CurrencyType>>();
+
+ if (!OrderBy.Any() || string.IsNullOrEmpty(OrderBy.First())) sortList.Add(col.Sort.Ascending("$natural"));
+
+ sortList.AddRange(OrderBy.Where(S => !string.IsNullOrEmpty(S)).Select(Field => col.Sort.Ascending(Field)));
+
+ var order = col.Sort.Combine(sortList);
+
+ col.AddIncludeFields(Fields);
+
+ col.Find(col.Filter.And(MongoQuery<CurrencyType>.Eq(D => D.Name, Name))).Limit(Limit).Skip(Skip).Sort(order);
+
+
+ Console.WriteLine(col.Count);
+ foreach (var currencyType in col)
+ {
+ Console.WriteLine(currencyType.CurrencyCode);
+ Console.WriteLine(currencyType.Description);
+
+ }
+
+
+ }
+ }
+}
@@ -3,5 +3,5 @@
<package id="MongoDB.Bson" version="2.3.0" targetFramework="net45" />
<package id="MongoDB.Driver" version="2.3.0" targetFramework="net45" />
<package id="MongoDB.Driver.Core" version="2.3.0" targetFramework="net45" />
- <package id="NUnit" version="3.5.0" targetFramework="net45" />
+ <package id="NUnit" version="3.6.1" targetFramework="net45" />
</packages>
Oops, something went wrong.

0 comments on commit 8c6ba05

Please sign in to comment.