コード例 #1
0
        //application routines

        private bool ProcessForm()
        {
            bool colDefsCreated = false;
            PFColumnDefinitionsExt currColDefs = null;

            try
            {
                DisableFormControls();
                this.Cursor = Cursors.WaitCursor;

                currColDefs = CreateColDefs(true);

                if (currColDefs != null)
                {
                    colDefsCreated = true;
                    _colDefs       = currColDefs;
                }
            }
            catch (System.Exception ex)
            {
                colDefsCreated = false;
                _msg.Length    = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                WriteToMessageLog(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                EnableFormControls();
                this.Cursor = Cursors.Default;
                this.Focus();
            }

            return(colDefsCreated);
        }
コード例 #2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            string configValue = string.Empty;

            try
            {
                this.Text = "Fixed Length Column Output Definitions";

                SetLoggingValues();

                SetHelpFileValues();

                SetFormValues();

                //SetListViewTest();

                _printer = new FormPrinter(this);

                _saveColDef = CreateColDefs(false);
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                WriteToMessageLog(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
        }
コード例 #3
0
        private bool ColumnDefinitionHasChanges()
        {
            bool         retval   = false;
            CompareLogic oCompare = new CompareLogic();

            _exitColDef = CreateColDefs(false);
            if (_exitColDef == null)
            {
                return(false);
            }

            oCompare.Config.MaxDifferences = 10;

            ComparisonResult compResult = oCompare.Compare(_saveColDef, _exitColDef);

            if (compResult.AreEqual == false)
            {
                _msg.Length = 0;
                _msg.Append(Environment.NewLine);
                _msg.Append("Column Definitions have changes:\r\n");
                _msg.Append(compResult.DifferencesString);
                _msg.Append(Environment.NewLine);
                WriteToMessageLog(_msg.ToString());
            }

            retval = !compResult.AreEqual;

            return(retval);
        }
コード例 #4
0
 private void InitColDefObject(ref PFColumnDefinitionsExt colDefs)
 {
     for (int i = 0; i < colDefs.ColumnDefinition.Length; i++)
     {
         colDefs.ColumnDefinition[_fieldNameInx].SourceColumnName                = string.Empty;
         colDefs.ColumnDefinition[_columnNameInx].OutputColumnName               = string.Empty;
         colDefs.ColumnDefinition[_columnLengthInx].OutputColumnLength           = -1;
         colDefs.ColumnDefinition[_colummAlignmentInx].OutputColumnDataAlignment = PFDataAlign.LeftJustify;
     }
 }
コード例 #5
0
        private PFColumnDefinitionsExt CreateColDefs(bool verifyNumbers)
        {
            int           numErrors = 0;
            StringBuilder errMsg    = new StringBuilder();

            if (this.listviewColDefs.Items.Count < 1)
            {
                return(null);
            }
            PFColumnDefinitionsExt colDefs = new PFColumnDefinitionsExt(this.listviewColDefs.Items.Count);

            //error message only shown if errors occur
            errMsg.Append("Unable to create PFColumnDefinitionsExt object.");
            errMsg.Append(Environment.NewLine);


            try
            {
                for (int i = 0; i < this.listviewColDefs.Items.Count; i++)
                {
                    colDefs.ColumnDefinition[i].SourceColumnName = this.listviewColDefs.Items[i].SubItems[_fieldNameInx].Text;
                    colDefs.ColumnDefinition[i].OutputColumnName = this.listviewColDefs.Items[i].SubItems[_columnNameInx].Text;
                    if (verifyNumbers)
                    {
                        if (PFTextProcessor.StringIsInt(this.listviewColDefs.Items[i].SubItems[_columnLengthInx].Text))
                        {
                            int colLen = Convert.ToInt32(this.listviewColDefs.Items[i].SubItems[_columnLengthInx].Text);
                            if (colLen > 0)
                            {
                                colDefs.ColumnDefinition[i].OutputColumnLength = Convert.ToInt32(this.listviewColDefs.Items[i].SubItems[_columnLengthInx].Text);
                            }
                            else
                            {
                                numErrors++;
                                errMsg.Append("Invalid negative output column length: ");
                                errMsg.Append(this.listviewColDefs.Items[i].SubItems[_columnLengthInx].Text);
                                errMsg.Append(Environment.NewLine);
                            }
                        }
                        else
                        {
                            numErrors++;
                            errMsg.Append("Invalid output column length: ");
                            errMsg.Append(this.listviewColDefs.Items[i].SubItems[_columnLengthInx].Text);
                            errMsg.Append(Environment.NewLine);
                        }
                    }
                    else
                    {
                        if (PFTextProcessor.StringIsInt(this.listviewColDefs.Items[i].SubItems[_columnLengthInx].Text))
                        {
                            colDefs.ColumnDefinition[i].OutputColumnLength = Convert.ToInt32(this.listviewColDefs.Items[i].SubItems[_columnLengthInx].Text);
                        }
                        else
                        {
                            colDefs.ColumnDefinition[i].OutputColumnLength = -1;
                        }
                    }
                    colDefs.ColumnDefinition[i].OutputColumnDataAlignment = (PFDataAlign)Enum.Parse(typeof(PFDataAlign), this.listviewColDefs.Items[i].SubItems[_colummAlignmentInx].Text);
                }
                if (numErrors > 0)
                {
                    throw new System.Exception(errMsg.ToString());
                }
            }
            catch (System.Exception ex)
            {
                colDefs     = null;
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                WriteToMessageLog(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }



            return(colDefs);
        }
コード例 #6
0
        //application routines

        public void ShowFixedLenInputColSpecForm(string tableName)
        {
            PFFixedLenColDefsInputForm frm        = new PFFixedLenColDefsInputForm();
            DialogResult           res            = DialogResult.None;
            string                 dbPlatformDesc = DatabasePlatform.Unknown.ToString();
            PFDatabase             db             = null;
            string                 connStr        = string.Empty;
            string                 nmSpace        = string.Empty;
            string                 clsName        = string.Empty;
            string                 dllPath        = string.Empty;
            DataTable              dt             = null;
            PFColumnDefinitionsExt colDefsExt     = null;
            string                 configValue    = string.Empty;
            string                 configKey      = string.Empty;

            try
            {
                _msg.Length = 0;
                _msg.Append("ShowFixedLenInputColSpecForm started ...\r\n");
                WriteToMessageLog(_msg.ToString());

                configValue = AppConfig.GetStringValueFromConfigFile("DefaultConnection_SQLServerCE35", string.Empty);
                if (configValue == string.Empty)
                {
                    _msg.Length = 0;
                    _msg.Append("Unable to find config.sys entry for DefaultConnection_SQLServerCE35");
                    throw new System.Exception(_msg.ToString());
                }
                dbPlatformDesc = DatabasePlatform.SQLServerCE35.ToString();
                connStr        = configValue;

                dbPlatformDesc = DatabasePlatform.SQLServerCE35.ToString();
                configValue    = AppConfig.GetStringValueFromConfigFile(dbPlatformDesc, string.Empty);
                string[] parsedConfig = configValue.Split('|');
                nmSpace = parsedConfig[0];
                clsName = parsedConfig[1];
                dllPath = parsedConfig[2];

                db = new PFDatabase(dbPlatformDesc, dllPath, nmSpace + "." + clsName);
                db.ConnectionString = connStr;
                db.OpenConnection();

                configKey   = dbPlatformDesc + "_" + tableName;
                configValue = AppConfig.GetStringValueFromConfigFile(configKey, string.Empty);
                if (configValue == string.Empty)
                {
                    _msg.Length = 0;
                    _msg.Append("Unable to find ");
                    _msg.Append(configKey);
                    _msg.Append(" in config.sys.");
                    AppMessages.DisplayErrorMessage(_msg.ToString());
                    return;
                }
                //db.SQLQuery = "select  CustomerKey ,GeographyKey ,CustomerAlternateKey ,Title ,FirstName ,MiddleName ,LastName ,NameStyle ,BirthDate ,MaritalStatus ,Suffix ,Gender ,EmailAddress ,YearlyIncome ,TotalChildren ,NumberChildrenAtHome ,EnglishEducation ,SpanishEducation ,FrenchEducation ,EnglishOccupation ,SpanishOccupation ,FrenchOccupation ,HouseOwnerFlag ,NumberCarsOwned ,AddressLine1 ,AddressLine2 ,Phone ,DateFirstPurchase ,CommuteDistance from DimCustomer where 1=0";
                db.SQLQuery    = configValue;
                db.CommandType = CommandType.Text;

                dt = db.GetQueryDataSchema();

                //colDefsExt = PFColumnDefinitionsExt.GetColumnDefinitionsExt(dt);

                colDefsExt = new PFColumnDefinitionsExt(1);

                frm.ColDefs = colDefsExt;

                frm.MessageLogUI = _messageLog;
                res = frm.ShowDialog();

                colDefsExt = frm.ColDefs;

                _msg.Length = 0;
                _msg.Append("Form closed with DialogResult = ");
                _msg.Append(res.ToString());
                WriteToMessageLog(_msg.ToString());

                if (res == DialogResult.OK)
                {
                    _msg.Length = 0;
                    _msg.Append(Environment.NewLine);
                    _msg.Append("COLUMN DEFINITIONS:\r\n\r\n");
                    _msg.Append(colDefsExt.ToXmlString());
                    _msg.Append(Environment.NewLine);
                    _msg.Append(Environment.NewLine);
                    WriteToMessageLog(_msg.ToString());
                }
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                WriteToMessageLog(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                if (db.IsConnected)
                {
                    db.CloseConnection();
                }
                db = null;

                if (frm != null)
                {
                    if (FormIsOpen(frm.Name))
                    {
                        frm.Close();
                    }
                }
                frm = null;

                _msg.Length = 0;
                _msg.Append("\r\n... ShowFixedLenInputColSpecForm finished.");
                WriteToMessageLog(_msg.ToString());
            }
        }