|
|
@@ -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
|
|