duhongyu лет назад: 5
Родитель
Сommit
f8edb2c568

+ 255 - 5
codegit/CallCenterApi/CallCenterApi.Interface/CallCenterApi.Interface/Controllers/Rotation/RotationController.cs

@@ -1,17 +1,267 @@
1
-using System;
1
+using CallCenter.Utility;
2
+using CallCenterApi.Interface.Controllers.Base;
3
+using System;
2 4
 using System.Collections.Generic;
5
+using System.Data;
6
+using System.IO;
3 7
 using System.Linq;
8
+using System.Reflection;
4 9
 using System.Web;
5 10
 using System.Web.Mvc;
6 11
 
7 12
 namespace CallCenterApi.Interface.Controllers.Rotation
8 13
 {
9
-    public class RotationController : Controller
14
+    public class RotationController : BaseController
10 15
     {
11
-        // GET: Rotation
12
-        public ActionResult Index()
16
+        BLL.Rotation bll = new BLL.Rotation();
17
+        /// <summary>
18
+        /// 上传用户图片
19
+        /// </summary>
20
+        /// <returns></returns>
21
+        public ActionResult UploadTX()
13 22
         {
14
-            return View();
23
+
24
+            Model.Rotation rotation = new Model.Rotation();
25
+
26
+            HttpPostedFile _upFile = RequestString.GetFile("upFile");
27
+            string filepath = "";
28
+
29
+            string path = string.Empty;
30
+
31
+            if (_upFile != null)
32
+            {
33
+                string datepath = DateTime.Now.ToString("yyyyMMddHHMMss");
34
+                string aLastName = _upFile.FileName.Substring(_upFile.FileName.LastIndexOf(".") + 1, (_upFile.FileName.Length - _upFile.FileName.LastIndexOf(".") - 1)); //扩展名
35
+
36
+                ///保存的名称
37
+                string newpath = _upFile.FileName;// datepath + "_" +
38
+                if (!Directory.Exists(Server.MapPath(this.Request.ApplicationPath + "\\Upload\\Rotation")))
39
+                {
40
+                    Directory.CreateDirectory(Server.MapPath(this.Request.ApplicationPath + "\\Upload\\Rotation"));
41
+                }
42
+                filepath = this.Request.ApplicationPath + "/Upload/Rotation/" + newpath;
43
+                string PhysicalPath = Server.MapPath(filepath);
44
+                _upFile.SaveAs(PhysicalPath);
45
+
46
+
47
+                path = "/Upload/Rotation/" + _upFile.FileName;
48
+                rotation.romath = path;
49
+                rotation.roname = _upFile.FileName;
50
+                rotation.uploaddate = DateTime.Now;
51
+                rotation.uploadpeo = CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;
52
+                rotation.isEnable = 0;                          //添加导数据库
53
+
54
+                if (bll.Add(rotation) > 0)
55
+                    return Success("成功");
56
+                else
57
+                    return Error("添加失败");
58
+            }
59
+            else
60
+            {
61
+                return Error("请选择要上传的文件");
62
+            }
63
+
64
+            #region 仅上传图片 不用
65
+            //string dataurl = HttpUtility.UrlDecode(RequestString.GetFormString("upFile"));
66
+            //if (!string.IsNullOrEmpty(dataurl))
67
+            //{
68
+            //    path = "/Upload/Rotation/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + DateTime.Now.ToString("dd") + "/";
69
+
70
+            //    ImageUpload iu = new ImageUpload();
71
+            //    iu.SavePath = path;
72
+            //    iu.DataUrl = dataurl;
73
+            //    iu.Upload64();
74
+            //    int n = iu.Error;
75
+            //    if (n == 0)
76
+            //    {
77
+
78
+            //        path = "/Upload/Rotation/" + iu.OutFileName;
79
+            //        rotation.romath = path;
80
+            //        rotation.roname = iu.OutFileName;
81
+            //        rotation.uploaddate = DateTime.Now;
82
+            //        rotation.uploadpeo = CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;// CurrentUser.UserData.F_UserCode;
83
+            //        rotation.isEnable = 0;                          //添加导数据库
84
+
85
+            //        if (bll.Add(rotation) > 0)
86
+            //            return Success("成功");
87
+            //        else
88
+            //            return Error("添加失败");
89
+            //    }
90
+            //    else
91
+            //    {
92
+            //        string msg = string.Empty;
93
+            //        switch (n)
94
+            //        {
95
+            //            case 1: msg = "请选择要上传的文件"; break;
96
+            //            case 2: msg = "上传的文件类型不支持"; break;
97
+            //            case 3: msg = "上传的文件过大"; break;
98
+            //            case 4: msg = "未知错误"; break;
99
+            //        }
100
+            //       return  Error(msg);
101
+            //    }
102
+            //}
103
+            //else
104
+            //{
105
+            //    return  Error("请选择要上传的文件");
106
+            //} 
107
+            #endregion
108
+
109
+
110
+
111
+        }
112
+        /// <summary>
113
+        /// 获取图片数据
114
+        /// </summary>
115
+        /// <returns></returns>
116
+        public ActionResult Getlist(int PageIndex, int PageSize, string name)
117
+        {
118
+
119
+            if (PageIndex == 0)
120
+            {
121
+                PageIndex = 1;
122
+            }
123
+            if (PageSize == 0)
124
+            {
125
+                PageSize = 10;
126
+            }
127
+            var sql = "";
128
+            ///按名称模糊查询
129
+            if (name != null)
130
+            {
131
+                if (name != "")
132
+                {
133
+                    sql += "  and roname like '%" + name + "%' ";
134
+                }
135
+
136
+            }
137
+            var recordCount = 0;
138
+            var dt = BLL.PagerBLL.GetListPager(
139
+                "Rotation",
140
+                "Rotation.id",
141
+                "*",
142
+                sql,
143
+                "ORDER BY Rotation.id desc ",
144
+                PageSize,
145
+                PageIndex,
146
+                true,
147
+                out recordCount);
148
+
149
+
150
+            List<Model.Rotation> modelList = new BLL.Rotation().DataTableToList(dt);
151
+            var list = new List<Model.Rotation>();
152
+            foreach (var item in modelList)
153
+            {
154
+                list.Add(new Model.Rotation
155
+                {
156
+                    id = item.id,
157
+                    roname = item.roname,
158
+                    romath = " http://oa.shuanghui.net:8046/" + item.romath,//"http://192.168.8.9:1001" + item.romath,
159
+                    uploadpeo = item.uploadpeo,
160
+                    uploaddate = item.uploaddate,
161
+                    isEnable = item.isEnable
162
+                });
163
+            }
164
+            #region 没分页的
165
+            //List<Model.Rotation> modelList = new List<Model.Rotation>();
166
+
167
+            //DataTable dt = new DataTable();
168
+            //dt = bll.GetList(name).Tables[0];
169
+
170
+            //int rowsCount = dt.Rows.Count;
171
+            //if (rowsCount > 0)
172
+            //{
173
+            //    Model.Rotation model;
174
+            //    for (int n = 0; n < rowsCount; n++)
175
+            //    {
176
+            //        model = DataRowToModelRotation(dt.Rows[n]);
177
+            //        if (model != null)
178
+            //        {
179
+
180
+            //            model.romath = "http://192.168.8.9:1001" + model.romath;
181
+            //            modelList.Add(model);
182
+            //        }
183
+            //    }
184
+            //} 
185
+            #endregion
186
+
187
+            var obj = new
188
+            {
189
+                modelList = list,
190
+                total = recordCount
191
+            };
192
+
193
+
194
+            return Success("加载成功", obj);
195
+        }
196
+        /// <summary>
197
+        /// 禁用图片
198
+        /// </summary>
199
+        /// <param name="id"></param>
200
+        /// <returns></returns>
201
+        public ActionResult Deldter(string ids)
202
+        {
203
+            if (bll.delrotation(ids))
204
+            {
205
+                return Success("禁用成功" + ",操作人:" + CurrentUser.UserData.F_UserCode);
206
+            }
207
+            else
208
+            {
209
+                return Error("禁用失败!" + ",操作人:" + CurrentUser.UserData.F_UserCode);
210
+            }
211
+        }
212
+        /// <summary>
213
+        /// 启用图片
214
+        /// </summary>
215
+        /// <param name="ids"></param>
216
+        /// <returns></returns>
217
+        public ActionResult poenRotion(string ids)
218
+        {
219
+            if (bll.poenRotion(ids))
220
+            {
221
+                return Success("启用成功" + ",操作人:" + CurrentUser.UserData.F_UserCode);
222
+            }
223
+            else
224
+            {
225
+                return Error("启用失败!" + ",操作人:" + CurrentUser.UserData.F_UserCode);
226
+            }
227
+        }
228
+
229
+        /// <summary>
230
+        /// 删除图片
231
+        /// </summary>
232
+        /// <param name="ids"></param>
233
+        /// <returns></returns>
234
+        public ActionResult SCRotion(string ids)
235
+        {
236
+            if (bll.SCRotion(ids))
237
+            {
238
+                return Success("删除成功" + ",操作人:" + CurrentUser.UserData.F_UserCode);
239
+            }
240
+            else
241
+            {
242
+                return Error("删除失败!" + ",操作人:" + CurrentUser.UserData.F_UserCode);
243
+            }
244
+        }
245
+        public Model.Rotation DataRowToModelRotation(DataRow row)
246
+        {
247
+            Model.Rotation model = new Model.Rotation();//主表字段
248
+            if (row != null)
249
+            {
250
+                #region 主表信息======================
251
+                //利用反射获得属性的所有公共属性
252
+                Type modelType = model.GetType();
253
+                for (int i = 0; i < row.Table.Columns.Count; i++)
254
+                {
255
+                    PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName);
256
+                    if (proInfo != null && row[i] != DBNull.Value)
257
+                    {
258
+                        //用索引值设置属性值
259
+                        proInfo.SetValue(model, row[i], null);
260
+                    }
261
+                }
262
+                #endregion
263
+            }
264
+            return model;
15 265
         }
16 266
     }
17 267
 }