Skip to content

Commit

Permalink
FR-3561 merge origin/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jokerosky committed Jul 30, 2016
2 parents b5b704a + ead1072 commit 121db29
Show file tree
Hide file tree
Showing 2,266 changed files with 82,962 additions and 86,105 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Expand Up @@ -7,6 +7,23 @@
*.sln.docstates
.vs

# Fr8 settings file
[Ss]ettings.config
[Ss]ettings.Debug.config
[Ss]ettings.Dev.config
[Ss]ettings.Release.config
[Ss]ettings.Demo.config
[Ss]ettings.config.src

# Service Configuration files for Azure Cloud Service
ServiceConfiguration.Release.cscfg
ServiceConfiguration.Dev.cscfg
ServiceConfiguration.Cloud.cscfg
ServiceConfiguration.Demo.cscfg

# Nuget packages
.nupkg

# Build results

[Dd]ebug/
Expand Down Expand Up @@ -148,8 +165,15 @@ bower_components
.bower-registry
.bower-tmp

### Node ###
node_modules

### VS Backup files ###
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm


_NCrunch_Dockyard/
Scripts/templateCache.js
Expand Down Expand Up @@ -206,6 +230,9 @@ Views/Shared/CDN/
/terminalAtlassian/log4net.terminals.Release.config
/terminalAtlassian/log4net.terminals.Dev.config
/terminalAtlassian/log4net.terminals.Demo.config
/terminalDemo/log4net.terminals.Release.config
/terminalDemo/log4net.terminals.Dev.config
/terminalDemo/log4net.terminals.Demo.config


/terminalAzure/log4net.terminals.Release.config
Expand All @@ -214,3 +241,4 @@ Views/Shared/CDN/
/terminalAzure/log4net.terminals.config
*.csproj.DotSettings
*.csproj.DotSettings
Services/PlanDirectory/ManifestPages/*.html
Binary file added .nuget/CredentialProvider.VSS.exe
Binary file not shown.
5 changes: 5 additions & 0 deletions .nuget/NuGet.Config
Expand Up @@ -3,4 +3,9 @@
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<add key="fr8-private" value="https://fr8.pkgs.visualstudio.com/DefaultCollection/_packaging/fr8-private/nuget/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
</configuration>
Binary file modified .nuget/NuGet.exe
Binary file not shown.
40 changes: 33 additions & 7 deletions App_Start/AutoMapperBootstrapper.cs
Expand Up @@ -6,6 +6,7 @@
using Fr8.Infrastructure.Data.DataTransferObjects;
using Hub.Interfaces;
using HubWeb.ViewModels;
using Fr8.Infrastructure.Data.States;

namespace HubWeb.App_Start
{
Expand All @@ -22,6 +23,26 @@ public AutoMapperBootStrapper(ITerminal terminal, IActivityTemplate activityTemp

public void ConfigureAutoMapper()
{
Mapper.CreateMap<PlanDO, PlanNoChildrenDTO>().ForMember(a => a.Id, opts => opts.ResolveUsing(ad => ad.Id))
.ForMember(a => a.Category, opts => opts.ResolveUsing(ad => ad.Category))
.ForMember(a => a.Description, opts => opts.ResolveUsing(ad => ad.Description))
.ForMember(a => a.LastUpdated, opts => opts.ResolveUsing(ad => ad.LastUpdated))
.ForMember(a => a.Name, opts => opts.ResolveUsing(ad => ad.Name))
.ForMember(a => a.PlanState, opts => opts.ResolveUsing(ad => ad.PlanState))
.ForMember(a => a.StartingSubPlanId, opts => opts.ResolveUsing(ad => ad.StartingSubPlanId))
.ForMember(a => a.Tag, opts => opts.ResolveUsing(ad => ad.Tag))
.ForMember(a => a.Visibility, opts => opts.ResolveUsing(ad => new PlanVisibilityDTO() { Hidden = ad.Visibility.BooleanValue() }));

Mapper.CreateMap<PlanNoChildrenDTO, PlanDO>().ForMember(a => a.Id, opts => opts.ResolveUsing(ad => ad.Id))
.ForMember(a => a.Category, opts => opts.ResolveUsing(ad => ad.Category))
.ForMember(a => a.Description, opts => opts.ResolveUsing(ad => ad.Description))
.ForMember(a => a.LastUpdated, opts => opts.ResolveUsing(ad => ad.LastUpdated))
.ForMember(a => a.Name, opts => opts.ResolveUsing(ad => ad.Name))
.ForMember(a => a.PlanState, opts => opts.ResolveUsing(ad => ad.PlanState))
.ForMember(a => a.StartingSubPlanId, opts => opts.ResolveUsing(ad => ad.StartingSubPlanId))
.ForMember(a => a.Tag, opts => opts.ResolveUsing(ad => ad.Tag))
.ForMember(a => a.Visibility, opts => opts.ResolveUsing(ad => ad.Visibility?.PlanVisibilityValue()));

Mapper.CreateMap<ActivityDO, ActivityDTO>().ForMember(a => a.Id, opts => opts.ResolveUsing(ad => ad.Id))
.ForMember(a => a.RootPlanNodeId, opts => opts.ResolveUsing(ad => ad.RootPlanNodeId))
.ForMember(a => a.ParentPlanNodeId, opts => opts.ResolveUsing(ad => ad.ParentPlanNodeId))
Expand Down Expand Up @@ -50,28 +71,33 @@ public void ConfigureAutoMapper()

Mapper.CreateMap<Fr8AccountDO, ManageUserVM>()
.ForMember(mu => mu.HasLocalPassword, opts => opts.ResolveUsing(account => !string.IsNullOrEmpty(account.PasswordHash)))
.ForMember(mu => mu.HasDocusignToken, opts => opts.Ignore())
.ForMember(mu => mu.HasGoogleToken, opts => opts.Ignore())
.ForMember(mu => mu.GoogleSpreadsheets, opts => opts.Ignore());


Mapper.CreateMap<UserVM, EmailAddressDO>()
.ForMember(userDO => userDO.Address, opts => opts.ResolveUsing(e => e.EmailAddress));







Mapper.CreateMap<UserVM, Fr8AccountDO>()
.ForMember(userDO => userDO.Id, opts => opts.ResolveUsing(e => e.Id))
.ForMember(userDO => userDO.FirstName, opts => opts.ResolveUsing(e => e.FirstName))
.ForMember(userDO => userDO.LastName, opts => opts.ResolveUsing(e => e.LastName))
.ForMember(userDO => userDO.UserName, opts => opts.ResolveUsing(e => e.UserName))
.ForMember(userDO => userDO.EmailAddress, opts => opts.ResolveUsing(e => new EmailAddressDO {Address = e.EmailAddress}))
.ForMember(userDO => userDO.EmailAddress, opts => opts.ResolveUsing(e => new EmailAddressDO { Address = e.EmailAddress }))
.ForMember(userDO => userDO.Roles, opts => opts.Ignore());

Mapper.CreateMap<PageDefinitionDTO, PageDefinitionDO>()
.ForMember(dest => dest.Url, opts => opts.Ignore())
.ForMember(dest => dest.Tags, opts => opts.MapFrom(
x => x.Tags.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList()));

Mapper.CreateMap<PageDefinitionDO, PageDefinitionDTO>()
.ForMember(dest => dest.Tags, opts => opts.MapFrom(x => string.Join(", ", x.Tags)));


}

private static List<PlanNodeDO> MapActivities(IEnumerable<ActivityDTO> activities)
Expand Down Expand Up @@ -108,7 +134,7 @@ private ActivityTemplateDTO GetActivityTemplate(ActivityDO ad)

if (ad.ActivityTemplateId == Guid.Empty)
{
return null;
return null;
}

return Mapper.Map<ActivityTemplateDTO>(_activityTemplate.GetByKey(ad.ActivityTemplateId));
Expand Down
28 changes: 28 additions & 0 deletions App_Start/StartupMigration.cs
Expand Up @@ -2,6 +2,8 @@
using Data.States;
using StructureMap;
using Fr8.Infrastructure.Utilities;
using Newtonsoft.Json;
using System.Linq;

namespace HubWeb.App_Start
{
Expand All @@ -23,5 +25,31 @@ public static void CreateSystemUser()
uow.SaveChanges();
}
}

//Prior to FR-3683 Salesforce refresh tokens were stored in nonsecure part of database
//This method is intended to save them into key vault
//This method is not a part of Seed method because at that point of time key vault is not yet configured
//TODO: delete this method after this is deployed to prod
public static void MoveSalesforceRefreshTokensIntoKeyVault()
{
using (var uow = ObjectFactory.GetInstance<IUnitOfWork>())
{
var terminalId = uow.TerminalRepository.GetQuery().Where(x => x.Name == "terminalSalesforce").Select(x => x.Id).FirstOrDefault();
if (terminalId == 0)
{
return;
}
var tokens = uow.AuthorizationTokenRepository.GetPublicDataQuery().Where(x => x.TerminalID == terminalId && x.AdditionalAttributes.StartsWith("refresh_token"));
foreach (var token in tokens)
{
var actualToken = uow.AuthorizationTokenRepository.FindTokenById(token.Id);
var refreshTokenFirstIndex = actualToken.AdditionalAttributes.IndexOf('=') + 1;
var refreshTokenLastIndex = actualToken.AdditionalAttributes.IndexOf(';');
actualToken.Token = JsonConvert.SerializeObject(new { AccessToken = actualToken.Token, RefreshToken = actualToken.AdditionalAttributes.Substring(refreshTokenFirstIndex, refreshTokenLastIndex - refreshTokenFirstIndex) });
actualToken.AdditionalAttributes = actualToken.AdditionalAttributes.Substring(refreshTokenLastIndex + 1);
}
uow.SaveChanges();
}
}
}
}
46 changes: 20 additions & 26 deletions App_Start/SwaggerConfig.cs
@@ -1,10 +1,12 @@
using System;
using System.Web.Http;
using WebActivatorEx;
using HubWeb;
using Swashbuckle.Application;
using Swashbuckle.Swagger;
using System.Web.Http.Description;
using System.Linq;
using HubWeb.Documentation.Swagger;
using HubWeb.Documentation.Swagger.OperationFilters;
using Swashbuckle.Swagger;

[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]

Expand All @@ -14,9 +16,7 @@ public class SwaggerConfig
{
public static void Register()
{
var thisAssembly = typeof(SwaggerConfig).Assembly;

GlobalConfiguration.Configuration
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
// By default, the service root url is inferred from the request used to access the docs.
Expand Down Expand Up @@ -101,7 +101,18 @@ public static void Register()
//
//c.IncludeXmlComments(GetXmlCommentsPath());
c.IncludeXmlComments(string.Format(@"{0}\bin\HubWeb.xml", System.AppDomain.CurrentDomain.BaseDirectory));
//prevent breaking swagger in case somebody change project configuration to not produce xml
var fileName = $@"{AppDomain.CurrentDomain.BaseDirectory}\bin\HubWeb.xml";
if (System.IO.File.Exists(fileName))
{
c.IncludeXmlComments(fileName);
}
fileName = $@"{AppDomain.CurrentDomain.BaseDirectory}\bin\Fr8Infrastructure.NET.xml";
if (System.IO.File.Exists(fileName))
{
c.IncludeXmlComments(fileName);
}
// Swashbuckle makes a best attempt at generating Swagger compliant JSON schemas for the various types
// exposed in your API. However, there may be occasions when more control of the output is needed.
Expand All @@ -115,6 +126,7 @@ public static void Register()
// complex Schema, use a Schema filter.
//
//c.MapType<ProductType>(() => new Schema { type = "integer", format = "int32" });
c.MapType<Guid>(() => new Schema { type = "string", format = "uuid", @default = Guid.Parse("1C194364-5507-4E61-8CA4-387132BF1AA8")});
// If you want to post-modify "complex" Schemas once they've been generated, across the board or for a
// specific type, you can wire up one or more Schema filters.
Expand Down Expand Up @@ -150,7 +162,7 @@ public static void Register()
// Post-modify Operation descriptions once they've been generated by wiring up one or more
// Operation filters.
//
//c.OperationFilter<AddDefaultResponse>();
c.OperationFilter<RemoveParameterModelNameOperationFilter>();
//
// If you've defined an OAuth2 flow as described above, you could use a custom filter
// to inspect some attribute on each action and infer which (if any) OAuth2 scopes are required
Expand All @@ -167,6 +179,7 @@ public static void Register()
//Removing duplicates filter
c.DocumentFilter<RemoveDuplicatesDocumentFilter>();
c.DocumentFilter<AddDefaultValuesDocumentFilter>();
// In contrast to WebApi, Swagger 2.0 does not include the query string component when mapping a URL
// to an action. As a result, Swashbuckle will raise an exception if it encounters multiple actions
Expand Down Expand Up @@ -235,23 +248,4 @@ public static void Register()
});
}
}

public class RemoveDuplicatesDocumentFilter : IDocumentFilter
{
public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
{
var duplicates1 = apiExplorer.ApiDescriptions.Where(x => x.RelativePath.ToLower().Contains("/" + x.HttpMethod.Method.ToLower() + "/") || x.RelativePath.ToLower().Contains("/" + x.HttpMethod.Method.ToLower() + "?")).ToList();
var duplicates2 = apiExplorer.ApiDescriptions.Where(x => x.RelativePath.EndsWith(x.HttpMethod.Method, System.StringComparison.OrdinalIgnoreCase)).ToList();
duplicates1.AddRange(duplicates2);
foreach (var item in duplicates1)
{
apiExplorer.ApiDescriptions.Remove(item);
}
foreach (var item in duplicates1)
{
swaggerDoc.paths.Remove("/" + item.RelativePath);
}
}
}

}
15 changes: 10 additions & 5 deletions App_Start/WebApiConfig.cs
Expand Up @@ -18,10 +18,12 @@ public static void Register(HttpConfiguration config)
RegisterAuthenticationEndPoints(config);

config.Routes.MapHttpRoute(
name: "DefaultApiWithAction",
routeTemplate: "api/v1/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
name: "DefaultApiWithAction",
routeTemplate: "api/v1/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional },
constraints:new {action = @"(?!^\d+$)^.+$" }
);

config.Routes.MapHttpRoute(
name: "DefaultApiGet",
routeTemplate: "api/v1/{controller}/{id}",
Expand All @@ -46,12 +48,15 @@ public static void Register(HttpConfiguration config)
defaults: new { id = RouteParameter.Optional, action = "Delete" },
constraints: new { httpMethod = new HttpMethodConstraint(HttpMethod.Delete) }
);



//config.Routes.MapHttpRoute(
// name: "DefaultApi",
// routeTemplate: "api/v1/{controller}/{id}",
// defaults: new { id = RouteParameter.Optional }
// );
HttpConfiguration config1 = GlobalConfiguration.Configuration;

config.Formatters.JsonFormatter.SerializerSettings.Formatting =
Newtonsoft.Json.Formatting.Indented;

Expand Down

0 comments on commit 121db29

Please sign in to comment.