using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Drawing;
using System.Data;
using System.Collections;
using System.Text;
using System.IO;
using System.Web;
using System.Windows;
using System.Threading;
namespace WebApplication
{
///
/// WebService1 的摘要说明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod(Description = "获取对应机型名称产能")]
public String Get_Product_Total(String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
String Temp=String.Empty;
String SqlConnect_Str = "server="+SERVER+";database="+DATABASE+";uid="+UID+";pwd="+PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure, sqlcon);
Temp = cmd.ExecuteScalar().ToString();
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
return null;
}
finally
{
sqlcon.Close();
}
return Temp;
}
/*public Boolean Get_Product_Total(List Store_Product_Name, String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
Boolean Flag = false;
String SqlConnect_Str = "server="+SERVER+";database="+DATABASE+";uid="+UID+";pwd="+PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
try
{
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure,sqlcon);
Store_Product_Name.Add(cmd.ExecuteScalar().ToString());
Flag = true;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}*/
[WebMethod(Description = "获取对应获取机型名称")]
public String[] Get_Product_Name(String Read_Product_Name, String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
String[] Temp = new String[100];
String SqlConnect_Str = "server=" + SERVER + ";database=" + DATABASE + ";uid=" + UID + ";pwd=" + PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
int n = 0;
try
{
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure, sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
if (n == 0)
{
Temp[n] = (sdr[Read_Product_Name].ToString());
n++;
}
else
{
Boolean ss = false;
foreach (String i in Temp)
{
if (i == sdr[Read_Product_Name].ToString())
{
ss = true;
break;
}
}
if (!ss)
{
Temp[n] = (sdr[Read_Product_Name].ToString());
n++;
}
}
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
return null;
}
finally
{
sqlcon.Close();
}
return Temp;
}
/*public Boolean Get_Product_Name(List Store_Product_Name, String Read_Product_Name, String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
Boolean Flag = false;
String SqlConnect_Str = "server=" + SERVER + ";database=" + DATABASE + ";uid=" + UID + ";pwd=" + PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
int n = 0;
try
{
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure,sqlcon);
SqlDataReader sdr=cmd.ExecuteReader();
while (sdr.Read())
{
if (n == 0)
Store_Product_Name.Add(sdr[Read_Product_Name].ToString());
else
{
Boolean ss = false;
foreach (String i in Store_Product_Name)
{
if (i == sdr[Read_Product_Name].ToString())
{
ss = true;
break;
}
}
if(!ss)
Store_Product_Name.Add(sdr[Read_Product_Name].ToString());
}
n++;
}
Flag = true;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}*/
[WebMethod(Description = "获取产能数据")]
public int Get_Capacity_Data(String JobNumber, String Year_Month_Day, String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
//Boolean Flag = false;
String SqlConnect_Str = "server=" + SERVER + ";database=" + DATABASE + ";uid=" + UID + ";pwd=" + PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
int n = 0;
try
{
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure,sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@JobNumber",JobNumber);
cmd.Parameters.Add("@Year_Month_Day",Year_Month_Day);
cmd.Parameters.Add("@GetTotalCount", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@rs", SqlDbType.Int).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
n = Convert.ToInt32(cmd.Parameters["@GetTotalCount"].Value.ToString());
}
else
n=0;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
n=25234512;
}
finally
{
sqlcon.Close();
}
return n;
}
[WebMethod(Description = "获取当前月度汇总总产能")]
public Boolean Get_Month_Capacity_Data(List> Month_Capacity_Data, List KeyInfo, String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
Boolean Flag = false;
String SqlConnect_Str = "server=" + SERVER + ";database=" + DATABASE + ";uid=" + UID + ";pwd=" + PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
try
{
foreach (String ss in KeyInfo)
{
List Temp = new List();
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure,sqlcon);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@JobNumber", ss);
cmd.Parameters.Add("@Date_Time", DateTime.Now.ToString("yyyy-MM-dd") + @"%");
cmd.Parameters.Add("@TotoNumber", SqlDbType.Int).Direction = ParameterDirection.Output;//返回
cmd.Parameters.Add("@rs", SqlDbType.Int).Direction = ParameterDirection.Output;//返回
cmd.ExecuteNonQuery();
if ((int)cmd.Parameters["@rs"].Value == 0)
{
Temp.Add(Convert.ToInt32(cmd.Parameters["@TotalNumber"].Value));
}
else
Temp.Add(0);
Month_Capacity_Data.Add(Temp);
}
Flag = true;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}
[WebMethod(Description = "获取产品型号信息")]
public String[] Get_Product_Type_Info(String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
String SqlConnect_Str = "server=" + SERVER + ";database=" + DATABASE + ";uid=" + UID + ";pwd=" + PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
String[] Temp = new String[20];
try
{
int n = 0;
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure, sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
Temp[n] = (sdr["Product_Type"].ToString() + "#" + sdr["Item_Count"].ToString() + "#" + sdr["SERVER_Name"].ToString() + "#" +
sdr["DataBase_Name"].ToString() + "#" + sdr["SERVER_UserName"].ToString() + "#" + sdr["SERVER_Password"].ToString() + "#" +
sdr["TABLE_Name"].ToString() + "#" + sdr["Stored_Procedure"].ToString());// + "#" + sdr["Date_Time"].ToString());
n++;
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
return null;
}
finally
{
sqlcon.Close();
}
return Temp;
}
/*public Boolean Get_Product_Type_Info(String []Item_Values, String []Item, String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
Boolean Flag = false;
String SqlConnect_Str = "server=" + SERVER + ";database=" + DATABASE + ";uid=" + UID + ";pwd=" + PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
int n = 0;
int s = 0;
try
{
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure,sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
if (s == 0)
{
Item[n] = (sdr["Product_Type"].ToString());
s++;
}
else
{
Boolean IsFind = false;
foreach (String ss in Item)
{
if (ss == sdr["Product_Type"].ToString())
{
IsFind = true;
break;
}
}
if (!IsFind)
{
Item[s] = (sdr["Product_Type"].ToString());
s++;
}
}
Item_Values[n]=(sdr["Product_Type"].ToString() + "#" + sdr["Item_Count"].ToString() + "#" + sdr["SERVER_Name"].ToString() + "#" +
sdr["DataBase_Name"].ToString() + "#" + sdr["SERVER_UserName"].ToString() + "#" + sdr["SERVER_Password"].ToString() + "#" +
sdr["TABLE_Name"].ToString() + "#" + sdr["Stored_Procedure"].ToString());// + "#" + sdr["Date_Time"].ToString());
n++;
}
Flag = true;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}*/
[WebMethod(Description = "获取员工信息")]
public String[] Get_Employee_Info(String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
String[] Temp = new String[100];
String SqlConnect_Str = "server=" + SERVER + ";database=" + DATABASE + ";uid=" + UID + ";pwd=" + PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
int n = 0;
try
{
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure, sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
Temp[n] = (sdr["Line_Body"].ToString() + "#" + sdr["Job_Number"].ToString() + "#" + sdr["Name"].ToString());
n++;
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
return null;
}
finally
{
sqlcon.Close();
}
return Temp;
}
/*public Boolean Get_Employee_Info(List Item_Values, List Item, String SERVER, String DATABASE, String UID, String PWD, String Sql_Stored_Procedure)
{
Boolean Flag = false;
String SqlConnect_Str = "server=" + SERVER + ";database=" + DATABASE + ";uid=" + UID + ";pwd=" + PWD;
SqlConnection sqlcon = new SqlConnection(SqlConnect_Str);
sqlcon.Open();
int n=0;
try
{
SqlCommand cmd = new SqlCommand(Sql_Stored_Procedure,sqlcon);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
if (n == 0)
Item.Add(sdr["Line_Body"].ToString());
else
{
Boolean IsFind = false;
foreach (String ss in Item)
{
if (ss == sdr["Line_Body"].ToString())
{
IsFind = true;
break;
}
}
if (!IsFind)
Item.Add(sdr["Line_Body"].ToString());
}
Item_Values.Add(sdr["Line_Body"].ToString() + "#" + sdr["Job_Number"].ToString() + "#" + sdr["Name"].ToString());
n++;
}
Flag = true;
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
Flag = false;
}
finally
{
sqlcon.Close();
}
return Flag;
}*/
}
}