jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
using System;
using System.Configuration;
using System.Web.Mvc;
using System.Web.Script.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using HH.AutoBom.Core;
using HH.WMS.WebUI;
using HH.WMS.WebUI.AppCode;
using HH.WMS.Common;
using HH.WMS.Entitys.Func;
using System.Collections.Generic;
using HH.WMS.Common.External;
 
namespace HH.WMS.WebUI.Controllers
{
    [MvcMenuFilter(false)]
    public class HomeController : BaseController
    {
        public ActionResult Index()
        {
            var loginer = FormsAuth.GetUserData<LoginerBase>();
            ViewBag.Title = HH.WMS.Common.Constants.appCode;//应用编码
            ViewBag.UserCode = loginer.UserCode; //用户登录名
            ViewBag.UserName = loginer.UserName; //用户真实名
            ViewBag.Settings = new sys_userService().GetDefaultUserSetttins();
            ViewBag.isDisplayTechnicalSupport = ProjectConfigs.isDisplayTechnicalSupport;
            ViewBag.isDisplaySystemIcon = ProjectConfigs.isDisplaySystemIcon;
            ViewBag.projectCode = Constants.SysConfig.PROJECT_CODE;
            return View();
        }
 
        public ActionResult Error()
        {
            return View();
        }
 
        public void Download()
        {
            Exporter.Instance().Download();
        }
 
        #region 修改密码页面
        /// <summary>
        /// 修改密码页面
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdatePwd()
        {
            return View();
        }
        #endregion
 
        #region 用户详情页
        /// <summary>
        /// 用户详情页
        /// </summary>
        /// <returns></returns>
        public ActionResult UserDetail()
        {
            return View();
        }
        #endregion
 
        #region 退出系统   清除redis和cookie
        /// <summary>
        /// 退出系统   清楚redis和cookie
        /// </summary>
        /// <param name="endType"></param>
        /// <returns></returns>
        public AccountEntity Exit(string endType)
        {
            AccountEntity acEntity = new AccountEntity();
            try
            {
                var loginer = FormsAuth.GetUserData<LoginerBase>();
                string appCode = Constants.appCode;
                string userName = loginer.UserCode;
                string flag = loginer.Flag;
 
                string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
 
                var entity = new
                {
                    userName = userName,
                    appCode = appCode,
                    flag = flag,
                    endType = endType,
                    ip = ip
                };
 
                string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
                string result = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/Account/CloseApp", jsonString);
 
                acEntity = Newtonsoft.Json.JsonConvert.DeserializeObject<AccountEntity>(result);
 
                //清除所有cookie
                for (int i = 0; i < Request.Cookies.Count; i++)
                {
                    Response.Cookies[Request.Cookies[i].Name].Expires = DateTime.Now.AddDays(-1);
                }
            }
            catch (Exception ex)
            {
                acEntity.Code = "1";
                acEntity.Data = ex.Message;
            }
            return acEntity;
        }
        #endregion
 
        #region 切换APP
        /// <summary>
        /// 切换APP
        /// </summary>
        /// <param name="after_appCode"></param>
        /// <returns></returns>
        public ActionResult ChangeApp(string after_appCode)
        {
            var loginer = FormsAuth.GetUserData<LoginerBase>();
            string front_appCode = Constants.appCode;
            string userName = loginer.UserCode;
            string old_flag = loginer.Flag;
 
            var entity = new
            {
                userName = userName,
                front_appCode = front_appCode,
                after_appCode = after_appCode,
                old_flag = old_flag
            };
            string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
            string result = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/Account/ChangeApp", jsonString);
            //清除所有cookie
            for (int i = 0; i < Request.Cookies.Count; i++)
            {
                Response.Cookies[Request.Cookies[i].Name].Expires = DateTime.Now.AddDays(-1);
            }
            return Content(result);
        }
        #endregion
 
        #region 静态脚本数据  获取文件服务器访问地址
        /// <summary>
        /// 静态脚本数据  获取文件服务器访问地址
        /// </summary>
        public JavaScriptResult FileServerData()
        {
            var webServiceURL = ConfigurationManager.AppSettings["FileServer"] != null ? ConfigurationManager.AppSettings["FileServer"].ToString() : "";
            var data = new
            {
                WebServiceURL = webServiceURL
            };
            var js = "var FileServerData = " + new JavaScriptSerializer().Serialize(data);
            return JavaScript(js);
        }
        #endregion
 
        #region 修改密码
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="oldPwd"></param>
        /// <param name="newPwd"></param>
        /// <param name="appCode"></param>
        /// <returns></returns>
        public ActionResult PwdEdit(string oldPwd, string newPwd)
        {
            var loginer = FormsAuth.GetUserData<LoginerBase>();
            string userName = loginer.UserCode;
            string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
            var entity = new
            {
                userName = userName,
                oldPwd = oldPwd,
                newPwd = newPwd,
                appCode = HH.WMS.Common.Constants.appCode,
                ip = ip
            };
            string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(entity);
            string result = HH.WMS.Common.WebApiManager.HttpAutoBom_Post("api/User/ChangePwd", jsonString);
            return Content(result);
        }
        #endregion
 
        public ActionResult UpdatePassword()
        {
            return View();
        }
 
        [HttpPost]
        public string UpdatePassword(string currentPwd, string newPwd)
        {
            var loginer = FormsAuth.GetUserData<LoginerBase>();
            string userName = loginer.UserCode;
            string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
            var sendData = new
            {
                userName = userName,
                oldPwd = currentPwd,
                newPwd = newPwd,
                appCode = Constants.appCode,
                ip = ip
            };
            string result = HttpAutobom_Post("api/User/ChangePwd", JsonConvert.SerializeObject(sendData));
            return result;
        }
 
        public ActionResult Main()
        {
            return View();
        }
        public ActionResult GetBussLine(int day)
        {
            string result = HttpWMS_Get("api/Inventory/GetBussLine?day=" + day);
            return Content(result);
        }
 
        public string GetLocationState()
        {
            //todo
            //根据用户获取仓库
            string result = HttpWMS_Get("api/LocationExt/GetLocationState?stockCode=");
            return result;
        }
 
        public string GetVersionLog()
        {
            string result = HttpWMS_Get("api/Inventory/GetVersionLog");
            return result;
        }
    }
}