-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProductInfo.cs
More file actions
217 lines (191 loc) · 10.3 KB
/
ProductInfo.cs
File metadata and controls
217 lines (191 loc) · 10.3 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Extensions;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Logging;
using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.XmlGenerators;
using Dynamicweb.Ecommerce.Prices;
using Dynamicweb.Ecommerce.Products;
using Dynamicweb.Extensibility.Notifications;
using System;
using System.Collections.Generic;
using System.Xml;
namespace Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications
{
/// <summary>
/// Notifications and argument classes for notification subscribers fired during generation of product information XML.
/// </summary>
public static class ProductInfo
{
/// <summary>
/// Occurs before the XML for a product info request is generated. This enables you to change or analyze the product before it's processed.
/// </summary>
/// <example>
/// <code description="Notification observer example" source="..\..\source="..\..\Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples\Notifications\OrderAfterGenerateXmlSubscriber.cs"Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples\Notifications\ProductInfoBeforeGenerateXmlSubscriber.cs" lang="CS"></code>
/// </example>
public const string OnBeforeGenerateProductInfoXml = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.LiveIntegration.OnBeforeGenerateProductInfoXml";
/// <summary>
/// Occurs after the XML for a product info request is generated. This enables you to change or analyze the XML before it's sent to the ERP.
/// </summary>
/// <example>
/// <code description="Notification observer example" source="..\..\source="..\..\Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples\Notifications\OrderAfterGenerateXmlSubscriber.cs"Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Examples\Notifications\ProductInfoAfterGenerateXmlSubscriber.cs" lang="CS"></code>
/// </example>
public const string OnAfterGenerateProductInfoXml = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.LiveIntegration.OnAfterGenerateProductInfoXml";
/// <summary>
/// Occurs after the response from ERP is returned before the product info object is stored. This enables you to change or analyze the product info object before it's added to cache.
/// </summary>
public const string OnAfterProductInfoProcessResponse = "Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Notifications.LiveIntegration.OnAfterProductInfoProcessResponse";
private static List<PriceProductSelection> GetProductSelectionsFromProducts(Dictionary<Product, double> products)
{
var productSelections = new List<PriceProductSelection>();
foreach (var product in products)
{
productSelections.Add(product.Key.GetPriceProductSelection(product.Value, null));
}
return productSelections;
}
/// <summary>
/// Arguments class for the OnBeforeGenerateProductInfoXml subscriber.
/// </summary>
/// <seealso cref="NotificationArgs" />
public class OnBeforeGenerateProductInfoXmlArgs : NotificationArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="OnBeforeGenerateProductInfoXmlArgs"/> class.
/// </summary>
/// <param name="products">The products for which the XML is generated.</param>
/// <param name="settings">An instance of ProductInfoXmlGeneratorSettings that determines how the XML is generated.</param>
[Obsolete("Use OnBeforeGenerateProductInfoXmlArgs(List<PriceProductSelection> products, ProductInfoXmlGeneratorSettings settings, Settings liveIntegrationSettings, Logger logger)")]
public OnBeforeGenerateProductInfoXmlArgs(Dictionary<Product, double> products, ProductInfoXmlGeneratorSettings settings, Settings liveIntegrationSettings, Logger logger)
{
ProductSelections = GetProductSelectionsFromProducts(products);
GeneratorSettings = settings;
Settings = liveIntegrationSettings;
Logger = logger;
}
public OnBeforeGenerateProductInfoXmlArgs(List<PriceProductSelection> products, ProductInfoXmlGeneratorSettings settings, Settings liveIntegrationSettings, Logger logger)
{
ProductSelections = products;
GeneratorSettings = settings;
Settings = liveIntegrationSettings;
Logger = logger;
}
/// <summary>
/// Gets the products for which the XML is being generated..
/// </summary>
/// <value>The products.</value>
[Obsolete("Use ProductSelections")]
public Dictionary<Product, double> Products { get; }
/// <summary>
/// Gets the products for which the XML is being generated..
/// </summary>
/// <value>The products.</value>
public List<PriceProductSelection> ProductSelections { get; }
/// <summary>
/// Gets the ProductInfoXmlGeneratorSettings that determines how the XML is generated
/// </summary>
/// <value>The generator settings.</value>
public ProductInfoXmlGeneratorSettings GeneratorSettings { get; }
/// <summary>
/// Settings
/// </summary>
public Settings Settings { get; }
/// <summary>
/// Logger
/// </summary>
public Logger Logger { get; }
}
/// <summary>
/// Arguments class for the OnAfterGenerateProductInfoXml subscriber.
/// </summary>
/// <seealso cref="NotificationArgs" />
public class OnAfterGenerateProductInfoXmlArgs : NotificationArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="OnAfterGenerateProductInfoXmlArgs"/> class.
/// </summary>
/// <param name="products">The products for which the XML has been generated.</param>
/// <param name="settings">The ProductInfoXmlGeneratorSettings that determines how the XML is generated.</param>
/// <param name="xmlDocument">The XML document that has been created. You can manipulate this document to alter the XML being sent to the ERP.</param>
[Obsolete("Use OnAfterGenerateProductInfoXmlArgs(List<PriceProductSelection> products, ProductInfoXmlGeneratorSettings settings, XmlDocument xmlDocument, Settings liveIntegrationSettings, Logger logger)")]
public OnAfterGenerateProductInfoXmlArgs(Dictionary<Product, double> products, ProductInfoXmlGeneratorSettings settings, XmlDocument xmlDocument, Settings liveIntegrationSettings, Logger logger)
{
ProductSelections = GetProductSelectionsFromProducts(products);
GeneratorSettings = settings;
XmlDocument = xmlDocument;
Settings = liveIntegrationSettings;
Logger = logger;
}
public OnAfterGenerateProductInfoXmlArgs(List<PriceProductSelection> products, ProductInfoXmlGeneratorSettings settings, XmlDocument xmlDocument, Settings liveIntegrationSettings, Logger logger)
{
ProductSelections = products;
GeneratorSettings = settings;
XmlDocument = xmlDocument;
Settings = liveIntegrationSettings;
Logger = logger;
}
/// <summary>
/// Gets the products for which the XML has been generated.
/// </summary>
/// <value>The products.</value>
[Obsolete("Use ProductSelections")]
public Dictionary<Product, double> Products { get; }
/// <summary>
/// Gets the products for which the XML has been generated.
/// </summary>
/// <value>The products.</value>
public List<PriceProductSelection> ProductSelections { get; }
/// <summary>
/// Gets the ProductInfoXmlGeneratorSettings that determines how the XML is generated.
/// </summary>
/// <value>The generator settings.</value>
public ProductInfoXmlGeneratorSettings GeneratorSettings { get; }
/// <summary>
/// Gets the XML document that has been created. You can manipulate this document to alter the XML being sent to the ERP.
/// </summary>
/// <value>The XML document.</value>
public XmlDocument XmlDocument { get; }
/// <summary>
/// Settings
/// </summary>
public Settings Settings { get; }
/// <summary>
/// Logger
/// </summary>
public Logger Logger { get; }
}
/// <summary>
/// Arguments class for the OnAfterProductInfoProcessResponse subscriber.
/// </summary>
/// <seealso cref="NotificationArgs" />
public class OnAfterProductInfoProcessResponseArgs : NotificationArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="OnAfterProductInfoProcessResponseArgs"/> class.
/// </summary>
public OnAfterProductInfoProcessResponseArgs(Products.ProductInfo productInfo, XmlDocument responseXml, Settings liveIntegrationSettings, Logger logger)
{
ProductInfo = productInfo;
ResponseXml = responseXml;
Settings = liveIntegrationSettings;
Logger = logger;
}
/// <summary>
/// Gets the product info object.
/// </summary>
/// <value>The products.</value>
public Products.ProductInfo ProductInfo { get; }
/// <summary>
/// Gets the response XML document.
/// </summary>
/// <value>The XML document.</value>
public XmlDocument ResponseXml { get; }
/// <summary>
/// Settings
/// </summary>
public Settings Settings { get; }
/// <summary>
/// Logger
/// </summary>
public Logger Logger { get; }
}
}
}