Browse Source

添加获取账套方法

章政 6 years ago
parent
commit
dbd97c3b9d
2 changed files with 82 additions and 2 deletions
  1. 42 1
      UAS_MesInterface(4.0)/MesHelper.cs
  2. 40 1
      UAS_MesInterface/MESHelper.cs

+ 42 - 1
UAS_MesInterface(4.0)/MesHelper.cs

@@ -16,6 +16,8 @@ namespace BenQGuru.eMES.DLLService
         [DispId(14)]
         bool CheckRoutePassed(string iSN, string iResCode, out string oErrMessage);
         bool GetRcardMOInfo(string iSN, out string oMoCode, out string oErrMessage);
+        bool GetMaster(out string Master);
+        bool SetMaster(string Master);
         bool CheckUserAndResourcePassed(string iUserCode, string iResCode, string iPassWord, out string oErrMessage);
         bool GetAddressRangeByMO(string iSN, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCdoe3, out string oErrMessage);
         bool SetAddressInfo(string iSN, string iWIFI, string iBT, string iCode1, string iCode2, string iCode3, out string oErrorMessage);
@@ -41,12 +43,14 @@ namespace BenQGuru.eMES.DLLService
         //用于存放批量执行的SQL
         List<string> sqls = new List<string>();
         //系统默认的的连接字符串
-        private string ConnectionStrings = "Data Source=192.168.230.200/orcl;User ID=MES_ZZ;PassWord=select!#%*(;";
+        private string ConnectionStrings = "Data Source=117.25.180.218/orcl;User ID=MES;PassWord=select!#%*(;";
         //用户选择的数据库的连接字符串
         private OracleConnection connection;
         //用户选择的数据库的连接字符串
         private OracleCommand command = null;
 
+        DataTable MasterDB;
+
         public MESHelper()
         {
             connection = new OracleConnection(ConnectionStrings);
@@ -1169,5 +1173,42 @@ namespace BenQGuru.eMES.DLLService
                 cmd.Connection.Open();
             }
         }
+
+        [Description("获取账套信息")]
+        public bool GetMaster(out string oMaster)
+        {
+            MasterDB = (DataTable)ExecuteSql("select ms_pwd,ma_user,ma_inneraddress from master", "select");
+            oMaster = "";
+            for (int i = 0; i < MasterDB.Rows.Count; i++)
+            {
+                if (i != MasterDB.Rows.Count - 1)
+                    oMaster += MasterDB.Rows[i]["ma_user"].ToString() + "|";
+                else
+                    oMaster += MasterDB.Rows[i]["ma_user"].ToString();
+            }
+            return true;
+        }
+
+        [Description("设置账套信息")]
+        public bool SetMaster(string iMaster)
+        {
+            for (int i = 0; i < MasterDB.Rows.Count; i++)
+            {
+                if (MasterDB.Rows[i]["ma_user"].ToString() == iMaster)
+                {
+                    ConnectionStrings = "Data Source=117.25.180.218/orcl;User ID=" + iMaster + ";PassWord=" + MasterDB.Rows[i]["ms_pwd"].ToString();
+                    try
+                    {
+                        connection = new OracleConnection(ConnectionStrings);
+                    }
+                    catch (Exception)
+                    {
+                        return false;
+                    }
+                    return true;
+                }
+            }
+            return false;
+        }
     }
 }

+ 40 - 1
UAS_MesInterface/MESHelper.cs

@@ -15,6 +15,8 @@ namespace BenQGuru.eMES.DLLService
         [DispId(12)]
         bool CheckRoutePassed(string iSN, string iResCode, out string oErrMessage);
         bool GetRcardMOInfo(string iSN, out string oMoCode, out string oErrMessage);
+        bool GetMaster(out string Master);
+        bool SetMaster(string Master);
         bool CheckUserAndResourcePassed(string iUserCode, string iResCode, string iPassWord, out string oErrMessage);
         bool GetAddressRangeByMO(string iSN, out string oWIFI, out string oBT, out string oCode1, out string oCode2, out string oCdoe3, out string oErrMessage);
         bool SetAddressInfo(string iSN, string iWIFI, string iBT, string iCode1, string iCode2, string iCode3, out string oErrorMessage);
@@ -38,12 +40,14 @@ namespace BenQGuru.eMES.DLLService
         //用于存放批量执行的SQL
         List<string> sqls = new List<string>();
         //系统默认的的连接字符串
-        private string ConnectionStrings = "Data Source=192.168.230.200/orcl;User ID=MES_ZZ;PassWord=select!#%*(;";
+        private string ConnectionStrings = "Data Source=192.168.230.200/orcl;User ID=MES;PassWord=select!#%*(;";
         //用户选择的数据库的连接字符串
         private OracleConnection connection;
         //用户选择的数据库的连接字符串
         private OracleCommand command = null;
 
+        DataTable MasterDB;
+
         public MESHelper()
         {
             connection = new OracleConnection(ConnectionStrings);
@@ -1085,5 +1089,40 @@ namespace BenQGuru.eMES.DLLService
                 cmd.Connection.Open();
             }
         }
+
+        public bool GetMaster(out string oMaster)
+        {
+            MasterDB = (DataTable)ExecuteSql("select ms_pwd,ma_user,ma_inneraddress from master", "select");
+            oMaster = "";
+            for (int i = 0; i < MasterDB.Rows.Count; i++)
+            {
+                if (i != MasterDB.Rows.Count - 1)
+                    oMaster += MasterDB.Rows[i]["ma_user"].ToString() + "|";
+                else
+                    oMaster += MasterDB.Rows[i]["ma_user"].ToString();
+            }
+            return true;
+        }
+
+        public bool SetMaster(string iMaster)
+        {
+            for (int i = 0; i < MasterDB.Rows.Count; i++)
+            {
+                if (MasterDB.Rows[i]["ma_user"].ToString() == iMaster)
+                {
+                    ConnectionStrings = "Data Source=" + MasterDB.Rows[i]["ma_inneraddress"].ToString() + "/orcl;User ID=" + iMaster + ";PassWord=" + MasterDB.Rows[i]["ms_pwd"].ToString();
+                    try
+                    {
+                        connection = new OracleConnection(ConnectionStrings);
+                    }
+                    catch (Exception)
+                    {
+                        return false;
+                    }
+                    return true;
+                }
+            }
+            return false;
+        }
     }
 }