-
Notifications
You must be signed in to change notification settings - Fork 0
/
Notice.asmx.cs
118 lines (116 loc) · 4.61 KB
/
Notice.asmx.cs
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
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Web.Services;
namespace SnnuWebService
{
/// <summary>
/// Notice 的摘要说明
/// </summary>
[WebService(Namespace = "http://webxml.zhaoqi.vip/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
// [System.Web.Script.Services.ScriptService]
public class Notice : System.Web.Services.WebService
{
private DAL.Message dal = new DAL.Message();
[WebMethod(Description =
"所支持查询的部门")]
public string [] getSupportDep()
{
List<string> ret = new List<string>();
MySqlDataReader reader = dal.AllDep();
while(reader.Read())
{
ret.Add(reader.GetValue(0).ToString());
}
reader.Close();
return ret.ToArray();
}
[WebMethod(Description =
"查询某个部门最近两周内的通知")]
public Model.Message[]getNoticeByDepartment(string dep)
{
List<Model.Message> ret = new List<Model.Message>();
MySqlDataReader reader = dal.QueryByDepartment(dep,"通知");
while (reader.Read())
{
Model.Message temp = new Model.Message();
temp.Department = reader["Department"].ToString();
temp.Title = reader["Title"].ToString();
temp.Link = reader["Link"].ToString();
temp.Type = "通知";
temp.Date = DateTime.Parse(reader["Date"].ToString());
ret.Add(temp);
}
return ret.ToArray();
}
[WebMethod(Description =
"查询以某个日期为准前后一周的通知")]
public Model.Message[]getNoticeByDate(string date)
{
List<Model.Message> ret = new List<Model.Message>();
DateTime d;
bool flag=DateTime.TryParse(date, out d);
if (flag == false)
return null;
DateTime start = d.AddDays(-7);
DateTime end = d.AddDays(7);
MySqlDataReader reader = dal.QueryByDate(start, end, "通知");
while (reader.Read())
{
Model.Message temp = new Model.Message();
temp.Department = reader["Department"].ToString();
temp.Title = reader["Title"].ToString();
temp.Link = reader["Link"].ToString();
temp.Type = "通知";
temp.Date = DateTime.Parse(reader["Date"].ToString());
ret.Add(temp);
}
return ret.ToArray();
}
[WebMethod(Description =
"查询某个部门的某个日期前后一周的通知")]
public Model.Message[]getNoticeByDepartmentAndDate(string dep,string date)
{
List<Model.Message> ret = new List<Model.Message>();
DateTime d;
bool flag = DateTime.TryParse(date, out d);
if (flag == false)
return null;
DateTime start = d.AddDays(-7);
DateTime end = d.AddDays(7);
MySqlDataReader reader = dal.QueryByDateAndDep(start, end, dep,"通知");
while (reader.Read())
{
Model.Message temp = new Model.Message();
temp.Department = reader["Department"].ToString();
temp.Title = reader["Title"].ToString();
temp.Link = reader["Link"].ToString();
temp.Type = "通知";
temp.Date = DateTime.Parse(reader["Date"].ToString());
ret.Add(temp);
}
return ret.ToArray();
}
[WebMethod(Description =
"通过标题查询通知(模糊查询)")]
public Model.Message[]getNoticeByLikeTitle(string keyword)
{
List<Model.Message> ret = new List<Model.Message>();
MySqlDataReader reader = dal.QueryByLikeTitle(keyword, "通知");
while(reader.Read())
{
Model.Message temp = new Model.Message();
temp.Department = reader["Department"].ToString();
temp.Title = reader["Title"].ToString();
temp.Link = reader["Link"].ToString();
temp.Type = "通知";
temp.Date = DateTime.Parse(reader["Date"].ToString());
ret.Add(temp);
}
return ret.ToArray();
}
}
}