Exemplo n.º 1
0
        private void Restart()
        {
            fctSQL.AppendText($@"{StaticFunctionsClass.DateTimeNowStr()} Event tracking stopped...{Environment.NewLine}");
            hsTracking.Marked = false;
            List <string> events = new List <string>();

            foreach (ListViewItem lvi in lvEvents.Items)
            {
                if (string.IsNullOrEmpty(lvi.Text))
                {
                    continue;
                }
                events.Add(lvi.Text);
            }
            if (events.Count > 0)
            {
                revent.CancelEvents();
                revent.QueueEvents(events.ToArray());


                //revent.QueueEvents(new string[] { "new_user","update_user" });

                fctSQL.AppendText($@"{StaticFunctionsClass.DateTimeNowStr()} Event tracking restarted...{Environment.NewLine}");
                hsTracking.Marked = true;
            }
            else
            {
                fctSQL.AppendText($@"{StaticFunctionsClass.DateTimeNowStr()} No events will be tracked !!!{Environment.NewLine}");
            }
        }
Exemplo n.º 2
0
        public string GetTypeString(DBDataTypes type, string fieldlength, string fieldprec, string fieldscale)
        {
            if (type.GetType() == typeof(DBVarchar))
            {
                int length = StaticFunctionsClass.ToIntDef(fieldlength, 0);
                if (length <= 0)
                {
                    length = StaticFunctionsClass.ToIntDef(fieldlength, 0);
                }
                return($@"VARCHAR({length})");
            }
            else if (type.GetType() == typeof(DBNumeric))
            {
                // NUMERIC(8, 3)
                int prec   = StaticFunctionsClass.ToIntDef(fieldprec, 0);
                int digits = StaticFunctionsClass.ToIntDef(fieldscale, 0);
                if (digits >= prec)
                {
                    txtPrecisionLength.Text = "1";
                    txtScale.Text           = "0";
                    prec   = 1;
                    digits = 0;
                }
                return($@"NUMERIC({prec},{digits})");
            }

            return(type.ToString());
        }
Exemplo n.º 3
0
        private void SpaltenNotify_SpaltenOnRaiseInfoHandler(object sender, MessageEventArgs k)
        {
            if (dgvResults.Columns.Count <= 0)
            {
                return;
            }
            if (k.Key.ToString() == SESpaltenEditor.Consts.ChangeCheckKey)
            {
                int n = StaticFunctionsClass.ToIntDef(k.Meldung, -1);
                if ((n >= 0) && (dgvResults.Columns.Count > n))
                {
                    dgvResults.Columns[n].Visible = (bool)k.Data;
                }
            }
            else if (k.Key.ToString() == SESpaltenEditor.Consts.SwapItemKey)
            {
                //Columns swapped
                Point pt = (Point)k.Data;
                int   d1 = dgvResults.Columns[pt.X].DisplayIndex;
                int   d2 = dgvResults.Columns[pt.Y].DisplayIndex;

                dgvResults.Columns[pt.X].DisplayIndex = d2;
                dgvResults.Columns[pt.Y].DisplayIndex = d1;
            }
            else if (k.Key.ToString() == SESpaltenEditor.Consts.CloseForm)
            {
                gridStore.StoreGridDesign();
            }
        }
Exemplo n.º 4
0
        public int RefreshDependenciesTo()
        {
            string cmd_index0      = "SELECT RDB$DEPENDENCIES.RDB$FIELD_NAME as Field ,RDB$DEPENDENCIES.RDB$DEPENDENT_NAME as DepentTo,CASE RDB$DEPENDENCIES.RDB$DEPENDENT_TYPE";
            string case0           = EnumClass.Instance.GetDependenciesTypeSQLCase() + " AS  DependentType FROM RDB$DEPENDENCIES";
            string cmd_index_where = "WHERE UPPER(RDB$DEPENDENCIES.RDB$DEPENDED_ON_NAME) = '" + TriggerObject.Name + "' AND RDB$DEPENDENCIES.RDB$FIELD_NAME IS NOT NULL";
            string cmd_index_order = "ORDER BY RDB$DEPENDENCIES.RDB$DEPENDENT_NAME,RDB$DEPENDENCIES.RDB$FIELD_NAME";
            string cmd_index       = $@"{cmd_index0} {case0} {cmd_index_where} {cmd_index_order};";

            dsDependenciesTo.Clear();
            dgvDependenciesTo.AutoGenerateColumns = true;

            try
            {
                var           con = new FbConnection(ConnectionStrings.Instance.MakeConnectionString(_dbReg));
                FbDataAdapter ds  = new FbDataAdapter(cmd_index, con);
                ds.Fill(dsDependenciesTo);
                con.Close();
                dgvDependenciesTo.DataMember = "Table";
                return(dsDependenciesTo.Tables[0].Rows.Count);
            }
            catch (Exception ex)
            {
                _localNotify?.AddToERROR($@"{StaticFunctionsClass.DateTimeNowStr()}->{this.Name}->RefreshDependenciesTo->{ex.Message}");
            }
            return(0);
        }
Exemplo n.º 5
0
        public string RemoveComments(string txt)
        {
            //Remove Singleline Comments
            _parentNotifies?.AddToINFO(StaticFunctionsClass.DateTimeNowStr() + " Remove comments");
            Application.DoEvents();
            int remstart = txt.IndexOf(_drc.SingleLineComment);
            int remend   = -1;

            if (remstart >= 0)
            {
                remend = txt.Substring(remstart).IndexOf(_drc.NewLine) + remstart;

                while ((remstart >= 0) && (remend > remstart))
                {
                    txt      = txt.Remove(remstart, remend - remstart + _drc.NewLine.Length);
                    remstart = txt.IndexOf(_drc.SingleLineComment);
                    remend   = txt.IndexOf(_drc.NewLine);
                }
            }

            //Remore Comments
            remstart = txt.IndexOf(_drc.CommentStart);
            if (remstart >= 0)
            {
                remend = txt.IndexOf(_drc.CommentEnd);
                while ((remstart >= 0) && (remend > remstart))
                {
                    txt      = txt.Remove(remstart, remend - remstart + _drc.CommentEnd.Length);
                    remstart = txt.IndexOf(_drc.CommentStart);
                    remend   = txt.IndexOf(_drc.CommentEnd);
                }
            }
            return(txt);
        }
Exemplo n.º 6
0
        public void MakeSQLNew()
        {
            SQLScript.Clear();

            string GenName = txtGenName.Text.Trim();

            if (!string.IsNullOrEmpty(GenName))
            {
                int?NewValue       = StaticFunctionsClass.ToIntDef(txtGenNewValue.Text.Trim(), null);
                int?IncrementValue = StaticFunctionsClass.ToIntDef(txtIncrementValue.Text.Trim(), null);
                var sb             = new StringBuilder();
                sb.Append($@"CREATE SEQUENCE {GenName};{Environment.NewLine}");
                if (NewValue != null)
                {
                    string cmd = ((IncrementValue != null) && (IncrementValue.Value > 0))
                        ?$@"ALTER SEQUENCE {txtGenName.Text.Trim()} RESTART WITH {NewValue.Value} INCREMENT BY {IncrementValue.Value};{Environment.NewLine}"
                        :$@"ALTER SEQUENCE {txtGenName.Text.Trim()} RESTART WITH {NewValue.Value};{Environment.NewLine}";

                    sb.Append(cmd);
                }
                sb.Append($@"{SQLPatterns.Commit}{Environment.NewLine}{Environment.NewLine}");
                sb.Append($@"COMMENT ON GENERATOR {GenName} IS '{fctGenDescription.Text}';{Environment.NewLine}");
                sb.Append($@"{SQLPatterns.Commit}{Environment.NewLine}{Environment.NewLine}");
                SQLScript.Add(sb.ToString());
            }
            else
            {
                SQLScript.Add("/* Generator name is not defined */");
            }
            SQLToUI();
        }
Exemplo n.º 7
0
        public TestOptionsClass EditToData()
        {
            TestOptionsClass to = new TestOptionsClass();

            to.manualTreshold = ckFixTreshold.Checked;
            double mt = StaticFunctionsClass.ToDoubleDef(txtManualTreshold.Text, -1);

            if (mt <= 0)
            {
                ckFixTreshold.Checked  = false;
                txtManualTreshold.Text = "1.0";
                to.treshold            = 1.0;
            }
            else
            {
                txtManualTreshold.Text = mt.ToString();
                to.treshold            = mt;
            }
            to.minBoardNr = (int)nmMinBoard.Value;
            to.maxBoardNr = (int)nmMaxBoard.Value;
            to.signalA    = ckSignalA.Checked;
            to.signalB    = ckSignalB.Checked;

            return(to);
        }
Exemplo n.º 8
0
        public void EditToData()
        {
            AppSettingsClass.Instance.Stamp = DateTime.Now;
            AppSettingsClass.Instance.DatabaseSettings.DefaultPacketSize = (int)numDefaultPacketSize.Value;
            AppSettingsClass.Instance.DatabaseSettings.DefaultPort       = (int)numDefaultPort.Value;
            AppSettingsClass.Instance.DatabaseSettings.DefaultPassword   = txtDefaultPassword.Text;
            AppSettingsClass.Instance.DatabaseSettings.DefaultUser       = txtDefaulUser.Text;
            AppSettingsClass.Instance.DatabaseSettings.OpenDatabaseCount = (int)numOpenDatabaseCount.Value;
            AppSettingsClass.Instance.PathSettings.DatabasesConfigPath   = txtDatabasesConfigPath.Text;

            AppSettingsClass.Instance.PathSettings.TempPath           = txtTemporaryPath.Text;
            AppSettingsClass.Instance.PathSettings.ScriptingPath      = txtScriptingPath.Text;
            AppSettingsClass.Instance.PathSettings.DatabaseConfigFile = txtDatabasesConfigFile.Text;
            AppSettingsClass.Instance.PathSettings.InfoPath           = txtInfoPath.Text;
            AppSettingsClass.Instance.PathSettings.ExportPath         = txtExportPath.Text;
            AppSettingsClass.Instance.PathSettings.SQLExportPath      = txtSQLExportPath.Text;
            AppSettingsClass.Instance.PathSettings.SQLHistoryPath     = txtSQLHistoryPath.Text;

            AppSettingsClass.Instance.SQLVariables.SetNewLine(txtSQLNewLine.Text);
            AppSettingsClass.Instance.SQLVariables.CommentStart          = txtSQLCommentStart.Text;
            AppSettingsClass.Instance.SQLVariables.CommentEnd            = txtSQLCommentEnd.Text;
            AppSettingsClass.Instance.SQLVariables.SkipForSelect         = StaticFunctionsClass.ToIntDef(txtSkipForSelect.Text, StaticVariablesClass.SQLSkipForSelect);
            AppSettingsClass.Instance.SQLVariables.MaxRowsForSelect      = StaticFunctionsClass.ToIntDef(txtSQLMaxRowForSelect.Text, StaticVariablesClass.SQLMaxRowForSelect);
            AppSettingsClass.Instance.SQLVariables.SingleLineComment     = txtSQLSingleLineCommand.Text;
            AppSettingsClass.Instance.SQLVariables.AlternativeTerminator = txtSQLAlternativeTerminator.Text;
            AppSettingsClass.Instance.SQLVariables.InitialTerminator     = txtSQLInitialTerminator.Text;
        }
Exemplo n.º 9
0
        private void PlaySingleNote(string HarpCode)
        {
            int kz = StaticFunctionsClass.ToIntDef(HarpCode, 0);

            //FormInstances.Instance().hc.SetTranspose(FormInstances.Instance().Transpose);
            if (kz >= 0)
            {
                if (kz < 100)
                {
                    FormInstances.Instance().hc.Play(kz, eBreathDirection.blow, 1000);
                }
                else
                {
                    FormInstances.Instance().hc.Play(kz - 100, eBreathDirection.blowPushed, 1000);
                }
            }
            else
            {
                if (kz > -100)
                {
                    FormInstances.Instance().hc.Play(Math.Abs(kz), eBreathDirection.draw, 1000);
                }
                else
                {
                    FormInstances.Instance().hc.Play(Math.Abs(kz + 100), eBreathDirection.drawPushed, 1000);
                }
            }
        }
Exemplo n.º 10
0
 private void txtSkipForSelect_TextChanged(object sender, EventArgs e)
 {
     if (!DoEvent)
     {
         return;
     }
     _dbReg.SkipForSelect = StaticFunctionsClass.ToIntDef(txtSkipForSelect.Text.Trim(), 1000);
 }
Exemplo n.º 11
0
 private void txtPacketsize_TextChanged(object sender, EventArgs e)
 {
     if (!DoEvent)
     {
         return;
     }
     _dbReg.PacketSize = StaticFunctionsClass.ToIntDef(txtPacketsize.Text, 0);
     connectionDataChanged();
 }
Exemplo n.º 12
0
        private void dgvResults_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            int rh = StaticFunctionsClass.ToIntDef(txtRowHeight.Text, dgvResults.RowTemplate.Height);

            foreach (DataGridViewRow x in dgvResults.Rows)
            {
                x.MinimumHeight = rh;
            }
        }
Exemplo n.º 13
0
 private void txtMaxPoolSize_TextChanged(object sender, EventArgs e)
 {
     if (!DoEvent)
     {
         return;
     }
     _dbReg.MaxPoolSize = StaticFunctionsClass.ToIntDef(txtMaxPoolSize.Text.Trim(), 15);
     connectionDataChanged();
 }
Exemplo n.º 14
0
 private void txtConnectionLifetime_TextChanged(object sender, EventArgs e)
 {
     if (!DoEvent)
     {
         return;
     }
     _dbReg.Lifetime = StaticFunctionsClass.ToIntDef(txtLifetime.Text.Trim(), 0);
     connectionDataChanged();
 }
Exemplo n.º 15
0
 private void txtPort_TextChanged(object sender, EventArgs e)
 {
     if (!DoEvent)
     {
         return;
     }
     _dbReg.Port = StaticFunctionsClass.ToIntDef(txtPort.Text.Trim(), 3050);
     connectionDataChanged();
 }
Exemplo n.º 16
0
        private void ExecuteCommandsFromFile(string filename)
        {
            var fi = new FileInfo(filename);

            if (!fi.Exists)
            {
                return;
            }

            var content = new StringBuilder();

            _notifies?.AddToINFO($@"{StaticFunctionsClass.DateTimeNowStr()} Prepare executing script in file {filename}");
            Application.DoEvents();
            string _connstr = ConnectionStrings.Instance.MakeConnectionString(_actScriptingDbReg);

            _sql = new DBBasicClassLibrary.SQLScriptingClass(_connstr, AppSettingsClass.Instance.SQLVariables.GetNewLine(), AppSettingsClass.Instance.SQLVariables.CommentStart, AppSettingsClass.Instance.SQLVariables.CommentEnd, AppSettingsClass.Instance.SQLVariables.SingleLineComment, "SCRIPT");
            _sql.ScriptNotify.Register4Info(EventMeldungRaised);
            _sql.Commands.Clear();

            int lineCount  = 0;
            int clearAfter = StaticFunctionsClass.ToIntDef(txtClear.Text, 1000);

            fcbCommands.Clear();
            fcbCommands.BeginUpdate();
            content.Clear();
            long mx = fi.Length / 20;

            pbProgress.Maximum = (int)mx;
            pbProgress.Minimum = 0;
            pbProgress.Value   = 0;

            using (var sr = new StreamReader(fi.FullName, Encoding.Default))
            {
                if (pbProgress.Maximum >= pbProgress.Minimum)
                {
                    pbProgress.Value = 0;
                }
                var startDt = DateTime.Now;
                while (!sr.EndOfStream)
                {
                    string str     = sr.ReadLine();
                    bool   cmdeady = _sql.AddCommandLine($@"{str}{Environment.NewLine}");
                    if (!cmdeady)
                    {
                        continue;
                    }
                    lineCount++;
                    var returnList = _sql.RunPreparedCommands();
                    _sql.Commands.Clear();
                }
                fcbCommands.EndUpdate();
                Cursor = Cursors.Default;
                _notifies?.AddToINFO($@"{StaticFunctionsClass.DateTimeNowStr()} Preparing done {lineCount.ToString()} commands");
                Application.DoEvents();
            }
        }
Exemplo n.º 17
0
        private void hsAddRestoreFile_Click(object sender, EventArgs e)
        {
            FirebirdSql.Data.Services.FbBackupFile bf = new FirebirdSql.Data.Services.FbBackupFile(txtRestoreLocation.Text);
            bf.BackupLength = StaticFunctionsClass.ToIntDef(txtRestoreFileSize.Text.Trim(), 0);
            string[]     obarr = { bf.BackupFile, bf.BackupLength.ToString() };
            ListViewItem lvi   = new ListViewItem(obarr);

            lvi.Tag = bf;
            lvRestore.Items.Add(lvi);
        }
Exemplo n.º 18
0
 public string RemoveDoubleSpaces(string txt)
 {
     //Remove double spaces
     _parentNotifies?.AddToINFO(StaticFunctionsClass.DateTimeNowStr() + " Remove double spaces");
     Application.DoEvents();
     while (txt.IndexOf("  ") >= 0)
     {
         txt = txt.Replace("  ", " ");
     }
     return(txt);
 }
Exemplo n.º 19
0
        public void EditToData()
        {
            AppSettingsClass.Instance().Stamp = DateTime.Now;
            AppSettingsClass.Instance().DatabaseSettings.DefaultPacketSize = StaticFunctionsClass.ToIntDef(txtDefaultPacketsize.Text, 8192);
            AppSettingsClass.Instance().DatabaseSettings.DefaultPassword = txtDefaultPassword.Text;
            AppSettingsClass.Instance().DatabaseSettings.DefaultUser = txtDefaulUser.Text;
            AppSettingsClass.Instance().PathSettings.DatabasesConfigPath = txtDatabasesConfigPath.Text;

            AppSettingsClass.Instance().PathSettings.TempPath = txtTemporaryPath.Text;
            AppSettingsClass.Instance().PathSettings.ScriptingPath = txtScriptingPath.Text;
            AppSettingsClass.Instance().PathSettings.DatabaseConfigFile = txtDatabasesConfigFile.Text;
        }
Exemplo n.º 20
0
 public void ScriptInfoRaised(object sender, MessageEventArgs e)
 {
     if (e.Data.GetType() == typeof(SCRIPTCommandClass))
     {
         var sc = (SCRIPTCommandClass)e.Data;
         fcbNotify.AppendText($@"{StaticFunctionsClass.DateTimeNowStr()} {e.Meldung}->{e.Key}->{sc.CommandType}->done in {sc.Costs} ms{Environment.NewLine}");
     }
     else
     {
         fcbNotify.AppendText($@"{StaticFunctionsClass.DateTimeNowStr()} {e.Meldung}->{e.Key}{Environment.NewLine}");
     }
 }
Exemplo n.º 21
0
        private void hsAddBackupFile_Click(object sender, EventArgs e)
        {
            int fLength = StaticFunctionsClass.ToIntDef(txtFileSize.Text.Trim(), 0);

            string[] obarr = { txtSQLLocation.Text, fLength.ToString() };
            var      lvi   = new ListViewItem(obarr)
            {
                Tag = _fi
            };

            lvFiles.Items.Add(lvi);
        }
Exemplo n.º 22
0
 private void PrepareCommandsFromSQL()
 {
     if (cbClearBeforePreparing.Checked)
     {
         _sql = new SQLScriptingClass(_actScriptingDbReg, "SCRIPT", _notifies, _eventnotifies);
         lvCommands.Items.Clear();
     }
     pbProgress.Maximum = fcbSQL.Lines.Count;;
     pbProgress.Minimum = 0;
     pbProgress.Value   = 0;
     _sql.PrepareCommands(fcbSQL.Lines, cbClearBeforePreparing.Checked);
     int clearAfter = StaticFunctionsClass.ToIntDef(txtClear.Text, 1000);
 }
Exemplo n.º 23
0
        private void txtTranspose_TextChanged(object sender, EventArgs e)
        {
            byte transpose = 0;

            if (doEvents)
            {
                transpose = (byte)StaticFunctionsClass.ToIntDef(txtTranspose.Text, 0);
                FormInstances.Instance().hc.SetTranspose(transpose);
            }
            doEvents = false;
            //txtTranspose.Text = transpose.ToString();
            doEvents = true;
        }
Exemplo n.º 24
0
        public string TestForValidation(string txt)
        {
            string cmd = txt.Replace(" ,", ",");

            int indv = cmd.IndexOf("VALUES(");

            if (indv >= 0)
            {
                int    changed = 0;
                string cmd2    = cmd.Substring(indv + 7);
                if (cmd2.Trim().EndsWith(");"))
                {
                    cmd2 = cmd2.Trim().Substring(0, cmd2.Trim().Length - 2);
                }
                string[] arr = cmd2.Split(',');
                for (int i = 0; i < arr.Length; i++)
                {
                    string arrcmd = arr[i].Trim();
                    int    n      = arrcmd.IndexOf("'", 1);
                    if ((n > -1) && (n < arrcmd.Length - 1))
                    {
                        arrcmd = arrcmd.Insert(n, "'");

                        _parentNotifies?.AddToINFO($@"{StaticFunctionsClass.DateTimeNowStr()} ...Executing script, Apostroph quotet:{arr[i]}->{arrcmd}");

                        arr[i] = arrcmd;
                        changed++;
                    }
                }
                if (changed > 0)
                {
                    var sb = new StringBuilder();
                    sb.Append(cmd.Substring(0, indv + 7));
                    bool first = true;
                    foreach (string str in arr)
                    {
                        if (!first)
                        {
                            sb.Append(",");
                        }
                        sb.Append(str);
                        first = false;
                    }
                    sb.Append($@");{Environment.NewLine}");
                    return(sb.ToString());
                }
            }
            return(cmd);
        }
Exemplo n.º 25
0
        private void PrepareCommandsFromSQL()
        {
            string _connstr = ConnectionStrings.Instance.MakeConnectionString(_actScriptingDbReg);

            _sql = new DBBasicClassLibrary.SQLScriptingClass(_connstr, AppSettingsClass.Instance.SQLVariables.GetNewLine(), AppSettingsClass.Instance.SQLVariables.CommentStart, AppSettingsClass.Instance.SQLVariables.CommentEnd, AppSettingsClass.Instance.SQLVariables.SingleLineComment, "SCRIPT");
            _sql.ScriptNotify.Register4Info(EventMeldungRaised);
            if (cbClearBeforePreparing.Checked)
            {
                lvCommands.Items.Clear();
            }
            pbProgress.Maximum = fcbSQL.Lines.Count;;
            pbProgress.Minimum = 0;
            pbProgress.Value   = 0;
            _sql.PrepareCommands(fcbSQL.Lines, cbClearBeforePreparing.Checked);
            int clearAfter = StaticFunctionsClass.ToIntDef(txtClear.Text, 1000);
        }
Exemplo n.º 26
0
        public string RefreshIndicesAndGetTablename()
        {
            string cmd_index = SQLStatements.Instance().GetIndiciesByName(_dbReg.Version, IndexName.Trim());

            DataFilled        = false;
            txtIndexName.Text = IndexName.Trim();
            string TableName = string.Empty;

            try
            {
                lvFields.Items.Clear();

                var con = new FbConnection(ConnectionStrings.Instance().MakeConnectionString(_dbReg));
                con.Open();
                string PkColumn        = string.Empty;
                string IndexName       = string.Empty;
                string IndexColumnName = string.Empty;
                int    Unique          = 0;

                FbCommand fcmd  = new FbCommand(cmd_index, con);
                var       dread = fcmd.ExecuteReader();

                if (dread.HasRows)
                {
                    while (dread.Read())
                    {
                        TableName        = dread.GetValue(0).ToString().Trim();
                        IndexColumnName  = dread.GetValue(2).ToString().Trim();
                        Unique           = StaticFunctionsClass.ToIntDef(dread.GetValue(3).ToString().Trim(), 0);
                        cbUnique.Checked = Unique > 0;
                        string[] lv = new string[1];
                        lv[0] = IndexColumnName;

                        ListViewItem lvi = new ListViewItem(lv);
                        lvFields.Items.Add(lvi);
                    }
                    DataFilled = true;
                }
                con.Close();
            }
            catch (Exception ex)
            {
                _localNotify?.AddToERROR(StaticFunctionsClass.DateTimeNowStr() + "->ConstraintForm->RefreshIndices()->" + ex.Message);
            }

            return(TableName);
        }
Exemplo n.º 27
0
        public void MakeSQLNew()
        {
            SQLScript.Clear();
            cbCollate.Enabled = true;
            var sb = new StringBuilder();

            sb.Append($@"CREATE DOMAIN {txtName.Text} AS ");
            sb.Append($@"{StaticVariablesClass.CompleteRawType(cbTypes.Text.Trim(), StaticFunctionsClass.ToIntDef(txtLength.Text.Trim(), 0))}");
            if (cbCharSet.Enabled)
            {
                if (cbCharSet.Text != "NONE")
                {
                    sb.Append($@" CHARACTER SET {cbCharSet.Text}");
                }
            }
            if (cbCollate.Enabled)
            {
                if (cbCollate.Text != "NONE")
                {
                    sb.Append($@" COLLATE {cbCollate.Text}");
                }
            }
            if (!string.IsNullOrEmpty(txtDefault.Text))
            {
                sb.Append($@" DEFAULT  '{txtDefault.Text}'");
            }

            sb.AppendLine($@";");
            sb.Append($@"{SQLPatterns.Commit}{Environment.NewLine}");

            if (cbNotNull.Checked)
            {
                sb.AppendLine($@"ALTER DOMAIN {txtName.Text} ADD CONSTRAINT CHECK (VALUE IS NOT NULL); /* adds not null flag to domain */");
                sb.AppendLine($@"{SQLPatterns.Commit}{Environment.NewLine}");
            }


            if (!string.IsNullOrEmpty(fctDescription.Text))
            {
                sb.AppendLine($@"COMMENT ON DOMAIN {txtName.Text} IS '{fctDescription.Text}';");
                sb.Append($@"{SQLPatterns.Commit}{Environment.NewLine}");
            }

            SQLScript.Add(sb.ToString());
            SQLToUI();
        }
Exemplo n.º 28
0
        public void RefreshDomain()
        {
            string cmd0 = "SELECT RDB$FIELDS.RDB$FIELD_NAME,RDB$FIELDS.RDB$CHARACTER_LENGTH,RDB$FIELDS.RDB$FIELD_SCALE,RDB$FIELD_PRECISION,RDB$FIELDS.RDB$FIELD_TYPE,RDB$FIELDS.RDB$DESCRIPTION,RDB$TYPES.RDB$TYPE_NAME FROM RDB$FIELDS";
            string cmd1 = "LEFT JOIN RDB$TYPES ON RDB$TYPES.RDB$TYPE = RDB$FIELDS.RDB$FIELD_TYPE";

            string where = "WHERE RDB$FIELDS.RDB$FIELD_NAME = '" + FieldObject.Domain + "' AND RDB$TYPES.RDB$FIELD_NAME = 'RDB$FIELD_TYPE'";
            string cmd = cmd0 + " " + cmd1 + " " + where + ";";

            ConnectionClass cc = ConnectionPoolClass.Instance().GetConnection("C1");

            cc.ShowExceptionMode = MessageLibrary.ShowError.no;
            DbDataReader dr = cc.ExecuteQuery(cmd, false);

            if (dr != null)
            {
                if (cc.HasRows())
                {
                    int n = 0;
                    while (cc.Read())
                    {
                        DomainObject            = DataClassFactory.GetDataClass(StaticVariablesClass.DomainsKeyStr) as DomainClass;
                        DomainObject.Name       = cc.GetValue(0).ToString().Trim();
                        DomainObject.Length     = StaticFunctionsClass.ToIntDef(cc.GetValue(1).ToString().Trim(), 0);
                        DomainObject.Scale      = StaticFunctionsClass.ToIntDef(cc.GetValue(2).ToString().Trim(), 0);
                        DomainObject.Precision  = StaticFunctionsClass.ToIntDef(cc.GetValue(3).ToString().Trim(), 0);
                        DomainObject.TypeNumber = StaticFunctionsClass.ToIntDef(cc.GetValue(4).ToString().Trim(), 0);
                        DomainObject.FieldType  = cc.GetValue(6).ToString().Trim();
                        DomainObject.RawType    = StaticVariablesClass.ConvertINTERNALType_TO_SQLType(DomainObject.FieldType, DomainObject.Length);

                        object ob = cc.GetValue(5);
                        DomainObject.Description = cc.GetValue(5).ToString().Trim();

                        /*
                         * if (!string.IsNullOrEmpty(ob.ToString()))
                         * {
                         *  byte[] bytetext = (byte[])cc.DBProvider.DataReader[3];
                         *  DomainObject.Description = System.Text.Encoding.UTF8.GetString(bytetext);
                         * }
                         */
                        n++;
                    }
                }
                cc.CloseConnection();
            }
        }
Exemplo n.º 29
0
        private void Notify_OnRaiseErrorHandler(object sender, MessageEventArgs k)
        {
            var sb = new StringBuilder();

            _errorCount++;
            if (_messagesCount > 0)
            {
                sb.Append($@"{StaticFunctionsClass.DateTimeNowStr()} Messages ({_messagesCount}) ");
            }
            if (_errorCount > 0)
            {
                sb.Append($@"{StaticFunctionsClass.DateTimeNowStr()} Errors ({_errorCount})");
            }

            fctMessages.AppendText($@"ERROR {k.Meldung}");
            tabPageMessages.Text = sb.ToString();
            fctMessages.ScrollLeft();
        }
Exemplo n.º 30
0
        private void Restore_ServiceOutput(object sender, FirebirdSql.Data.Services.ServiceOutputEventArgs e)
        {
            n++;
            StaticFunctionsClass.SetDoubleBuffered(lvBackupMessage);
            lvBackupMessage.BeginUpdate();

            string[]     m   = { n.ToString(), e.Message, StaticFunctionsClass.DateTimeNowStr() };
            ListViewItem lvi = new ListViewItem(m);

            lvRestoreMessage.Items.Add(lvi);
            lvRestoreMessage.Items[lvRestoreMessage.Items.Count - 1].EnsureVisible();
            lvRestoreMessage.EndUpdate();

            if (n % 20 == 0)
            {
                Application.DoEvents();
            }
        }