Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
* Notice,News
* CampusCard
* Libiary
  • Loading branch information
ZhaoQi99 committed Nov 14, 2018
2 parents 72eaa68 + 3dd80b2 commit 65fc872
Show file tree
Hide file tree
Showing 20 changed files with 1,544 additions and 18 deletions.
1 change: 1 addition & 0 deletions CampusCard.asmx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%@ WebService Language="C#" CodeBehind="CampusCard.asmx.cs" Class="SnnuWebService.CampusCard" %>
69 changes: 69 additions & 0 deletions CampusCard.asmx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace SnnuWebService
{
/// <summary>
/// CampusCard 的摘要说明
/// </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 CampusCard : System.Web.Services.WebService
{

SpiderCard spider = new SpiderCard();
[WebMethod(Description =
"查询校园卡余额")]
public double getBalance(string id)
{
double ret = 0;
spider.Search(id);
if (spider.BeingUsed())
ret = Convert.ToDouble(spider.getBalance());
else
ret = -1;
return ret;
}
[WebMethod(Description =
"查询最近一周的消费明细")]
public Model.CardItem[] getConsumptionDdetails(string id)
{
List<Model.CardItem> ret = new List<Model.CardItem>();
List<Dictionary<string, string>> ListDic = new List<Dictionary<string, string>>();
spider.Search(id);
if (spider.BeingUsed())
{
ListDic = spider.ConsumptionDetails();
}
foreach (Dictionary<string, string> dic in ListDic)
{
Model.CardItem t = new Model.CardItem();
t.Balance = Convert.ToDouble(dic["卡余额"].ToString());
t.Date = DateTime.Parse(dic["时间"].ToString());
t.Id = dic["卡号"].ToString();
t.Frequency = Convert.ToInt32(dic["次数"].ToString());
t.OrigiAmount = Convert.ToDouble(dic["原金额"].ToString());
t.TransAmount = Convert.ToDouble(dic["交易额"].ToString());
t.Location = dic["记录信息"].ToString();
ret.Add(t);
}
return ret.ToArray();
}
[WebMethod(Description =
"查询最后一次消费时间")]
public DateTime getLastConsumptionTime(string id)
{
DateTime ret = DateTime.MinValue;
spider.Search(id);
if (spider.BeingUsed())
ret = DateTime.Parse(spider.getLastConsumptionTime());
return ret;
}
}
}
56 changes: 56 additions & 0 deletions DAL/Message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using MySql.Data.MySqlClient;
using System;
using System.Configuration;
using System.Text;
using System.Data;

namespace SnnuWebService.DAL
{
public class Message
{
private string Conn
=ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;

public MySqlDataReader AllDep()
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select distinct Department from Message");
return SqlHelper.ExecuteReader(Conn,CommandType.Text, strSql.ToString());
}

public MySqlDataReader QueryByDate(DateTime start,DateTime end,string type)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from Message");
strSql.Append(" where Type='" + type + "' ");
strSql.Append("and Date between '"+start.ToString("yyyy-MM-dd") +"' and '");
strSql.Append(end.ToString("yyyy-MM-dd") + "'");
return SqlHelper.ExecuteReader(Conn,CommandType.Text, strSql.ToString());
}
public MySqlDataReader QueryByDateAndDep(DateTime start, DateTime end, string dep,string type)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from Message");
strSql.Append(" where Type='" + type + "' ");
strSql.Append("and " + "Department='" + dep + "' ");
strSql.Append("and Date between '" + start.ToString("yyyy-MM-dd") + "' and '");
strSql.Append(end.ToString("yyyy-MM-dd") + "'");
return SqlHelper.ExecuteReader(Conn, CommandType.Text, strSql.ToString());
}
public MySqlDataReader QueryByLikeTitle(string keyworld,string type)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * from Message");
strSql.Append(" where Type='" + type + "' ");
strSql.Append("and title like '%" + keyworld + "%'");
return SqlHelper.ExecuteReader(Conn, CommandType.Text, strSql.ToString());
}
public MySqlDataReader QueryByDepartment(string dep,string type)
{
DateTime d = DateTime.Now;
DateTime start = d.AddDays(-7);
DateTime end = d.AddDays(7);
return QueryByDateAndDep(start, end, dep, type);
}
}
}
1 change: 1 addition & 0 deletions Libiary.asmx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%@ WebService Language="C#" CodeBehind="Libiary.asmx.cs" Class="SnnuWebService.Libiary" %>
43 changes: 43 additions & 0 deletions Libiary.asmx.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace SnnuWebService
{
/// <summary>
/// Libiary 的摘要说明
/// </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 Libiary : System.Web.Services.WebService
{
Order spider = new Order();
[WebMethod(Description =
"获取图书预约到馆信息")]
public Model.LibiaryItem[] GetBookBorrowInfo()
{
List<Model.LibiaryItem> ret = new List<Model.LibiaryItem>();
List<Dictionary<string, string>> ListDic = new List<Dictionary<string, string>>();
spider.Url = spider.GetSpiderUrl();
spider.Search();
ListDic = spider.GetList();
foreach (Dictionary<string, string> dic in ListDic)
{
Model.LibiaryItem t = new Model.LibiaryItem();
t.Name = dic["预约者"].ToString();
t.Author = dic["著者"].ToString();
t.Location = dic["取书地点"].ToString();
t.Branch = dic["单册分馆"].ToString();
t.Book = dic["书名"].ToString();
t.Deadline = DateTime.Parse(dic["保留结束日期"].ToString());
ret.Add(t);
}
return ret.ToArray();
}
}
}
109 changes: 109 additions & 0 deletions Model/CardItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SnnuWebService.Model
{
public class CardItem
{
private string id;
private DateTime date = DateTime.MinValue;
private int frequency;
private double origiAmount;
private double transAmount;
private double balance;
private string location = string.Empty;

public string Id
{
get
{
return id;
}

set
{
id = value;
}
}

public DateTime Date
{
get
{
return date;
}

set
{
date = value;
}
}

public int Frequency
{
get
{
return frequency;
}

set
{
frequency = value;
}
}

public double OrigiAmount
{
get
{
return origiAmount;
}

set
{
origiAmount = value;
}
}

public double TransAmount
{
get
{
return transAmount;
}

set
{
transAmount = value;
}
}

public double Balance
{
get
{
return balance;
}

set
{
balance = value;
}
}

public string Location
{
get
{
return location;
}

set
{
location = value;
}
}
}
}
95 changes: 95 additions & 0 deletions Model/LibiaryItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SnnuWebService.Model
{
public class LibiaryItem
{
private string name;
private string book;
private string author;
private DateTime deadline=DateTime.MinValue;
private string branch;
private string location;

public string Name
{
get
{
return name;
}

set
{
name = value;
}
}

public string Book
{
get
{
return book;
}

set
{
book = value;
}
}

public string Author
{
get
{
return author;
}

set
{
author = value;
}
}

public DateTime Deadline
{
get
{
return deadline;
}

set
{
deadline = value;
}
}

public string Branch
{
get
{
return branch;
}

set
{
branch = value;
}
}

public string Location
{
get
{
return location;
}

set
{
location = value;
}
}
}
}
Loading

0 comments on commit 65fc872

Please sign in to comment.