yzh
2022-03-14 94879204c236edaf6ee80a176c2a781a352b2b93
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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
<%@ WebHandler Language="C#" Class="GwProductHandler" %>
using Dao;
using Model;
// using Newtonsoft.Json;
//using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.IO;
using System.Diagnostics;
 
public class GwProductHandler : PageHandler<SysUser>
{
    private GwProductDao _Dao = new GwProductDao();
    private GwSpDao _GwSpDao = new GwSpDao();
    private GwOpGroupDao _GwOpGroupDao = new GwOpGroupDao();
    private SysXhDao _SysXhDao = new SysXhDao();
 
    private List<GwOp> _OpList;
    private List<GwOpGroup> _GroupList;
    private List<GwProduct> _ProductList;   //产品及产品分类
    //private List<GwProduct> _ProductClassList;  //产品分类
 
    public override JsonPageResult ProcessRequestInternal(PageContext<SysUser> context)
    {
        string @string = context.GetString("action");
        switch (@string)
        {
            case "delete":
                return this.Delete(context);    //删除
            case "update":
                return this.Update(context);    //修改
            case "add":
                return this.Add(context);       //添加
            case "list":
                return this.List(context);      //查询
            case "get":
                return this.Get(context);      //获取记录信息                    
            case "updateStatus":
                return this.UpdateStatus(context);  //启用或停用
            case "upLoad":
                return this.UpLoad(context);    //图标文件上传
 
            default:
                throw new Exception("Invalid Action=" + @string);
        }
    }
 
    //加载产品及产品分类信息
    private JsonPageResult List(PageContext<SysUser> context)
    {
        //Console.WriteLine("List.............[" + context.GetInt("name") + "][" + context.GetInt("classes") + "]");
        int classes = context.GetInt("classes");
        string name = context.GetString("name");
 
        int recordCount = 0;
        int pageSize = context.GetInt("pageSize", 50);
        int pageIndex = context.GetInt("pageIndex", 1);
 
        List<GwProduct> list = _Dao.LoadInfoList(classes, name, pageSize, pageIndex, out recordCount);
 
        string str1 = "";
        if (list != null && list.Count > 0)
        {
 
            int num = 0;
            foreach (GwProduct bean in list)
            {
                ++num;
                str1 = str1 + (object) "<tr><td>" +  "<img src=\"../static/images/productIcon/" + (object) bean.Icon + "\" >";
                str1 = str1 + "</td><td>" + bean.Name + "</td>";
                str1 = string.Concat(new object[4]
                {
                         str1,
                          "<td>",
                         bean.Instructions,
                         "</td>"
                });
                str1 = str1 + "<td>" + (object)this.ClassesToName(bean.Classes) + "</td>";
                if (bean.RouterType == 1)
                {
                    str1 += "<td rowspan=\"1\"><div class=\"btn  btn-primary btn-xs\">点路由</div>";
                    str1 += string.Format("<div>移动:{0}</div><div>电信:{1}</div><div>联通:{2}</div>", (object)this.GetOpName(bean.CmOpId), (object)this.GetOpName(bean.CtOpId), (object)this.GetOpName(bean.CuOpId));
                }
                else if (bean.RouterType == 3)
                {
                    str1 += "<td rowspan=\"1\"><div class=\"btn  btn-success  btn-xs\">组路由</div>";
                    str1 += string.Format("<div>移动:{0}</div><div>电信:{1}</div><div>联通:{2}</div>", (object)this.GetGroupName(bean.CmGroupid), (object)this.GetGroupName(bean.CtGroupid), (object)this.GetGroupName(bean.CuGroupid));
                }
                else
                {
                    str1 += "<td rowspan=\"1\"></td>";
                }
                str1 = str1 + "<td>" + ProductToName(bean.ParentId) + "</td>";
                str1 = str1 + "<td>" + IsDefaultToName(bean.IsDefault) + "</td>";
                str1 = str1 + "<td>" + IsEnableToName(bean.IsEnable) + "</td>";
                str1 = string.Concat(new object[4]
                {
                         str1,
                         "<td>",
                         bean.Sort,
                         "</td>"
                });
                str1 = string.Concat(new object[4]
                {
                        str1,
                        "<td>",
                         bean.GivingNum,   //默认赠送条数
                          "</td>"
                });
 
                str1 += string.Format("<td>{0}元/条</td>", (object)(Convert.ToDecimal(bean.Price) / new Decimal(1000)));
                str1 = str1 + "<td>" + bean.CreateTime + "</td>";
                str1 += "<td  class=\"text-right\">";
                str1 = bean.IsEnable != 0 ? str1 + string.Format("<a href=\"javascript:;\" data-id=\"{0}\" data-is_enable=\"0\" class=\"action-update-status btn btn-primary btn-xs\"><i class=\"fa fa-toggle-off\"></i>&nbsp;停用</a> ", (object) bean.Id ) : str1 + string.Format("<a href=\"javascript:;\" data-id=\"{0}\" data-is_enable=\"1\" class=\"action-update-status btn  btn-default btn-xs\"><i class=\"fa fa-toggle-on\"/></i>&nbsp;启用</a> ", (object) bean.Id );
                str1 += string.Format("<a href=\"javascript:;\" data-id=\"{0}\" class=\"action-modal-edit btn  btn-success btn-xs\"><i class=\"fa fa-edit\"></i>&nbsp;编辑</a> ", (object) bean.Id);
                str1 += string.Format("<a href=\"javascript:;\" data-id=\"{0}\" class=\"action-delete btn  btn-default btn-xs\"><i class=\"fa fa-trash\"></i>&nbsp;删除</a> ", (object) bean.Id);
                str1 += "</td>";
                str1 += "</tr>";
            }
        }
        else
            str1 += "<tr><td colspan=\"13\" style=\"padding-left:5px; text-align: center;\">暂无信息</td></tr>";
 
        return new JsonPageResult(true,  new
        {
            Table = str1.ToString(),
            TotalCount = recordCount
        });
    }
 
    //通道运行状态或错误信息
    private string FormatOpError(int opStatus, int opError, string remark)
    {
        StringBuilder stringBuilder = new StringBuilder();
        if (opStatus == 0)
        {
            stringBuilder.Append("<span class=\"label label-default\">已停用</span>");
        }
        else
        {
            stringBuilder.Append("<a data-html=\"true\"  data-content=\"<pre style='width:200px;height:160px;'>" + HttpUtility.HtmlEncode(remark) + "</pre>\" type=\"button\" class=\"btn-xs\" data-trigger=\"click\" data-toggle=\"popover\" data-placement=\"left\">");
            if (opError == 0)
                stringBuilder.Append("<span class=\"label label-primary\">正常</span>");
            else if (opError == 5)
                stringBuilder.Append("<span class=\"label label-danger\">异常</span>");
            else
                stringBuilder.Append("NA");
            stringBuilder.Append("</a>");
        }
        return stringBuilder.ToString();
    }
 
    public bool IsInt(string input)
    {
        for (int index = 0; index < input.Length; ++index)
        {
            if (!char.IsNumber(input, index))
                return false;
        }
        return true;
    }
 
 
    //删除产品或产品分类
    private JsonPageResult Delete(PageContext<SysUser> context)
    {
        string ID = context.GetString("id");
 
        if (this._Dao.GwProductUseCount(ID) > 0)
            throw new ArgumentException("当前产品分类已在产品信息使用中,无法删除!");
        if (this._Dao.GwSpUseCount(ID) > 0)
            throw new ArgumentException("当前产品在客户账号信息中使用,无法删除!");
        this._Dao.Delete(ID);
        return new JsonPageResult(true, "删除信息成功!");
 
    }
 
    //添加产品或产品分类
    private JsonPageResult Add(PageContext<SysUser> context)
    {
 
        string id = _SysXhDao.getXh("GW_PRODUCT");  //获取生成产品ID
        string name = context.GetString("name");
        int classes = context.GetInt("classes", -1);
        string icon = "";
        string instructions = "";
        int isDefault = 0;
        int sort = 0;
 
        int routerType = 0;
        int cmOpId = 0;
        int cuOpId = 0;
        int ctOpId = 0;
        string cmExtParams = "";
        string cuExtParams = "";
        string ctExtParams = "";
        int cmGroupid = 0;
        int cuGroupid = 0;
        int ctGroupid = 0;
        int price = 0;
        int givingNum = 0;
 
        string info = "" ;
        if (classes == -1) {
            throw new ArgumentException("请选择类别!");
        }
        else
        {
            if(classes == 1)
            {
                info = "产品";
                if (string.IsNullOrEmpty(name))
                {
                    throw new ArgumentException(info + "名称不能为空!");
                }
 
            }
            else if (classes == 0)
            {
                info = "产品分类";
                if (string.IsNullOrEmpty(name))
                {
                    throw new ArgumentException(info + "名称不能为空!");
                }
 
            }
 
        }
 
        //1-产品;0-分类
        if (classes==1)
        {
            icon = context.GetString("icon");
            instructions = context.GetString("instructions");
            isDefault = context.GetInt("isDefault", 0);
 
            int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 1);
            price = num;
            givingNum = context.GetInt("givingNum", 0);
            sort = context.GetInt("sort", 0);
 
            routerType = context.GetInt("routerType", 1);
            //路由类型:1-通道路由;3-通道组路由。
            if (routerType==1)
            {
                cmOpId = context.GetInt("cmOpId", 0);
                cuOpId = context.GetInt("cuOpId", 0);
                ctOpId = context.GetInt("ctOpId", 0);
                cmExtParams = context.GetString("cmExtParams");
                cuExtParams = context.GetString("cuExtParams");
                ctExtParams = context.GetString("ctExtParams");
 
            }
            else if (routerType==3)
            {
                cmGroupid = context.GetInt("cmGroupid", 0);
                cuGroupid = context.GetInt("cuGroupid", 0);
                ctGroupid = context.GetInt("ctGroupid", 0);
 
            }
 
        }
        string parentId = context.GetString("parentId", "0");
        string path = "";
        if (parentId.Equals("0"))
        {
            path = "0";
        }
        else
        {
            GwProduct newProduct = _Dao.Get(parentId);
            if(newProduct!=null)
            {
                path = newProduct.Path=="" ? "0" : newProduct.Path + "," + newProduct.Id ;
            }
            else
            {
                path = "0";
            }
 
        }
        int isEnable = context.GetInt("isEnable", 0);
 
        //int price = context.GetInt("price", 0);
        //int givingNum = context.GetInt("givingNum", 0);
        string remark = context.GetString("remark", "");
        DateTime createTime = DateTime.Now;
        string creator = context.OperatorID;
        //DateTime update_time = context.GetDateTime("update_time");
        //string updateor = context.GetString("updateor", "");
 
        //校验
        if (classes == -1) {
            throw new ArgumentException("请选择类别!");
        }
        else
        {
            if(string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("请输入名称!");
            }
            //产品相关项校验
            if (classes == 1)
            {
                if (routerType==0 )
                    throw new ArgumentException("请选择路由类型!");
                if (cmGroupid == 0 && cuGroupid == 0 && ctGroupid == 0 && routerType == 3 && classes==1)
                    throw new ArgumentException("至少指定一个通道组!");
                if (cmOpId == 0 && cuOpId == 0 && ctOpId == 0 && routerType == 1 && classes==1)
                    throw new ArgumentException("至少指定一个通道!");
                if (!string.IsNullOrEmpty(context.GetString("sort")) && !Regex.IsMatch(context.GetString("sort"), "^[0-9]*$"))
                    throw new Exception("序号必须为数字");
                if (!string.IsNullOrEmpty(context.GetString("price")) && !Regex.IsMatch(context.GetString("price"), "^[0-9]*$") && price<=0 )
                    throw new Exception("参考单价不能小于等于0");
                if (!string.IsNullOrEmpty(context.GetString("givingNum")) && !Regex.IsMatch(context.GetString("givingNum"), "^[0-9]*$"))
                    throw new Exception("默认赠送条数必须为整数");
            }
            //产品相关项校验
            else if (classes == 0)
            {
 
            }
 
        }
 
        this._Dao.Add(new GwProduct()
        {
            Id = id,
            Name = name,
            Icon = icon,
            Instructions = instructions,
            Classes = classes,
            ParentId = parentId,
            Path = path,
            IsDefault = isDefault,
            IsEnable = isEnable,
            Sort = sort,
            RouterType = routerType,
            CmOpId = cmOpId,
            CuOpId = cuOpId,
            CtOpId = ctOpId,
            CmGroupid = cmGroupid,
            CuGroupid = cuGroupid,
            CtGroupid = ctGroupid,
            CmExtParams = cmExtParams,
            CuExtParams = cuExtParams,
            CtExtParams = ctExtParams,
            Price = price,    //单价换算
            GivingNum = givingNum,
            Remark = remark,
            CreateTime = createTime,
            Creator = creator
            //UpdateTime = update_time,
            //Updateor = updateor
 
        });
        return new JsonPageResult(true, info + "信息添加成功!");
    }
 
    //更新产品或产品分类
    private JsonPageResult Update(PageContext<SysUser> context)
    {
        string id = context.GetString("id");
        string name = context.GetString("name");
        int classes = context.GetInt("classes", -1);
        string icon = "";
        string instructions = "";
        int isDefault = 0;
        int sort = 0;
 
        int routerType = 0;
        int cmOpId = 0;
        int cuOpId = 0;
        int ctOpId = 0;
        string cmExtParams = "";
        string cuExtParams = "";
        string ctExtParams = "";
        int cmGroupid = 0;
        int cuGroupid = 0;
        int ctGroupid = 0;
        int price = 0;
        int givingNum = 0;
 
        string info = "" ;
        if (classes == -1) {
            throw new ArgumentException("请选择类别!");
        }
        else
        {
            if(classes == 1)
            {
                info = "产品";
                if (string.IsNullOrEmpty(name))
                {
                    throw new ArgumentException(info + "名称不能为空!");
                }
 
            }
            else if (classes == 0)
            {
                info = "产品分类";
                if (string.IsNullOrEmpty(name))
                {
                    throw new ArgumentException(info + "名称不能为空!");
                }
 
            }
 
        }
 
 
        //1-产品;0-分类
        if (classes==1)
        {
            icon = context.GetString("icon");
            instructions = context.GetString("instructions");
            isDefault = context.GetInt("isDefault", 0);
 
            int num = Math.Max((int) (context.GetDecimal("price", new Decimal(4, 0, 0, false, (byte) 2)) * new Decimal(1000)), 1);
            price = num;
            givingNum = context.GetInt("givingNum", 0);
            sort = context.GetInt("sort", 0);
 
            routerType = context.GetInt("routerType", 1);
            //路由类型:1-通道路由;3-通道组路由。
            if (routerType==1)
            {
                cmOpId = context.GetInt("cmOpId", 0);
                cuOpId = context.GetInt("cuOpId", 0);
                ctOpId = context.GetInt("ctOpId", 0);
                cmExtParams = context.GetString("cmExtParams");
                cuExtParams = context.GetString("cuExtParams");
                ctExtParams = context.GetString("ctExtParams");
 
            }
            else if (routerType==3)
            {
                cmGroupid = context.GetInt("cmGroupid", 0);
                cuGroupid = context.GetInt("cuGroupid", 0);
                ctGroupid = context.GetInt("ctGroupid", 0);
 
            }
 
        }
        string parentId = context.GetString("parentId", "0");
        string path = "";
        if (parentId.Equals("0"))
        {
            path = "0";
        }
        else
        {
            GwProduct newProduct = _Dao.Get(parentId);
            if(newProduct!=null)
            {
                path = newProduct.Path=="" ? "0" : newProduct.Path + "," + newProduct.Id ;
            }
            else
            {
                path = "0";
            }
 
        }
        int isEnable = context.GetInt("isEnable", 0);
 
        string remark = context.GetString("remark", "");
        //DateTime createTime = context.GetDateTime("createTime");
        //int creator = context.GetInt("creator", 0);
        //DateTime updateTime = context.GetDateTime("updateTime");
        DateTime updateTime = DateTime.Now;
        string updateor = context.OperatorID;
 
        //校验
        if (classes == -1) {
            throw new ArgumentException("请选择类别!");
        }
        else
        {
            if(string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("请输入名称!");
            }
            //产品相关项校验
            if (classes == 1)
            {
                if (routerType==0 )
                    throw new ArgumentException("请选择路由类型!");
                if (cmGroupid == 0 && cuGroupid == 0 && ctGroupid == 0 && routerType == 3 && classes==1)
                    throw new ArgumentException("至少指定一个通道组!");
                if (cmOpId == 0 && cuOpId == 0 && ctOpId == 0 && routerType == 1 && classes==1)
                    throw new ArgumentException("至少指定一个通道!");
                if (!string.IsNullOrEmpty(context.GetString("sort")) && !Regex.IsMatch(context.GetString("sort"), "^[0-9]*$"))
                    throw new Exception("序号必须为数字");
                if (!string.IsNullOrEmpty(context.GetString("price")) && !Regex.IsMatch(context.GetString("price"), "^[0-9]*$") && price<=0 )
                    throw new Exception("参考单价不能小于等于0");
                if (!string.IsNullOrEmpty(context.GetString("givingNum")) && !Regex.IsMatch(context.GetString("givingNum"), "^[0-9]*$"))
                    throw new Exception("默认赠送条数必须为整数");
            }
            //产品相关项校验
            else if (classes == 0)
            {
 
            }
 
        }
 
        this._Dao.Update(new GwProduct()
        {
            Id = id,
            Name = name,
            Icon = icon,
            Instructions = instructions,
            Classes = classes,
            ParentId = parentId,
            Path = path,
            IsDefault = isDefault,
            IsEnable = isEnable,
            Sort = sort,
            RouterType = routerType,
            CmOpId = cmOpId,
            CuOpId = cuOpId,
            CtOpId = ctOpId,
            CmGroupid = cmGroupid,
            CuGroupid = cuGroupid,
            CtGroupid = ctGroupid,
            CmExtParams = cmExtParams,
            CuExtParams = cuExtParams,
            CtExtParams = ctExtParams,
            Price = price,    //单价换算
            GivingNum = givingNum,
            Remark = remark,
            //CreateTime = createTime,
            //Creator = creator,
            UpdateTime = updateTime,
            Updateor = updateor
 
        });
 
        //更新关联的产品路径PATH
        _Dao.UpdatePath(id, path);
 
 
        return new JsonPageResult(true, info + "信息更新成功!");
    }
 
    //根据主键获取产品或产品分类信息
    private JsonPageResult Get(PageContext<SysUser> context)
    {
        return new JsonPageResult(true, this._Dao.Get(context.GetString("id")));
    }
 
    //图标文件上传
    private JsonPageResult UpLoad(PageContext<SysUser> context)
    {
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();
        HttpPostedFile httpPostedFile = context.Files["certPath"];
        if (httpPostedFile == null || httpPostedFile.FileName == "")
            throw new Exception("请选择要上传的BMP(位图)、JPG、JPEG、PNG、GIF文件,并检查文件大小!");
        string extension = Path.GetExtension(httpPostedFile.FileName);
        if (!extension.Equals(".jpg", StringComparison.OrdinalIgnoreCase)
                    && !extension.Equals(".jpeg", StringComparison.OrdinalIgnoreCase)
                    && !extension.Equals(".png", StringComparison.OrdinalIgnoreCase)
                    && !extension.Equals(".gif", StringComparison.OrdinalIgnoreCase)
                    && !extension.Equals(".bmp", StringComparison.OrdinalIgnoreCase))
            throw new Exception("上传文件格式不正确,只允许上传BMP(位图)、JPG、JPEG、PNG、GIF文件!");
        if (httpPostedFile.ContentLength > 5242880 )
            throw new Exception("文件上传不能超过5M,请检查文件大小,是否有写权限!");
 
        //string @string = context.GetString("ablackpool");
        //if (string.IsNullOrEmpty(@string))
        //  throw new Exception("请选择黑名单池!");
 
        List<Stream> outputStreamList = new List<Stream>();
        if (extension.Equals(".jpg", StringComparison.OrdinalIgnoreCase)
                    && extension.Equals(".jpeg", StringComparison.OrdinalIgnoreCase)
                    && extension.Equals(".png", StringComparison.OrdinalIgnoreCase)
                    && extension.Equals(".gif", StringComparison.OrdinalIgnoreCase)
                    && extension.Equals(".bmp", StringComparison.OrdinalIgnoreCase))
            outputStreamList.Add(httpPostedFile.InputStream);
        //else if (extension.Equals(".zip", StringComparison.OrdinalIgnoreCase))
        //   ZipUtils.Decompression(httpPostedFile.InputStream, ref outputStreamList, true);
 
        //string fieldName = "c:/AYZH";
        //HttpContext httpContext = new HttpContext();
        //WebTool.SaveUploadFile(httpContext, fieldName);
 
        stopwatch.Stop();
        string str = "上传耗时:" + (object) stopwatch.ElapsedMilliseconds + "ms";
        return new JsonPageResult(true, (object) new
        {
            Message = "文件上传成功!",
            Msg = str
        });
    }
 
    //获取通道列表
    private List<GwOp> OpList
    {
        get
        {
            if (this._OpList == null)
            {
                using (GwOpDao gwOpDao = new GwOpDao())
                    this._OpList = gwOpDao.LoadInfoList();
            }
            return this._OpList;
        }
    }
 
    //加载产品及产品分类信息
    private List<GwProduct> ProductAllList()
    {
        GwProduct bean = new GwProduct();
        bean.Classes = -1;
        bean.IsDefault = -1;
        bean.IsEnable = -1;
 
        List<GwProduct> list = _Dao.getAllList(bean);
 
        return list;
    }
 
    //获取产品或产品分类列表
    private List<GwProduct> ProductList
    {
        get
        {
            if (this._ProductList == null)
            {
                this._ProductList = this.ProductAllList();
            }
            return this._ProductList;
        }
    }
 
    //产品或产品分类ID转换名称
    private string ProductToName(string productId)
    {
        if (this.ProductList == null)
            return string.Empty;
        GwProduct bean = this.ProductList.Find((Predicate<GwProduct>)(product => product.Id == productId));
        if (bean != null)
            //return string.Format("{0}-{1}", (object)bean.Id, (object)bean.Name);
            return string.Format("{0}", (object)bean.Name);
        return string.Empty;
    }
 
    //更新信息启用或停用
    private JsonPageResult UpdateStatus(PageContext<SysUser> context)
    {
        string id = context.GetString("id");
        string isEnable = context.GetString("isEnable");
 
        if(isEnable=="0") {
            if (this._Dao.GwProductUseCount(id) > 0)
                throw new ArgumentException("当前产品分类已在产品信息使用中,无法停用!");
            if (this._Dao.GwSpUseCount(id) > 0)
                throw new ArgumentException("当前产品在客户账号信息中使用,无法停用!");
        }
        this._Dao.UpdateStatus(id, isEnable);
        return new JsonPageResult(true, "更新信息状态成功!");
 
    }
 
    //获取通道组列表
    private List<GwOpGroup> GroupList
    {
        get
        {
            if (this._GroupList == null)
            {
                using (GwOpGroupDao gwOpGroupDao = new GwOpGroupDao())
                    this._GroupList = gwOpGroupDao.GetGroupList();
            }
            return this._GroupList;
        }
    }
 
    //通道ID转换名称
    private string GetOpName(int opID)
    {
        if (this.OpList == null)
            return string.Empty;
        GwOp gwOp = this.OpList.Find((Predicate<GwOp>)(op => op.OpID == opID));
        if (gwOp != null)
            return string.Format("{0}-{1}", (object)gwOp.OpID, (object)gwOp.OpName);
        return string.Empty;
    }
 
    //产品类别转换名称
    private string ClassesToName(int classes)
    {
        if (classes == -1)
            return string.Empty;
        else if(classes == 0)
            return "0-产品分类";
        else if(classes == 1)
            return "1-产品";
 
        return string.Empty;
    }
 
    //产品是否默认转换名称
    private string IsDefaultToName(int isDefault)
    {
        if (isDefault == -1)
            return string.Empty;
        else if(isDefault == 0)
            return "0-个性化";
        else if(isDefault == 1)
            return "1-系统默认";
 
        return string.Empty;
    }
 
    //启用停用转换名称
    private string IsEnableToName(int isEnable)
    {
        if (isEnable == -1)
            return string.Empty;
        else if(isEnable == 0)
            return "0-停用";
        else if(isEnable == 1)
            return "1-启用";
 
        return string.Empty;
    }
 
    //通道组ID转换名称
    private string GetGroupName(int groupID)
    {
        if (this.GroupList == null)
            return string.Empty;
        GwOpGroup gwOpGroup = this.GroupList.Find((Predicate<GwOpGroup>)(group => group.GroupID == groupID));
        if (gwOpGroup != null)
            return string.Format("{0}-{1}", (object)gwOpGroup.GroupID, (object)gwOpGroup.GroupName);
        return string.Empty;
    }
}