-
Notifications
You must be signed in to change notification settings - Fork 2
/
BBStoreService.svc.cs
584 lines (461 loc) · 22 KB
/
BBStoreService.svc.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
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Users;
using DotNetNuke.Security.Membership;
using System;
using System.Collections.Generic;
namespace Bitboxx.DNNModules.BBStore
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "BBStoreService" in code, svc and config file together.
public class BBStoreService : IBBStoreService
{
private BBStoreImportController _importController;
public BBStoreImportController ImportController
{
get
{
if (_importController == null)
_importController = new BBStoreImportController();
return _importController;
}
}
#region IBBStoreService Members
public string Login(string portalId, string userId, string password)
{
UserLoginStatus loginStatus = new UserLoginStatus();
UserInfo user = UserController.ValidateUser(Convert.ToInt32(portalId), userId, password,
"","","0.0.0.0",ref loginStatus);
if (user == null)
throw new Exception("Access Request Denied. Invalid UserId and Password");
Guid tokenId = Guid.NewGuid();
BBStoreSecurityToken token = new BBStoreSecurityToken()
{
UserId = user.UserID,
PortalId = Convert.ToInt32(portalId),
UserName = user.Username
};
DataCache.SetCache("BBStoreSecurityToken_" + tokenId.ToString(), token, new TimeSpan(0, 5, 0));
return tokenId.ToString();
}
public List<ProductGroupInfo> GetProductGroups(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
return ImportController.GetProductGroups(portalId, storeGuid);
}
public ProductGroupInfo GetProductGroupByName(string PortalId, string strStoreGuid, string Language, string ProductGroupName, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
return ImportController.GetProductGroupByName(portalId, Language, ProductGroupName, storeGuid);
}
public List<SimpleProductInfo> GetSimpleProducts(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
return ImportController.GetSimpleProducts(portalId, storeGuid);
}
public void DeleteProducts(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.DeleteProducts(portalId, storeGuid);
}
public void DeleteProduct(string PortalId, string strStoreGuid, string simpleProductId, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
int productId = -1;
Int32.TryParse(simpleProductId, out productId);
if (productId < 0)
throw new Exception("ProductId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.DeleteProduct(portalId, productId, storeGuid);
}
public int SaveProduct(string PortalId, string strStoreGuid, SimpleProductInfo product, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (product == null)
throw new Exception("Product must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
return ImportController.SaveProduct(portalId, product, storeGuid);
}
public void SaveProductLang(string PortalId, string strStoreGuid, SimpleProductLangInfo productLang, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (productLang == null)
throw new Exception("ProductLang must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveProductLang(portalId, productLang, storeGuid);
}
public void SaveProductInGroup(string PortalId, string strStoreGuid, string ProductId, string ProductGroupId, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
int productId = -1;
Int32.TryParse(ProductId, out productId);
if (productId < 0)
throw new Exception("ProductId must be zero or greater");
int productGroupId = -1;
Int32.TryParse(ProductGroupId, out productGroupId);
if (productId < 0)
throw new Exception("ProductGroupId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveProductInGroup(portalId, productId, productGroupId, storeGuid);
}
public void DeleteProductGroups(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.DeleteProductGroups(portalId, storeGuid);
}
public void SaveProductGroup(string PortalId, string strStoreGuid, ProductGroupInfo productGroup, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (productGroup == null)
throw new Exception("ProductGroup must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveProductGroup(portalId, productGroup, storeGuid);
}
public void SaveProductGroupLang(string PortalId, string strStoreGuid, ProductGroupLangInfo productGroupLang, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (productGroupLang == null)
throw new Exception("ProductGroupLang must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveProductGroupLang(portalId, productGroupLang, storeGuid);
}
public void DeleteFeatureGroups(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.DeleteFeatureGroups(portalId,storeGuid);
}
public void SaveFeatureGroup(string PortalId, string strStoreGuid, FeatureGroupInfo featureGroup, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (featureGroup == null)
throw new Exception("FeatureGroup must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveFeatureGroup(portalId, featureGroup, storeGuid);
}
public void SaveFeatureGroupLang(string PortalId, string strStoreGuid, FeatureGroupLangInfo featureGroupLang, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (featureGroupLang == null)
throw new Exception("FeatureGroupLang must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveFeatureGroupLang(portalId, featureGroupLang, storeGuid);
}
public void DeleteFeatureLists(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.DeleteFeatureLists(portalId, storeGuid);
}
public void SaveFeatureList(string PortalId, string strStoreGuid, FeatureListInfo featureList, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (featureList == null)
throw new Exception("FeatureList must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveFeatureList(portalId, featureList, storeGuid);
}
public void SaveFeatureListLang(string PortalId, string strStoreGuid, FeatureListLangInfo featureListLang, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (featureListLang == null)
throw new Exception("FeatureListLang must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveFeatureListLang(portalId, featureListLang, storeGuid);
}
public void SaveFeatureListItem(string PortalId, string strStoreGuid, FeatureListItemInfo featureListItem, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (featureListItem == null)
throw new Exception("FeatureListItem must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveFeatureListItem(portalId, featureListItem, storeGuid);
}
public void SaveFeatureListItemLang(string PortalId, string strStoreGuid, FeatureListItemLangInfo featureListItemLang, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (featureListItemLang == null)
throw new Exception("FeatureListItemLang must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveFeatureListItemLang(portalId, featureListItemLang, storeGuid);
}
public void SaveFeature(string PortalId, string strStoreGuid, FeatureInfo feature, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (feature == null)
throw new Exception("Feature must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveFeature(portalId, feature, storeGuid);
}
public void SaveFeatureLang(string PortalId, string strStoreGuid, FeatureLangInfo featureLang, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (featureLang == null)
throw new Exception("FeatureLang must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveFeatureLang(portalId, featureLang, storeGuid);
}
public void DeleteFeatures(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.DeleteFeatures(portalId, storeGuid);
}
public void SaveProductGroupFeature(string PortalId, string strStoreGuid, string FeatureId, string ProductGroupId, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
int featureId = -1;
Int32.TryParse(FeatureId, out featureId);
if (featureId < 0)
throw new Exception("FeatureId must be zero or greater");
int productGroupId = -1;
Int32.TryParse(ProductGroupId, out productGroupId);
if (productGroupId < 0)
throw new Exception("ProductGroupId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveProductGroupFeature(portalId, featureId, productGroupId, storeGuid);
}
public void SaveFeatureValue(string PortalId, string strStoreGuid, FeatureValueInfo featureValue, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (featureValue == null)
throw new Exception("FeatureValue must not be null");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveFeatureValue(portalId, featureValue, storeGuid);
}
public void SaveProductGroupListItem(string PortalId, string strStoreGuid, string ProductGroupId, string FeatureListItemId, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
int productGroupId = -1;
Int32.TryParse(ProductGroupId, out productGroupId);
if (productGroupId < 0)
throw new Exception("ProductGroupId must be zero or greater");
int featureListItemId = -1;
Int32.TryParse(FeatureListItemId, out featureListItemId);
if (featureListItemId < 0)
throw new Exception("FeatureListItemId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveProductGroupListItem(portalId, productGroupId, featureListItemId, storeGuid);
}
public void DeleteProductGroupListItems(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.DeleteProductGroupListItems(portalId, storeGuid);
}
public void SaveImage(string PortalId, string strStoreGuid, int productId, byte[] pictureData, string fileName, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (productId < 0)
throw new Exception("ProductId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.SaveImage(portalId, productId, pictureData, fileName, storeGuid);
}
public void DeleteProductImages(string PortalId, string strStoreGuid, int productId, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
if (productId < 0)
throw new Exception("ProductId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.DeleteProductImages(portalId, productId, storeGuid);
}
public void DeleteEmptyImageDirectories(string PortalId, string Token)
{
// Deletion of folders initiates App Restart -> Token expires !
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
ImportController.DeleteEmptyImageDirectories(portalId);
}
public void DeleteProductImagesAll(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.DeleteProductImagesAll(portalId, storeGuid);
}
public void ImportStore(string PortalId, BBStoreInfo bbStore, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
ImportController.ImportStore(portalId, bbStore);
}
public BBStoreInfo ExportStore(string PortalId, string strStoreGuid, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
return ImportController.ExportStore(portalId, storeGuid);
}
public void ResetStore(string PortalId, string strStoreGuid, bool skipImages, string Token)
{
int portalId = -1;
Int32.TryParse(PortalId, out portalId);
if (portalId < 0)
throw new Exception("PortalId must be zero or greater");
Guid storeGuid = new Guid(strStoreGuid);
if (storeGuid == Guid.Empty)
throw new Exception("StoreGuid must be valid!");
ImportController.ResetStore(portalId, skipImages, storeGuid);
}
#endregion
}
}