Beispiel #1
0
        private static void Conn_StateChange(object sender, StateChangeEventArgs e)
        {
            MyConsole.Info(e.CurrentState.ToString());

            if (e.CurrentState == ConnectionState.Broken || e.CurrentState == ConnectionState.Closed)
            {
                MyConsole.Error("Oracle: connection lost");
                try
                {
                    OracleConnection conn = (OracleConnection)sender;
                    conn.Open();
                }
                catch (Exception ex)
                {
                    MyConsole.Error(ex.Message);
                    return;
                }
                MyConsole.Info("Oracle: connection successful");
            }
        }
Beispiel #2
0
            public string Put(int UserID, string text)
            {
                OracleCommand cmd = HydraBilling.GetOracleCommand("SI_SUBJECTS_PKG.SI_SUBJ_COMMENTS_PUT", conn);

                cmd.Parameters.Add("num_N_LINE_ID", OracleDbType.Int32);
                cmd.Parameters["num_N_LINE_ID"].Direction = ParameterDirection.InputOutput;
                cmd.Parameters["num_N_LINE_ID"].Value     = null;
                cmd.Parameters.Add("num_N_SUBJECT_ID", OracleDbType.Int32, UserID, ParameterDirection.Input);
                cmd.Parameters.Add("clb_CL_COMMENT", OracleDbType.Clob, text, ParameterDirection.Input);
                try
                {
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
                catch (Exception e)
                {
                    MyConsole.Error(e.Message);
                }

                return(new Result().GetResultString("OK", "", int.Parse(cmd.Parameters["num_N_LINE_ID"].Value.ToString())));
            }
Beispiel #3
0
        static void Main(string[] args)
        {
            //Переменные программы
            int    webServerPort  = 8081;
            string oracleHost     = "";
            int    oraclePort     = 1521;
            string oracleSid      = "hydra";
            string oracleUser     = "******";
            string oraclePassword = "";

            //Переменный класса
            OracleConnection conn;
            HttpServer       httpServer;
            Thread           threadWD;
            Thread           thread;

            log4net.Config.XmlConfigurator.Configure();

            var route_config = new List <Route>()
            {
                new Route {
                    Name     = "Run query",
                    UrlRegex = @"^/Query/(.*)$",
                    Method   = "POST",
                    Callable = RunQuery
                },
                new Route {
                    Name     = "Run procedure",
                    UrlRegex = @"^/Procedure/(.*)$",
                    Method   = "POST",
                    Callable = RunProcedure
                },
            };

            conn = DBUtils.GetDBConnection(oracleHost, oraclePort, oracleSid, oracleUser, oraclePassword);
            MyConsole.Info("Oracle: get connection: " + conn);
            try
            {
                conn.Open();
                MyConsole.Info("Oracle: connection successful");

                MyConsole.Info("Hydra billing: init start");
                HydraBilling.Context.Init(conn);
                MyConsole.Info("Hydra billing: init complite");
                conn.Close();
            }
            catch (Exception ex)
            {
                MyConsole.Error(ex.Message);
                Console.Read();
                return;
            }

            MyConsole.Info("Web server: starting");
            httpServer = new HttpServer(webServerPort, route_config);
            thread     = new Thread(new ThreadStart(httpServer.Listen));
            thread.Start();

            Thread.Sleep(100);
            if (!thread.IsAlive)
            {
                MyConsole.Error(httpServer.error);
                Console.Read();
                return;
            }
            MyConsole.Info("Web server: started");



            /*using (DbDataReader reader = cmd.ExecuteReader())
             * {
             *  if (reader.HasRows)
             *  {
             *
             *      while (reader.Read())
             *      {
             *          // Get index of Column Emp_ID in query statement.
             *          int empIdIndex = reader.GetOrdinal("Emp_Id"); // 0
             *
             *
             *          long empId =  Convert.ToInt64(reader.GetValue(0));
             *
             *          // Index of Emp_ID = 1
             *          string empNo = reader.GetString(1);
             *          int empNameIndex = reader.GetOrdinal("Emp_Name");// 2
             *          string empName = reader.GetString(empNameIndex);
             *
             *          // Index of column Mng_Id.
             *          // Chỉ số (index) của cột Mng_Id trong câu lệnh SQL.
             *          int mngIdIndex = reader.GetOrdinal("Mng_Id");
             *
             *          long? mngId = null;
             *
             *          if (!reader.IsDBNull(mngIdIndex))
             *          {
             *              mngId = Convert.ToInt64(reader.GetValue(mngIdIndex));
             *          }
             *          Console.WriteLine("--------------------");
             *          Console.WriteLine("empIdIndex:" + empIdIndex);
             *          Console.WriteLine("EmpId:" + empId);
             *          Console.WriteLine("EmpNo:" + empNo);
             *          Console.WriteLine("EmpName:" + empName);
             *          Console.WriteLine("MngId:" + mngId);
             *      }
             *  }
             * }*/
            /*conn.Open();
             * using (DbDataReader dbReader = DBOracleUtils.OracleQuery("select VC_SUBJ_NAME from SI_V_USERS", conn))
             * {
             *  while (dbReader.Read())
             *  {
             *      int empNameIndex = dbReader.GetOrdinal("VC_SUBJ_NAME");// 2
             *      string empName = dbReader.GetString(empNameIndex);
             *      Console.WriteLine("VC_SUBJ_NAME:" + empName);
             *  }
             * }
             * conn.Close();*/
        }