Przeglądaj źródła

图片附件上传

zhupei 4 lat temu
rodzic
commit
fa01371d49

+ 1 - 1
RMYY_CallCenter_Api.Utility/Helper/FileHelper.cs

@@ -16,7 +16,7 @@ namespace RMYY_CallCenter_Api.Utility
16 16
         /// <param name="hpFile">文件</param>
17 17
         /// <param name="path">路径</param>
18 18
         /// <returns></returns>
19
-        public static string Upload(HttpPostedFile hpFile, string path)
19
+        public static string Upload(HttpPostedFileBase hpFile, string path)
20 20
         {
21 21
             path = HttpContext.Current.Server.MapPath("..") + path;
22 22
             string newName = "(" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ")" + hpFile.FileName;

+ 6 - 3
RMYY_CallCenter_Api/Controllers/DictionaryType/GongDanTypeController.cs

@@ -21,9 +21,12 @@ namespace RMYY_CallCenter_Api.Controllers
21 21
         /// 获取列表
22 22
         /// </summary>
23 23
         /// <returns></returns>
24
-        public ActionResult GetList()
24
+        public ActionResult GetList(int typeid=0)
25 25
         {
26
-            var gModel = gongdanBll.GetAllList();
26
+            string sql = "";
27
+            if (typeid != 0)
28
+                sql += $" F_TypeId=" + typeid;
29
+            var gModel = gongdanBll.GetList(sql);
27 30
             List<T_Sys_GongDan> g_list = gongdanBll.DataTableToList(gModel.Tables[0]);
28 31
             g_list.Sort((x, y) => x.F_Sort - y.F_Sort);
29 32
             var treelist = new List<TreeModel>();
@@ -36,7 +39,6 @@ namespace RMYY_CallCenter_Api.Controllers
36 39
                 treeModel.parentid = item.F_ParentID.ToString();
37 40
                 treelist.Add(treeModel);
38 41
             }
39
-
40 42
             return Success("获取成功", treelist.TreeRecursion("0"));
41 43
         }
42 44
 
@@ -141,6 +143,7 @@ namespace RMYY_CallCenter_Api.Controllers
141 143
                 ModuleInfo.F_Name = input.F_Name;
142 144
                 ModuleInfo.F_Remark = input.F_Remark;
143 145
                 ModuleInfo.F_Sort = input.F_Sort;
146
+                ModuleInfo.F_TypeId = input.F_TypeId;
144 147
                 if (gongdanBll.Update(ModuleInfo))
145 148
                 {
146 149
                     return Success("修改成功");

+ 1 - 1
RMYY_CallCenter_Api/Controllers/System/DepartmentController.cs

@@ -17,7 +17,7 @@ namespace RMYY_CallCenter_Api.Controllers.System
17 17
         /// 获取列表
18 18
         /// </summary>
19 19
         /// <returns></returns>
20
-        public ActionResult GetList(string keyword,int hosid,int pid=0, int pageindex = 1, int pagesize = 10)
20
+        public ActionResult GetList(string keyword,int hosid=0,int pid=0, int pageindex = 1, int pagesize = 10)
21 21
         {
22 22
             DataTable date = new DataTable();
23 23
             string sql = "";

+ 68 - 1
RMYY_CallCenter_Api/Controllers/System/KnowledgeController.cs

@@ -1,6 +1,9 @@
1
-using RMYY_CallCenter_Api.Utility;
1
+using RMYY_CallCenter_Api.DB;
2
+using RMYY_CallCenter_Api.Utility;
2 3
 using System;
3 4
 using System.Collections.Generic;
5
+using System.Data;
6
+using System.IO;
4 7
 using System.Linq;
5 8
 using System.Web;
6 9
 using System.Web.Mvc;
@@ -11,6 +14,49 @@ namespace RMYY_CallCenter_Api.Controllers.System
11 14
     {
12 15
         Bll.T_Sys_Knowledge knbll = new Bll.T_Sys_Knowledge();
13 16
 
17
+
18
+        /// <summary>
19
+        /// 获取知识库列表
20
+        /// </summary>
21
+        /// <param name="keywords"></param>
22
+        /// <param name="typeid"></param>
23
+        /// <param name="pagesize"></param>
24
+        /// <param name="pageindex"></param>
25
+        /// <returns></returns>
26
+        public ActionResult GetList(string keywords,int typeid,  int ptypeid=0, int pagesize = 10, int pageindex = 1)
27
+        {
28
+            string sql = "and F_IsDel=0";
29
+            DataTable dt = new DataTable();
30
+            if (!string.IsNullOrEmpty(keywords))
31
+                sql += $" and F_KeyWords like'%" + keywords.Trim() + "%' or F_Title like '%" + keywords.Trim() + "%' or F_Content like '%" + keywords.Trim() + "%'";
32
+            if (typeid != 0)
33
+                sql += $" and F_TypeId="+typeid;
34
+            if (ptypeid != 0)
35
+                sql += $" and F_TypeId in(select F_GDId from T_Sys_GongDan where F_TypeId="+ptypeid+")";
36
+            int recordCount = 0;
37
+            dt = Bll.PagerBll.GetListPager
38
+                (
39
+                "T_Sys_Knowledge",
40
+                "F_Id",
41
+                "*",
42
+                sql,
43
+                "ORDER BY F_Id desc",
44
+                pagesize,
45
+                pageindex,
46
+                true,
47
+                out recordCount
48
+                );
49
+            var modelist = knbll.DataTableToList(dt);
50
+            var obj = new
51
+            {
52
+                state = "sucess",
53
+                message = "成功",
54
+                rows = modelist
55
+            };
56
+            return Content(obj.ToJson());
57
+        }
58
+
59
+
14 60
         //添加知识库
15 61
         public ActionResult AddInfo(string title, string key, string con, string tid, string fileids)
16 62
         {
@@ -82,7 +128,28 @@ namespace RMYY_CallCenter_Api.Controllers.System
82 128
             }
83 129
             else
84 130
                 return Error("请选择要编辑的知识库!");
131
+        }
132
+
133
+
134
+        /// <summary>
135
+        /// 删除
136
+        /// </summary>
137
+        /// <param name="ids"></param>
138
+        /// <returns></returns>
139
+        public ActionResult DelInfos(string[] ids)
140
+        {
141
+            if (ids != null && ids.Length > 0)
142
+            {
143
+                string idstr = string.Join(",", ids);
144
+                string sql = "update T_Sys_Knowledge set F_IsDel=1 where F_Id in(" + idstr + ")";
145
+                if (DbHelperSQL.ExecuteSql(sql) > 0)
146
+                    return Success("删除成功!");
147
+                else return Error("删除失败!");
148
+
149
+            }
150
+            else return Error("获取参数失败!");
85 151
 
86 152
         }
153
+
87 154
     }
88 155
 }

+ 116 - 2
RMYY_CallCenter_Api/Controllers/WorkOrderBaseController.cs

@@ -2,6 +2,7 @@
2 2
 using System;
3 3
 using System.Collections.Generic;
4 4
 using System.Data;
5
+using System.IO;
5 6
 using System.Linq;
6 7
 using System.Web;
7 8
 using System.Web.Mvc;
@@ -128,16 +129,129 @@ namespace RMYY_CallCenter_Api.Controllers
128 129
         }
129 130
 
130 131
 
132
+        /// <summary>
133
+        /// 上传附件
134
+        /// </summary>
135
+        /// <returns></returns>
136
+        //[Authority]
137
+        public ActionResult UploadFile()
138
+        {
139
+            #region 多个上传
140
+            HttpFileCollectionBase files = Request.Files;
141
+            if (files.Count > 0)
142
+            {
143
+                List<Model.T_Sys_Accessories> acs = new List<Model.T_Sys_Accessories>();
144
+                string path = "/Upload/Files/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
145
+                for (int i = 0; i < files.Count; i++)
146
+                {
147
+                    HttpPostedFileBase file = files[i];
148
+                    string name = FileHelper.Upload(file, path);
149
+
150
+                    Model.T_Sys_Accessories model_T_Sys_Accessories = new Model.T_Sys_Accessories();
151
+                    model_T_Sys_Accessories.F_AddTime = DateTime.Now;//上传时间
152
+                    model_T_Sys_Accessories.F_FileName = name;//附件名称
153
+                    model_T_Sys_Accessories.F_FileType = Path.GetExtension(file.FileName);//附件类型
154
+                    model_T_Sys_Accessories.F_FileUrl = path + name;//附件地址
155
+                    model_T_Sys_Accessories.F_Size = file.ContentLength;
156
+                    model_T_Sys_Accessories.F_UserCode = User.F_UserCode;//上传人  
157
+                    int id = new Bll.T_Sys_Accessories().Add(model_T_Sys_Accessories);
158
+                    model_T_Sys_Accessories.F_FileId = id;
159
+                    acs.Add(model_T_Sys_Accessories);
160
+                }
161
+                return Success("成功", acs);
162
+            }
163
+            else
164
+            {
165
+                return Error("请选择要上传的文件");
166
+            }
167
+            #endregion
168
+
169
+        }
170
+
171
+        /// <summary>
172
+        /// 上传图片
173
+        /// </summary>
174
+        /// <returns></returns>
175
+        public ActionResult UploadImage()
176
+        {
177
+            string path = string.Empty;
178
+            HttpPostedFileBase _upfile = Request.Files["upFile"];
179
+            if (_upfile != null)
180
+            {
181
+                path = "/Upload/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
182
+                ImageHelper iu = new ImageHelper();
183
+                iu.SavePath = path;
184
+                iu.PostFile = _upfile;
185
+                iu.Upload();
186
+                path = path + iu.OutFileName;
187
+                return Success("成功", path);
188
+            }
189
+            else
190
+                return Error("请选择要上传的文件");
191
+        }
192
+
193
+        /// <summary>
194
+        /// 上传图片表单
195
+        /// </summary>
196
+        /// <returns></returns>
197
+        public ActionResult UploadImage64()
198
+        {
199
+            string path = string.Empty;
200
+            //HttpPostedFile _upfile = RequestString.GetFile("upFile");
201
+            string dataurl = HttpUtility.UrlDecode(Request.Form["dataurl"]);
202
+            if (!string.IsNullOrEmpty(dataurl))
203
+            {
204
+                path = "/Upload/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
205
+                ImageHelper iu = new ImageHelper();
206
+                iu.SavePath = path;
207
+                iu.DataUrl = dataurl;
208
+                iu.Upload64();
209
+
210
+                //var configfj = new Bll.T_Sys_SystemConfig().GetModelList(" F_ParamCode='FileUrlPath' ").FirstOrDefault();
211
+
212
+                int n = iu.Error;
213
+                if (n == 0)
214
+                {
215
+                    var obj = new
216
+                    {
217
+                        //ym = configfj != null ? configfj.F_ParamValue : "",
218
+                        imgurl = path + iu.OutFileName,
219
+                        smallimgurl = path + iu.OutThumbFileName
220
+                    };
221
+
222
+                    return Success("成功", obj);
223
+                }
224
+                else
225
+                {
226
+                    string msg = string.Empty;
227
+                    switch (n)
228
+                    {
229
+                        case 1: msg = "请选择要上传的文件"; break;
230
+                        case 2: msg = "上传的文件类型不支持"; break;
231
+                        case 3: msg = "上传的文件过大"; break;
232
+                        case 4: msg = "未知错误"; break;
233
+                    }
234
+                    return Error(msg);
235
+                }
236
+            }
237
+            else
238
+            {
239
+                return Error("请选择要上传的文件");
240
+            }
241
+
242
+        }
243
+
244
+
131 245
         public class HosArea
132 246
         {
133 247
             /// <summary>
134 248
             /// 院区id
135 249
             /// </summary>
136
-          public  int hosid { get; set; }
250
+            public int hosid { get; set; }
137 251
             /// <summary>
138 252
             /// 院区名称
139 253
             /// </summary>
140
-          public  string hosname { get; set; }
254
+            public string hosname { get; set; }
141 255
         }
142 256
 
143 257