示例#1
0
        /// <summary>
        /// Display a custom error
        /// </summary>
        /// <param name="error">The error that should be shown</param>
        public static bool DisplayCustomError(ClassGenException error)
        {
            bool continueProcessing = true;

            ClassGenExceptionCollection errors = new ClassGenExceptionCollection();

            errors.Add(error);
            frmDialogErrorView frm = new frmDialogErrorView(errors);

            if (errors.CriticalExceptionCount == 0)
            {
                frm.ContinuableForm = true;
            }
            if (frm.ShowDialog() == DialogResult.Cancel)
            {
                continueProcessing = false;
            }

            return(continueProcessing);
        }
示例#2
0
        private void RefreshGrid()
        {
            // Populate the grid with the errors
            // Copy the collection first
            ClassGenExceptionCollection errors = new ClassGenExceptionCollection();

            if (_coll != null)
            {
                foreach (ClassGenException err in _coll)
                {
                    if (err.ClassGenExceptionIconType == ClassGenExceptionIconType.Critical && _errorsOn)
                    {
                        errors.Add(err);
                    }
                    if (err.ClassGenExceptionIconType == ClassGenExceptionIconType.Warning && _warningsOn)
                    {
                        errors.Add(err);
                    }
                    if (err.ClassGenExceptionIconType == ClassGenExceptionIconType.Information && _informationOn)
                    {
                        errors.Add(err);
                    }
                }
            }

            gridViewError.Columns.Clear();
            gridError.DataSource = errors;
            gridViewError.PopulateColumns();

            // Go through the collection to see if we have more than one record index
            int recIndex = -9999;

            _collectionContainsMoreThanOneRecordIndex = false;
            foreach (ClassGenException ex in errors)
            {
                if (ex.RecordIndex != recIndex)
                {
                    if (recIndex == -9999)
                    {
                        recIndex = ex.RecordIndex;
                    }
                    else
                    {
                        _collectionContainsMoreThanOneRecordIndex = true;
                        break;
                    }
                }
            }

            // Take off all the columns
            //foreach (GridColumn col in gridViewError.Columns)
            //{
            //    col.VisibleIndex = -1;
            //    col.OptionsColumn.ShowInCustomizationForm = false;
            //}
            for (int colIndex = gridViewError.Columns.Count - 1; colIndex >= 0; colIndex--)
            {
                gridViewError.Columns[colIndex].VisibleIndex = -1;
                gridViewError.Columns[colIndex].OptionsColumn.ShowInCustomizationForm = false;
            }

            // Put them back in the order we want them
            int count = 0;

            gridViewError.OptionsView.RowAutoHeight = true;

            gridViewError.Columns["ClassGenExceptionIconType"].VisibleIndex = ++count;
            gridViewError.Columns["ClassGenExceptionIconType"].OptionsColumn.ShowInCustomizationForm = false;
            gridViewError.Columns["ClassGenExceptionIconType"].OptionsColumn.ShowCaption             = false;
            gridViewError.Columns["ClassGenExceptionIconType"].OptionsColumn.AllowEdit   = false;
            gridViewError.Columns["ClassGenExceptionIconType"].OptionsColumn.AllowMove   = false;
            gridViewError.Columns["ClassGenExceptionIconType"].OptionsColumn.AllowSize   = false;
            gridViewError.Columns["ClassGenExceptionIconType"].OptionsColumn.AllowSort   = DevExpress.Utils.DefaultBoolean.True;
            gridViewError.Columns["ClassGenExceptionIconType"].OptionsColumn.FixedWidth  = true;
            gridViewError.Columns["ClassGenExceptionIconType"].OptionsFilter.AllowFilter = false;
            //gridViewError.Columns["ClassGenExceptionIconType"].Width = 35;

            if (_collectionContainsMoreThanOneRecordIndex)
            {
                gridViewError.Columns["RecordIndex"].VisibleIndex = ++count;
                gridViewError.Columns["RecordIndex"].OptionsColumn.ShowInCustomizationForm   = true;
                gridViewError.Columns["RecordIndex"].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridViewError.Columns["RecordIndex"].Caption = "Row";
                gridViewError.Columns["RecordIndex"].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridViewError.Columns["RecordIndex"].OptionsColumn.AllowEdit   = false;
                gridViewError.Columns["RecordIndex"].OptionsColumn.AllowMove   = false;
                gridViewError.Columns["RecordIndex"].OptionsColumn.AllowSize   = false;
                gridViewError.Columns["RecordIndex"].OptionsColumn.AllowSort   = DevExpress.Utils.DefaultBoolean.True;
                gridViewError.Columns["RecordIndex"].OptionsColumn.FixedWidth  = true;
                gridViewError.Columns["RecordIndex"].OptionsFilter.AllowFilter = false;
                //gridViewError.Columns["RecordIndex"].Width = 35;
            }

            RepositoryItemMemoEdit memoEdit = gridError.RepositoryItems.Add("MemoEdit") as RepositoryItemMemoEdit;

            gridViewError.Columns["DescriptionWithException"].VisibleIndex = ++count;
            gridViewError.Columns["DescriptionWithException"].OptionsColumn.ShowInCustomizationForm = true;
            gridViewError.Columns["DescriptionWithException"].Caption = "Description";
            //gridViewError.Columns["DescriptionWithException"].OptionsColumn.AllowEdit = false;
            gridViewError.Columns["DescriptionWithException"].OptionsColumn.AllowEdit   = true;
            gridViewError.Columns["DescriptionWithException"].OptionsColumn.AllowMove   = false;
            gridViewError.Columns["DescriptionWithException"].OptionsColumn.AllowSize   = false;
            gridViewError.Columns["DescriptionWithException"].OptionsColumn.AllowSort   = DevExpress.Utils.DefaultBoolean.True;
            gridViewError.Columns["DescriptionWithException"].OptionsFilter.AllowFilter = false;
            gridViewError.Columns["DescriptionWithException"].ColumnEdit = memoEdit;

            if (_collectionContainsMoreThanOneRecordIndex)
            {
                gridViewError.Columns["RecordKey"].VisibleIndex = ++count;
                gridViewError.Columns["RecordKey"].OptionsColumn.ShowInCustomizationForm   = true;
                gridViewError.Columns["RecordKey"].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridViewError.Columns["RecordKey"].Caption = "Record Key";
                gridViewError.Columns["RecordKey"].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gridViewError.Columns["RecordKey"].OptionsColumn.AllowEdit   = false;
                gridViewError.Columns["RecordKey"].OptionsColumn.AllowMove   = false;
                gridViewError.Columns["RecordKey"].OptionsColumn.AllowSize   = false;
                gridViewError.Columns["RecordKey"].OptionsColumn.AllowSort   = DevExpress.Utils.DefaultBoolean.True;
                gridViewError.Columns["RecordKey"].OptionsColumn.FixedWidth  = true;
                gridViewError.Columns["RecordKey"].OptionsFilter.AllowFilter = false;
                //gridViewError.Columns["RecordKey"].Width = 100;
            }

            gridViewError.Columns["PropertyName"].VisibleIndex = -1;
            gridViewError.Columns["PropertyName"].OptionsColumn.ShowInCustomizationForm = true;
            gridViewError.Columns["PropertyName"].Caption = "Property Name";
            gridViewError.Columns["PropertyName"].OptionsColumn.AllowEdit   = false;
            gridViewError.Columns["PropertyName"].OptionsColumn.AllowMove   = false;
            gridViewError.Columns["PropertyName"].OptionsColumn.AllowSize   = false;
            gridViewError.Columns["PropertyName"].OptionsColumn.AllowSort   = DevExpress.Utils.DefaultBoolean.True;
            gridViewError.Columns["PropertyName"].OptionsFilter.AllowFilter = false;

            // Check the errors collection for critical exceptions
            if (errors.CriticalExceptionCount > 0 &&
                _continuableForm)
            {
                layoutContinueProcessing.Visibility = LayoutVisibility.Never;
            }
        }
示例#3
0
        /// <summary>
        /// Fix the search filter so that it can be passed back into the databsae
        /// </summary>
        /// <param name="srchFilter">The search filter string to fix</param>
        /// <param name="searchObjectType">The search object type to work against for field naming</param>
        /// <param name="errors">An errors collection with any errors encountered</param>
        /// <returns>The finished and fixed string</returns>
        public static string FixSearchFilter(string srchFilter, Type searchObjectType, ref ClassGenExceptionCollection errors)
        {
            // Hunt through the freakin' string to see if we can replace
            // any of the values on the way back to the db
            string searchPhrase = @"\(?\[(.+?)\]\)?";

            try
            {
                string type = searchObjectType.ToString().Replace("iMaintStarter.", "");
                srchFilter = srchFilter.Replace("= False", "= 0").Replace("= True", "<> 0");
                srchFilter = srchFilter.Replace("= 'False'", "= 0").Replace("= 'True'", "<> 0");
                MatchCollection matches = Regex.Matches(srchFilter, searchPhrase);
                foreach (Match m in matches)
                {
                    try
                    {
                        // Replace the string that you're passing back to the db
                        string val = m.Groups[1].Value;

                        switch (type)
                        {
                        case "ForgeMetric":
                            //ForgeMetricField fldForgeMetric = (ForgeMetricField)Enum.Parse(typeof(ForgeMetricField), val);
                            //srchFilter = srchFilter.Replace(m.Value, "[" + ForgeMetric.GetDBFieldName(fldForgeMetric) + "]");
                            break;

                        case "Search_RunChartMasterDetail":
                            //Search_RunChartMasterDetailField fldSearch_RunChartMasterDetail = (Search_RunChartMasterDetailField)Enum.Parse(typeof(Search_RunChartMasterDetailField), val);
                            //srchFilter = srchFilter.Replace(m.Value, "[" + Search_RunChartMasterDetail.GetDBFieldName(fldSearch_RunChartMasterDetail) + "]");
                            break;

                        case "Search_RunChartFull":
                            //Search_RunChartFullField fldSearch_RunChartFull = (Search_RunChartFullField)Enum.Parse(typeof(Search_RunChartFullField), val);
                            //srchFilter = srchFilter.Replace(m.Value, "[" + Search_RunChartFull.GetDBFieldName(fldSearch_RunChartFull) + "]");
                            break;

                        case "Search_TrainingInstructor":
                            //mwsModel.Search_TrainingInstructorField fldTrainingInstructor =
                            //    (mwsModel.Search_TrainingInstructorField)Enum.Parse(typeof(mwsModel.Search_TrainingInstructorField), val);
                            //srchFilter = srchFilter.Replace(m.Value, "[" +
                            //    mwsModel.Search_TrainingInstructor.GetDBFieldName(fldTrainingInstructor) +
                            //    "]");
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        errors.Add(new ClassGenException(ex));
                    }
                }

                // Next, go in and try to find the dates (surrounded by # signs -
                // freakin' MS Access programmers)
                searchPhrase = @"\#(\d{4}-\d{2}\-\d{2})\#";
                srchFilter   = Regex.Replace(srchFilter, searchPhrase, "'$1'");
            }
            catch (Exception ex)
            {
                errors.Add(new ClassGenException(ex));
            }

            return(srchFilter);
        }