示例#1
0
 public frmDialogErrorView(ClassGenExceptionCollection coll, string processDescription)
 {
     InitializeComponent();
     _coll     = coll;
     this.Text = "Errors were found...";
     ucErrorView.ProcessDescription = processDescription;
 }
示例#2
0
        /// <summary>
        /// Create a log entry in the system
        /// </summary>
        /// <param name="eventType">The event type</param>
        /// <param name="msg">The message to log</param>
        /// <returns>An error collection with anything found</returns>
        public static ClassGenExceptionCollection CreateLogEntry(SystemEventType eventType, string msg)
        {
            ClassGenExceptionCollection errors = new ClassGenExceptionCollection();

            // Generate a log entry
            LogSystem item = new LogSystem();

            item.DateLogged = DateTime.Now;
            item.EventType  = eventType.ToString();
            item.Message    = msg;
            errors          = item.AddUpdate();

            return(errors);
        }
示例#3
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);
        }
示例#4
0
 public ucErrorView(ClassGenExceptionCollection coll)
 {
     InitializeComponent();
     _coll = coll;
 }
示例#5
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;
            }
        }
示例#6
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);
        }
        protected void mainContent_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e)
        {
            // When the callback is called, reset just this frame
            mainContent.Controls.Clear();
            List <string> paramCollection = Utils.SplitStringToGenericList(e.Parameter, "||||");
            string        param           = e.Parameter;

            if (paramCollection.Count > 1)
            {
                param = paramCollection[0];
            }
            //int test = 1;

            // Get the url that was passed and load the proper control
            string pageTarget = (param.EndsWith("/") ? param.Substring(0, param.Length - 1) : param).ToLower();

            pageTarget = (pageTarget.StartsWith("/") ? pageTarget.Substring(1) : pageTarget);
            List <string> targets = Utils.SplitStringToGenericList(pageTarget, "/");
            string        keyVal  = string.Empty;
            long?         id      = null;

            //List<Control> loadedControls = new List<Control>();
            switch (targets[0])
            {
            case "personnel":                               // The Personnel functions
                switch (targets[1])
                {
                case "contact":                                     // /Personnel/Contact
                    switch (targets[2])
                    {
                    case "list":                                                                                                                            // /Personnel/Contact/List
                        ucListEmployees cntrlList = ((ucListEmployees)UserControlHelper.LoadControl(Page,
                                                                                                    "~/Personnel/ucListEmployees.ascx", new object[] { })); // Load the user control and place it
                        cntrlList.ID = "ucContactList";
                        mainContent.Controls.Add(cntrlList);
                        break;

                    case "edit":
                        // Get the ID	// /Personnel/Contact/Edit/-9223372036854775767
                        id = long.Parse(targets.Count > 3 ? targets[3] : null);

                        // Find out if we're coming back around on an edit
                        if (paramCollection.Count > 1)
                        {
                            keyVal = "ucContactEdit_";

                            // Yup - this is saved from an edit
                            Dictionary <string, string> kvp = new Dictionary <string, string>();
                            List <string> nv       = Utils.SplitStringToGenericList(paramCollection[1], "||");
                            List <string> tmpSplit = new List <string>();
                            foreach (string s in nv)
                            {
                                tmpSplit = Utils.SplitStringToGenericList(s, "|");                                                              // Split the value
                                kvp.Add(tmpSplit[0].Replace(keyVal, string.Empty),
                                        (tmpSplit.Count > 1 ? tmpSplit[1] : string.Empty));
                                //if (tmpSplit.Count > 1)
                                //{
                                //	kvp.Add(tmpSplit[0].Replace(keyVal, string.Empty), tmpSplit[1]);
                                //}
                                //else
                                //{
                                //	kvp.Add(tmpSplit[0].Replace(keyVal, string.Empty), string.Empty);
                                //}
                            }

                            // Update the value in the db
                            ContactCollection           coll   = new ContactCollection("iContactID = " + kvp["txtID"].ToString());
                            ClassGenExceptionCollection errors = new ClassGenExceptionCollection();
                            if (coll.Count > 0)
                            {
                                coll[0].FirstName = kvp["txtFirstName"];
                                coll[0].LastName  = kvp["txtLastName"];
                                errors.AddRange(coll.AddUpdateAll());
                            }
                        }

                        // Go out and get the new employee info
                        ucEditEmployee cntrlEdit = ((ucEditEmployee)UserControlHelper.LoadControl(Page,
                                                                                                  "~/Personnel/ucEditEmployee.ascx", new object[] { id })); // Load the user control and place it
                        mainContent.Controls.Add(cntrlEdit);
                        break;
                    }
                    break;

                default:
                    break;
                }

                break;

            default:
                break;
            }
        }
示例#8
0
 public frmDialogErrorView(ClassGenExceptionCollection coll)
 {
     InitializeComponent();
     _coll     = coll;
     this.Text = "Errors were found...";
 }