Example #1
0
        private void RefreshStrip()
        {
            OracleDbService.ConnOpen();
            topToolStrip(
                OracleDbService.SelectSingleValue(@"SELECT
( SELECT OBJECT_NAME FROM all_objects WHERE UPPER( OBJECT_NAME ) like UPPER( '%pkg_update%' ) AND OBJECT_TYPE LIKE 'PACKAGE' ) ||
'(' || (SELECT STATUS FROM all_objects WHERE UPPER( OBJECT_NAME ) like UPPER( '%pkg_update%' ) AND OBJECT_TYPE LIKE 'PACKAGE' ) ||
',' || (SELECT STATUS FROM all_objects WHERE UPPER( OBJECT_NAME ) like UPPER( '%pkg_update%' ) AND OBJECT_TYPE LIKE 'PACKAGE BODY' ) || ')'
FROM dual"),
                "");

            topToolStrip(
                OracleDbService.SelectSingleValue(
                    $"SELECT USERNAME||'@'||DB_LINK from ALL_DB_LINKS WHERE db_link LIKE '%{AppConfig.OracleRemoteLinkName}%'"),
                "линк:");

            bottomStatusStrip(OracleDbService.SelectSingleValue(
                                  $@"SELECT * FROM dual@""{AppConfig.OracleRemoteLinkName}"""),
                              "");

            bottomStatusStrip(
                OracleDbService.SelectSingleValue(
                    "SELECT * FROM v$version WHERE BANNER LIKE '%Database%'"),
                "");

            topToolStrip(
                OracleDbService.SelectSingleValue(
                    $@"SELECT MAX(UPDATE_END) FROM abt.update_log2@""{AppConfig.OracleRemoteLinkName}"" WHERE SIGNATURE LIKE SYS_CONTEXT('USERENV','SERVER_HOST')|| '%'"),
                "посл. обнов.:");

            OracleDbService.conn.Close();
        }
Example #2
0
        string UpdateStart(string comment)
        {
            progressBar.Invoke(new Action(() => { progressBar.Value = 0; }));
            SetControlsEnabling(false);
            var start_time = OracleDateFormat(DateTime.Now);

            OracleDbService.ConnOpen();

            string SERVER_HOST = OracleDbService.SelectSingleValue($"SELECT SYS_CONTEXT('USERENV','SERVER_HOST') FROM dual");

            OracleDbService.ConnOpen();
            string signature = OracleDbService.SelectSingleValue($"SELECT '{SERVER_HOST}_'||to_char({start_time},'ddmmyyyy') FROM dual");
            int    signature_count
                = int.Parse(OracleDbService.SelectSingleValue(
                                $@"SELECT count(*) FROM abt.update_log2@""{AppConfig.OracleRemoteLinkName}"" where SIGNATURE='{signature}' and ""COMMENT""='{comment}'"));

            if (signature_count == 0)
            {
                OracleDbService.ConnOpen();
                OracleDbService.Insert($@"
insert into abt.update_log2@""{AppConfig.OracleRemoteLinkName}""
( SIGNATURE,UPDATE_START,""IP_ADDRESS"",""NETWORK_PROTOCOL"",""OS_USER"",""PROXY_USER"",""SESSION_USER"",""host"",""COMMENT"")
values
('{signature}'
, {start_time}
, '{OracleDbService.SelectSingleValue( "SELECT SYS_CONTEXT('USERENV','IP_ADDRESS') FROM dual" )}'
, '{OracleDbService.SelectSingleValue( "SELECT SYS_CONTEXT('USERENV','NETWORK_PROTOCOL') FROM dual" )}'
, '{OracleDbService.SelectSingleValue( "SELECT SYS_CONTEXT('USERENV','OS_USER') FROM dual" )}'
, '{OracleDbService.SelectSingleValue( "SELECT SYS_CONTEXT('USERENV','PROXY_USER') FROM dual" )}'
, '{OracleDbService.SelectSingleValue( "SELECT SYS_CONTEXT('USERENV','SESSION_USER') FROM dual" )}'
, '{SERVER_HOST}'
, '{comment}')");
            }

            OracleDbService.ConnOpen();
            OracleDbService.Insert($@"
UPDATE abt.update_log2@""{AppConfig.OracleRemoteLinkName}"" SET
  BAR_CODES = null
, CONTRACTORS = null
, COUNTRIES = null
, CUSTOMERS = null
, GOODS = null
, GROUPS = null
, GROUP_ITEMS = null
, ITEMS = null
, PRICES_CACHE = null
, UPDATE_START = {start_time}
, UPDATE_END = null
  WHERE SIGNATURE = '{signature}' and ""COMMENT""='{comment}'");

            return(signature);
        }
Example #3
0
        private void fullUpdateButton_Click(object sender, EventArgs e)
        {
            msg("ожидайте проверки всех параметров...", logList);
            task = Task.Factory.StartNew(() =>
            {
                OracleDbService.ConnOpen();

                if (!IsLinkExist)
                {
                    msg("линк\t...\tFAIL\t\t попытка пересоздать линк...", logList, Color.Orange);
                    CreateLink();
                    Task.Factory.StartNew(() =>
                    {
                        ConfigureView();
                    });
                    msg("линк\t...\tОК", logList, Color.LightGreen);
                }
                else
                {
                    msg("линк\t...\tОК", logList, Color.LightGreen);
                }

                if (!IsLinkHasCorrectUser)
                {
                    msg("юзер\t...\tFAIL\t\t попытка пересоздать юзера...", logList, Color.Orange);
                    RemoveLink();
                    CreateLink();
                    Task.Factory.StartNew(() =>
                    {
                        ConfigureView();
                    });
                    msg("юзер\t...\tОК", logList, Color.LightGreen);
                }
                else
                {
                    msg("юзер\t...\tОК", logList, Color.LightGreen);
                }

                if (!IsPkgExist || !IsPkgValid || !IsPkgBodyValid)
                {
                    msg("пакет\t...\tINVALID\t\t попытка пересоздать пакет...", logList, Color.Orange);
                    RemovePkg();
                    CreatePkg();
                    CreatePkgBody();
                    CompilePkg();
                    CompilePkgBody();
                    Task.Factory.StartNew(() =>
                    {
                        ConfigureView();
                    });
                    msg("пакет\t...\tVALID", logList, Color.LightGreen);
                }
                else
                {
                    msg("пакет\t...\tVALID", logList, Color.LightGreen);
                }

                OracleDbService.conn.Open();
                if (DownloadUpdate())
                {
                    OracleDbService.conn.Open();
                    if (ProcessUpdate())
                    {
                        ConfigureView();
                        MessageBox.Show(null,
                                        "Можете продолжить работу",
                                        "Обновление завершено!",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                    }
                }
                OracleDbService.conn.Close();
            },
                                         token);
        }