示例#1
0
 /// <summary>
 /// Check if the current connection information is connected
 /// </summary>
 /// <param name="ip">Ip address</param>
 /// <param name="port">Port</param>
 /// <param name="userName">User name</param>
 /// <param name="password">Password</param>
 /// <param name="dbType">Type of DataBaseType</param>
 /// <returns>Returns true if it can connect, otherwise returns false</returns>
 public bool connect()
 {
     try
     {
         // An attempt to perform a database operation is considered incorrect if an exception is thrown
         if (DATABASE_TYPE == DataBaseType.MySql)
         {
             MySqlConnector connector = MySqlConnector.GetInstance(IP, PORT, USER_NAME, PASSWORD, "");
             DataTable      tb        = connector.ExecuteDataTable(Database.MYSQL_ALL_DATABASE_SCRIPT);
             tb.Rows[0]["Database"].ToString();
         }
         else if (DATABASE_TYPE == DataBaseType.SqlServer)
         {
             SqlServerConnector connector = SqlServerConnector.GetInstance(IP, USER_NAME, PASSWORD, "");
             DataTable          tb        = connector.ExecuteDataTable(Database.SQLSERVER_ALL_TABLE_SCRIPT);
             tb.Rows[0]["NAME"].ToString();
         }
         else if (DATABASE_TYPE == DataBaseType.Oracle)
         {
             OracleConnector connector = OracleConnector.GetInstance(IP, USER_NAME, PASSWORD);
             DataTable       tb        = connector.ExecuteDataTable(Database.ORACLE_ALL_USER_SCRIPT);
             tb.Rows[0][0].ToString();
         }
         else
         {
             // unknow database, return the false
             return(false);
         }
     }
     catch
     {
         return(false);
     }
     return(true);
 }
        protected override void OnStart(string[] args)
        {
            timer.Start();

            try
            {
                OC = new OracleConnector(CTS);
            }
            catch
            {
                throw;
            }

            ImportTask = new Task(() =>
            {
                while (CTS.IsCancellationRequested == false)
                {
                    //запуск заданий импорта изображений из базы данных
                    CTS.Token.ThrowIfCancellationRequested();
                    OC.Import(OC.ServiceSettings.SelectStandardCommand, ImportType.Standard);
                    OC.Import(OC.ServiceSettings.SelectValuteCommand, ImportType.Valute);
                    OC.Import(OC.ServiceSettings.SelectStandardSpisokCommand, ImportType.StandardSpisok);
                    OC.Import(OC.ServiceSettings.SelectSwiftCommand, ImportType.Swift);
                }
            }, CTS.Token);
            ImportTask.Start();
        }
示例#3
0
        public void ReadFirstTest()
        {
            string          ServerName   = "localhost";                                                                              // TODO: Initialize to an appropriate value
            int             PortNumber   = 1521;                                                                                     // TODO: Initialize to an appropriate value
            string          TableName    = "GeoData";                                                                                // TODO: Initialize to an appropriate value
            string          UserName     = "******";                                                                                 // TODO: Initialize to an appropriate value
            string          Password     = "******";                                                                               // TODO: Initialize to an appropriate value
            string          DatabaseName = "XE";
            OracleConnector target       = new OracleConnector(ServerName, PortNumber, TableName, UserName, Password, DatabaseName); // TODO: Initialize to an appropriate value
            object          expected     = null;                                                                                     // TODO: Initialize to an appropriate value
            object          actual;

            actual = target.ReadFirst();
            Assert.AreEqual(expected, actual);
        }
示例#4
0
        public static DbConnector GetConenctorByProvider(string provider)
        {
            DbConnector connector = null;

            switch (provider.ToLower())
            {
            case "mssqlserver":
                connector = new MSSQLConnecctor(new ConnectionHelper());
                break;

            case "oracle":
                connector = new OracleConnector(new ConnectionHelper());
                break;
            }
            return(connector);
        }
示例#5
0
        /// <summary>
        /// Load all database information for this connection (oracle does not apply)
        /// </summary>
        /// <returns>List's all scheme name</returns>
        public List <string> initScheme()
        {
            List <string> schemes = new List <string>();

            try
            {
                // An attempt to perform a database operation is considered incorrect if an exception is thrown
                if (DATABASE_TYPE == DataBaseType.MySql)
                {
                    MySqlConnector connector = MySqlConnector.GetInstance(IP, PORT, USER_NAME, PASSWORD, "");
                    DataTable      tb        = connector.ExecuteDataTable(Database.MYSQL_ALL_DATABASE_SCRIPT);
                    for (int i = 0; i < tb.Rows.Count; i++)
                    {
                        schemes.Add(tb.Rows[i]["Database"].ToString());
                    }
                }
                else if (DATABASE_TYPE == DataBaseType.SqlServer)
                {
                    SqlServerConnector connector = SqlServerConnector.GetInstance(IP, USER_NAME, PASSWORD, "");
                    DataTable          tb        = connector.ExecuteDataTable(Database.SQLSERVER_ALL_TABLE_SCRIPT);
                    for (int i = 0; i < tb.Rows.Count; i++)
                    {
                        schemes.Add(tb.Rows[i]["NAME"].ToString());
                    }
                }
                else if (DATABASE_TYPE == DataBaseType.Oracle)
                {
                    OracleConnector connector = OracleConnector.GetInstance(IP, USER_NAME, PASSWORD);
                    DataTable       tb        = connector.ExecuteDataTable(Database.ORACLE_ALL_USER_SCRIPT);
                    for (int i = 0; i < tb.Rows.Count; i++)
                    {
                        schemes.Add(tb.Rows[i][0].ToString());
                    }
                }
                else
                {
                    // unknow database, return the false
                }
            }
            catch
            {
            }
            return(schemes);
        }
示例#6
0
 public VtwinPanel(OracleConnector oracle, DataRow r, Machine inspMachine)
 {
     _oracle = oracle;
     CreateInspectionObject(r, inspMachine);
 }
 public Customer(OracleConnector oracle, WebSerivceConnector webservice, EntityConnector entity)
 {
     this.oracle = oracle;
     this.webservice = webservice;
     this.entity = entity;
 }
示例#8
0
 public ORM()
 {
     connection = OracleConnector.getConnection();
 }
示例#9
0
        public void GetPermission()
        {
            DataSet ds = null;
            List <OracleParameter> inputParameter  = null;
            List <OracleParameter> outputParameter = null;
            List <string>          tableNames      = null;

            try
            {
                Tool.ShowWaiting();
                inputParameter = new List <OracleParameter>();
                inputParameter.AddRange(new OracleParameter[] {
                    new OracleParameter("domain_user", OracleDbType.Varchar2, 200, domainId.ToLower(), ParameterDirection.Input)
                });

                outputParameter = new List <OracleParameter>();
                outputParameter.AddRange(new OracleParameter[] {
                    new OracleParameter("userInfo", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output),
                    new OracleParameter("branchInfo", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output),
                    new OracleParameter("outCursor", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output),
                    new OracleParameter("allStaff", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output),
                    new OracleParameter("allHead", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output)
                });

                tableNames = new List <string>();
                tableNames.Add("UserInfo");
                tableNames.Add("BranchInfo");
                tableNames.Add("AvailableUser");
                tableNames.Add("AllUser");
                tableNames.Add("AllHead");

                ds = OracleConnector.GetByProcedure("getUserInfo", inputParameter, outputParameter, tableNames);
                if (ds == null || ds.Tables == null ||
                    ds.Tables["UserInfo"] == null || ds.Tables["UserInfo"].Rows == null || ds.Tables["UserInfo"].Rows.Count.Equals(0) ||
                    ds.Tables["BranchInfo"] == null || ds.Tables["BranchInfo"].Rows == null || ds.Tables["BranchInfo"].Rows.Count.Equals(0) ||
                    ds.Tables["AvailableUser"] == null || ds.Tables["AvailableUser"].Rows == null || ds.Tables["AvailableUser"].Rows.Count.Equals(0) ||
                    ds.Tables["AllUser"] == null || ds.Tables["AllUser"].Rows == null || ds.Tables["AllUser"].Rows.Count.Equals(0))
                {
                    throw new MofException("Өгөгдөл харах эрхгүй байна эсвэл хэрэглэгчийн мэдээлэл CMC буюу хүний нөөцийн системээс олдсонгүй!");
                }

                allHead           = ds.Tables["AllHead"];
                branchInfo        = ds.Tables["BranchInfo"];
                allUser           = ds.Tables["AllUser"];
                availableUsers    = ds.Tables["AvailableUser"];
                Tool.userDomainId = domainId;
                Tool.userStaffId  = decimal.Parse(ds.Tables["UserInfo"].Rows[0].ItemArray[0].ToString());
                Tool.userBrId     = decimal.Parse(ds.Tables["UserInfo"].Rows[0].ItemArray[1].ToString());
                Tool.userMainBrId = decimal.Parse(ds.Tables["UserInfo"].Rows[0].ItemArray[2].ToString());
                Tool.userLName    = ds.Tables["UserInfo"].Rows[0].ItemArray[3].ToString();
                Tool.userFName    = ds.Tables["UserInfo"].Rows[0].ItemArray[4].ToString();
                Tool.permissionId = decimal.Parse(ds.Tables["UserInfo"].Rows[0].ItemArray[5].ToString());

                Tool.xmlStr = ds.GetXml();
                DrawContent(FormType.IncomeList);
                InitMailNotification();
            }
            catch (MofException ex)
            {
                System.Diagnostics.Debug.WriteLine("Эрхийн мэдээлэлд алдаа гарлаа: " + ex.Message);
                Tool.ShowError(ex.Message, ex.InnerException.Message);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Эрхийн мэдээлэлд алдаа гарлаа: " + ex.Message);
                Tool.ShowError("Эрхийн мэдээлэлд алдаа гарлаа!", ex.Message);
            }
            finally
            {
                ds         = null; inputParameter = null; outputParameter = null;
                tableNames = null; Tool.CloseWaiting();
            }
        }
示例#10
0
 public DEMSourceConfiguration()
 {
     Oracle = new OracleConnector("geusjup3", 1685, "FPH.DKDHM10", "mike11cs", "mike11cspw", "jupiter");
     _st    = SourceType.HydroInform;
 }