UserBll.cs
9.79 KB
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using Quiz.DAL;
using Quiz.Models;
namespace Quiz.BLL
{
public class UserBll
{
public static int IsAnswer(string iphone)
{
return DAL.User.IsAnswer(iphone);
}
public static List<Models.User> GetUsers()
{
return DAL.User.GetUsers();
}
public static bool AddUserAnswer(Models.UserAnswer model)
{
return DAL.User.AddUserAnswer(model);
}
public static List<Models.Topic> GetTopics()
{
return DAL.User.GetTopics();
}
public static List<Models.School> GetSchools()
{
return DAL.User.GetSchools();
}
public static UserAnswer GetUserAnswerOne(string phone)
{
return DAL.User.GetUserAnswerOne(phone);
}
public static bool ExamineSendMsg(string code, string mobile)
{
return DAL.User.ExamineSendMsg(code, mobile);
}
//数据解析
public static List<UserAnswer> GetAnswers()
{
return DAL.User.GetAnswers();
}
public static List<UserAnswer> GetAnswerskq()
{
return DAL.User.GetAnswerskq();
}
public static List<Models.Topic> GetTopicskq()
{
return DAL.User.GetTopicskq();
}
public static List<Models.User> GetUserskq()
{
return DAL.User.GetUserskq();
}
public static List<UserAnswer> GetAnswersyc()
{
return DAL.User.GetAnswersyc();
}
public static List<UserAnswer> getschoolMB()
{
return DAL.User.getschoolMB();
}
public static List<Models.Topic> GetTopicsyc()
{
return DAL.User.GetTopicsyc();
}
public static List<Models.User> GetUsersyc()
{
return DAL.User.GetUsersyc();
}
public static List<Models.User> GetUsersycTwo() {
return DAL.User.GetUsersycTwo();
}
public static DataKanbans getDataKanbanlist()
{
DataKanbans resetlist = new DataKanbans();
var schooltypelist = DAL.User.GetSchoolList();
var scholcount = DAL.User.getschoolcountT();
var rtypelist = DAL.User.getschooltypeRecoveryList();
var rlist = DAL.User.getschoolRecoveryList();
var schoolList = DAL.User.GetSchoolNameList();
///总人数分步
if (schooltypelist != null && schooltypelist.Count > 0)
{
resetlist.TotalSchoolCount = new List<schoolTypeM>();
resetlist.TotalSchoolCount = scholcount;
}
//调查人数分部
if (rtypelist != null && rtypelist.Count > 0)
{
resetlist.SchoolTypesList = new List<schoolTypeM>();
resetlist.SchoolTypesList = rtypelist;
}
//今日
if (schoolList != null && schoolList.Count > 0)
{
decimal dayCount = 0;
decimal RdayCount = 0;
int isok = 0;
List<schoolRecovery> daySchoolR = new List<schoolRecovery>();
if (rlist != null && rlist.Count > 0)
{
daySchoolR = rlist.FindAll(o => o.Intime == DateTime.Now.ToString("yyyy-MM-dd"));
if (daySchoolR != null && daySchoolR.Count > 0) isok = 1;
}
resetlist.SchoolDayCount = new List<schoolRecovery>();
foreach (var item in schoolList)
{
schoolRecovery schoolday = new schoolRecovery();
schoolday.schoolName = item.schoolName;
dayCount = dayCount + item.schoolcount;
if (isok == 1)
{
var get = daySchoolR.Find(o => o.schoolName == item.schoolName);
if (get != null && !string.IsNullOrEmpty(get.schoolName))
{
schoolday.RecoveryCount = get.RecoveryCount;
decimal rcount = get.RecoveryCount / item.schoolcount;
schoolday.Recovery = decimal.Parse(rcount.ToString("#0.00")) * 100;
RdayCount = RdayCount + get.RecoveryCount;
}
else
{
schoolday.schoolcount = 0;
schoolday.Recovery = 0;
}
}
else
{
schoolday.schoolcount = 0;
schoolday.Recovery = 0;
}
resetlist.SchoolDayCount.Add(schoolday);
}
resetlist.dayRCount = RdayCount;
decimal dayR = RdayCount / dayCount;
resetlist.dayRecovery = decimal.Parse(dayR.ToString("#0.00")) * 100;
}
//累计
if (schoolList != null && schoolList.Count > 0)
{
resetlist.SchoolCount = new List<schoolRecovery>();
decimal TotalCount = 0;
decimal RTotalcount = 0;
int isok = 0;
if (rlist != null && rlist.Count > 0) isok = 1;
foreach (var item in schoolList)
{
schoolRecovery schoolday = new schoolRecovery();
TotalCount = TotalCount + item.schoolcount;
schoolday.schoolName = item.schoolName;
if (isok == 1)
{
var get = rlist.Find(o => o.schoolName == item.schoolName);
if (get != null && !string.IsNullOrEmpty(get.schoolName))
{
schoolday.RecoveryCount = int.Parse(get.RecoveryCount.ToString());
decimal rcount = get.RecoveryCount / item.schoolcount;
schoolday.Recovery = decimal.Parse(rcount.ToString("#0.00")) * 100;
RTotalcount = RTotalcount + int.Parse(get.RecoveryCount.ToString());
}
else
{
schoolday.RecoveryCount = 0;
schoolday.Recovery = 0;
}
}
else
{
schoolday.RecoveryCount = 0;
schoolday.Recovery = 0;
}
resetlist.SchoolCount.Add(schoolday);
}
resetlist.TotalRCount = RTotalcount;
decimal totalR = RTotalcount / TotalCount;
resetlist.TotalRecovery = decimal.Parse(totalR.ToString("#0.00")) * 100;
// resetlist.TotalRecovery = decimal.Parse(dayR.ToString("#0.00")) * 100;
resetlist.TotalCount = TotalCount;
}
return resetlist;
}
public static resetModel yanzheng(string mobile)
{
resetModel m = new resetModel();
var get = DAL.User.getIsKanuser(mobile);
if (get != null && !string.IsNullOrEmpty(get.PhoneName))
{
//生成4位随机码
Random rad = new Random();//实例化随机数产生器rad;
int code = rad.Next(1000, 10000);//用rad生成大于等于1000,小于等于9999的随机数;
List<string> Mymobile = new List<string>();
Mymobile.Add(mobile);
string cons = string.Format("【满意度调查】您正在参与的教育调查4位验证码为:{0}", code);
var ss = new sendDC()
{
Content = cons,
Mobile = Mymobile
};
string postData = Newtonsoft.Json.JsonConvert.SerializeObject(ss);
string result = PostUrl("http://campus.myjxt.com/api/Common/ExamineSendMsg", postData);
resetModel reset = Newtonsoft.Json.JsonConvert.DeserializeObject<resetModel>(result);
Utility.Helper.SaveLog(string.Format("status={0}&code={1}&mobile={2}", reset.status, code, mobile), "mobilecode");
if (reset.status == 1)
{
m.status = 1;
m.data = code;
}
else
{
m.message = reset.message;
}
}
else {
m.status = 0;
m.message = "您暂无权限观看看板数据!";
}
return m;
}
public static string PostUrl(string url, string postData)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
//req.TimeOut = "800";//设置请求超时时间,单位为毫秒
req.ContentType = "application/json";
byte[] data = Encoding.UTF8.GetBytes(postData);
req.ContentLength = data.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
//获取响应内容
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
return result;
}
}
}