Преглед изворни кода

签证图片上传TryCatch

jiangjc пре 1 година
родитељ
комит
2f6c5c39e9
1 измењених фајлова са 22 додато и 14 уклоњено
  1. 22 14
      OASystem/OASystem.Api/Controllers/GroupsController.cs

+ 22 - 14
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -525,25 +525,33 @@ namespace OASystem.API.Controllers
 
             DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
             int sucNum = 0;
-            foreach (var item in dto.base64DataList)
+            try
             {
-                string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
-                string result = decodeBase64ToImage(item, imageName);
-
-                if (!string.IsNullOrEmpty(result))
+                foreach (var item in dto.base64DataList)
                 {
-                    Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
-                    pic.CreateUserId = dto.CreateUserId;
-                    pic.PicName = imageName;
-                    pic.PicPath = result;
-                    pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
-
-                    int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
-                    if (insertResult > 0)
+                    string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
+                    string result = decodeBase64ToImage(item, imageName);
+
+                    if (!string.IsNullOrEmpty(result))
                     {
-                        sucNum++;
+                        Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
+                        pic.CreateUserId = dto.CreateUserId;
+                        pic.PicName = imageName;
+                        pic.PicPath = result;
+                        pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
+
+                        int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
+                        if (insertResult > 0)
+                        {
+                            sucNum++;
+                        }
                     }
                 }
+
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, ex.Message));
             }
 
             string msg = string.Format(@"成功上传{0}张", sucNum);