Changed a lot LOL
This commit is contained in:
@@ -30,7 +30,7 @@ namespace PartSource.Automation.Jobs
|
||||
|
||||
await SyncronizeIdsAndSkus();
|
||||
//await AddSkus();
|
||||
// await AddVariants();
|
||||
// await AddVariants();
|
||||
|
||||
return new AutomationJobResult
|
||||
{
|
||||
@@ -43,12 +43,13 @@ namespace PartSource.Automation.Jobs
|
||||
/// </summary>
|
||||
private async Task SyncronizeIdsAndSkus()
|
||||
{
|
||||
IEnumerable<Product> products = await _shopifyClient.Products.Get();
|
||||
IEnumerable<Product> products = await _shopifyClient.Products.Get(new Dictionary<string, object> { { "limit", 250 } });
|
||||
|
||||
_partSourceContext.Database.ExecuteSqlCommand("UPDATE ImportData SET ShopifyId = NULL");
|
||||
//_partSourceContext.Database.ExecuteSqlCommand("UPDATE ImportData SET ShopifyId = NULL");
|
||||
|
||||
while (products != null && products.Any())
|
||||
{
|
||||
|
||||
foreach (Product product in products)
|
||||
{
|
||||
foreach (Variant variant in product.Variants)
|
||||
@@ -62,16 +63,19 @@ namespace PartSource.Automation.Jobs
|
||||
}
|
||||
}
|
||||
|
||||
await _partSourceContext.SaveChangesAsync();
|
||||
|
||||
try
|
||||
{
|
||||
products = await _shopifyClient.Products.GetNext();
|
||||
await _partSourceContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
products = await _shopifyClient.Products.GetPrevious();
|
||||
Console.WriteLine("Failed to save a batch of products");
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
products = await _shopifyClient.Products.GetNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +89,7 @@ namespace PartSource.Automation.Jobs
|
||||
.ToList();
|
||||
|
||||
// items = items.Where(i => i.Title == items.First().Title).ToList();
|
||||
//
|
||||
//
|
||||
foreach (ImportData importData in items)
|
||||
{
|
||||
try
|
||||
@@ -145,12 +149,12 @@ namespace PartSource.Automation.Jobs
|
||||
Title = importData.Title,
|
||||
Vendor = importData.Vendor,
|
||||
Tags = string.Join(",", productTags),
|
||||
Published = true,
|
||||
//ProductType = importData.FINELINE_NM,
|
||||
Images = productImages.ToArray(),
|
||||
//Variants = productVariants.ToArray(),
|
||||
CreatedAt = DateTime.Now,
|
||||
UpdatedAt = DateTime.Now
|
||||
UpdatedAt = DateTime.Now,
|
||||
PublishedAt = DateTime.Now
|
||||
};
|
||||
|
||||
requestData = await _shopifyClient.Products.Add(requestData);
|
||||
@@ -259,12 +263,12 @@ namespace PartSource.Automation.Jobs
|
||||
Title = items[0].Title,
|
||||
Vendor = items[0].Vendor,
|
||||
Tags = string.Join(",", productTags),
|
||||
Published = true,
|
||||
//ProductType = importData.FINELINE_NM,
|
||||
Images = productImages.ToArray(),
|
||||
//Variants = productVariants.ToArray(),
|
||||
CreatedAt = DateTime.Now,
|
||||
UpdatedAt = DateTime.Now
|
||||
UpdatedAt = DateTime.Now,
|
||||
PublishedAt = DateTime.Now
|
||||
};
|
||||
|
||||
requestData = await _shopifyClient.Products.Add(requestData);
|
||||
|
||||
@@ -19,6 +19,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Ratermania.Shopify;
|
||||
using Ratermania.Shopify.Resources;
|
||||
using Ratermania.Shopify.Exceptions;
|
||||
|
||||
namespace PartSource.Automation.Jobs
|
||||
{
|
||||
@@ -40,29 +41,50 @@ namespace PartSource.Automation.Jobs
|
||||
|
||||
public async Task<AutomationJobResult> Run()
|
||||
{
|
||||
IList<ImportData> parts = _partSourceContext.ImportData
|
||||
.Where(p => p.UpdatedAt < DateTime.Now.AddDays(-3))
|
||||
.Take(50)
|
||||
.ToList();
|
||||
IEnumerable<Product> products = null;
|
||||
|
||||
while (parts != null && parts.Count > 0)
|
||||
try
|
||||
{
|
||||
foreach (ImportData importData in parts)
|
||||
products = await _shopifyClient.Products.Get(new Dictionary<string, object> { { "limit", 250 } });
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
// TODO: Logging
|
||||
return new AutomationJobResult
|
||||
{
|
||||
Message = "Failed to get products from Shopify",
|
||||
IsSuccess = false
|
||||
};
|
||||
}
|
||||
|
||||
while (products != null && products.Any())
|
||||
{
|
||||
foreach (Product product in products)
|
||||
{
|
||||
try
|
||||
{
|
||||
Product product = await _shopifyClient.Products.GetById(importData.ShopifyId.GetValueOrDefault());
|
||||
if (product == null)
|
||||
ImportData importData = await _partSourceContext.ImportData
|
||||
.Where(i => i.ShopifyId == product.Id && i.UpdatedAt <= DateTime.Now.AddDays(-7))
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (importData == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
bool isFitment = false;
|
||||
|
||||
IList<Vehicle> vehicles = _vehicleService.GetVehiclesForPart(importData.PartNumber, importData.LineCode);
|
||||
IList<Vehicle> vehicles = _vehicleService.GetVehiclesForPart(importData.PartNumber, importData.LineCode, 255);
|
||||
|
||||
if (vehicles.Count > 250)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
IList<int> vehicleIdFitment = _vehicleService.GetVehicleIdFitment(vehicles);
|
||||
if (vehicleIdFitment.Count > 0)
|
||||
|
||||
if (vehicleIdFitment.Count > 0 && vehicleIdFitment.Count <= 250)
|
||||
{
|
||||
isFitment = true;
|
||||
|
||||
@@ -121,11 +143,25 @@ namespace PartSource.Automation.Jobs
|
||||
|
||||
await _shopifyClient.Metafields.Add(isFitmentMetafield);
|
||||
|
||||
|
||||
//Metafield noteTextMetafield = new Metafield
|
||||
//{
|
||||
// Namespace = "Flags",
|
||||
// Key = "IsFitment",
|
||||
// Value = isFitment.ToString(),
|
||||
// ValueType = "string",
|
||||
// OwnerResource = "product",
|
||||
// OwnerId = product.Id
|
||||
//};
|
||||
|
||||
//await _shopifyClient.Metafields.Add(noteTextMetafield);
|
||||
|
||||
|
||||
List<string> tags = new List<string>
|
||||
{
|
||||
importData.LineCode,
|
||||
importData.PartNumber
|
||||
};
|
||||
{
|
||||
importData.LineCode,
|
||||
importData.PartNumber
|
||||
};
|
||||
|
||||
for (int j = 0; j < vehicleIdFitment.Count; j += 25)
|
||||
{
|
||||
@@ -143,25 +179,32 @@ namespace PartSource.Automation.Jobs
|
||||
|
||||
await _shopifyClient.Products.Update(product);
|
||||
|
||||
importData.IsFitment = isFitment;
|
||||
importData.UpdatedAt = DateTime.Now;
|
||||
importData.UpdateType = "Fitment";
|
||||
}
|
||||
|
||||
|
||||
catch (ShopifyClientException ex)
|
||||
{
|
||||
// TODO: Log
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!ex.Message.Contains("response content", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Console.WriteLine($"{importData.VariantSku}: {ex.Message}");
|
||||
}
|
||||
// TODO: Log
|
||||
}
|
||||
}
|
||||
|
||||
await _partSourceContext.SaveChangesAsync();
|
||||
try
|
||||
{
|
||||
_partSourceContext.SaveChanges();
|
||||
products = await _shopifyClient.Products.GetNext();
|
||||
}
|
||||
|
||||
parts = _partSourceContext.ImportData
|
||||
.Where(p => p.UpdatedAt < DateTime.Now.AddDays(-3))
|
||||
.Take(50)
|
||||
.ToList();
|
||||
catch (Exception ex)
|
||||
{
|
||||
products = await _shopifyClient.Products.GetNext();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,10 @@ namespace PartSource.Automation.Jobs
|
||||
|
||||
public async Task<AutomationJobResult> Run()
|
||||
{
|
||||
IList<ImportData> importDataz = _partSourceContext.ImportData.ToList();
|
||||
|
||||
return new AutomationJobResult();
|
||||
|
||||
IDictionary<string, object> parameters = new Dictionary<string, object>
|
||||
{
|
||||
{ "limit", 250 }
|
||||
@@ -59,7 +63,7 @@ namespace PartSource.Automation.Jobs
|
||||
continue;
|
||||
}
|
||||
|
||||
await DeletePositionMetafields(product.Id);
|
||||
//await DeletePositionMetafields(product.Id);
|
||||
|
||||
string currentPosition = fitments[0].Position;
|
||||
List<int> vehicleIds = new List<int>();
|
||||
@@ -85,6 +89,8 @@ namespace PartSource.Automation.Jobs
|
||||
|
||||
await SavePositionMetafield(product, vehicleIds, currentPosition);
|
||||
|
||||
|
||||
|
||||
importData.UpdatedAt = DateTime.Now;
|
||||
importData.UpdateType = "Positioning";
|
||||
|
||||
@@ -169,22 +175,5 @@ namespace PartSource.Automation.Jobs
|
||||
|
||||
await _shopifyClient.Metafields.Add(vehicleMetafield);
|
||||
}
|
||||
|
||||
private async Task DeletePositionMetafields(long shopifyId)
|
||||
{
|
||||
IDictionary<string, object> parameters = new Dictionary<string, object>
|
||||
{
|
||||
{ "metafield[owner_id]", shopifyId},
|
||||
{ "metafield[owner_resource]", "product" },
|
||||
{ "namespace", "position" },
|
||||
};
|
||||
|
||||
IEnumerable<Metafield> metafields = await _shopifyClient.Metafields.Get(parameters);
|
||||
|
||||
foreach (Metafield metafield in metafields)
|
||||
{
|
||||
await _shopifyClient.Metafields.Delete(metafield);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using PartSource.Automation.Jobs.Interfaces;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using PartSource.Automation.Jobs.Interfaces;
|
||||
using PartSource.Automation.Models;
|
||||
using PartSource.Data;
|
||||
using PartSource.Data.Models;
|
||||
@@ -27,11 +29,13 @@ namespace PartSource.Automation.Jobs
|
||||
public async Task<AutomationJobResult> Run()
|
||||
{
|
||||
IEnumerable<Product> products = null;
|
||||
IEnumerable<PartPrice> prices = null;
|
||||
int updateCount = 0;
|
||||
|
||||
try
|
||||
{
|
||||
products = await _shopifyClient.Products.Get();
|
||||
products = await _shopifyClient.Products.Get(new Dictionary<string, object> { { "limit", 250 } });
|
||||
prices = await _partSourceContext.PartPrices.ToListAsync();
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
@@ -50,8 +54,9 @@ namespace PartSource.Automation.Jobs
|
||||
{
|
||||
if (product.Variants.Length > 0)
|
||||
{
|
||||
|
||||
Variant variant = product.Variants[0];
|
||||
PartPrice partPrice = _partSourceContext.PartPrices.Where(p => p.SKU == variant.Sku).FirstOrDefault();
|
||||
PartPrice partPrice = prices.Where(p => p.SKU == variant.Sku).FirstOrDefault();
|
||||
|
||||
if (partPrice == null || !partPrice.Your_Price.HasValue || !partPrice.Compare_Price.HasValue)
|
||||
{
|
||||
@@ -65,7 +70,8 @@ namespace PartSource.Automation.Jobs
|
||||
product.Variants[0].Price = partPrice.Your_Price.Value;
|
||||
product.Variants[0].CompareAtPrice = partPrice.Compare_Price.Value;
|
||||
|
||||
product.PublishedAt = partPrice.Active.ToUpperInvariant() == "Y" ? DateTime.Now : default;
|
||||
product.PublishedAt = partPrice.Active.Trim().ToUpperInvariant() == "Y" ? (DateTime?)DateTime.Now : null;
|
||||
product.PublishedScope = PublishedScope.Global;
|
||||
|
||||
Metafield metafield = new Metafield
|
||||
{
|
||||
@@ -81,29 +87,37 @@ namespace PartSource.Automation.Jobs
|
||||
{
|
||||
await _shopifyClient.Metafields.Add(metafield);
|
||||
await _shopifyClient.Products.Update(product);
|
||||
|
||||
|
||||
updateCount++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Console.WriteLine("bad update");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
;
|
||||
Console.WriteLine("failed getting parts");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_partSourceContext.SaveChanges();
|
||||
// _partSourceContext.SaveChanges();
|
||||
|
||||
try
|
||||
{
|
||||
//await _shopifyClient.Products.SaveChanges();
|
||||
|
||||
products = await _shopifyClient.Products.GetNext();
|
||||
|
||||
Console.SetCursorPosition(0, 2);
|
||||
Console.Clear();
|
||||
Console.Write($"Updated: {updateCount} ");
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"profiles": {
|
||||
"PartSource.Automation": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "AddAndUpdateProducts",
|
||||
"commandLineArgs": "UpdatePositioning",
|
||||
"environmentVariables": {
|
||||
"PS_AUTOMATION_ENVIRONMENT": "development"
|
||||
}
|
||||
|
||||
9
PartSource.Backoffice/App.xaml
Normal file
9
PartSource.Backoffice/App.xaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="PartSource.Backoffice.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:PartSource.Backoffice"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
17
PartSource.Backoffice/App.xaml.cs
Normal file
17
PartSource.Backoffice/App.xaml.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace PartSource.Backoffice
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
10
PartSource.Backoffice/AssemblyInfo.cs
Normal file
10
PartSource.Backoffice/AssemblyInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
15
PartSource.Backoffice/Components/MenuBar.xaml
Normal file
15
PartSource.Backoffice/Components/MenuBar.xaml
Normal file
@@ -0,0 +1,15 @@
|
||||
<UserControl x:Class="PartSource.Backoffice.Components.MenuBar"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:PartSource.Backoffice.Components"
|
||||
mc:Ignorable="d" >
|
||||
|
||||
|
||||
<StackPanel>
|
||||
<Button FontFamily="Segoe MDL2 Assets" FontSize="32" Background="#0000" BorderThickness="0" Foreground="#FFF">
|
||||

|
||||
</Button>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
33
PartSource.Backoffice/Components/MenuBar.xaml.cs
Normal file
33
PartSource.Backoffice/Components/MenuBar.xaml.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PartSource.Backoffice.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MenuBar.xaml
|
||||
/// </summary>
|
||||
public partial class MenuBar : UserControl
|
||||
{
|
||||
public MenuBar()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void MenuItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// TODO: Check if any tasks are running
|
||||
|
||||
Application.Current.MainWindow.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
20
PartSource.Backoffice/Components/ProgressDisplay.xaml
Normal file
20
PartSource.Backoffice/Components/ProgressDisplay.xaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="PartSource.Backoffice.Components.ProgressDisplay"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:PartSource.Backoffice.Components"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Padding="10">
|
||||
|
||||
|
||||
<StackPanel>
|
||||
<WrapPanel>
|
||||
<TextBlock>Current Operation:</TextBlock>
|
||||
<Label x:Name="OperationNameDisplay">None</Label>
|
||||
</WrapPanel>
|
||||
<ProgressBar Height="32" Background="#444" BorderThickness="0" />
|
||||
</StackPanel>
|
||||
|
||||
</UserControl>
|
||||
26
PartSource.Backoffice/Components/ProgressDisplay.xaml.cs
Normal file
26
PartSource.Backoffice/Components/ProgressDisplay.xaml.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PartSource.Backoffice.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for StatusBars.xaml
|
||||
/// </summary>
|
||||
public partial class ProgressDisplay : UserControl
|
||||
{
|
||||
public ProgressDisplay()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
16
PartSource.Backoffice/Components/TaskSetup.xaml
Normal file
16
PartSource.Backoffice/Components/TaskSetup.xaml
Normal file
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="PartSource.Backoffice.Components.TaskSetup"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:PartSource.Backoffice.Components"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Padding="10">
|
||||
|
||||
<StackPanel>
|
||||
<TextBlock>Metafield Groups:</TextBlock>
|
||||
<CheckBox Content="Fitment" />
|
||||
<CheckBox Content="Product Feed" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
26
PartSource.Backoffice/Components/TaskSetup.xaml.cs
Normal file
26
PartSource.Backoffice/Components/TaskSetup.xaml.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PartSource.Backoffice.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for TaskSetup.xaml
|
||||
/// </summary>
|
||||
public partial class TaskSetup : UserControl
|
||||
{
|
||||
public TaskSetup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
40
PartSource.Backoffice/MainWindow.xaml
Normal file
40
PartSource.Backoffice/MainWindow.xaml
Normal file
@@ -0,0 +1,40 @@
|
||||
<Window xmlns:Components="clr-namespace:PartSource.Backoffice.Components"
|
||||
x:Class="PartSource.Backoffice.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:PartSource.Backoffice"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="262" Width="520" Background="#222" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
|
||||
|
||||
<Window.Resources>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="#FFF" />
|
||||
<Setter Property="FontWeight" Value="DemiBold"/>
|
||||
<Setter Property="Margin" Value="0,0,10,10" />
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Label">
|
||||
<Setter Property="Foreground" Value="#CCC" />
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="CheckBox">
|
||||
<Setter Property="Foreground" Value="#FFF"/>
|
||||
<Setter Property="Margin" Value="0,0,0,5"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Button">
|
||||
<Setter Property="Margin" Value="10, 20"/>
|
||||
<Setter Property="Padding" Value="25, 5" />
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
<StackPanel>
|
||||
<Components:TaskSetup />
|
||||
<Components:ProgressDisplay />
|
||||
<Button x:Name="Update" Content="Start" HorizontalAlignment="left" Click="Update_Click" />
|
||||
</StackPanel>
|
||||
</Window>
|
||||
33
PartSource.Backoffice/MainWindow.xaml.cs
Normal file
33
PartSource.Backoffice/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace PartSource.Backoffice
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Update_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
9
PartSource.Backoffice/PartSource.Backoffice.csproj
Normal file
9
PartSource.Backoffice/PartSource.Backoffice.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
23
PartSource.Backoffice/Services/FtpService.cs
Normal file
23
PartSource.Backoffice/Services/FtpService.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
||||
namespace PartSource.Automation.Services
|
||||
{
|
||||
public class FtpService
|
||||
{
|
||||
|
||||
public void Download(string filename)
|
||||
{
|
||||
//FtpWebRequest request = (FtpWebRequest)WebRequest.Create($"{_ftpConfiguration.Url}/{filename}");
|
||||
//request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password);
|
||||
//request.Method = WebRequestMethods.Ftp.DownloadFile;
|
||||
|
||||
//using FtpWebResponse response = (FtpWebResponse)request.GetResponse();
|
||||
//using Stream responseStream = response.GetResponseStream();
|
||||
//using FileStream fileStream = new FileStream($"%APPDATALOCAL%\\{filename}", FileMode.Create);
|
||||
|
||||
//responseStream.CopyTo(fileStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,5 +15,7 @@ namespace PartSource.Data.Models
|
||||
public int EngineConfigId { get; set; }
|
||||
|
||||
public string Position { get; set; }
|
||||
|
||||
public string NoteText { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,6 +271,11 @@ namespace PartSource.Services
|
||||
}
|
||||
|
||||
public IList<Vehicle> GetVehiclesForPart(string partNumber, string lineCode)
|
||||
{
|
||||
return GetVehiclesForPart(partNumber, lineCode, -1);
|
||||
}
|
||||
|
||||
public IList<Vehicle> GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles)
|
||||
{
|
||||
if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode))
|
||||
{
|
||||
@@ -290,6 +295,11 @@ namespace PartSource.Services
|
||||
v => new { v.BaseVehicleId, v.EngineConfigId },
|
||||
(f, v) => v);
|
||||
|
||||
if (maxVehicles > 0)
|
||||
{
|
||||
vehicles = vehicles.Take(maxVehicles);
|
||||
}
|
||||
|
||||
return vehicles.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,43 +18,129 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PartSource.Backoffice", "PartSource.Backoffice\PartSource.Backoffice.csproj", "{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Also Debug|Any CPU = Also Debug|Any CPU
|
||||
Also Debug|x64 = Also Debug|x64
|
||||
Also Debug|x86 = Also Debug|x86
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Also Debug|Any CPU.ActiveCfg = Also Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Also Debug|Any CPU.Build.0 = Also Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Also Debug|x64.ActiveCfg = Also Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Also Debug|x64.Build.0 = Also Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Also Debug|x86.ActiveCfg = Also Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Also Debug|x86.Build.0 = Also Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Release|x64.Build.0 = Release|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{126B8961-1D86-4F73-9BB9-79ECE78E9257}.Release|x86.Build.0 = Release|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Also Debug|Any CPU.ActiveCfg = Also Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Also Debug|Any CPU.Build.0 = Also Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Also Debug|x64.ActiveCfg = Also Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Also Debug|x64.Build.0 = Also Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Also Debug|x86.ActiveCfg = Also Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Also Debug|x86.Build.0 = Also Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{B4848BCD-6BCC-44BD-AD6E-38511AEC1851}.Release|x86.Build.0 = Release|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Also Debug|Any CPU.ActiveCfg = Also Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Also Debug|Any CPU.Build.0 = Also Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Also Debug|x64.ActiveCfg = Also Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Also Debug|x64.Build.0 = Also Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Also Debug|x86.ActiveCfg = Also Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Also Debug|x86.Build.0 = Also Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{2E7BCDF6-643E-405A-A69A-4907DF5491AF}.Release|x86.Build.0 = Release|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Also Debug|Any CPU.ActiveCfg = Also Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Also Debug|Any CPU.Build.0 = Also Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Also Debug|x64.ActiveCfg = Also Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Also Debug|x64.Build.0 = Also Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Also Debug|x86.ActiveCfg = Also Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Also Debug|x86.Build.0 = Also Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x64.Build.0 = Release|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x86.Build.0 = Release|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Also Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Also Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Also Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Also Debug|x64.Build.0 = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Also Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Also Debug|x86.Build.0 = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Release|x64.Build.0 = Release|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{FDC22085-4C5A-4CCD-B0DB-9D31F90ECE90}.Release|x86.Build.0 = Release|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Also Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Also Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Also Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Also Debug|x64.Build.0 = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Also Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Also Debug|x86.Build.0 = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{AFC51C34-2E44-4A8A-8311-F98DB7DDA15E}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
Reference in New Issue
Block a user