Skip to content

Commit 65fc872

Browse files
committed
Merge branch 'dev'
* Notice,News * CampusCard * Libiary
2 parents 72eaa68 + 3dd80b2 commit 65fc872

20 files changed

+1544
-18
lines changed

CampusCard.asmx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%@ WebService Language="C#" CodeBehind="CampusCard.asmx.cs" Class="SnnuWebService.CampusCard" %>

CampusCard.asmx.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Services;
6+
7+
namespace SnnuWebService
8+
{
9+
/// <summary>
10+
/// CampusCard 的摘要说明
11+
/// </summary>
12+
[WebService(Namespace = "http://webxml.zhaoqi.vip/")]
13+
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
14+
[System.ComponentModel.ToolboxItem(false)]
15+
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
16+
// [System.Web.Script.Services.ScriptService]
17+
public class CampusCard : System.Web.Services.WebService
18+
{
19+
20+
SpiderCard spider = new SpiderCard();
21+
[WebMethod(Description =
22+
"查询校园卡余额")]
23+
public double getBalance(string id)
24+
{
25+
double ret = 0;
26+
spider.Search(id);
27+
if (spider.BeingUsed())
28+
ret = Convert.ToDouble(spider.getBalance());
29+
else
30+
ret = -1;
31+
return ret;
32+
}
33+
[WebMethod(Description =
34+
"查询最近一周的消费明细")]
35+
public Model.CardItem[] getConsumptionDdetails(string id)
36+
{
37+
List<Model.CardItem> ret = new List<Model.CardItem>();
38+
List<Dictionary<string, string>> ListDic = new List<Dictionary<string, string>>();
39+
spider.Search(id);
40+
if (spider.BeingUsed())
41+
{
42+
ListDic = spider.ConsumptionDetails();
43+
}
44+
foreach (Dictionary<string, string> dic in ListDic)
45+
{
46+
Model.CardItem t = new Model.CardItem();
47+
t.Balance = Convert.ToDouble(dic["卡余额"].ToString());
48+
t.Date = DateTime.Parse(dic["时间"].ToString());
49+
t.Id = dic["卡号"].ToString();
50+
t.Frequency = Convert.ToInt32(dic["次数"].ToString());
51+
t.OrigiAmount = Convert.ToDouble(dic["原金额"].ToString());
52+
t.TransAmount = Convert.ToDouble(dic["交易额"].ToString());
53+
t.Location = dic["记录信息"].ToString();
54+
ret.Add(t);
55+
}
56+
return ret.ToArray();
57+
}
58+
[WebMethod(Description =
59+
"查询最后一次消费时间")]
60+
public DateTime getLastConsumptionTime(string id)
61+
{
62+
DateTime ret = DateTime.MinValue;
63+
spider.Search(id);
64+
if (spider.BeingUsed())
65+
ret = DateTime.Parse(spider.getLastConsumptionTime());
66+
return ret;
67+
}
68+
}
69+
}

DAL/Message.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using MySql.Data.MySqlClient;
2+
using System;
3+
using System.Configuration;
4+
using System.Text;
5+
using System.Data;
6+
7+
namespace SnnuWebService.DAL
8+
{
9+
public class Message
10+
{
11+
private string Conn
12+
=ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
13+
14+
public MySqlDataReader AllDep()
15+
{
16+
StringBuilder strSql = new StringBuilder();
17+
strSql.Append("select distinct Department from Message");
18+
return SqlHelper.ExecuteReader(Conn,CommandType.Text, strSql.ToString());
19+
}
20+
21+
public MySqlDataReader QueryByDate(DateTime start,DateTime end,string type)
22+
{
23+
StringBuilder strSql = new StringBuilder();
24+
strSql.Append("select * from Message");
25+
strSql.Append(" where Type='" + type + "' ");
26+
strSql.Append("and Date between '"+start.ToString("yyyy-MM-dd") +"' and '");
27+
strSql.Append(end.ToString("yyyy-MM-dd") + "'");
28+
return SqlHelper.ExecuteReader(Conn,CommandType.Text, strSql.ToString());
29+
}
30+
public MySqlDataReader QueryByDateAndDep(DateTime start, DateTime end, string dep,string type)
31+
{
32+
StringBuilder strSql = new StringBuilder();
33+
strSql.Append("select * from Message");
34+
strSql.Append(" where Type='" + type + "' ");
35+
strSql.Append("and " + "Department='" + dep + "' ");
36+
strSql.Append("and Date between '" + start.ToString("yyyy-MM-dd") + "' and '");
37+
strSql.Append(end.ToString("yyyy-MM-dd") + "'");
38+
return SqlHelper.ExecuteReader(Conn, CommandType.Text, strSql.ToString());
39+
}
40+
public MySqlDataReader QueryByLikeTitle(string keyworld,string type)
41+
{
42+
StringBuilder strSql = new StringBuilder();
43+
strSql.Append("select * from Message");
44+
strSql.Append(" where Type='" + type + "' ");
45+
strSql.Append("and title like '%" + keyworld + "%'");
46+
return SqlHelper.ExecuteReader(Conn, CommandType.Text, strSql.ToString());
47+
}
48+
public MySqlDataReader QueryByDepartment(string dep,string type)
49+
{
50+
DateTime d = DateTime.Now;
51+
DateTime start = d.AddDays(-7);
52+
DateTime end = d.AddDays(7);
53+
return QueryByDateAndDep(start, end, dep, type);
54+
}
55+
}
56+
}

Libiary.asmx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%@ WebService Language="C#" CodeBehind="Libiary.asmx.cs" Class="SnnuWebService.Libiary" %>

Libiary.asmx.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
using System.Web.Services;
6+
7+
namespace SnnuWebService
8+
{
9+
/// <summary>
10+
/// Libiary 的摘要说明
11+
/// </summary>
12+
[WebService(Namespace = "http://webxml.zhaoqi.vip/")]
13+
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
14+
[System.ComponentModel.ToolboxItem(false)]
15+
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
16+
// [System.Web.Script.Services.ScriptService]
17+
public class Libiary : System.Web.Services.WebService
18+
{
19+
Order spider = new Order();
20+
[WebMethod(Description =
21+
"获取图书预约到馆信息")]
22+
public Model.LibiaryItem[] GetBookBorrowInfo()
23+
{
24+
List<Model.LibiaryItem> ret = new List<Model.LibiaryItem>();
25+
List<Dictionary<string, string>> ListDic = new List<Dictionary<string, string>>();
26+
spider.Url = spider.GetSpiderUrl();
27+
spider.Search();
28+
ListDic = spider.GetList();
29+
foreach (Dictionary<string, string> dic in ListDic)
30+
{
31+
Model.LibiaryItem t = new Model.LibiaryItem();
32+
t.Name = dic["预约者"].ToString();
33+
t.Author = dic["著者"].ToString();
34+
t.Location = dic["取书地点"].ToString();
35+
t.Branch = dic["单册分馆"].ToString();
36+
t.Book = dic["书名"].ToString();
37+
t.Deadline = DateTime.Parse(dic["保留结束日期"].ToString());
38+
ret.Add(t);
39+
}
40+
return ret.ToArray();
41+
}
42+
}
43+
}

Model/CardItem.cs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
6+
namespace SnnuWebService.Model
7+
{
8+
public class CardItem
9+
{
10+
private string id;
11+
private DateTime date = DateTime.MinValue;
12+
private int frequency;
13+
private double origiAmount;
14+
private double transAmount;
15+
private double balance;
16+
private string location = string.Empty;
17+
18+
public string Id
19+
{
20+
get
21+
{
22+
return id;
23+
}
24+
25+
set
26+
{
27+
id = value;
28+
}
29+
}
30+
31+
public DateTime Date
32+
{
33+
get
34+
{
35+
return date;
36+
}
37+
38+
set
39+
{
40+
date = value;
41+
}
42+
}
43+
44+
public int Frequency
45+
{
46+
get
47+
{
48+
return frequency;
49+
}
50+
51+
set
52+
{
53+
frequency = value;
54+
}
55+
}
56+
57+
public double OrigiAmount
58+
{
59+
get
60+
{
61+
return origiAmount;
62+
}
63+
64+
set
65+
{
66+
origiAmount = value;
67+
}
68+
}
69+
70+
public double TransAmount
71+
{
72+
get
73+
{
74+
return transAmount;
75+
}
76+
77+
set
78+
{
79+
transAmount = value;
80+
}
81+
}
82+
83+
public double Balance
84+
{
85+
get
86+
{
87+
return balance;
88+
}
89+
90+
set
91+
{
92+
balance = value;
93+
}
94+
}
95+
96+
public string Location
97+
{
98+
get
99+
{
100+
return location;
101+
}
102+
103+
set
104+
{
105+
location = value;
106+
}
107+
}
108+
}
109+
}

Model/LibiaryItem.cs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Web;
5+
6+
namespace SnnuWebService.Model
7+
{
8+
public class LibiaryItem
9+
{
10+
private string name;
11+
private string book;
12+
private string author;
13+
private DateTime deadline=DateTime.MinValue;
14+
private string branch;
15+
private string location;
16+
17+
public string Name
18+
{
19+
get
20+
{
21+
return name;
22+
}
23+
24+
set
25+
{
26+
name = value;
27+
}
28+
}
29+
30+
public string Book
31+
{
32+
get
33+
{
34+
return book;
35+
}
36+
37+
set
38+
{
39+
book = value;
40+
}
41+
}
42+
43+
public string Author
44+
{
45+
get
46+
{
47+
return author;
48+
}
49+
50+
set
51+
{
52+
author = value;
53+
}
54+
}
55+
56+
public DateTime Deadline
57+
{
58+
get
59+
{
60+
return deadline;
61+
}
62+
63+
set
64+
{
65+
deadline = value;
66+
}
67+
}
68+
69+
public string Branch
70+
{
71+
get
72+
{
73+
return branch;
74+
}
75+
76+
set
77+
{
78+
branch = value;
79+
}
80+
}
81+
82+
public string Location
83+
{
84+
get
85+
{
86+
return location;
87+
}
88+
89+
set
90+
{
91+
location = value;
92+
}
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)