Beispiel #1
0
        public void TestFuncInParams()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                // function FuncInParams (p_int32 in number, p_double in number, p_date in date, p_string in varchar2, p_clob in clob, p_blob in blob) return clob;
                IDbCommand command = new OraCommand("test_pkg.FuncInParams");
                command.CommandType = System.Data.CommandType.StoredProcedure;

                OraParamCLOB returnParam = new OraParamCLOB("return", System.Data.ParameterDirection.ReturnValue, null);
                command.AddDBParam(returnParam);
                command.AddDBParam(new OraParamInt32("p_int32", System.Data.ParameterDirection.Input, 1234));
                command.AddDBParam(new OraParamDouble("p_double", System.Data.ParameterDirection.Input, 1234.23d));
                command.AddDBParam(new OraParamDateTime("p_date", System.Data.ParameterDirection.Input, DateTime.Now));
                command.AddDBParam(new OraParamString("p_string", System.Data.ParameterDirection.Input, "STRING qwe фывфыв"));
                command.AddDBParam(new OraParamCLOB("p_clob", System.Data.ParameterDirection.Input, "CLOB 123123 qweqweqweq йцуйцуйу"));
                command.AddDBParam(new OraParamBLOB("p_blob", System.Data.ParameterDirection.Input, new byte[] { 1, 2, 3, 4, 5, 6 }));

                using (DbTransaction transaction = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    transaction.Success = true;
                }

                string retStr = returnParam.ParamValue;
                Debug.Assert(!string.IsNullOrEmpty(retStr), "FuncInParams");
            }
        }
Beispiel #2
0
        public void TestDBSettingReadWriter()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                byte[] etalon_blob = new byte[] { 1, 2, 3, 4, 5, 4, 3, 2, 1, 23, 3, 4 };
                OraDBSettingReadWriter settingRW = new OraDBSettingReadWriter(dbManager, _LogMgr);
                settingRW.WriteValue("Setting1", "Simple string1");
                settingRW.WriteValue("Setting2", "Simple string2");
                settingRW.WriteValue("Setting3", "Long string - CLOB. ".PadRight(10000, '#'));
                settingRW.WriteValue("Setting4", string.Empty);
                settingRW.WriteValue("Setting5", (string)null);
                settingRW.WriteValue("SettingB1", etalon_blob);
                settingRW.WriteValue("SettingB2", new byte[] { });
                settingRW.WriteValue("SettingB3", (byte[])null);
                settingRW.Save("User1", "Section1", "Subsection1");

                string result      = null;
                byte[] result_blob = null;
                settingRW.Load("User1", "Section1", "Subsection1");

                Debug.Assert(!settingRW.ReadValue("Setting_?", out result), "Find non-exist setting");
                settingRW.ReadValue("Setting1", out result);
                Debug.Assert(result == "Simple string1", "Setting1 non-equal");
                settingRW.ReadValue("Setting2", out result);
                Debug.Assert(result == "Simple string2", "Setting2 non-equal");
                settingRW.ReadValue("Setting3", out result);
                Debug.Assert(result == "Long string - CLOB. ".PadRight(10000, '#'), "Setting3 CLOB non-equal");
                settingRW.ReadValue("Setting4", out result);
                Debug.Assert(string.IsNullOrEmpty(result), "Setting4 non-empty");
                settingRW.ReadValue("Setting5", out result);
                Debug.Assert(string.IsNullOrEmpty(result), "Setting5 non-empty");

                settingRW.ReadValue("SettingB1", out result_blob);
                for (int i = 0; i < result_blob.Length; i++)
                {
                    if (result_blob[i] != etalon_blob[i])
                    {
                        Debug.Assert(false, "SettingB1. Blob byte[" + i.ToString() + "] non-equal");
                        return;
                    }
                }
                settingRW.ReadValue("SettingB2", out result_blob);
                Debug.Assert(result_blob == null, "SettingB2 non-null");

                settingRW.ReadValue("SettingB3", out result_blob);
                Debug.Assert(result_blob == null, "SettingB3 non-null");

                settingRW.Load("User__2", "Section1", "Subsection1");
                Debug.Assert(!settingRW.ReadValue("Setting1", out result), "Find setting of non-exist user");

                settingRW.Load("User1", "Section__2", "Subsection1");
                Debug.Assert(!settingRW.ReadValue("Setting1", out result), "Find setting of non-exist section");

                settingRW.Load("User1", "Section1", "Subsection__2");
                Debug.Assert(!settingRW.ReadValue("Setting1", out result), "Find setting of non-exist subsection");
            }
        }
Beispiel #3
0
        public void TestProcRefCur()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                // procedure ProcRefCur (p_date out date, p_cur in out sys_refcursor) as
                IDbCommand command = new OraCommand("test_pkg.ProcRefCur");
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddDBParam(new OraParamDateTime("p_date", System.Data.ParameterDirection.Output, null));
                OraParamRefCursor refCur = new OraParamRefCursor("p_cur", System.Data.ParameterDirection.InputOutput);
                command.AddDBParam(refCur);

                using (DbTransaction transaction = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    transaction.Success = true;
                }

                Debug.Assert(refCur.ParamValue.Rows.Count != 0, "p_cur");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[0] != null, "p_cur[0][0]");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[1] != null, "p_cur[0][1]");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[2] != null, "p_cur[0][2]");
                Debug.Assert(command.Params["p_date"].GetValue() != null, "p_date");

                object o  = refCur.ParamValue.Rows[0]["blob_"];
                byte[] ba = (byte[])o;
            }
        }
Beispiel #4
0
        public void TestNullNotChanged()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingWithNullNotChangedAttributeProperties setting = new SettingWithNullNotChangedAttributeProperties();
                setting.Init();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);

                OraCommand command = new OraCommand("delete from test_setting");
                command.CommandType = System.Data.CommandType.Text;
                using (DbTransaction tr = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    tr.Success = true;
                }

                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting);

                Debug.Assert(setting.String1Property == "str", "String1Property is changed");
                Debug.Assert(setting.PointProperty == new Point(11, 22), "PointProperty is changed");
                Debug.Assert(SettingListProperties.CompareLists <string>(setting.StringListProperty, new List <string>()
                {
                    "1", "2"
                }), "StringListProperty is changed");
            }
        }
Beispiel #5
0
        public void TesIgnoreAttribute()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingWithIgnoreAttributeProperties setting = new SettingWithIgnoreAttributeProperties();
                setting.Init();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);
                setting.PointProperty      = new Point(33, 44);
                setting.String1Property    = "after";
                setting.StringListProperty = new List <string>()
                {
                    "22", "33"
                };
                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting);

                Debug.Assert(setting.String1Property == "after", "String1Property not ignored");
                Debug.Assert(setting.PointProperty == new Point(33, 44), "PointProperty not ignored");
                Debug.Assert(SettingListProperties.CompareLists <string>(setting.StringListProperty, new List <string>()
                {
                    "22", "33"
                }), "StringListProperty not ignored");
            }
        }
Beispiel #6
0
        public void TestNullToEmptyAttribute()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingWithNullToEmptyAttributeProperties setting = new SettingWithNullToEmptyAttributeProperties();
                setting.Init();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);

                OraCommand command = new OraCommand("delete from test_setting");
                command.CommandType = System.Data.CommandType.Text;
                using (DbTransaction tr = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    tr.Success = true;
                }

                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting);

                Debug.Assert(setting.String1Property != null, "Null string property");
                Debug.Assert(setting.PointProperty == Point.Empty, "Not empty Point property");
                Debug.Assert(setting.StringListProperty != null, "String list property is null");
                Debug.Assert(setting.BlobProperty != null, "Blob list property is null");
                Debug.Assert(setting.FontProperty != null, "Font list property is null");
            }
        }
Beispiel #7
0
        public void TestFuncNullOutParams()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                // function FuncNullOutParams (p_int32 out number, p_double out number, p_date out date, p_string out varchar2, p_clob out clob, p_blob out blob) return blob;
                IDbCommand command = new OraCommand("test_pkg.FuncNullOutParams");
                command.CommandType = System.Data.CommandType.StoredProcedure;

                OraParamString returnParam = new OraParamString("return", System.Data.ParameterDirection.ReturnValue, null);
                command.AddDBParam(returnParam);
                command.AddDBParam(new OraParamInt32("p_int32", System.Data.ParameterDirection.Output, null));
                command.AddDBParam(new OraParamDouble("p_double", System.Data.ParameterDirection.Output, null));
                command.AddDBParam(new OraParamDateTime("p_date", System.Data.ParameterDirection.Output, null));
                command.AddDBParam(new OraParamString("p_string", System.Data.ParameterDirection.Output, null, 2000));
                command.AddDBParam(new OraParamCLOB("p_clob", System.Data.ParameterDirection.Output, null));
                command.AddDBParam(new OraParamBLOB("p_blob", System.Data.ParameterDirection.Output, (byte[])null));

                using (DbTransaction transaction = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    transaction.Success = true;
                }

                Debug.Assert(returnParam.ParamValue == null, "returnParam");
                Debug.Assert(command.Params["p_int32"].GetValue() == null, "p_int32");
                Debug.Assert(command.Params["p_double"].GetValue() == null, "p_double");
                Debug.Assert(command.Params["p_date"].GetValue() == null, "p_date");
                Debug.Assert(command.Params["p_string"].GetValue() == null, "p_string");
                Debug.Assert(command.Params["p_clob"].GetValue() == null, "p_clob");
                Debug.Assert(command.Params["p_blob"].GetValue() == null, "p_blob");
            }
        }
Beispiel #8
0
        public void TestFuncRefCur()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                // function FuncRefCur(p_int32 in number, p_clob in out number, p_cur out sys_refcursor) return date;
                IDbCommand command = new OraCommand("test_pkg.FuncRefCur");
                command.CommandType = System.Data.CommandType.StoredProcedure;

                OraParamDateTime returnParam = new OraParamDateTime("return", System.Data.ParameterDirection.ReturnValue, null);
                command.AddDBParam(returnParam);
                command.AddDBParam(new OraParamInt32("p_int32", System.Data.ParameterDirection.Input, null));
                command.AddDBParam(new OraParamCLOB("p_clob", System.Data.ParameterDirection.InputOutput, "132"));
                OraParamRefCursor refCur = new OraParamRefCursor("p_cur", System.Data.ParameterDirection.Output);
                command.AddDBParam(refCur);

                using (DbTransaction transaction = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    transaction.Success = true;
                }

                Debug.Assert(refCur.ParamValue.Rows.Count != 0, "p_cur");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[0] != null, "p_cur[0][0]");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[1] != null, "p_cur[0][1]");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[2] != null, "p_cur[0][2]");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[3] != null, "p_cur[0][3]");
                Debug.Assert(command.Params["p_clob"].GetValue() != null, "p_clob");
                Debug.Assert(command.Params["return"].GetValue() != null, "return");
            }
        }
Beispiel #9
0
        private void ButtonRun_Click(object sender, EventArgs e)
        {
            var conn = new OraConnection();

            conn.CreateNewConnection("Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=11.22.33.44)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=CUSTOMDB)));User Id=system;Password=System01;");
            var obj = conn.GetScalar(@"select {0} from dual", string.Empty);

            //var date = conn.TestMethod();
            //textBoxResult.Text = date.ToString();
            //textBoxResult.Text += Environment.NewLine;
            //textBoxResult.Text += conn.TestMethodTwo(514);
            conn.CloseConnection();
        }
Beispiel #10
0
        public void TestFuncAll()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                // function FuncAll(p_int32 in out number, p_double in out number, p_date in out date, p_string in out varchar2, p_clob in out clob, p_blob in out blob, p_cur out sys_refcursor, p_cur2 in out sys_refcursor) return varchar2;
                IDbCommand command = new OraCommand("test_pkg.FuncAll");
                command.CommandType = System.Data.CommandType.StoredProcedure;

                OraParamString returnParam = new OraParamString("return", System.Data.ParameterDirection.ReturnValue, null, 2000);
                command.AddDBParam(returnParam);
                command.AddDBParam(new OraParamInt32("p_int32", System.Data.ParameterDirection.InputOutput, null));
                command.AddDBParam(new OraParamDouble("p_double", System.Data.ParameterDirection.InputOutput, -1.234));
                command.AddDBParam(new OraParamDateTime("p_date", System.Data.ParameterDirection.InputOutput, DateTime.Now));
                command.AddDBParam(new OraParamString("p_string", System.Data.ParameterDirection.InputOutput, "INPUT ", 2000));
                command.AddDBParam(new OraParamCLOB("p_clob", System.Data.ParameterDirection.InputOutput, null));
                command.AddDBParam(new OraParamBLOB("p_blob", System.Data.ParameterDirection.InputOutput, (byte[])null));
                OraParamRefCursor refCur = new OraParamRefCursor("p_cur", System.Data.ParameterDirection.Output);
                command.AddDBParam(refCur);
                OraParamRefCursor refCur2 = new OraParamRefCursor("p_cur2", System.Data.ParameterDirection.InputOutput);
                command.AddDBParam(refCur2);

                using (DbTransaction transaction = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    transaction.Success = true;
                }

                Debug.Assert(returnParam.ParamValue != null, "returnParam");
                Debug.Assert(command.Params["p_int32"].GetValue() != null, "p_int32");
                Debug.Assert(command.Params["p_double"].GetValue() != null, "p_double");
                Debug.Assert(command.Params["p_date"].GetValue() != null, "p_date");
                Debug.Assert(command.Params["p_string"].GetValue() != null, "p_string");
                Debug.Assert(command.Params["p_clob"].GetValue() != null, "p_clob");
                Debug.Assert(command.Params["p_blob"].GetValue() != null, "p_blob");

                Debug.Assert(refCur.ParamValue.Rows.Count != 0, "p_cur");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[0] != null, "p_cur[0][0]");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[1] != null, "p_cur[0][1]");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[2] != null, "p_cur[0][2]");
                Debug.Assert(refCur.ParamValue.Rows[0].ItemArray[3] != null, "p_cur[0][3]");

                Debug.Assert(refCur2.ParamValue.Rows.Count != 0, "p_cur2");
                Debug.Assert(refCur2.ParamValue.Rows[0].ItemArray[0] != null, "p_cur2[0][0]");
                Debug.Assert(refCur2.ParamValue.Rows[0].ItemArray[1] != null, "p_cur2[0][1]");
                Debug.Assert(refCur2.ParamValue.Rows[0].ItemArray[2] != null, "p_cur2[0][2]");
            }
        }
Beispiel #11
0
        public void TestSQLQuery()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                IDbCommand command = new OraCommand("select sysdate from dual");
                command.CommandType = System.Data.CommandType.Text;

                System.Data.DataTable tab = dbManager.ExecuteSelect(command);

                Debug.Assert(tab.Rows.Count != 0, "DataTable");
                DateTime date = (DateTime)tab.Rows[0]["sysdate"];
            }
        }
Beispiel #12
0
        public void TestNullToDefault()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingWithNullToDefaultAttributeProperties setting = new SettingWithNullToDefaultAttributeProperties();
                setting.Init();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);

                OraCommand command = new OraCommand("delete from test_setting");
                command.CommandType = System.Data.CommandType.Text;
                using (DbTransaction tr = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    tr.Success = true;
                }

                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting);

                Debug.Assert(setting.BoolProperty == false, "BoolProperty not equal to default");
                Debug.Assert(setting.String1Property == "default", "String1Property not equal to default");
                Debug.Assert(setting.PointProperty == new Point(55, 77), "PointProperty not equal to default");
                Debug.Assert(setting.SizeProperty == new Size(88, 99), "SizeProperty not equal to default");
                Debug.Assert(setting.DateTimeProperty == new DateTime(1111, 11, 11, 11, 11, 11), "DateTime not equal to default");
                Debug.Assert(setting.DateTime2Property == new DateTime(1111, 11, 11, 11, 11, 11), "DateTime2 not equal to default");
                Debug.Assert(setting.DateTime3Property == null, "DateTime3 not equal to default");
                Debug.Assert(SettingBlobProperties.CompareBlobs(setting.BlobProperty, new byte[] { 1, 2, 3, 4 }), "BlobProperty not equal to default");
                Debug.Assert(SettingListProperties.CompareLists <string>(setting.StringListProperty, new List <string>()
                {
                    "1", "2", "3", "4"
                }), "StringListProperty not equal to default");

                /*Debug.Assert(SettingListProperties.CompareLists<Font>(setting.FontListProperty, new List<Font>() {new Font("Arial", 10, FontStyle.Bold),
                 *                                                                                                new Font("Arial", 10, FontStyle.Bold),
                 *                                                                                                new Font("Arial", 10, FontStyle.Bold)}), "FontListProperty not equal to default");
                 * Debug.Assert(Font.Equals(setting.FontProperty, new Font("Arial", 10, FontStyle.Bold)), "FontProperty not equal to default");*/
                Debug.Assert(setting.TestEnumProperty == TestEnum.Unknown, "TestEnumProperty not equal to default");
                Debug.Assert(setting.TestEnumFlagProperty == (TestEnumFlag.First | TestEnumFlag.Second), "TestEnumFlagProperty not equal to default");
            }
        }
Beispiel #13
0
        private void InitCoreService()
        {
            IDbConnection dbConnection = new OraConnection();

            CompositionContainer.ComposeExportedValue <IDbConnection>(dbConnection);

            _dbMgr = new OraDBMgr(dbConnection, LogMgr);
            CompositionContainer.ComposeExportedValue <IDbMgr>(_dbMgr);

            _settingMgr = new SettingMgr(LogMgr);
            _settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(_dbMgr, LogMgr);
            CompositionContainer.ComposeExportedValue <ISettingMgr>(_settingMgr);

            _regionMgr = new RegionMgr(LogMgr);
            CompositionContainer.ComposeExportedValue <IRegionMgr>(_regionMgr);

            int firstMenuIndex = 2;
            BarCommandRegion mainMenuRegion = new BarCommandRegion(RegionName.MainMenu, _mainForm.MainMenu, firstMenuIndex);

            _regionMgr.AddCommandRegion(RegionName.MainMenu, new MainMenuCommandRegionDecorator(RegionName.MainMenu, mainMenuRegion));
            _regionMgr.AddCommandRegion(RegionName.PlugginMenuItem, new SubMenuCommandRegionDecorator(RegionName.PlugginMenuItem, mainMenuRegion, _mainForm.PlugginBarButtonItem));

            int firstToolBarIndex          = 2;
            BarCommandRegion toolBarRegion = new BarCommandRegion(RegionName.MainToolBar, _mainForm.MainToolBar, firstToolBarIndex);

            _regionMgr.AddCommandRegion(RegionName.MainToolBar, toolBarRegion);

            IViewRegion documentRegion = new DocumentViewRegion(RegionName.DocumentRegion, _mainForm.MainDocumentManager, _mainForm.MainDockManager, LogMgr);

            _regionMgr.AddViewRegion(RegionName.DocumentRegion, documentRegion);

            IViewRegion dockPanelRegion = new DockingViewRegion(RegionName.DockPanelRegion, _mainForm.MainDocumentManager, _mainForm.MainDockManager, LogMgr);

            _regionMgr.AddViewRegion(RegionName.DockPanelRegion, dockPanelRegion);

            IViewFormMgr viewFormMgr = new ViewFormMgr(_mainForm, _mainForm.MainTaskBar, LogMgr);

            CompositionContainer.ComposeExportedValue <IViewFormMgr>(viewFormMgr);

            IMessageBoxMgr messageBoxMgr = new MessageBoxMgr(_mainForm, LogMgr, null, typeof(MainWaitForm));

            CompositionContainer.ComposeExportedValue <IMessageBoxMgr>(messageBoxMgr);

            _plugginMgr = ServiceMgr.Current.GetInstance <IPlugginMgr>();
            _eventMgr   = ServiceMgr.Current.GetInstance <IEventMgr>();
        }
Beispiel #14
0
        public void TestSQLQuery5()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                IDbCommand command = new OraCommand("begin execute immediate 'create or replace view test_view as select 1 col_name from dual'; end;");
                command.CommandType = System.Data.CommandType.Text;

                using (DbTransaction transaction = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    transaction.Success = true;
                }
            }
        }
Beispiel #15
0
        public void TestConnection()
        {
            using (IDbConnection conn = new OraConnection())
            {
                Debug.Assert(!conn.IsOpenConnection, "IsConnect1");
                Debug.Assert(!conn.CheckConnection(), "CheckConnection1");

                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                Debug.Assert(conn.CheckConnection(), "CheckConnection2");
                Debug.Assert(conn.IsOpenConnection, "IsConnect2");

                conn.TestConnection();
                Debug.Assert(conn.CheckConnection(), "CheckConnection3");
                Debug.Assert(conn.IsOpenConnection, "IsConnect3");

                conn.CloseConnection();
                Debug.Assert(!conn.IsOpenConnection, "IsConnect4");
                Debug.Assert(!conn.CheckConnection(), "CheckConnection4");

                conn.ReConnect();
                Debug.Assert(conn.IsOpenConnection, "IsConnect5");
                Debug.Assert(conn.CheckConnection(), "CheckConnection5");

                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                Debug.Assert(conn.CheckConnection(), "CheckConnection6");
                Debug.Assert(conn.IsOpenConnection, "IsConnect6");

                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                conn.ReConnect();
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                Debug.Assert(conn.CheckConnection(), "CheckConnection7");
                Debug.Assert(conn.IsOpenConnection, "IsConnect7");


                conn.ReConnect();
                conn.ReConnect();
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                conn.CloseConnection();
                conn.CloseConnection();
                conn.ReConnect();
                Debug.Assert(conn.CheckConnection(), "CheckConnection8");
                Debug.Assert(conn.IsOpenConnection, "IsConnect8");
            }
        }
Beispiel #16
0
        public void TestSQLQuery3()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                IDbCommand command = new OraCommand("insert into  test_tab (int32, double, string, datetime) values (1, 1.2, '123', sysdate)");
                command.CommandType = System.Data.CommandType.Text;

                using (DbTransaction transaction = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    dbManager.Execute(command);
                    dbManager.Execute(command);
                    transaction.Success = true;
                }
            }
        }
Beispiel #17
0
        public void TestSQLQuery4()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                IDbCommand command = new OraCommand("update test_tab set int32 = :param1 where string = :param2 returning count(*) into :param3");
                command.CommandType = System.Data.CommandType.Text;

                command.AddDBParam(new OraParamInt32(":param1", System.Data.ParameterDirection.Input, 222));
                command.AddDBParam(new OraParamString(":param2", System.Data.ParameterDirection.Input, "123", 100));
                command.AddDBParam(new OraParamInt32(":param3", System.Data.ParameterDirection.Output, null));

                using (DbTransaction transaction = new DbTransaction(dbManager))
                {
                    dbManager.Execute(command);
                    transaction.Success = true;
                }
            }
        }
Beispiel #18
0
        public void TestSaveLoadListProperty()
        {
            SettingMgr settingMgr = new SettingMgr(_LogMgr);

            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                settingMgr.ReadWriteProvider = new OraDBSettingReadWriter(dbManager, _LogMgr);

                SettingListProperties setting = new SettingListProperties();
                setting.Init();
                SettingListProperties setting2 = new SettingListProperties();

                settingMgr.SaveSettings("User2", "Section1", "Subsection1", setting);
                settingMgr.LoadSetting("User2", "Section1", "Subsection1", setting2);

                Debug.Assert(setting.Equals(setting2), "2. Saved and loaded settings are not equal (List types).");
            }
        }
Beispiel #19
0
        public void TestSQLQuery2()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                IDbCommand command = new OraCommand("select to_date('01.01.1111 01:01:01', 'dd.mm.yyyy hh24:mi:ss') col_date, '1+2' col_str, 1+2 col_num from dual");
                command.CommandType = System.Data.CommandType.Text;

                System.Data.DataTable tab = dbManager.ExecuteSelect(command);

                Debug.Assert(tab.Rows.Count != 0, "DataTable");
                DateTime date = (DateTime)tab.Rows[0]["col_date"];
                Debug.Assert(date == new DateTime(1111, 1, 1, 1, 1, 1), "DateEqual");

                string str = tab.Rows[0]["col_str"].ToString();
                Debug.Assert(string.Equals(str, "1+2"), "StrEqual");

                Int32 n = Convert.ToInt32(tab.Rows[0]["col_num"]);
                Debug.Assert(n == 1 + 2, "NumEqual");
            }
        }
Beispiel #20
0
        public void TestProcNullInParams()
        {
            using (IDbConnection conn = new OraConnection())
            {
                conn.OpenConnection("chipanddale", "chipanddale", "xe");
                IDbMgr dbManager = new OraDBMgr(conn, _LogMgr);

                // procedure ProcInParams (p_int32 in number, p_double in number, p_date in date, p_string in varchar2, p_clob in clob, p_blob in blob);
                IDbCommand command = new OraCommand("test_pkg.ProcInParams");
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddDBParam(new OraParamInt32("p_int32", System.Data.ParameterDirection.Input, null));
                command.AddDBParam(new OraParamDouble("p_double", System.Data.ParameterDirection.Input, null));
                command.AddDBParam(new OraParamDateTime("p_date", System.Data.ParameterDirection.Input, null));
                command.AddDBParam(new OraParamString("p_string", System.Data.ParameterDirection.Input, null));
                command.AddDBParam(new OraParamCLOB("p_clob", System.Data.ParameterDirection.Input, null));
                command.AddDBParam(new OraParamBLOB("p_blob", System.Data.ParameterDirection.Input, (byte[])null));

                dbManager.StartTransaction();
                dbManager.Execute(command);
                dbManager.RollbackTransaction();
            }
        }
Beispiel #21
0
        public void TestMultiTread2()
        {
            Thread thread1 = new Thread(() =>
            {
                using (IDbConnection conn = new OraConnection())
                {
                    conn.OpenConnection("chipanddale", "chipanddale", "xe");
                    IDbMgr dbManager    = new OraDBMgr(conn, _LogMgr);
                    IDbCommand command  = new OraCommand("select * from all_objects");
                    command.CommandType = System.Data.CommandType.Text;

                    System.Data.DataTable tab = null;
                    for (int i = 0; i < 50; i++)
                    {
                        tab = dbManager.ExecuteSelect(command);
                    }
                }
            });

            Thread thread2 = new Thread(() =>
            {
                using (IDbConnection conn = new OraConnection())
                {
                    conn.OpenConnection("chipanddale", "chipanddale", "xe");
                    IDbMgr dbManager    = new OraDBMgr(conn, _LogMgr);
                    IDbCommand command  = new OraCommand("insert into  test_tab (int32, double, string, datetime) values (1, 1.2, '123', sysdate)");
                    command.CommandType = System.Data.CommandType.Text;

                    using (DbTransaction transaction = new DbTransaction(dbManager))
                    {
                        for (int i = 0; i < 1000; i++)
                        {
                            dbManager.Execute(command);
                        }
                        transaction.Success = true;
                    }
                }
            });

            Thread thread3 = new Thread(() =>
            {
                using (IDbConnection conn = new OraConnection())
                {
                    conn.OpenConnection("chipanddale", "chipanddale", "xe");
                    IDbMgr dbManager    = new OraDBMgr(conn, _LogMgr);
                    IDbCommand command  = new OraCommand("begin execute immediate 'create or replace view test_view as select 1 col_name from dual'; end;");
                    command.CommandType = System.Data.CommandType.Text;

                    for (int i = 0; i < 100; i++)
                    {
                        dbManager.Execute(command);
                    }
                }
            });

            Thread thread4 = new Thread(() =>
            {
                using (IDbConnection conn = new OraConnection())
                {
                    conn.OpenConnection("chipanddale", "chipanddale", "xe");
                    IDbMgr dbManager    = new OraDBMgr(conn, _LogMgr);
                    IDbCommand command  = new OraCommand("test_pkg.FuncAll");
                    command.CommandType = System.Data.CommandType.StoredProcedure;

                    for (int i = 0; i < 100; i++)
                    {
                        command.Params.Clear();
                        OraParamString returnParam = new OraParamString("return", System.Data.ParameterDirection.ReturnValue, null, 2000);
                        command.AddDBParam(returnParam);
                        command.AddDBParam(new OraParamInt32("p_int32", System.Data.ParameterDirection.InputOutput, null));
                        command.AddDBParam(new OraParamDouble("p_double", System.Data.ParameterDirection.InputOutput, -1.234));
                        command.AddDBParam(new OraParamDateTime("p_date", System.Data.ParameterDirection.InputOutput, DateTime.Now));
                        command.AddDBParam(new OraParamString("p_string", System.Data.ParameterDirection.InputOutput, "INPUT ", 2000));
                        command.AddDBParam(new OraParamCLOB("p_clob", System.Data.ParameterDirection.InputOutput, null));
                        command.AddDBParam(new OraParamBLOB("p_blob", System.Data.ParameterDirection.InputOutput, (byte[])null));
                        OraParamRefCursor refCur = new OraParamRefCursor("p_cur", System.Data.ParameterDirection.Output);
                        command.AddDBParam(refCur);
                        OraParamRefCursor refCur2 = new OraParamRefCursor("p_cur2", System.Data.ParameterDirection.InputOutput);
                        command.AddDBParam(refCur2);
                        using (DbTransaction transaction = new DbTransaction(dbManager))
                        {
                            dbManager.Execute(command);
                            dbManager.Execute(command);
                            transaction.Success = true;
                        }
                    }
                }
            });

            Thread thread5 = new Thread(() =>
            {
                using (IDbConnection conn = new OraConnection())
                {
                    conn.OpenConnection("chipanddale", "chipanddale", "xe");
                    IDbMgr dbManager    = new OraDBMgr(conn, _LogMgr);
                    IDbCommand command  = new OraCommand("insert into  test_tab (int32, double, string, datetime) values (1, 1.2, '123', sysdate)");
                    command.CommandType = System.Data.CommandType.Text;

                    using (DbTransaction transaction = new DbTransaction(dbManager))
                    {
                        for (int i = 0; i < 1000; i++)
                        {
                            dbManager.Execute(command);
                        }
                        transaction.Success = true;
                    }
                }
            });

            Thread thread6 = new Thread(() =>
            {
                using (IDbConnection conn = new OraConnection())
                {
                    conn.OpenConnection("chipanddale", "chipanddale", "xe");
                    IDbMgr dbManager    = new OraDBMgr(conn, _LogMgr);
                    IDbCommand command  = new OraCommand("insert into  test_tab (int32, double, string, datetime) values (1, 1.2, '123', sysdate)");
                    command.CommandType = System.Data.CommandType.Text;

                    for (int i = 0; i < 1000; i++)
                    {
                        using (DbTransaction transaction = new DbTransaction(dbManager))
                        {
                            dbManager.Execute(command);
                            transaction.Success = true;
                        }
                    }
                }
            });

            thread1.Start();
            thread2.Start();
            thread3.Start();
            thread4.Start();
            thread5.Start();
            thread6.Start();

            thread1.Join();
            thread2.Join();
            thread3.Join();
            thread4.Join();
            thread5.Join();
            thread6.Join();
        }