feature: lodge insurance
This commit is contained in:
@@ -109,6 +109,7 @@ namespace Disco.Services.Authorization
|
||||
{ "Job.Actions.Delete", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.Delete, (c, v) => c.Job.Actions.Delete = v, "Delete Jobs", "Can delete jobs", false) },
|
||||
{ "Job.Actions.ForceClose", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.ForceClose, (c, v) => c.Job.Actions.ForceClose = v, "Force Close Jobs", "Can force close jobs", false) },
|
||||
{ "Job.Actions.GenerateDocuments", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.GenerateDocuments, (c, v) => c.Job.Actions.GenerateDocuments = v, "Generate Documents", "Can generate documents for jobs", false) },
|
||||
{ "Job.Actions.LogInsurance", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.LogInsurance, (c, v) => c.Job.Actions.LogInsurance = v, "Log Insurance", "Can log insurance for non-warranty jobs", false) },
|
||||
{ "Job.Actions.LogRepair", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.LogRepair, (c, v) => c.Job.Actions.LogRepair = v, "Log Repair", "Can log repair for non-warranty jobs", false) },
|
||||
{ "Job.Actions.LogWarranty", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.LogWarranty, (c, v) => c.Job.Actions.LogWarranty = v, "Log Warranty", "Can log warranty for jobs", false) },
|
||||
{ "Job.Actions.RemoveAnyAttachments", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.RemoveAnyAttachments, (c, v) => c.Job.Actions.RemoveAnyAttachments = v, "Remove Any Attachments", "Can remove any attachments from jobs", false) },
|
||||
@@ -133,7 +134,7 @@ namespace Disco.Services.Authorization
|
||||
{ "Job.Properties.NonWarrantyProperties.InsuranceClaimFormSent", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.InsuranceClaimFormSent, (c, v) => c.Job.Properties.NonWarrantyProperties.InsuranceClaimFormSent = v, "Insurance Claim Form Sent Property", "Can update property", false) },
|
||||
{ "Job.Properties.NonWarrantyProperties.InsuranceDetails", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.InsuranceDetails, (c, v) => c.Job.Properties.NonWarrantyProperties.InsuranceDetails = v, "Insurance Detail Properties", "Can update insurance detail properties", false) },
|
||||
{ "Job.Properties.NonWarrantyProperties.InvoiceReceived", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.InvoiceReceived, (c, v) => c.Job.Properties.NonWarrantyProperties.InvoiceReceived = v, "Invoice Received Property", "Can update property", false) },
|
||||
{ "Job.Properties.NonWarrantyProperties.IsInsuranceClaim", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.IsInsuranceClaim, (c, v) => c.Job.Properties.NonWarrantyProperties.IsInsuranceClaim = v, "Is Insurance Claim Property", "Can update property", false) },
|
||||
{ "Job.Properties.NonWarrantyProperties.IsInsuranceClaim", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.IsInsuranceClaim, (c, v) => c.Job.Properties.NonWarrantyProperties.IsInsuranceClaim = v, "Is Insurance Claim Property", "Can update property", false) },
|
||||
{ "Job.Properties.NonWarrantyProperties.PurchaseOrderRaised", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.PurchaseOrderRaised, (c, v) => c.Job.Properties.NonWarrantyProperties.PurchaseOrderRaised = v, "Purchase Order Raised Property", "Can update property", false) },
|
||||
{ "Job.Properties.NonWarrantyProperties.PurchaseOrderReference", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.PurchaseOrderReference, (c, v) => c.Job.Properties.NonWarrantyProperties.PurchaseOrderReference = v, "Purchase Order Reference Property", "Can update property", false) },
|
||||
{ "Job.Properties.NonWarrantyProperties.PurchaseOrderSent", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.PurchaseOrderSent, (c, v) => c.Job.Properties.NonWarrantyProperties.PurchaseOrderSent = v, "Purchase Order Sent Property", "Can update property", false) },
|
||||
@@ -337,6 +338,7 @@ namespace Disco.Services.Authorization
|
||||
new ClaimNavigatorItem("Job.Actions.Delete", false),
|
||||
new ClaimNavigatorItem("Job.Actions.ForceClose", false),
|
||||
new ClaimNavigatorItem("Job.Actions.GenerateDocuments", false),
|
||||
new ClaimNavigatorItem("Job.Actions.LogInsurance", false),
|
||||
new ClaimNavigatorItem("Job.Actions.LogRepair", false),
|
||||
new ClaimNavigatorItem("Job.Actions.LogWarranty", false),
|
||||
new ClaimNavigatorItem("Job.Actions.RemoveAnyAttachments", false),
|
||||
@@ -647,6 +649,7 @@ namespace Disco.Services.Authorization
|
||||
c.Job.Actions.Delete = true;
|
||||
c.Job.Actions.ForceClose = true;
|
||||
c.Job.Actions.GenerateDocuments = true;
|
||||
c.Job.Actions.LogInsurance = true;
|
||||
c.Job.Actions.LogRepair = true;
|
||||
c.Job.Actions.LogWarranty = true;
|
||||
c.Job.Actions.RemoveAnyAttachments = true;
|
||||
@@ -1341,6 +1344,11 @@ namespace Disco.Services.Authorization
|
||||
/// </summary>
|
||||
public const string GenerateDocuments = "Job.Actions.GenerateDocuments";
|
||||
|
||||
/// <summary>Log Insurance
|
||||
/// <para>Can log insurance for non-warranty jobs</para>
|
||||
/// </summary>
|
||||
public const string LogInsurance = "Job.Actions.LogInsurance";
|
||||
|
||||
/// <summary>Log Repair
|
||||
/// <para>Can log repair for non-warranty jobs</para>
|
||||
/// </summary>
|
||||
@@ -1481,7 +1489,7 @@ namespace Disco.Services.Authorization
|
||||
/// </summary>
|
||||
public const string InvoiceReceived = "Job.Properties.NonWarrantyProperties.InvoiceReceived";
|
||||
|
||||
/// <summary>Is Insurance Claim Property
|
||||
/// <summary>Is Insurance Claim Property
|
||||
/// <para>Can update property</para>
|
||||
/// </summary>
|
||||
public const string IsInsuranceClaim = "Job.Properties.NonWarrantyProperties.IsInsuranceClaim";
|
||||
|
||||
@@ -23,10 +23,12 @@
|
||||
[ClaimDetails("Remove from Any Queues", "Can remove from any job queues")]
|
||||
public bool RemoveAnyQueues { get; set; }
|
||||
|
||||
[ClaimDetails("Log Warranty", "Can log warranty for jobs")]
|
||||
[ClaimDetails("Lodge Warranty", "Can lodge warranty for jobs")]
|
||||
public bool LogWarranty { get; set; }
|
||||
[ClaimDetails("Log Repair", "Can log repair for non-warranty jobs")]
|
||||
[ClaimDetails("Lodge Repair", "Can lodge repair for non-warranty jobs")]
|
||||
public bool LogRepair { get; set; }
|
||||
[ClaimDetails("Lodge Insurance", "Can lodge insurance for non-warranty jobs")]
|
||||
public bool LogInsurance { get; set; }
|
||||
|
||||
[ClaimDetails("Convert HWar Jobs To HNWar", "Can convert warranty jobs to non-warranty jobs")]
|
||||
public bool ConvertHWarToHNWar { get; set; }
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
[ClaimDetails("Edit Components", "Can edit and remove job components")]
|
||||
public bool EditComponents { get; set; }
|
||||
|
||||
[ClaimDetails("Is Insurance Claim Property", "Can update property")]
|
||||
[ClaimDetails("Is Insurance Claim Property", "Can update property")]
|
||||
public bool IsInsuranceClaim { get; set; }
|
||||
|
||||
[ClaimDetails("Insurance Claim Form Sent Property", "Can update property")]
|
||||
|
||||
@@ -324,6 +324,7 @@
|
||||
<Compile Include="Expressions\ExpressionTypeMemberDescriptor.cs" />
|
||||
<Compile Include="Expressions\Extensions\DataExt.cs" />
|
||||
<Compile Include="Expressions\Extensions\DeviceExt.cs" />
|
||||
<Compile Include="Expressions\Extensions\EmailExt.cs" />
|
||||
<Compile Include="Expressions\Extensions\ImageExt.cs" />
|
||||
<Compile Include="Expressions\Extensions\ImageResultImplementations\BaseImageExpressionResult.cs" />
|
||||
<Compile Include="Expressions\Extensions\ImageResultImplementations\BitmapImageExpressionResult.cs" />
|
||||
@@ -412,6 +413,10 @@
|
||||
<Compile Include="Plugins\Features\DetailsProvider\DetailsProviderService.cs" />
|
||||
<Compile Include="Plugins\Features\DetailsProvider\UserContactFeature.cs" />
|
||||
<Compile Include="Plugins\Features\DocumentHandlerProvider\DocumentHandlerProviderFeature.cs" />
|
||||
<Compile Include="Plugins\Features\InsuranceProvider\InsuranceProviderFeature.cs" />
|
||||
<Compile Include="Plugins\Features\InsuranceProvider\InsuranceProviderSubmitJobException.cs" />
|
||||
<Compile Include="Plugins\Features\RepairProvider\RepairProvider2Feature.cs" />
|
||||
<Compile Include="Plugins\Features\WarrantyProvider\WarrantyProvider2Feature.cs" />
|
||||
<Compile Include="Plugins\Features\WirelessProfileProvider\ProvisionWirelessProfilesResult.cs" />
|
||||
<Compile Include="Plugins\Features\WirelessProfileProvider\WirelessProfile.cs" />
|
||||
<Compile Include="Plugins\Features\WirelessProfileProvider\WirelessProfileTransformation.cs" />
|
||||
@@ -540,6 +545,7 @@
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
||||
@@ -4,6 +4,7 @@ using Disco.Models.Repository;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Logging;
|
||||
using Disco.Services.Plugins;
|
||||
using Disco.Services.Plugins.Features.InsuranceProvider;
|
||||
using Disco.Services.Plugins.Features.RepairProvider;
|
||||
using Disco.Services.Plugins.Features.WarrantyProvider;
|
||||
using Disco.Services.Users;
|
||||
@@ -63,7 +64,6 @@ namespace Disco.Services
|
||||
return (!j.ClosedDate.HasValue) && j.DeviceHeld.HasValue &&
|
||||
!j.DeviceReadyForReturn.HasValue && !j.DeviceReturnedDate.HasValue;
|
||||
}
|
||||
public static void OnDeviceReadyForReturn(this Job j, User Technician)
|
||||
public static void OnDeviceReadyForReturn(this Job j, DiscoDataContext Database, User Technician)
|
||||
{
|
||||
if (!j.CanDeviceReadyForReturn())
|
||||
@@ -182,19 +182,21 @@ namespace Disco.Services
|
||||
public static void OnLogWarranty(this Job j, DiscoDataContext Database, string FaultDescription, List<JobAttachment> SendAttachments, PluginFeatureManifest WarrantyProviderDefinition, OrganisationAddress Address, User TechUser, Dictionary<string, string> WarrantyProviderProperties)
|
||||
{
|
||||
if (!j.CanLogWarranty())
|
||||
throw new InvalidOperationException("Log Warranty was Denied");
|
||||
throw new InvalidOperationException("Lodge Warranty was Denied");
|
||||
|
||||
PublishJobResult publishJobResult = null;
|
||||
|
||||
using (WarrantyProviderFeature WarrantyProvider = WarrantyProviderDefinition.CreateInstance<WarrantyProviderFeature>())
|
||||
using (WarrantyProviderFeature warrantyProvider = WarrantyProviderDefinition.CreateInstance<WarrantyProviderFeature>())
|
||||
{
|
||||
if (SendAttachments != null && SendAttachments.Count > 0)
|
||||
var warrantyProvider2 = warrantyProvider as WarrantyProvider2Feature;
|
||||
|
||||
if (warrantyProvider2 == null && SendAttachments != null && SendAttachments.Count > 0)
|
||||
{
|
||||
publishJobResult = DiscoServicesJobs.Publish(
|
||||
Database,
|
||||
j,
|
||||
TechUser,
|
||||
WarrantyProvider.WarrantyProviderId,
|
||||
warrantyProvider.WarrantyProviderId,
|
||||
null,
|
||||
FaultDescription,
|
||||
SendAttachments,
|
||||
@@ -216,10 +218,14 @@ namespace Disco.Services
|
||||
else
|
||||
submitDescription = string.Concat(FaultDescription, Environment.NewLine, Environment.NewLine, j.GenerateFaultDescriptionFooter(Database, WarrantyProviderDefinition));
|
||||
|
||||
string providerRef = WarrantyProvider.SubmitJob(Database, j, Address, TechUser, submitDescription, WarrantyProviderProperties);
|
||||
string providerRef;
|
||||
if (warrantyProvider2 != null)
|
||||
providerRef = warrantyProvider2.SubmitJob(Database, j, Address, TechUser, FaultDescription, SendAttachments, WarrantyProviderProperties);
|
||||
else
|
||||
providerRef = warrantyProvider.SubmitJob(Database, j, Address, TechUser, submitDescription, WarrantyProviderProperties);
|
||||
|
||||
j.JobMetaWarranty.ExternalLoggedDate = DateTime.Now;
|
||||
j.JobMetaWarranty.ExternalName = WarrantyProvider.WarrantyProviderId;
|
||||
j.JobMetaWarranty.ExternalName = warrantyProvider.WarrantyProviderId;
|
||||
|
||||
if (providerRef != null && providerRef.Length > 100)
|
||||
j.JobMetaWarranty.ExternalReference = providerRef.Substring(0, 100);
|
||||
@@ -232,7 +238,7 @@ namespace Disco.Services
|
||||
JobId = j.Id,
|
||||
TechUserId = TechUser.UserId,
|
||||
Timestamp = DateTime.Now,
|
||||
Comments = string.Format("# Warranty Claim Submitted\r\nProvider: **{0}**\r\nAddress: **{1}**\r\nReference: **{2}**\r\n___\r\n```{3}```", WarrantyProvider.Manifest.Name, Address.Name, providerRef, FaultDescription)
|
||||
Comments = string.Format("# Warranty Claim Submitted\r\nProvider: **{0}**\r\nAddress: **{1}**\r\nReference: **{2}**\r\n___\r\n```{3}```", warrantyProvider.Manifest.Name, Address.Name, providerRef, FaultDescription)
|
||||
};
|
||||
Database.JobLogs.Add(jobLog);
|
||||
|
||||
@@ -249,7 +255,7 @@ namespace Disco.Services
|
||||
public static void OnLogWarranty(this Job j, DiscoDataContext Database, string FaultDescription, string ManualProviderName, string ManualProviderReference, OrganisationAddress Address, User TechUser)
|
||||
{
|
||||
if (!j.CanLogWarranty())
|
||||
throw new InvalidOperationException("Log Warranty was Denied");
|
||||
throw new InvalidOperationException("Lodge Warranty was Denied");
|
||||
|
||||
j.JobMetaWarranty.ExternalLoggedDate = DateTime.Now;
|
||||
j.JobMetaWarranty.ExternalName = ManualProviderName;
|
||||
@@ -369,6 +375,7 @@ namespace Disco.Services
|
||||
#endregion
|
||||
|
||||
#region Insurance Claim Form Sent
|
||||
[Obsolete("Use Log Insurance instead")]
|
||||
public static bool CanInsuranceClaimFormSent(this Job j)
|
||||
{
|
||||
if (!UserService.CurrentAuthorization.Has(Claims.Job.Properties.NonWarrantyProperties.InsuranceClaimFormSent))
|
||||
@@ -378,6 +385,7 @@ namespace Disco.Services
|
||||
j.JobMetaNonWarranty.IsInsuranceClaim &&
|
||||
!j.JobMetaInsurance.ClaimFormSentDate.HasValue;
|
||||
}
|
||||
[Obsolete("Use Log Insurance instead")]
|
||||
public static void OnInsuranceClaimFormSent(this Job j)
|
||||
{
|
||||
if (!j.CanInsuranceClaimFormSent())
|
||||
@@ -404,19 +412,21 @@ namespace Disco.Services
|
||||
public static void OnLogRepair(this Job j, DiscoDataContext Database, string RepairDescription, List<JobAttachment> SendAttachments, PluginFeatureManifest RepairProviderDefinition, OrganisationAddress Address, User TechUser, Dictionary<string, string> RepairProviderProperties)
|
||||
{
|
||||
if (!j.CanLogRepair())
|
||||
throw new InvalidOperationException("Log Repair was Denied");
|
||||
throw new InvalidOperationException("Lodge Repair was Denied");
|
||||
|
||||
PublishJobResult publishJobResult = null;
|
||||
|
||||
using (RepairProviderFeature RepairProvider = RepairProviderDefinition.CreateInstance<RepairProviderFeature>())
|
||||
using (RepairProviderFeature repairProvider = RepairProviderDefinition.CreateInstance<RepairProviderFeature>())
|
||||
{
|
||||
if (SendAttachments != null && SendAttachments.Count > 0)
|
||||
var repairProvider2 = repairProvider as RepairProvider2Feature;
|
||||
|
||||
if (repairProvider2 == null && SendAttachments != null && SendAttachments.Count > 0)
|
||||
{
|
||||
publishJobResult = DiscoServicesJobs.Publish(
|
||||
Database,
|
||||
j,
|
||||
TechUser,
|
||||
RepairProvider.ProviderId,
|
||||
repairProvider.ProviderId,
|
||||
null,
|
||||
RepairDescription,
|
||||
SendAttachments,
|
||||
@@ -438,10 +448,14 @@ namespace Disco.Services
|
||||
else
|
||||
submitDescription = string.Concat(RepairDescription, Environment.NewLine, Environment.NewLine, j.GenerateFaultDescriptionFooter(Database, RepairProviderDefinition));
|
||||
|
||||
string providerRef = RepairProvider.SubmitJob(Database, j, Address, TechUser, submitDescription, RepairProviderProperties);
|
||||
string providerRef;
|
||||
if (repairProvider2 != null)
|
||||
providerRef = repairProvider2.SubmitJob(Database, j, Address, TechUser, submitDescription, SendAttachments, RepairProviderProperties);
|
||||
else
|
||||
providerRef = repairProvider.SubmitJob(Database, j, Address, TechUser, submitDescription, RepairProviderProperties);
|
||||
|
||||
j.JobMetaNonWarranty.RepairerLoggedDate = DateTime.Now;
|
||||
j.JobMetaNonWarranty.RepairerName = RepairProvider.ProviderId;
|
||||
j.JobMetaNonWarranty.RepairerName = repairProvider.ProviderId;
|
||||
|
||||
if (providerRef != null && providerRef.Length > 100)
|
||||
j.JobMetaNonWarranty.RepairerReference = providerRef.Substring(0, 100);
|
||||
@@ -454,7 +468,7 @@ namespace Disco.Services
|
||||
JobId = j.Id,
|
||||
TechUserId = TechUser.UserId,
|
||||
Timestamp = DateTime.Now,
|
||||
Comments = string.Format("# Repair Request Submitted\r\nProvider: **{0}**\r\nAddress: **{1}**\r\nReference: **{2}**\r\n___\r\n```{3}```", RepairProvider.Manifest.Name, Address.Name, providerRef, RepairDescription)
|
||||
Comments = string.Format("# Repair Request Submitted\r\nProvider: **{0}**\r\nAddress: **{1}**\r\nReference: **{2}**\r\n___\r\n```{3}```", repairProvider.Manifest.Name, Address.Name, providerRef, RepairDescription)
|
||||
};
|
||||
Database.JobLogs.Add(jobLog);
|
||||
|
||||
@@ -471,7 +485,7 @@ namespace Disco.Services
|
||||
public static void OnLogRepair(this Job j, DiscoDataContext Database, string FaultDescription, string ManualProviderName, string ManualProviderReference, OrganisationAddress Address, User TechUser)
|
||||
{
|
||||
if (!j.CanLogRepair())
|
||||
throw new InvalidOperationException("Log Repair was Denied");
|
||||
throw new InvalidOperationException("Lodge Repair was Denied");
|
||||
|
||||
j.JobMetaNonWarranty.RepairerLoggedDate = DateTime.Now;
|
||||
j.JobMetaNonWarranty.RepairerName = ManualProviderName;
|
||||
@@ -512,6 +526,72 @@ namespace Disco.Services
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Log Insurance
|
||||
public static bool CanLogInsurance(this Job j)
|
||||
{
|
||||
if (!UserService.CurrentAuthorization.HasAny(Claims.Job.Actions.LogInsurance, Claims.Job.Properties.NonWarrantyProperties.InsuranceClaimFormSent))
|
||||
return false;
|
||||
|
||||
return j.JobTypeId == JobType.JobTypeIds.HNWar &&
|
||||
j.DeviceSerialNumber != null &&
|
||||
j.JobMetaNonWarranty.IsInsuranceClaim &&
|
||||
!j.JobMetaInsurance.ClaimFormSentDate.HasValue;
|
||||
}
|
||||
public static void OnLogInsurance(this Job j, DiscoDataContext database, List<JobAttachment> attachments, PluginFeatureManifest providerDefinition, OrganisationAddress address, User techUser, Dictionary<string, string> providerProperties)
|
||||
{
|
||||
if (!j.CanLogInsurance())
|
||||
throw new InvalidOperationException("Lodge Insurance was Denied");
|
||||
|
||||
using (var provider = providerDefinition.CreateInstance<InsuranceProviderFeature>())
|
||||
{
|
||||
var providerRef = provider.SubmitJob(database, j, address, techUser, attachments, providerProperties);
|
||||
|
||||
j.JobMetaInsurance.Insurer = provider.ProviderId;
|
||||
j.JobMetaInsurance.ClaimFormSentDate = DateTime.Now;
|
||||
j.JobMetaInsurance.ClaimFormSentUserId = techUser.UserId;
|
||||
|
||||
if (providerRef != null && providerRef.Length > 200)
|
||||
j.JobMetaInsurance.InsurerReference = providerRef.Substring(0, 200);
|
||||
else
|
||||
j.JobMetaInsurance.InsurerReference = providerRef;
|
||||
|
||||
// Write Log
|
||||
var jobLog = new JobLog()
|
||||
{
|
||||
JobId = j.Id,
|
||||
TechUserId = techUser.UserId,
|
||||
Timestamp = DateTime.Now,
|
||||
Comments = $"# Insurance Claim Submitted\r\nProvider: **{provider.Manifest.Name}**\r\nAddress: **{address.Name}**\r\nReference: **{providerRef}**",
|
||||
};
|
||||
database.JobLogs.Add(jobLog);
|
||||
}
|
||||
}
|
||||
public static void OnLogInsurance(this Job j, DiscoDataContext database, string manualProviderName, string manualProviderReference, OrganisationAddress address, User techUser)
|
||||
{
|
||||
if (!j.CanLogInsurance())
|
||||
throw new InvalidOperationException("Lodge Insurance was Denied");
|
||||
|
||||
j.JobMetaInsurance.Insurer = manualProviderName;
|
||||
j.JobMetaInsurance.ClaimFormSentDate = DateTime.Now;
|
||||
j.JobMetaInsurance.ClaimFormSentUserId = techUser.UserId;
|
||||
|
||||
if (manualProviderReference != null && manualProviderReference.Length > 200)
|
||||
j.JobMetaInsurance.InsurerReference = manualProviderReference.Substring(0, 200);
|
||||
else
|
||||
j.JobMetaInsurance.InsurerReference = manualProviderReference;
|
||||
|
||||
// Write Log
|
||||
JobLog jobLog = new JobLog()
|
||||
{
|
||||
JobId = j.Id,
|
||||
TechUserId = techUser.UserId,
|
||||
Timestamp = DateTime.Now,
|
||||
Comments = $"# Manual Insurance Request Submitted\r\nProvider: **{manualProviderName}**\r\nAddress: **{address.Name}**\r\nReference: **{manualProviderReference ?? "<none>"}**",
|
||||
};
|
||||
database.JobLogs.Add(jobLog);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Close
|
||||
public static void OnCloseNormally(this Job j, DiscoDataContext Database, User Technician)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.BI.Config;
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Services.Plugins.Features.InsuranceProvider
|
||||
{
|
||||
[PluginFeatureCategory(DisplayName = "Insurance Providers")]
|
||||
public abstract class InsuranceProviderFeature : PluginFeature
|
||||
{
|
||||
/// <summary>
|
||||
/// The insurer identifier. Used to link this provider to any <see cref="JobMetaInsurance.Insurer"/>. This identifier is used to automatically set the Insurer when a job is submitted using this plugin.
|
||||
/// </summary>
|
||||
public abstract string ProviderId { get; }
|
||||
|
||||
#region Job Submission
|
||||
|
||||
/// <summary>
|
||||
/// Called when a user selects this plugin to submit the insurance claim and allows a plugin to inject a View to collect additional information.
|
||||
/// </summary>
|
||||
/// <returns>A Tuple consisting of the Razor View type and a View Model</returns>
|
||||
public virtual Tuple<Type, dynamic> SubmitJobBegin(DiscoDataContext database, Controller controller, Job job, OrganisationAddress address, User techUser)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the RepairDescription is completed and allows the plugin to parse any data collected from SubmitJobBegin.
|
||||
/// </summary>
|
||||
/// <returns>A Dictionary of key/value items which are persisted throughout the submission and passed into the final SubmitJob method.</returns>
|
||||
public virtual Dictionary<string, string> SubmitJobParseProperties(DiscoDataContext database, FormCollection form, Controller controller, Job job, OrganisationAddress address, User techUser)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plugins are required to disclose any information that will be transmitted to any external party. This method is expected to return a clear list all data which will be transmitted.
|
||||
/// </summary>
|
||||
/// <returns>A Dictionary of key/value items which contain all information which will be disclosed to the plugin provider.</returns>
|
||||
public abstract Dictionary<string, string> SubmitJobDiscloseInfo(DiscoDataContext database, Job job, OrganisationAddress address, User techUser, Dictionary<string, string> providerProperties);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the plugin should submit the job to the external party.
|
||||
/// </summary>
|
||||
/// <returns>A reference number/identifier from the external party which is stored in <see cref="JobMetaInsurance.InsurerReference"/></returns>
|
||||
public abstract string SubmitJob(DiscoDataContext database, Job job, OrganisationAddress address, User techUser, List<JobAttachment> attachments, Dictionary<string, string> providerProperties);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Job Details
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="true"/> when additional Job Details are supported by the external party. When <see cref="true"/>, JobDetailsViewModel must be implemented.
|
||||
/// </summary>
|
||||
public abstract bool JobDetailsSupported { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when a job's insurance information is shown. Allows a plugin to inject a View to display additional information.
|
||||
/// </summary>
|
||||
/// <returns>A Tuple consisting of the Razor View type and a View Model</returns>
|
||||
public virtual Tuple<Type, dynamic> JobDetails(DiscoDataContext database, Controller controller, Job job)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static PluginFeatureManifest FindPluginFeature(string pluginIdOrInsuranceProviderId)
|
||||
{
|
||||
var defs = Plugins.GetPluginFeatures(typeof(InsuranceProviderFeature));
|
||||
var def = defs.FirstOrDefault(d => d.PluginManifest.Id.Equals(pluginIdOrInsuranceProviderId, StringComparison.OrdinalIgnoreCase));
|
||||
if (def != null)
|
||||
return def;
|
||||
else
|
||||
foreach (var d in defs)
|
||||
{
|
||||
using (var providerInstance = d.CreateInstance<InsuranceProviderFeature>())
|
||||
{
|
||||
if (providerInstance.ProviderId != null && providerInstance.ProviderId.Equals(pluginIdOrInsuranceProviderId, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Disco.Services.Plugins.Features.InsuranceProvider
|
||||
{
|
||||
public class InsuranceProviderSubmitJobException : Exception
|
||||
{
|
||||
public InsuranceProviderSubmitJobException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.BI.Config;
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Disco.Services.Plugins.Features.RepairProvider
|
||||
{
|
||||
[PluginFeatureCategory(DisplayName = "Repair Providers")]
|
||||
public abstract class RepairProvider2Feature : RepairProviderFeature
|
||||
{
|
||||
public override sealed string SubmitJob(DiscoDataContext Database, Job Job, OrganisationAddress Address, User TechUser, string RepairDescription, Dictionary<string, string> ProviderProperties)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public abstract string SubmitJob(DiscoDataContext database, Job job, OrganisationAddress address, User techUser, string description, List<JobAttachment> attachments, Dictionary<string, string> providerProperties);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.BI.Config;
|
||||
using Disco.Models.Repository;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Disco.Services.Plugins.Features.WarrantyProvider
|
||||
{
|
||||
[PluginFeatureCategory(DisplayName = "Warranty Providers")]
|
||||
public abstract class WarrantyProvider2Feature : WarrantyProviderFeature
|
||||
{
|
||||
public override sealed string SubmitJob(DiscoDataContext Database, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription, Dictionary<string, string> WarrantyProviderProperties)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public abstract string SubmitJob(DiscoDataContext database, Job job, OrganisationAddress address, User techUser, string description, List<JobAttachment> attachments, Dictionary<string, string> providerProperties);
|
||||
}
|
||||
}
|
||||
@@ -530,6 +530,7 @@ namespace Disco.Services.Plugins
|
||||
public void LogWarning(string Message)
|
||||
{
|
||||
LogWarning(Message, null);
|
||||
PluginsLog.LogPluginWarning(this, Message);
|
||||
}
|
||||
public void LogWarning(string MessageFormat, params object[] Args)
|
||||
{
|
||||
@@ -537,7 +538,7 @@ namespace Disco.Services.Plugins
|
||||
}
|
||||
public void LogMessage(string Message)
|
||||
{
|
||||
LogMessage(Message, null);
|
||||
PluginsLog.LogPluginMessage(this, Message);
|
||||
}
|
||||
public void LogMessage(string MessageFormat, params object[] Args)
|
||||
{
|
||||
|
||||
@@ -179,6 +179,15 @@ namespace Disco.Services.Plugins
|
||||
return new HttpStatusCodeResult(System.Net.HttpStatusCode.OK, description);
|
||||
}
|
||||
|
||||
public ActionResult BadRequest()
|
||||
{
|
||||
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
|
||||
}
|
||||
public ActionResult BadRequest(string description)
|
||||
{
|
||||
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, description);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Content
|
||||
@@ -262,11 +271,17 @@ namespace Disco.Services.Plugins
|
||||
}
|
||||
public ActionResult RedirectToPluginAction(string PluginAction)
|
||||
{
|
||||
if (string.IsNullOrEmpty(PluginAction))
|
||||
throw new ArgumentNullException("PluginAction");
|
||||
return RedirectToPluginAction(PluginAction, null);
|
||||
}
|
||||
public ActionResult RedirectToPluginAction(string pluginAction, object routeValues)
|
||||
{
|
||||
if (string.IsNullOrEmpty(pluginAction))
|
||||
throw new ArgumentNullException(nameof(pluginAction));
|
||||
|
||||
var routeValues = new RouteValueDictionary(new { PluginId = Manifest.Id, PluginAction = PluginAction });
|
||||
string pluginActionUrl = UrlHelper.GenerateUrl("Plugin", null, null, routeValues, RouteTable.Routes, HostController.Request.RequestContext, false);
|
||||
var routeValueDictionary = new RouteValueDictionary(routeValues);
|
||||
routeValueDictionary.Add("PluginId", Manifest.Id);
|
||||
routeValueDictionary.Add("PluginAction", pluginAction);
|
||||
string pluginActionUrl = UrlHelper.GenerateUrl("Plugin", null, null, routeValueDictionary, RouteTable.Routes, HostController.Request.RequestContext, false);
|
||||
|
||||
return new RedirectResult(pluginActionUrl, false);
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ namespace Disco.Services.Plugins
|
||||
private readonly PluginControllerDescription controllerDescription;
|
||||
private readonly MethodInfo methodInfo;
|
||||
private readonly IAuthorizationFilter[] authorizationFilters;
|
||||
private readonly ActionMethodSelectorAttribute methodSelector;
|
||||
private readonly PluginParameterDescriptor[] parameterDescriptors;
|
||||
public override string UniqueId { get; }
|
||||
public override string ActionName { get; }
|
||||
@@ -146,6 +147,7 @@ namespace Disco.Services.Plugins
|
||||
UniqueId = $"{ControllerDescriptor.UniqueId}_{methodName}";
|
||||
ActionName = methodName;
|
||||
authorizationFilters = DiscoverAuthorizationFilters();
|
||||
methodSelector = DiscoverMethodSelector();
|
||||
parameterDescriptors = DiscoverParameters();
|
||||
}
|
||||
|
||||
@@ -159,6 +161,11 @@ namespace Disco.Services.Plugins
|
||||
return filters.ToArray();
|
||||
}
|
||||
|
||||
private ActionMethodSelectorAttribute DiscoverMethodSelector()
|
||||
{
|
||||
return methodInfo.GetCustomAttributes<ActionMethodSelectorAttribute>(true).FirstOrDefault();
|
||||
}
|
||||
|
||||
private PluginParameterDescriptor[] DiscoverParameters()
|
||||
{
|
||||
var methodParams = methodInfo.GetParameters();
|
||||
@@ -187,6 +194,9 @@ namespace Disco.Services.Plugins
|
||||
|
||||
public ActionResult Execute(PluginWebHandlerController pluginController, ControllerContext controllerContext)
|
||||
{
|
||||
if (methodSelector != null && !methodSelector.IsValidForRequest(controllerContext, methodInfo))
|
||||
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest);
|
||||
|
||||
var methodParameters = BuildMethodParameters(methodInfo, controllerContext.Controller);
|
||||
|
||||
return (ActionResult)methodInfo.Invoke(pluginController, methodParameters);
|
||||
|
||||
@@ -237,7 +237,7 @@ namespace Disco.Services.Plugins
|
||||
if (_PluginManifests == null)
|
||||
throw new InvalidOperationException("Plugins have not been initialized");
|
||||
|
||||
return _PluginManifests.Values.SelectMany(pm => pm.Features).Where(fm => fm.CategoryType.IsAssignableFrom(FeatureCategoryType)).OrderBy(fm => fm.PluginManifest.Name).ToList();
|
||||
return _PluginManifests.Values.SelectMany(pm => pm.Features).Where(fm => FeatureCategoryType.IsAssignableFrom(fm.CategoryType)).OrderBy(fm => fm.PluginManifest.Name).ToList();
|
||||
}
|
||||
public static List<PluginFeatureManifest> GetPluginFeatures()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user