C# MES上传数据 + webservice

 public class Program
    {
        public static String[] Program_As = { @"/EI_MB_WIN",@"/EI_GP_OnDisplay", @"/EI_DOS", @"/EI_GP_WIN", @"/EQ_FR",@"/EQ_OnDisplay",@"/EQ_DOS",@"/EQ_WIN"};
        public static String ISN = String.Empty;//存储ISN

        public static int Main(string[] args)
        {
            if (args.Length == 2)
            {
                if (GetIsnCode(args[1]))//读取SN条码
                {
                    WebReference.WebServiceDemo webservice = new WebReference.WebServiceDemo();//引用服务
                    WebReference_168.WebServiceDemo webservice168 = new WebReference_168.WebServiceDemo();//引用168服务器
                    DataBase Opertion_TestDatabase = new DataBase(@"SERVER2\SERVER2", @"E_Data_Interactive_Processing", "sa", "adminsystem", "");
                    if (TestNetConnectity("192.167.30.2"))
                    {
                        //上传主板WINDOWS测试数据到MES数据库
                        if (args[0].ToUpper() == Program_As[0])
                        {
                            if (webservice.Insert_MainBoard_Test_Data(ISN, "ShenBo_test") == 0)
                            {
                                ShowInfo("MainBoard Windows Test Data Upload EMS DataBase Succeeded!!", 2);
                                return 0;


                            }
                            else
                            {
                                ShowInfo("MainBoard Windows Test Data Uploading EMS DataBase Fail!!", 1);
                                return 1;
                            }

                        }

                        //上传显卡开机显示测试数据上传MES数据库
                        else if (args[0].ToUpper() == Program_As[1])
                        {
                            if (webservice.Insert_Graogucs_Test_Data(@"Graogucs_Card_Switch_On_The_Test", ISN) != 0)
                            {
                                ShowInfo("Graogucs Card On Display Test Data Upload EMS DataBase Fail!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("Graogucs Card On Display Test Data Upload EMS DataBase Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //显卡DOS or LINUX 过站信息上传MES系统
                        else if (args[0].ToUpper() == Program_As[2])
                        {
                            if (webservice.Insert_Graogucs_Test_Data(@"Graogucs_Card_Dos", ISN) != 0)
                            {
                                ShowInfo("Graogucs Card DOS or Linux Test Data Upload EMS DataBase Fail!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("Graogucs Card DOS or Linux Test Data Upload EMS DataBase Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //上传显卡WINDOWS测试数据上传MES数据库
                        else if (args[0].ToUpper() == Program_As[3])
                        {
                            if (webservice.Insert_Graogucs_Test_Data("Graogucs_Card_Win", ISN) != 0)
                            {
                                ShowInfo("Graogucs Card Windows Test Data Upload EMS DataBase Fail!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("Graogucs Card Windows Test Data Upload EMS DataBase Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //查询EMS 炉后目检过站信息
                        else if (args[0].ToUpper() == Program_As[4])
                        {
                            if (webservice.Querying_EMS_ScannState(ISN, 106) != 0)
                            {
                                ShowInfo("The inspection after furnace is not scanned!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("inspection after furnace Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //查询EMS 开机显示过站信息
                        else if (args[0].ToUpper() == Program_As[5])
                        {
                            if (webservice.Querying_EMS_ScannState(ISN, 121) != 0)
                            {
                                ShowInfo("The boot display scan record was not found!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("On Display Scan record Querying Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //查询EMS DOS||LINUX过站信息
                        else if (args[0].ToUpper() == Program_As[6])
                        {
                            if (webservice.Querying_EMS_ScannState(ISN, 119) != 0)
                            {
                                ShowInfo("The Linux Or Dos Scan record was not found!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("The Linux or Dos Scan record Querying Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //查询EMS WINDOWS过站信息
                        else if (args[0].ToUpper() == Program_As[7])
                        {
                            if (webservice.Querying_EMS_ScannState(ISN, 120) != 0)
                            {
                                ShowInfo("The Windows Scan record was not found!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("The Windows Scan record Querying Succeeded", 2);
                                return 0;
                            }
                        }
                        else
                            help();
                    }
                    else if (TestNetConnectity("192.168.6.45"))
                    {
                        //上传主板WINDOWS测试数据到MES数据库
                        if (args[0].ToUpper() == Program_As[0])
                        {
                            if (webservice168.Insert_MainBoard_Test_Data(ISN, "ShenBo_test") == 0)
                            {
                                ShowInfo("MainBoard Windows Test Data Upload EMS DataBase Succeeded!!", 2);
                                return 0;
                            }
                            else
                            {
                                ShowInfo("MainBoard Windows Test Data Uploading EMS DataBase Fail!!", 1);
                                return 1;
                            }
                        }

                        //上传显卡开机显示测试数据上传MES数据库
                        else if (args[0].ToUpper() == Program_As[1])
                        {
                            if (webservice168.Insert_Graogucs_Test_Data(@"Graogucs_Card_Switch_On_The_Test", ISN) != 0)
                            {
                                ShowInfo("Graogucs Card On Display Test Data Upload EMS DataBase Fail!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("Graogucs Card On Display Test Data Upload EMS DataBase Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //显卡DOS or LINUX 过站信息上传MES系统
                        else if (args[0].ToUpper() == Program_As[2])
                        {
                            if (webservice168.Insert_Graogucs_Test_Data(@"Graogucs_Card_Dos", ISN) != 0)
                            {
                                ShowInfo("Graogucs Card DOS or Linux Test Data Upload EMS DataBase Fail!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("Graogucs Card DOS or Linux Test Data Upload EMS DataBase Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //上传显卡WINDOWS测试数据上传MES数据库
                        else if (args[0].ToUpper() == Program_As[3])
                        {
                            if (webservice168.Insert_Graogucs_Test_Data("Graogucs_Card_Win", ISN) != 0)
                            {
                                ShowInfo("Graogucs Card Windows Test Data Upload EMS DataBase Fail!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("Graogucs Card Windows Test Data Upload EMS DataBase Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //查询EMS 炉后目检过站信息
                        else if (args[0].ToUpper() == Program_As[4])
                        {
                            if (webservice168.Querying_EMS_ScannState(ISN, 106) != 0)
                            {
                                ShowInfo("The inspection after furnace is not scanned!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("inspection after furnace Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //查询EMS 开机显示过站信息
                        else if (args[0].ToUpper() == Program_As[5])
                        {
                            if (webservice168.Querying_EMS_ScannState(ISN, 121) != 0)
                            {
                                ShowInfo("The boot display scan record was not found!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("On Display Scan record Querying Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //查询EMS DOS||LINUX过站信息
                        else if (args[0].ToUpper() == Program_As[6])
                        {
                            if (webservice168.Querying_EMS_ScannState(ISN, 119) != 0)
                            {
                                ShowInfo("The Linux Or Dos Scan record was not found!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("The Linux or Dos Scan record Querying Succeeded!!", 2);
                                return 0;
                            }
                        }

                        //查询EMS WINDOWS过站信息
                        else if (args[0].ToUpper() == Program_As[7])
                        {
                            if (webservice168.Querying_EMS_ScannState(ISN, 120) != 0)
                            {
                                ShowInfo("The Windows Scan record was not found!!", 1);
                                return 1;
                            }
                            else
                            {
                                ShowInfo("The Windows Scan record Querying Succeeded", 2);
                                return 0;
                            }
                        }
                        else
                            help();
                    }
                    else
                    {
                        ShowInfo("Serve2 Connection Fail!!", 1);
                        return 1;
                    }


                    //for (int n = 0; n <= Program_As.Length; n++)
                    //{
                    //}
                }
            }
            help();
            return 1;
        }

        public static bool TestNetConnectity(string strIP)//判断网段是否可连接
        {
            // Windows L2TP VPN和非Windows VPN使用ping VPN服务端的方式获取是否可以连通   
            Ping pingSender = new Ping();
            PingOptions options = new PingOptions();

            // Use the default Ttl value which is 128,   
            // but change the fragmentation behavior.   
            options.DontFragment = true;

            // Create a buffer of 32 bytes of data to be transmitted.   
            string data = "testtesttesttesttesttesttesttest";
            byte[] buffer = Encoding.ASCII.GetBytes(data);
            int timeout = 120;
            PingReply reply = pingSender.Send(strIP, timeout, buffer, options);

            return (reply.Status == IPStatus.Success);
        }

        public static void TITLE()//表头
        {
            Console.WriteLine("TestDataUpload_MES_Tools Test Tools V1.00 -Ferex Incorporation,By Shenbo,2020-02-26");
        }
        public static void help()//帮助信息
        {
            Console.Clear();
            TITLE();
            Console.BackgroundColor = ConsoleColor.Blue;
            Console.WriteLine("=======================================================================================================================");
            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(@"TestDataUpload_MES_Tools [/EI_MB_WIN][/EI_GP_OnDisplay][/EI_DOS][/EI_GP_WIN][/EQ_FR][/EQ_OnDisplay][/EQ_DOS][/EQ_WIN]");
            Console.WriteLine(@"/EI_MB_WIN:MainBoard Windows Test Data Upload EMS DataBase.");
            Console.WriteLine(@"/EI_GP_OnDisplay:Graogucs Card On Display Test Data Upload EMS DataBase.");
            Console.WriteLine(@"/EI_DOS:Graogucs Card DOS or Linux Test Data Upload EMS DataBase.");
            Console.WriteLine(@"/EI_GP_WIN:MainBoard Windows Test Data Uploading EMS DataBase.");
            Console.WriteLine(@"/EQ_FR:Graogucs Card inspection after furnace Data Querying.");
            Console.WriteLine(@"/EQ_OnDisplay:Graogucs Card On Display Data Querying.");
            Console.WriteLine(@"/EQ_DOS:Graogucs Card Dos Or Linux Data Querying.");
            Console.WriteLine(@"/EQ_WIN:Windows Data Querying.");
            Console.ResetColor();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("-----------------------------------------------------------------------------------------------------------------------");
            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.WriteLine(@"TestDataUpload_MES_Tools.exe /EM_MB_WIN C:\SN.TXT");
            Console.WriteLine(@"TestDataUpload_MES_Tools.exe /EQ_WIN C:\SN.TXT");
            Console.WriteLine(@"TestDataUpload_MES_Tools.exe /EI_GP_WIN C:\SN.TXT");
            Console.WriteLine(@"TestDataUpload_MES_Tools.exe /EQ_WIN:Windows C:\SN.TXT");
            Console.ReadKey();
        }
        public static void ShowInfo(String swif, int Item)//显示的结果
        {
            if (Item == 1)
                Console.BackgroundColor = ConsoleColor.Red;
            else if (Item == 2)
                Console.BackgroundColor = ConsoleColor.Green;
            Console.WriteLine(swif);
            Console.ResetColor();
        }
        public static Boolean GetIsnCode(String FileNmae)//读取SN条码
        {
            Boolean Flag = true;
            FileStream fs = new FileStream(FileNmae,FileMode.Open,FileAccess.Read);
            StreamReader sr = new StreamReader(fs,Encoding.Default);
            try
            {

                ISN=sr.ReadLine();
            }
            catch (Exception ex)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message);
                Console.ResetColor();
            }
            finally
            {
                sr.Close();
                fs.Close();
            }

            return Flag;
        }
    }
}

/*WEBSERVICE*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Collections;
using System.Data;

namespace WebServiceDemo
{
    /// <summary>
    /// WebServiceDemo 的摘要说明WebServiceDemo
    /// </summary>
    [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 WebServiceDemo : System.Web.Services.WebService
    {
        public static String sqlser = @"server=192.168.3.210\MESSQL;database=SFC;uid=sa;pwd=123456";
        public SqlConnection sqlCon = new SqlConnection(sqlser);

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod(Description = "用于查询MES测试扫描过站状态")]
        public int Querying_EMS_ScannState(String Isn, int Postion_Code)
        {
            try
            {
                sqlCon.Open();
                SqlCommand sql_cmd = new SqlCommand("Querying_EMS_ScanInfo",this.sqlCon);
                sql_cmd.CommandType = CommandType.StoredProcedure;
                sql_cmd.Parameters.Add("@Isn",Isn);
                sql_cmd.Parameters.Add("@Postion_Code",Postion_Code);
                sql_cmd.Parameters.Add("@rs",SqlDbType.Int).Direction=ParameterDirection.Output;
                sql_cmd.ExecuteScalar();
                if ((int)sql_cmd.Parameters["@rs"].Value != 0)
                {
                    Console.WriteLine("fail!!");
                    return 1;
                }
                else
                {
                    Console.WriteLine("pass!!");
                    return 0;
                }
                //return (int)sql_cmd.Parameters["@rs"].Value;
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.ToString());
                Console.ResetColor();
                return 3;
            }
            finally
            {
                this.sqlCon.Close();
            }
        }
        [WebMethod(Description = "用于插入主板测试工序过站数据及装态信息查检")]
        public int Insert_MainBoard_Test_Data(String Isn, String StoredProcedure_Str)
        {
            try
            {
                sqlCon.Open();
                SqlCommand sql_cmd = new SqlCommand(StoredProcedure_Str, sqlCon);
                sql_cmd.CommandType = CommandType.StoredProcedure;
                sql_cmd.Parameters.Add("@y_isn varchar",Isn);
                sql_cmd.Parameters.Add("@y_result",0);
                sql_cmd.Parameters.Add("@y_reMessage",SqlDbType.VarChar,1000).Direction=ParameterDirection.Output;
                sql_cmd.Parameters.Add("@y_flag", SqlDbType.Int).Direction = ParameterDirection.Output;
                sql_cmd.ExecuteScalar();
                if ((int)sql_cmd.Parameters["@rs"].Value != 0)
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.WriteLine(sql_cmd.Parameters["@y_reMessage"].ToString());
                    Console.ResetColor();
                    return (int)sql_cmd.Parameters["@rs"].Value;
                }
                return 0;
            }
            catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.ToString());
                Console.ResetColor();
                return 3;
            }
            finally
            {
                this.sqlCon.Close();
            }
        }

        [WebMethod(Description = "用于插入显卡测试工序过站数据及状态信息查检")]
        public int Insert_Graogucs_Test_Data(String Isn, String StoredProcedure_Str)
        {
            try
            {

                sqlCon.Open();
                SqlCommand cmd = new SqlCommand(StoredProcedure_Str, sqlCon);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Isn", Isn);//插入Isn
                cmd.Parameters.Add("@rs", 1);//设置返回值
                cmd.Parameters["@rs"].Direction = ParameterDirection.Output;//获取返回值
                cmd.ExecuteScalar();
                if ((int)cmd.Parameters["@rs"].Value == 0)
                {
                    //Console.ForegroundColor = ConsoleColor.Green;
                    //Console.WriteLine("Insert Graogucs Card Switch On The Test DataBase Successfully!!");
                    //Console.ResetColor();
                    return 0;
                }
                else if ((int)cmd.Parameters["@rs"].Value == 1)//前段工序漏扫描
                {
                    return 1;
                }
                else
                {
                    return 2;
                }
            }
            catch (Exception ex)//连接数据库失败
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.ToString());
                Console.ResetColor();
                return 3;
            }
            finally
            {
                this.sqlCon.Close();
            }
        }

        [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;
        }
 
        [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;
        }
 
        [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<List<int>> Month_Capacity_Data, List<String> 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<int> Temp = new List<int>();
                    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;
        }
 
        [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;
        }

    }
}

 

  • 8
    点赞
  • 68
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值