duhongyu 5 gadi atpakaļ
vecāks
revīzija
15db65c071

+ 32 - 47
代码/System.Model/T_Sys_Accessories.cs

@@ -7,67 +7,50 @@ namespace System.Model
7 7
     /// <summary>
8 8
     /// 附件表
9 9
     /// </summary>
10
-	[Serializable]
10
+    [Serializable]
11 11
     public partial class T_Sys_Accessories
12 12
     {
13 13
         public T_Sys_Accessories()
14 14
         { }
15 15
         #region Model
16
-        private int _f_fileid;
17
-        private string _f_filename;
18
-        private string _f_filetype;
19
-        private string _f_fileurl;
20
-        private string _f_usercode;
21
-        private DateTime? _f_addtime;
16
+        private int _f_id;
17
+        private string _f_name;
18
+        private string _f_type;
19
+        private string _f_url;
22 20
         private long? _f_size;
23
-        private string _f_oriname;
21
+        private string _f_createuser;
22
+        private DateTime? _f_createtime;
24 23
         /// <summary>
25 24
         /// 附件id
26 25
         /// </summary>
27
-        public int F_FileId
26
+        public int F_Id
28 27
         {
29
-            set { _f_fileid = value; }
30
-            get { return _f_fileid; }
28
+            set { _f_id = value; }
29
+            get { return _f_id; }
31 30
         }
32 31
         /// <summary>
33 32
         /// 附件名称
34 33
         /// </summary>
35
-        public string F_FileName
34
+        public string F_Name
36 35
         {
37
-            set { _f_filename = value; }
38
-            get { return _f_filename; }
36
+            set { _f_name = value; }
37
+            get { return _f_name; }
39 38
         }
40 39
         /// <summary>
41 40
         /// 附件类型(后缀名)
42 41
         /// </summary>
43
-        public string F_FileType
42
+        public string F_Type
44 43
         {
45
-            set { _f_filetype = value; }
46
-            get { return _f_filetype; }
44
+            set { _f_type = value; }
45
+            get { return _f_type; }
47 46
         }
48 47
         /// <summary>
49 48
         /// 上传路径
50 49
         /// </summary>
51
-        public string F_FileUrl
50
+        public string F_Url
52 51
         {
53
-            set { _f_fileurl = value; }
54
-            get { return _f_fileurl; }
55
-        }
56
-        /// <summary>
57
-        /// 添加人工号
58
-        /// </summary>
59
-        public string F_UserCode
60
-        {
61
-            set { _f_usercode = value; }
62
-            get { return _f_usercode; }
63
-        }
64
-        /// <summary>
65
-        /// 上传时间
66
-        /// </summary>
67
-        public DateTime? F_AddTime
68
-        {
69
-            set { _f_addtime = value; }
70
-            get { return _f_addtime; }
52
+            set { _f_url = value; }
53
+            get { return _f_url; }
71 54
         }
72 55
         /// <summary>
73 56
         /// 附件大小
@@ -78,20 +61,22 @@ namespace System.Model
78 61
             get { return _f_size; }
79 62
         }
80 63
         /// <summary>
81
-        /// 文件原名
64
+        /// 添加人工号
82 65
         /// </summary>
83
-        public string F_OriName
66
+        public string F_CreateUser
84 67
         {
85
-            get
86
-            {
87
-                return _f_oriname;
88
-            }
89
-
90
-            set
91
-            {
92
-                _f_oriname = value;
93
-            }
68
+            set { _f_createuser = value; }
69
+            get { return _f_createuser; }
70
+        }
71
+        /// <summary>
72
+        /// 上传时间
73
+        /// </summary>
74
+        public DateTime? F_CreateTime
75
+        {
76
+            set { _f_createtime = value; }
77
+            get { return _f_createtime; }
94 78
         }
95 79
         #endregion Model
80
+
96 81
     }
97 82
 }

+ 23 - 15
代码/TVShoppingCallCenter_ZLJ/Controllers/knowledge/KnowledgeController.cs

@@ -154,8 +154,8 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.knowledge
154 154
         public List<T_Sys_Accessories> GetFileData(string ids, string prefix)
155 155
         {
156 156
             List<IConditionalModel> conModels = new List<IConditionalModel>();
157
-            conModels.Add(new ConditionalModel() { FieldName = "F_FileId", ConditionalType = ConditionalType.In , FieldValue = ids });
158
-            var model = _sys_accessoriesrepository.GetListALL(conModels, " F_AddTime  desc").Result ;
157
+            conModels.Add(new ConditionalModel() { FieldName = "F_Id", ConditionalType = ConditionalType.In , FieldValue = ids });
158
+            var model = _sys_accessoriesrepository.GetListALL(conModels, " F_CreateTime  desc").Result ;
159 159
             return model;
160 160
         }
161 161
         private string CategoryId(int  parentid)
@@ -205,41 +205,49 @@ namespace TVShoppingCallCenter_ZLJ.Controllers.knowledge
205 205
         public async Task<IActionResult> UploadFiles(List<IFormFile> files)
206 206
         {
207 207
             List<T_Sys_Accessories> acs = new List<T_Sys_Accessories>();
208
-            string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
208
+            string user = "8000";
209
+          //  string user = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid).Value;
209 210
             long size = files.Sum(f => f.Length);       //统计所有文件的大小
210
-              string path = Directory.GetCurrentDirectory() + "/ Upload /Files/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd");     //记录日志内容
211
+              string path =  "\\Upload\\Files\\" + DateTime.Now.ToString("yyyy") + "\\" + DateTime.Now.ToString("MM") + "\\" + DateTime.Now.ToString("dd");
212
+            string fliepath = Directory.GetCurrentDirectory() + path;
213
+            //记录日志内容
214
+            if (!Directory.Exists(fliepath))
215
+            {
216
+                Directory.CreateDirectory(fliepath);
217
+            }
211 218
             if (files.Count > 0)
212 219
             {
213 220
                 foreach (var item in files)     //上传选定的文件列表
214 221
                 {
215 222
                     if (item.Length > 0)        //文件大小 0 才上传
216 223
                     {
217
-                        var thispath = path + "\\" + item.FileName;     //当前上传文件应存放的位置
224
+                        var thispath = fliepath + "\\" + item.FileName;     //当前上传文件应存放的位置
218 225
                         //上传文件
219 226
                         using (var stream = new FileStream(thispath, FileMode.Create))      //创建特定名称的文件流
220 227
                         {
221 228
                             try
222 229
                             {
223
-                                await item.CopyToAsync(stream);     //上传文件
230
+                                 await  item.CopyToAsync(stream);     //上传文件
224 231
                                 T_Sys_Accessories model_T_Sys_Accessories = new T_Sys_Accessories();
225
-                                model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
226
-                                model_T_Sys_Accessories.F_FileName = item.FileName;//附件名称
227
-                                model_T_Sys_Accessories.F_FileType = item.FileName.Split ('.')[1];//附件类型
228
-                                model_T_Sys_Accessories.F_FileUrl = thispath;//附件地址
232
+                                model_T_Sys_Accessories.F_CreateTime  = DateTime.Now;//上传时间
233
+                                model_T_Sys_Accessories.F_Name  = item.FileName;//附件名称
234
+                                model_T_Sys_Accessories.F_Type  = item.FileName.Split ('.')[1];//附件类型
235
+                                model_T_Sys_Accessories.F_Url  = path + "\\" + item.FileName;//附件地址
229 236
                                 model_T_Sys_Accessories.F_Size = item.Length;
230
-                                model_T_Sys_Accessories.F_UserCode = user;//上传人  
231
-                                var  id = _sys_accessoriesrepository.Add(model_T_Sys_Accessories);
232
-                                model_T_Sys_Accessories.F_FileId = id.Result ;
237
+                                model_T_Sys_Accessories.F_CreateUser  = user;//上传人  
238
+                                var id = await _sys_accessoriesrepository.Add(model_T_Sys_Accessories);
239
+                                model_T_Sys_Accessories.F_Id = id;
233 240
                                 acs.Add(model_T_Sys_Accessories);
241
+
234 242
                             }
235 243
                             catch (Exception ex)        //上传异常处理
236 244
                             {
237
-
245
+                                return Success("成功", ex.Message);
238 246
                             }
239 247
                         }
240 248
                     }
241 249
                 }
242
-                return Success("成功", acs);
250
+                return Success("成功",  acs);
243 251
             }
244 252
             {
245 253
                 return Error("请选择要上传的文件");