mengjie лет назад: 6
Родитель
Сommit
420373ade1

+ 55 - 1
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/knowledge/KnowledgeController.cs

@@ -458,7 +458,7 @@ namespace CallCenterApi.Interface.Controllers.knowledge
458 458
         /// </summary>
459 459
         /// <returns></returns>
460 460
         [Authority]
461
-        public ActionResult UpLoadProcess(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file)
461
+        public ActionResult UpLoadProcessOld(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file)
462 462
         {
463 463
             try
464 464
             {
@@ -537,5 +537,59 @@ namespace CallCenterApi.Interface.Controllers.knowledge
537 537
         }
538 538
 
539 539
         #endregion
540
+
541
+        /// <summary>
542
+        /// 上传附件
543
+        /// </summary>
544
+        /// <returns></returns>
545
+        [Authority]
546
+        public ActionResult UpLoadProcess(string id, string name, string type, string lastModifiedDate, int size, HttpPostedFileBase file)
547
+        {
548
+            try
549
+            {
550
+                if (file == null) return Error("参数传入失败");
551
+                if (Request.Files.Count == 0) return Error("保存失败");
552
+
553
+                string userCode = CurrentUser.UserData.F_UserCode;
554
+                string filePathName = string.Empty;
555
+                string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy/MM/dd") + "/";
556
+                string localPath = Server.MapPath(Path.Combine(HttpRuntime.AppDomainAppPath, path));
557
+                if (Request.Files.Count == 0)
558
+                {
559
+                    return Error("保存失败");
560
+                }
561
+                string ex = Path.GetExtension(file.FileName);
562
+                filePathName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid().ToString("N") + ex;
563
+                if (!System.IO.Directory.Exists(localPath))
564
+                {
565
+                    System.IO.Directory.CreateDirectory(localPath);
566
+                }
567
+                file.SaveAs(Path.Combine(localPath, filePathName));
568
+                #region 添加日志
569
+                Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
570
+                model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
571
+                model_T_Sys_Accessories.F_FileName = filePathName;//附件名称
572
+                model_T_Sys_Accessories.F_FileType = type;//附件类型
573
+                model_T_Sys_Accessories.F_FileUrl = path + filePathName;//附件地址
574
+                model_T_Sys_Accessories.F_Size = size;
575
+                model_T_Sys_Accessories.F_UserCode = userCode;//上传人  
576
+                int fid = new BLL.T_Sys_Accessories().Add(model_T_Sys_Accessories);
577
+
578
+                #endregion
579
+                if (fid > 0)
580
+                {
581
+                    //返回附件的ID
582
+                    model_T_Sys_Accessories.F_FileId = fid;//修改为返回对象以便查看图片
583
+                    return Success("文件成功", model_T_Sys_Accessories);
584
+                }
585
+                else
586
+                    return Success("文件失败");
587
+
588
+            }
589
+            catch (Exception ex)
590
+            {
591
+                return Error(ex.Message);
592
+            }
593
+        }
540 594
     }
541 595
 }