Browse Source

文件导入

duhongyu 5 years ago
parent
commit
c4407dda7e

+ 20 - 6
代码/TVShoppingCallCenter_ZLJ/Controllers/AutoDial/OutboundTaskController.cs

@@ -520,15 +520,29 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.AutoDial
520 520
                     string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
521 521
 
522 522
                     model.F_Parentid = pid;
523
-                    if (dr["是否完成外呼"].ToString()=="是")
523
+                    if (dr.Table.Columns.Contains("是否完成外呼"))
524 524
                     {
525
-                        model.F_ISOutbound = 1;
525
+                        if (dr["是否完成外呼"].ToString() == "是")
526
+                        {
527
+                            model.F_ISOutbound = 1;
528
+                        }
529
+                        else
530
+                            model.F_ISOutbound = 0;
526 531
                     }
527 532
                     else
528
-                        model.F_ISOutbound = 0;
529
-                  
530
-                   // model.F_LastCallid = it.F_LastCallid;
531
-                    model.F_Tel = dr["外呼号码"].ToString();
533
+                    {
534
+                        return Error("模板错误,请选择正确的模板");
535
+                    }
536
+
537
+                    // model.F_LastCallid = it.F_LastCallid;
538
+                    if (dr.Table.Columns.Contains("外呼号码"))
539
+                    {
540
+                        model.F_Tel = dr["外呼号码"].ToString();
541
+                    }
542
+                    else
543
+                    {
544
+                        return Error("模板错误,请选择正确的模板");
545
+                    }
532 546
                     var call = _sys_autodialrepository.GetListALL(x => x.F_Tel == dr["外呼号码"].ToString() && x.F_ISOutbound == 0 &&
533 547
                    x.F_IsDelete == 0).Result;
534 548
                     if (call!=null && call.Count ()>0)

+ 29 - 22
代码/TVShoppingCallCenter_ZLJ/Controllers/Customer/VIPInfoController.cs

@@ -615,31 +615,38 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Customer
615 615
 
616 616
                     foreach (PropertyInfo item in PropertyList)
617 617
                     {
618
-                        if (dbcolslist.Contains(item.Name))
618
+                        try
619 619
                         {
620
-                            Type tType = null;
621
-                            object o = dr[titlelist[dbcolslist.IndexOf(item.Name)]]; 
622
-                            if (item.PropertyType.FullName.Contains(typeof(DateTime).FullName))
620
+                            if (dbcolslist.Contains(item.Name))
623 621
                             {
624
-                                tType= typeof(DateTime);
625
-                            }
626
-                            else if (item.PropertyType.FullName.Contains(typeof(Int64).FullName))
627
-                            {
628
-                                tType = typeof(Int64);
629
-                            }
630
-                            else if (item.PropertyType.FullName.Contains(typeof(Int32).FullName))
631
-                            {
632
-                                tType = typeof(Int32);
633
-                            }
634
-                            else if (item.PropertyType.FullName.Contains(typeof(Decimal).FullName))
635
-                            {
636
-                                tType = typeof(Decimal);
622
+                                Type tType = null;
623
+                                object o = dr[titlelist[dbcolslist.IndexOf(item.Name)]];
624
+                                if (item.PropertyType.FullName.Contains(typeof(DateTime).FullName))
625
+                                {
626
+                                    tType = typeof(DateTime);
627
+                                }
628
+                                else if (item.PropertyType.FullName.Contains(typeof(Int64).FullName))
629
+                                {
630
+                                    tType = typeof(Int64);
631
+                                }
632
+                                else if (item.PropertyType.FullName.Contains(typeof(Int32).FullName))
633
+                                {
634
+                                    tType = typeof(Int32);
635
+                                }
636
+                                else if (item.PropertyType.FullName.Contains(typeof(Decimal).FullName))
637
+                                {
638
+                                    tType = typeof(Decimal);
639
+                                }
640
+                                else { tType = item.PropertyType; }
641
+                                object v = null;
642
+                                if (o != null && o != DBNull.Value)
643
+                                    v = Convert.ChangeType(dr[titlelist[dbcolslist.IndexOf(item.Name)]].ToString(), tType);
644
+                                item.SetValue(model, v, null);
637 645
                             }
638
-                            else { tType = item.PropertyType; }
639
-                            object v = null;
640
-                            if (o!=null&&o!=DBNull.Value)
641
-                             v = Convert.ChangeType(dr[titlelist[dbcolslist.IndexOf(item.Name)]].ToString(), tType);
642
-                            item.SetValue(model, v, null);                            
646
+                        }
647
+                        catch 
648
+                        {
649
+                            return Error("模板错误,请选择正确的模板");
643 650
                         }
644 651
                     }
645 652
 

+ 48 - 24
代码/TVShoppingCallCenter_ZLJ/Controllers/ManagementCenter/TodoManagementController.cs

@@ -294,43 +294,67 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.ManagementCenter
294 294
                 {
295 295
                     var model = new T_Sys_TodoManagement();
296 296
                     string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
297
-                   
298
-                    if (dr["分类"].ToString() == "日程")
297
+                    if (dr.Table.Columns.Contains ("分类"))
299 298
                     {
300
-                        model.F_Type = 0;
301
-                        model.F_Name = dr["待办标题"].ToString();
302
-                        model.F_Content = dr["待办内容"].ToString();
299
+                        if (dr["分类"].ToString() == "日程")
300
+                        {
301
+                            model.F_Type = 0;
302
+                            model.F_Name = dr["待办标题"].ToString();
303
+                            model.F_Content = dr["待办内容"].ToString();
304
+                        }
305
+                        else
306
+                        {
307
+                            model.F_Type = 1;
308
+                            model.F_PeopleName = dr["待联系人姓名"].ToString();
309
+                            model.F_Tel = dr["待联系人电话"].ToString();
310
+                        }
303 311
                     }
304 312
                     else
305 313
                     {
306
-                        model.F_Type = 1;
307
-                        model.F_PeopleName = dr["待联系人姓名"].ToString();
308
-                        model.F_Tel = dr["待联系人电话"].ToString();
314
+                        return Error("模板错误,请选择正确的模板");
315
+                    }
316
+                    if (dr.Table.Columns.Contains("任务状态"))
317
+                    {
318
+                        if (dr["任务状态"].ToString() == "未完成")
319
+                            model.F_State = 0;
320
+                        else
321
+                            model.F_State = 1;
309 322
                     }
310
-                       
311
-                    if (dr["任务状态"].ToString() == "未完成")
312
-                        model.F_State = 0;
313 323
                     else
314
-                        model.F_State = 1;
315
-                    if (dr["是否提醒"].ToString() == "是")
324
+                    {
325
+                        return Error("模板错误,请选择正确的模板");
326
+                    }
327
+                    if (dr.Table.Columns.Contains("是否提醒"))
328
+                    {
329
+                        if (dr["是否提醒"].ToString() == "是")
316 330
                         model.F_IsRemind = 1;
317 331
                     else
318 332
                         model.F_IsRemind = 0;
319
-                    
320
-                 
321
-                    if (!string .IsNullOrEmpty (dr["待办提醒时间"].ToString()))
333
+                    }
334
+                    else
322 335
                     {
323
-                        try
324
-                        {
325
-                            model.F_Remindertime =DateTime .Parse (dr["待办提醒时间"].ToString() );
326
-                        }
327
-                        catch
336
+                        return Error("模板错误,请选择正确的模板");
337
+                    }
338
+
339
+                    if (dr.Table.Columns.Contains("待办提醒时间"))
340
+                    {
341
+                        if (!string.IsNullOrEmpty(dr["待办提醒时间"].ToString()))
328 342
                         {
329
-                            errmsg = errmsg + "\r\n第" + index + "行导入失败!待办提醒时间格式错误";
330
-                            continue;
343
+                            try
344
+                            {
345
+                                model.F_Remindertime = DateTime.Parse(dr["待办提醒时间"].ToString());
346
+                            }
347
+                            catch
348
+                            {
349
+                                errmsg = errmsg + "\r\n第" + index + "行导入失败!待办提醒时间格式错误";
350
+                                continue;
351
+                            }
331 352
                         }
332 353
                     }
333
-                       
354
+                    else
355
+                    {
356
+                        return Error("模板错误,请选择正确的模板");
357
+                    }
334 358
                     model.F_CreateTime = DateTime.Now;
335 359
                     model.F_CreateUser = user;
336 360
                     model.F_IsDelete = 0;

+ 53 - 44
代码/TVShoppingCallCenter_ZLJ/Controllers/Product/ProductController.cs

@@ -81,66 +81,75 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.Product
81 81
                 {
82 82
                     dirList.Add(arrykey[i], arryvalue[i]);
83 83
                 }
84
-
85
-                IList<ProductInput> IProducts = ModelConvertHelper<ProductInput>.ConvertToModelByColumns(dtExcel, dirList);
86
-                List<ProductInput> Products = ModelConvertHelper<ProductInput>.ConvertIListToList(IProducts);
87
-                int num = Products.Count;
88
-                List<ProductInput> inputlist = new List<ProductInput>();
89
-
90
-                //判断表格内是否有重复
91
-                for (int i = 0; i < Products.Count - 1; i++)
84
+                try
92 85
                 {
93
-                    for (int j = i + 1; j < Products.Count; j++)
86
+                    IList<ProductInput> IProducts = ModelConvertHelper<ProductInput>.ConvertToModelByColumns(dtExcel, dirList);
87
+                    List<ProductInput> Products = ModelConvertHelper<ProductInput>.ConvertIListToList(IProducts);
88
+                    int num = Products.Count;
89
+                    List<ProductInput> inputlist = new List<ProductInput>();
90
+                    //判断表格内是否有重复
91
+                    for (int i = 0; i < Products.Count - 1; i++)
94 92
                     {
95
-                        if (Products[i].ProductId == Products[j].ProductId)
93
+                        for (int j = i + 1; j < Products.Count; j++)
96 94
                         {
97
-                            return Error(Products[i].ProductId + "ID有重复:" + Products[j].ProductId);
95
+                            if (Products[i].ProductId == Products[j].ProductId)
96
+                            {
97
+                                return Error(Products[i].ProductId + "ID有重复:" + Products[j].ProductId);
98
+                            }
99
+                            if (Products[i].ProductName == Products[j].ProductName)
100
+                            {
101
+                                return Error(Products[i].ProductId + " 名称有重复:" + Products[j].ProductId);
102
+                            }
103
+                            if (Products[i].ProductShortName == Products[j].ProductShortName)
104
+                            {
105
+                                return Error(Products[i].ProductId + "商品副标题 有重复:" + Products[j].ProductId);
106
+                            }
98 107
                         }
99
-                        if ( Products[i].ProductName == Products[j].ProductName)
108
+
109
+                    }
110
+                    //判断
111
+                    foreach (ProductInput input in Products)
112
+                    {
113
+                        Expression<Func<T_Bus_Product, bool>> eq = a => a.F_ProductName == input.ProductName;
114
+
115
+
116
+
117
+                        if (await _productRepository.GetCount(eq) > 0)
100 118
                         {
101
-                            return Error(Products[i].ProductId + " 名称有重复:" + Products[j].ProductId);
119
+                            return Error("商品名称有重复:" + input.ProductName);
102 120
                         }
103
-                        if (Products[i].ProductShortName == Products[j].ProductShortName)
121
+                        eq = b => b.F_ProductId == input.ProductId;
122
+                        if (await _productRepository.GetCount(eq) > 0)
104 123
                         {
105
-                            return Error(Products[i].ProductId + "商品副标题 有重复:" + Products[j].ProductId);
124
+                            return Error("商品ID有重复:" + input.ProductId);
106 125
                         }
126
+                        eq = b => b.F_ProductShortName == input.ProductShortName;
127
+                        if (await _productRepository.GetCount(eq) > 0)
128
+                        {
129
+                            return Error("商品副标题有重复:" + input.ProductShortName);
130
+                        }
131
+                        input.IsDelete = 0;
132
+                        input.IsSale = 1;
133
+                        if (!string.IsNullOrEmpty(input.ProductId))
134
+                            inputlist.Add(input);
107 135
                     }
108
-
109
-                }
110
-                //判断
111
-                foreach (ProductInput input in Products)
112
-                {
113
-                    Expression<Func<T_Bus_Product, bool>> eq = a => a.F_ProductName == input.ProductName;
114
-                   
115
-                   
116
-
117
-                    if (await _productRepository.GetCount(eq) > 0)
118
-                    {
119
-                        return Error("商品名称有重复:" + input.ProductName);
120
-                    }
121
-                    eq = b => b.F_ProductId == input.ProductId;
122
-                    if (await _productRepository.GetCount(eq) > 0)
136
+                    if (await AddProductFun(inputlist))
123 137
                     {
124
-                        return Error("商品ID有重复:" + input.ProductId);
138
+                        return Success("已导入数据");
125 139
                     }
126
-                    eq = b => b.F_ProductShortName == input.ProductShortName;
127
-                    if (await _productRepository.GetCount(eq) > 0)
140
+                    else
128 141
                     {
129
-                        return Error("商品副标题有重复:" + input.ProductShortName);
142
+                        return Error("导入失败");
130 143
                     }
131
-                    input.IsDelete = 0;
132
-                    input.IsSale = 1;
133
-                    if (!string.IsNullOrEmpty(input.ProductId))
134
-                         inputlist.Add(input);
135 144
                 }
136
-                if (await AddProductFun(inputlist))
145
+                catch
137 146
                 {
138
-                    return Success("已导入数据");
139
-                }
140
-                else
141
-                {
142
-                    return Error("导入失败");
147
+                    return Error("模板错误,请选择正确的模板");
143 148
                 }
149
+                
150
+               
151
+
152
+               
144 153
             }
145 154
             return Success("请选择要导入的文件");
146 155
         }

+ 99 - 91
代码/TVShoppingCallCenter_ZLJ/Controllers/TaskManagement/TaskManagementController.cs

@@ -450,111 +450,119 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.TaskManagement
450 450
                 int index = 1;
451 451
                 foreach (DataRow dr in dtExcel.Rows)
452 452
                 {
453
+                    
453 454
                     var model = new T_Sys_TaskManagement();
454 455
                     string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
455
-                    model.F_Name = dr["任务名称"].ToString();
456
-                    model.F_Content = dr["任务内容"].ToString();
457
-                    if (string .IsNullOrEmpty (dr["任务开始时间"].ToString()))
458
-                    {
459
-                        errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入任务开始时间";
460
-                        continue;
461
-                    }
462
-                    if (string.IsNullOrEmpty(dr["任务结束时间"].ToString()))
463
-                    {
464
-                        errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入任务结束时间";
465
-                        continue;
466
-                    }
467
-                    if (string.IsNullOrEmpty(dr["目标金额"].ToString()))
468
-                    {
469
-                        errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入目标金额";
470
-                        continue;
471
-                    }
472
-                    try
473
-                    {
474
-                        model.F_StartTime = DateTime.Parse(dr["任务开始时间"].ToString());
475
-                    }
476
-                    catch
477
-                    {
478
-                        errmsg = errmsg + "\r\n第" + index + "行导入失败!任务开始时间格式错误";
479
-                        continue;
480
-                    }
481
-                    try
482
-                    {
483
-                        model.F_EndTime = DateTime.Parse(dr["任务结束时间"].ToString());
484
-                    }
485
-                    catch
486
-                    {
487
-                        errmsg = errmsg + "\r\n第" + index + "行导入失败!任务结束时间格式错误";
488
-                        continue;
489
-                    }
490
-                    if (dr["任务类型"].ToString() == "月")
491
-                        model.F_Type = 2;
492
-                    else if (dr["任务类型"].ToString() == "周")
493
-                        model.F_Type = 1;
494
-                    else
495
-                        model.F_Type = 0;
496
-                     if (_sys_departmentRepository.GetSingle(x => x.F_DeptName == dr["任务部门"].ToString()).Result !=null )
497
-                    {
498
-                        model.F_Deptid = _sys_departmentRepository.GetSingle(x => x.F_DeptName == dr["任务部门"].ToString()).Result.F_DeptId.ToString ();
499
-                    }
500
-                     else
501
-                    {
502
-                        errmsg = errmsg + "\r\n第" + index + "行导入失败!请检查任务部门";
503
-                        continue;
504
-                    }
505
-                    if (_sys_useraccountRepository.GetSingle(x => x.F_UserName == dr["任务人"].ToString()&&x.F_DeleteFlag ==0).Result != null)
506
-                    {
507
-                        model.F_Tasker = _sys_useraccountRepository.GetSingle(x => x.F_UserName == dr["任务人"].ToString() && x.F_DeleteFlag == 0).Result.F_UserId   ;
508
-                      
509
-                    }
510
-                    else
511
-                    {
512
-                        errmsg = errmsg + "\r\n第" + index + "行导入失败!请检查任务人";
513
-                        continue;
514
-                    }
515
-                    try
516
-                    {
517
-                        model.F_Money = float .Parse(dr["目标金额"].ToString());
518
-                    }
519
-                    catch
520
-                    {
521
-                        errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入正确的目标金额";
522
-                        continue;
523
-                    }
524
-                    if (string.IsNullOrEmpty(dr["当前金额"].ToString()))
525
-                        model.F_Currentamount = 0;
526 456
                     try
527 457
                     {
528
-                        model.F_Currentamount = float.Parse(dr["当前金额"].ToString());
529
-                    }
530
-                    catch
531
-                    {
532
-                        errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入正确的当前金额";
533
-                        continue;
534
-                    }
535
-                    if (!string .IsNullOrEmpty (dr["任务提醒时间"].ToString()))
536
-                    {
458
+                        model.F_Name = dr["任务名称"].ToString();
459
+                        model.F_Content = dr["任务内容"].ToString();
460
+                        if (string.IsNullOrEmpty(dr["任务开始时间"].ToString()))
461
+                        {
462
+                            errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入任务开始时间";
463
+                            continue;
464
+                        }
465
+                        if (string.IsNullOrEmpty(dr["任务结束时间"].ToString()))
466
+                        {
467
+                            errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入任务结束时间";
468
+                            continue;
469
+                        }
470
+                        if (string.IsNullOrEmpty(dr["目标金额"].ToString()))
471
+                        {
472
+                            errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入目标金额";
473
+                            continue;
474
+                        }
475
+                        try
476
+                        {
477
+                            model.F_StartTime = DateTime.Parse(dr["任务开始时间"].ToString());
478
+                        }
479
+                        catch
480
+                        {
481
+                            errmsg = errmsg + "\r\n第" + index + "行导入失败!任务开始时间格式错误";
482
+                            continue;
483
+                        }
537 484
                         try
538 485
                         {
539
-                            model.F_Remindertime = DateTime.Parse(dr["任务提醒时间"].ToString());
486
+                            model.F_EndTime = DateTime.Parse(dr["任务结束时间"].ToString());
540 487
                         }
541 488
                         catch
542 489
                         {
543
-                            errmsg = errmsg + "\r\n第" + index + "行导入失败!任务提醒时间格式错误";
490
+                            errmsg = errmsg + "\r\n第" + index + "行导入失败!任务结束时间格式错误";
491
+                            continue;
492
+                        }
493
+                        if (dr["任务类型"].ToString() == "月")
494
+                            model.F_Type = 2;
495
+                        else if (dr["任务类型"].ToString() == "周")
496
+                            model.F_Type = 1;
497
+                        else
498
+                            model.F_Type = 0;
499
+                        if (_sys_departmentRepository.GetSingle(x => x.F_DeptName == dr["任务部门"].ToString()).Result != null)
500
+                        {
501
+                            model.F_Deptid = _sys_departmentRepository.GetSingle(x => x.F_DeptName == dr["任务部门"].ToString()).Result.F_DeptId.ToString();
502
+                        }
503
+                        else
504
+                        {
505
+                            errmsg = errmsg + "\r\n第" + index + "行导入失败!请检查任务部门";
506
+                            continue;
507
+                        }
508
+                        if (_sys_useraccountRepository.GetSingle(x => x.F_UserName == dr["任务人"].ToString() && x.F_DeleteFlag == 0).Result != null)
509
+                        {
510
+                            model.F_Tasker = _sys_useraccountRepository.GetSingle(x => x.F_UserName == dr["任务人"].ToString() && x.F_DeleteFlag == 0).Result.F_UserId;
511
+
512
+                        }
513
+                        else
514
+                        {
515
+                            errmsg = errmsg + "\r\n第" + index + "行导入失败!请检查任务人";
544 516
                             continue;
545 517
                         }
518
+                        try
519
+                        {
520
+                            model.F_Money = float.Parse(dr["目标金额"].ToString());
521
+                        }
522
+                        catch
523
+                        {
524
+                            errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入正确的目标金额";
525
+                            continue;
526
+                        }
527
+                        if (string.IsNullOrEmpty(dr["当前金额"].ToString()))
528
+                            model.F_Currentamount = 0;
529
+                        try
530
+                        {
531
+                            model.F_Currentamount = float.Parse(dr["当前金额"].ToString());
532
+                        }
533
+                        catch
534
+                        {
535
+                            errmsg = errmsg + "\r\n第" + index + "行导入失败!请输入正确的当前金额";
536
+                            continue;
537
+                        }
538
+                        if (!string.IsNullOrEmpty(dr["任务提醒时间"].ToString()))
539
+                        {
540
+                            try
541
+                            {
542
+                                model.F_Remindertime = DateTime.Parse(dr["任务提醒时间"].ToString());
543
+                            }
544
+                            catch
545
+                            {
546
+                                errmsg = errmsg + "\r\n第" + index + "行导入失败!任务提醒时间格式错误";
547
+                                continue;
548
+                            }
549
+                        }
550
+                        else
551
+                        {
552
+                            model.F_Remindertime = model.F_EndTime.Value.AddDays(-3);
553
+                        }
554
+                        model.F_Taskprogress = string.Format("{0:f2}", model.F_Currentamount / model.F_Money * 100);
555
+                        if (dr["任务类型"].ToString() == "终止")
556
+                            model.F_State = 2;
557
+                        else if (dr["任务类型"].ToString() == "暂停")
558
+                            model.F_State = 1;
559
+                        else
560
+                            model.F_State = 0;
546 561
                     }
547
-                    else
562
+                   catch
548 563
                     {
549
-                        model.F_Remindertime = model.F_EndTime.Value.AddDays(-3);
564
+                        return Error("模板错误,请选择正确的模板");
550 565
                     }
551
-                    model.F_Taskprogress = string.Format("{0:f2}", model.F_Currentamount / model.F_Money * 100);
552
-                    if (dr["任务类型"].ToString() == "终止")
553
-                        model.F_State = 2;
554
-                    else if (dr["任务类型"].ToString() == "暂停")
555
-                        model.F_State = 1;
556
-                    else
557
-                        model.F_State = 0;
558 566
                     model.F_CreateTime = DateTime.Now;
559 567
                     model.F_CreateUser  = user;
560 568
                     model.F_IsDelete = 0;