📄 oaservice.asmx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Web;
using System.Web.Services;
namespace OAWebService
{
/// <summary>
/// Service1 的摘要说明。
/// </summary>
public class OAService : System.Web.Services.WebService
{
protected System.Data.SqlClient.SqlConnection MyConnection;
public OAService()
{
//CODEGEN: 该调用是 ASP.NET Web 服务设计器所必需的
InitializeComponent();
MyConnection= new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
}
#region 组件设计器生成的代码
//Web 服务设计器所必需的
private IContainer components = null;
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if(disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
#endregion
// WEB 服务示例
// HelloWorld() 示例服务返回字符串 Hello World
// 若要生成,请取消注释下列行,然后保存并生成项目
// 若要测试此 Web 服务,请按 F5 键
// [WebMethod]
// public string HelloWorld()
// {
// return "Hello World";
// }
[WebMethod]
public string GetOnlineUser()
{
DataSet ds= new DataSet();
SqlDataAdapter MyCommand = new SqlDataAdapter("OnlineUser",MyConnection);
MyCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Fill(ds,"Online");
DataTable dt = ds.Tables[0];
string tableH ="<table cellSpacing='0' cellPadding='0' width='100%'border='1'borderColor='lightgrey' style='FONT-SIZE: 9pt;'><tr style='BACKGROUND-COLOR:brown;FONT-WEIGHT: bold; COLOR: white;'><td width='40%'height='18px'align='center'>用户名</td><td width='60%'align='center'>登录时间</td></tr>";
string table = "";
foreach(DataRow row in dt.Rows)
{
table += "<tr><td height='18px'align='center'><a style='cursor=hand'onMouseover=this.style.color='#990000';this.style.textDecoration='underline' onMouseout=this.style.color='black';this.style.textDecoration='none' onClick =javascript:a=window.open('ShortcutNewMessage.aspx?Accepter="+row["UserName"]+"','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,revisable=no,left=100,top=0,width=445,height=352');window.event.returnValue=false;>"+row["UserName"]+"</a></td><td align='center'>"+((DateTime)row["Date"]).ToString("M-dd HH:m:s")+"</td></tr>";
}
string tableE = "</table>";
return tableH + table + tableE;
}
[WebMethod]
public string GetNewMessage(string UserID)
{
if(MyConnection.State.ToString() == "Closed")
MyConnection.Open();
SqlCommand MyCommand = new SqlCommand("MessageNotify",MyConnection);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add(new SqlParameter("@AccepterID", SqlDbType.NVarChar, 120));
MyCommand.Parameters["@AccepterID"].Value = UserID;
SqlDataReader myReader = MyCommand.ExecuteReader();
string rev="";
try
{
while(myReader.Read())
{
rev = myReader.GetString(0);
}
myReader.Close();
}
finally
{
}
MyConnection.Close();
if(System.Convert.ToBoolean(rev))
return "信息";
else
return "";
}
[WebMethod]
public string GetNewDocument(string UserID)
{
if(MyConnection.State.ToString() == "Closed")
MyConnection.Open();
SqlCommand MyCommand = new SqlCommand("DocumentNotify",MyConnection);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add(new SqlParameter("@AccepterID", SqlDbType.NVarChar, 120));
MyCommand.Parameters["@AccepterID"].Value = UserID;
SqlDataReader myReader = MyCommand.ExecuteReader();
string rev="";
try
{
while(myReader.Read())
{
rev = myReader.GetString(0);
}
myReader.Close();
}
finally
{
}
MyConnection.Close();
if(System.Convert.ToBoolean(rev))
return "文档";
else
return "";
}
[WebMethod]
public string GetNewFile(string UserID)
{
if(MyConnection.State.ToString() == "Closed")
MyConnection.Open();
SqlCommand MyCommand = new SqlCommand("FileNotify",MyConnection);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add(new SqlParameter("@AccepterID", SqlDbType.NVarChar, 120));
MyCommand.Parameters["@AccepterID"].Value = UserID;
SqlDataReader myReader = MyCommand.ExecuteReader();
string rev="";
try
{
while(myReader.Read())
{
rev = myReader.GetString(0);
}
myReader.Close();
}
finally
{
}
MyConnection.Close();
if(System.Convert.ToBoolean(rev))
return "文件";
else
return "";
}
[WebMethod]
public string GetNewMeeting(string UserID)
{
if(MyConnection.State.ToString() == "Closed")
MyConnection.Open();
SqlCommand MyCommand = new SqlCommand("MeetingNotify",MyConnection);
MyCommand.CommandType = CommandType.StoredProcedure;
MyCommand.Parameters.Add(new SqlParameter("@AccepterID", SqlDbType.NVarChar, 120));
MyCommand.Parameters["@AccepterID"].Value = UserID;
SqlDataReader myReader = MyCommand.ExecuteReader();
string rev="";
try
{
while(myReader.Read())
{
rev = myReader.GetString(0);
}
myReader.Close();
}
finally
{
}
MyConnection.Close();
if(System.Convert.ToBoolean(rev))
return "会议通知";
else
return "";
}
[WebMethod]
public string GetTodaySch(string UserID)
{
if(MyConnection.State.ToString() == "Closed")
MyConnection.Open();
SqlDataAdapter MyCommand = new SqlDataAdapter("PromptSchedule",MyConnection);
MyCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
MyCommand.SelectCommand.Parameters.Add(new SqlParameter("@PersonID", SqlDbType.Int, 4));
MyCommand.SelectCommand.Parameters["@PersonID"].Value = UserID;
DataSet ds = new DataSet();
MyCommand.Fill(ds,"Schedule");
if(ds.Tables["Schedule"].Rows.Count<=0)
return "";
else
{
DataTable dt = ds.Tables["Schedule"];
string tableH ="<table cellSpacing='1' cellPadding='1' width='100%'style='BORDER-RIGHT: #ccc 1px solid; BORDER-TOP: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; BORDER-BOTTOM: #ccc 1px solid;FONT-SIZE: 9pt;'>";
string table = "";
foreach(DataRow row in dt.Rows)
{
table += "<tr><td style='BACKGROUND-COLOR:brown;FONT-WEIGHT: bold; COLOR: white;BORDER-RIGHT: #ccc 1px solid; BORDER-TOP: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; BORDER-BOTTOM: #ccc 1px solid;FONT-SIZE: 9pt;'>"+((DateTime)row["PlanTime"]).ToString("M-dd HH:m:s")+"</td></tr><tr><td style='BORDER-RIGHT: #ccc 1px solid; BORDER-TOP: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; BORDER-BOTTOM: #ccc 1px solid;FONT-SIZE: 9pt;'>"+row["Contents"].ToString()+"</td></tr>";
}
string tableE = "</table>";
return dt.Rows.Count.ToString()+"|"+tableH + table + tableE;
}
}
[WebMethod]
public string GetOldSch(string UserID)
{
if(MyConnection.State.ToString() == "Closed")
MyConnection.Open();
SqlDataAdapter MyCommand = new SqlDataAdapter("PromptSchedule1",MyConnection);
MyCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
MyCommand.SelectCommand.Parameters.Add(new SqlParameter("@PersonID", SqlDbType.Int, 4));
MyCommand.SelectCommand.Parameters["@PersonID"].Value = UserID;
DataSet ds = new DataSet();
MyCommand.Fill(ds,"Schedule");
if(ds.Tables["Schedule"].Rows.Count<=0)
return "";
else
{
DataTable dt = ds.Tables["Schedule"];
string tableH ="<table cellSpacing='1' cellPadding='1' width='100%'style='BORDER-RIGHT: #ccc 1px solid; BORDER-TOP: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; BORDER-BOTTOM: #ccc 1px solid;FONT-SIZE: 9pt;'>";
string table = "";
foreach(DataRow row in dt.Rows)
{
table += "<tr><td style='BACKGROUND-COLOR:brown;FONT-WEIGHT: bold; COLOR: white;BORDER-RIGHT: #ccc 1px solid; BORDER-TOP: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; BORDER-BOTTOM: #ccc 1px solid;FONT-SIZE: 9pt;'>"+((DateTime)row["PlanTime"]).ToString("M-dd HH:m:s")+"</td></tr><tr><td style='BORDER-RIGHT: #ccc 1px solid; BORDER-TOP: #ccc 1px solid; BORDER-LEFT: #ccc 1px solid; BORDER-BOTTOM: #ccc 1px solid;FONT-SIZE: 9pt;'>"+row["Contents"].ToString()+"</td></tr>";
}
string tableE = "</table>";
return dt.Rows.Count.ToString()+"|"+tableH + table + tableE;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -