IO-70 Begin OEC through partner.

This commit is contained in:
Patrick Fic
2021-11-23 00:30:33 -08:00
parent f175578686
commit 6556c74266
23 changed files with 292 additions and 5 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -187,6 +187,7 @@
<Compile Include="Utils\JsonExtensions.cs" />
<Compile Include="Utils\LoginHelpers.cs" />
<Compile Include="Utils\Notifications.cs" />
<Compile Include="Utils\OEConnection.cs" />
<Compile Include="Utils\PowerModeEventHandler.cs" />
<Compile Include="Utils\PPGMixData.cs" />
<Compile Include="Utils\Queries\JobsQueries.cs" />
@@ -257,6 +258,54 @@
<Content Include="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="EmsBase\EMS.ENV">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMS.LIN">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMS.PFH">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMS.PFL">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMS.PFM">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMS.PFO">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMS.PFP">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMS.PFT">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMS.STL">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMS.TTL">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMSA.AD1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMSA.dbt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMSB.AD2">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMSB.dbt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMSV.dbt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="EmsBase\EMSV.VEH">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -294,19 +343,19 @@
<Version>6.0.0.3</Version>
</PackageReference>
<PackageReference Include="FirebaseAuthentication.net">
<Version>3.7.1</Version>
<Version>3.7.2</Version>
</PackageReference>
<PackageReference Include="GraphQL.Client">
<Version>3.2.3</Version>
<Version>4.0.1</Version>
</PackageReference>
<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft">
<Version>3.2.3</Version>
<Version>4.0.1</Version>
</PackageReference>
<PackageReference Include="Hardcodet.NotifyIcon.Wpf">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="MaterialDesignThemes">
<Version>4.1.0</Version>
<Version>4.2.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.CSharp">
<Version>4.7.0</Version>

View File

@@ -105,7 +105,7 @@ namespace BodyshopPartner.Utils.Decoder
var reader = new DBFReader(fis);
var type = reader.GetType();
logger.Trace(reader.Fields.ToString());
reader.SetSelectFields(new string[] { "INS_CO_ID","INS_CO_NM","INS_ADDR1","INS_ADDR2","INS_CITY","INS_ST","INS_ZIP","INS_CTRY",
"INS_EA","POLICY_NO","DED_AMT","DED_STATUS","ASGN_NO","ASGN_DATE","ASGN_TYPE","CLM_NO","CLM_OFC_ID","CLM_OFC_NM","CLM_ADDR1",

View File

@@ -69,6 +69,16 @@ namespace BodyshopPartner.Utils
(req, res, props) => { HandleImport(req, res); }
, "POST");
Route.Add("/oec/", (req, res, props) =>
{
hlog("Received an OEC from ImEX.online");
res.WithCORS();
res.Close();
}, "OPTIONS");
Route.Add("/oec/",
(req, res, props) => { HandleOec(req, res); }
, "POST");
logger.Trace("Starting HTTP server...");
hlog = HttpLogger;
@@ -92,6 +102,29 @@ namespace BodyshopPartner.Utils
}
}
private static void HandleOec(System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse res)
{
logger.Trace("/oec/ - POST");
//Input will be an array of objects containing XMLs.
var requestBody = ParseBody(req);
JObject HttpResponse = new JObject();
try
{
Utils.OEConnection.SendToOEConnection(requestBody);
HttpResponse.Add("success", true);
}
catch (Exception Ex)
{
logger.Error(Ex, "Error encountered while handling import requests.");
hlog("Error encountered while handling import requests.");
HttpResponse.Add("success", false);
HttpResponse.Add("error", Ex.ToString());
}
res.WithCORS().AsText(JsonConvert.SerializeObject(HttpResponse));
}
private static void HandleQbPost(System.Net.HttpListenerRequest req, System.Net.HttpListenerResponse res)
{
logger.Trace("/qb/ - POST");

View File

@@ -0,0 +1,196 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using DotNetDBF;
using Newtonsoft.Json.Linq;
namespace BodyshopPartner.Utils
{
public static class OEConnection
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private static string workingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
private static string emsBasePath = workingDirectory + @"\EmsBase";
private static string TempEmsDir = @"C:\VPS\TEMPEMS";
private static Encoding DbfFileCharEncoding = Encoding.GetEncoding("UTF-8");
private static byte DbfFileSignature = DBFSignature.DBase3;
private static byte DbfFileLanguageDriver = 0x37;
public static void SendToOEConnection(dynamic PartsOrder)
{
GenerateAd1File(PartsOrder.job);
}
public static DBFField[] ReadDbfFields(string dbfFilePath)
{
using (var blankEmsFileStream = File.Open(dbfFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (var reader = new DBFReader(blankEmsFileStream))
{
return reader.Fields;
}
}
}
public static string GenerateFileName(dynamic Job)
{
if (string.IsNullOrEmpty(Job.clm_no?.Value)) { return Job.ro_number?.Value; }
return Job.clm_no;
}
public static void GenerateAd1File(dynamic Job)
{
try
{
DBFField[] Ad1Fields = ReadDbfFields(emsBasePath + @"\EMSA.AD1");
using (var fileStream = File.Create(TempEmsDir + $@"\{GenerateFileName(Job)}A.ad1"))
{
using (var writer = new DBFWriter())
{
writer.CharEncoding = DbfFileCharEncoding;
writer.Signature = DbfFileSignature;
writer.LanguageDriver = DbfFileLanguageDriver;
writer.Fields = Ad1Fields;
writer.AddRecord(
Job.ins_co_id?.Value,
Job.ins_co_nm?.Value,
Job.ins_addr1?.Value,
Job.ins_addr2?.Value,
Job.ins_city?.Value,
Job.ins_st?.Value,
Job.ins_zip?.Value,
Job.ins_ctry?.Value,
Job.ins_ph1?.Value,
Job.ins_ph1x?.Value,
Job.ins_ph2?.Value,
Job.ins_ph2x?.Value,
Job.ins_fax?.Value,
Job.ins_faxx?.Value,
Job.ins_ct_ln?.Value,
Job.ins_ct_fn?.Value,
Job.ins_title?.Value,
Job.ins_ct_ph?.Value,
Job.ins_ct_phx?.Value,
Job.ins_ea?.Value,
Job.ins_memo?.Value,
Job.policy_no?.Value,
Job.ded_amt?.Value,
Job.ded_status?.Value,
Job.asgn_no?.Value,
string.IsNullOrEmpty(Job.asgn_date?.Value) ? null : DateTime.Parse(Job.asgn_date?.Value),
Job.asgn_type?.Value,
Job.clm_no?.Value,
Job.clm_ofc_id?.Value,
Job.clm_ofc_nm?.Value,
Job.clm_addr1?.Value,
Job.clm_addr2?.Value,
Job.clm_city?.Value,
Job.clm_st?.Value,
Job.clm_zip?.Value,
Job.clm_ctry?.Value,
Job.clm_ph1?.Value,
Job.clm_ph1x?.Value,
Job.clm_ph2?.Value,
Job.clm_ph2x?.Value,
Job.clm_fax?.Value,
Job.clm_faxx?.Value,
Job.clm_ct_ln?.Value,
Job.clm_ct_fn?.Value,
Job.clm_title?.Value,
Job.clm_ct_ph?.Value,
Job.clm_ct_phx?.Value,
Job.clm_ea?.Value,
Job.payee_nms?.Value,
Job.pay_type?.Value,
Job.pay_date?.Value,
Job.pay_chknm?.Value,
Job.pay_amt?.Value,
Job.pay_memo?.Value,
Job.agt_co_id?.Value,
Job.agt_co_nm?.Value,
Job.agt_addr1?.Value,
Job.agt_addr2?.Value,
Job.agt_city?.Value,
Job.agt_st?.Value,
Job.agt_zip?.Value,
Job.agt_ctry?.Value,
Job.agt_ph1?.Value,
Job.agt_ph1x?.Value,
Job.agt_ph2?.Value,
Job.agt_ph2x?.Value,
Job.agt_fax?.Value,
Job.agt_faxx?.Value,
Job.agt_ct_ln?.Value,
Job.agt_ct_fn?.Value,
Job.agt_ct_ph?.Value,
Job.agt_ct_phx?.Value,
Job.agt_ea?.Value,
Job.agt_lic_no?.Value,
string.IsNullOrEmpty(Job.loss_date?.Value) ? null : DateTime.Parse(Job.loss_date?.Value),
Job.loss_cat?.Value,
Job.loss_type?.Value,
Job.loss_desc?.Value,
Job.theft_ind?.Value,
Job.cat_no?.Value,
Job.tlos_ind?.Value,
Job.loss_memo?.Value,
Job.cust_pr?.Value,
Job.insd_ln?.Value,
Job.insd_fn?.Value,
Job.insd_title?.Value,
Job.insd_co_nm?.Value,
Job.insd_addr1?.Value,
Job.insd_addr2?.Value,
Job.insd_city?.Value,
Job.insd_st?.Value,
Job.insd_zip?.Value,
Job.insd_ctry?.Value,
Job.insd_ph1?.Value,
Job.insd_ph1x?.Value,
Job.insd_ph2?.Value,
Job.insd_ph2x?.Value,
Job.insd_fax?.Value,
Job.insd_faxx?.Value,
Job.insd_ea?.Value,
Job.ownr_ln?.Value,
Job.ownr_fn?.Value,
Job.ownr_title?.Value,
Job.ownr_co_nm?.Value,
Job.ownr_addr1?.Value,
Job.ownr_addr2?.Value,
Job.ownr_city?.Value,
Job.ownr_st?.Value,
Job.ownr_zip?.Value,
Job.ownr_ctry?.Value,
Job.ownr_ph1?.Value,
Job.ownr_ph1x?.Value,
Job.ownr_ph2?.Value,
Job.ownr_ph2x?.Value,
Job.ownr_fax?.Value,
Job.ownr_faxx?.Value,
Job.ownr_ea.Value
); ;
writer.Write(fileStream);
}
}
}
catch (Exception ex)
{
logger.Error(ex,"Error when creating AD1 file.");
}
}
}
}

View File

@@ -17,6 +17,8 @@ namespace BodyshopPartner.ViewModels
p => true,
async p =>
{
// Utils.OEConnection.SendToOEConnection();
await TestGql();
});
}

View File

@@ -144,6 +144,10 @@ namespace BodyshopPartner.ViewModels
private async void _updateTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
await updateCheck();
if (UpdateAvailable)
{
await InstallUpdates();
}
}
private void MonitoringPathsChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

View File

@@ -159,6 +159,9 @@
<Button Command="{Binding BrowseForPaintScalePathCommand, UpdateSourceTrigger=PropertyChanged}"
Margin="8"
Content="{x:Static p:Resources.Label_BrowsePaintScalePath}" />
<Button Command="{Binding TestCommand}"
Margin="8"
Content="OE Test" />
<!--<Button Click="Button_Click"
Margin="8"
Content="Test" />