-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathIProductManager.cs
119 lines (100 loc) · 4 KB
/
IProductManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Moryx.AbstractionLayer.Products;
using Moryx.Modules;
namespace Moryx.Products.Management
{
/// <summary>
/// Management component
/// </summary>
internal interface IProductManager : IPlugin
{
/// <summary>
/// Returns all available product importers
/// </summary>
IProductImporter[] Importers { get; }
/// <summary>
/// Returns all products on this machine
/// </summary>
IReadOnlyList<IProductType> LoadTypes(ProductQuery query);
/// <summary>
/// Load types using filter expression
/// </summary>
IReadOnlyList<TType> LoadTypes<TType>(Expression<Func<TType, bool>> selector);
/// <summary>
/// Load product instance by id
/// </summary>
IProductType LoadType(long id);
/// <summary>
/// Load product by identity
/// </summary>
IProductType LoadType(ProductIdentity identity);
/// <summary>
/// Create a new product for the given group type
/// </summary>
IProductType CreateType(string type);
/// <summary>
/// Event raised when a product changed
/// </summary>
event EventHandler<IProductType> TypeChanged;
/// <summary>
/// Save a product to the database
/// </summary>
long SaveType(IProductType modifiedInstance);
/// <summary>
/// Create revision of this product with provided revision number
/// </summary>
IProductType Duplicate(ProductType source, ProductIdentity identity);
/// <summary>
/// Import the given file as a product to the database
/// </summary>
Task<ProductImportResult> Import(string importer, object parameters);
/// <summary>
/// Import GUID based
/// </summary>
ImportState ImportParallel(string importer, object parameters);
/// <summary>
/// Fetch import progress
/// </summary>
/// <param name="session"></param>
/// <returns></returns>
ImportState ImportProgress(Guid session);
/// <summary>
/// Try to delete a product. If it is still used as a part in other products, it will return <c>false</c>
/// </summary>
/// <param name="productId">Id of the product that is deprecated and should be deleted.</param>
/// <returns><value>True</value> if the product was removed, <value>false</value> otherwise</returns>
bool DeleteType(long productId);
/// <summary>
/// Create an instance of given product
/// </summary>
/// <param name="productType">Product to instantiate</param>
/// <param name="save">Flag if new instance should already be saved</param>
/// <returns>New instance</returns>
ProductInstance CreateInstance(IProductType productType, bool save);
/// <summary>
/// Updates the database from the instance
/// </summary>
void SaveInstances(params ProductInstance[] productInstances);
/// <summary>
/// Get instances with the given ids.
/// </summary>
/// <param name="ids">The IDs of instances that should be loaded</param>
/// <returns>The instance with the id when it exists.</returns>
IReadOnlyList<ProductInstance> GetInstances(params long[] ids);
/// <summary>
/// Get all instances that match a certain expression
/// </summary>
IReadOnlyList<TInstance> GetInstances<TInstance>(Expression<Func<TInstance, bool>> selector);
/// <summary>
/// Return type wrapper to a type
/// </summary>
/// <param name="typeName">Full name of the type</param>
/// <returns></returns>
ProductTypeWrapper GetTypeWrapper(string typeName);
}
}