Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void ProcessInputQueueEntry(long parentNodeId, ExperianInputQueue eiq, UserInfo     uinf)
        {
            try
            {
                logger.InfoFormat("Processing InputQueue entry: {0}, Major: {1}, Minor:     {2}", eiq.Id, eiq.MajorType,
                                  eiq.MinorType);

                var parser = ExperianInputXMLParserFactory.Construct(eiq);
                // TODO: Try-catch + log the eiq ID + new status code for this eiq.
                switch (eiq.MajorType)
                {
                    case InputMajorType.ReportCases:
                        switch (eiq.MinorType)
                        {
                        case 1: // 1.1 -- Schema 2.1.1
                                CreateNewRegistration((ExperianReportCase)parser.GetObject(), parentNodeId, uinf);
                                break;
                            case 2: // 1.2 -- Schema 2.2.1
                                DeleteRegistration(parser, uinf);
                                break;
                            case 3: // 1.3 -- Schema 2.3.1
                                MoveToSolicitor(parser, parentNodeId, uinf);
                                break;
                            case 4: // 1.4 -- Schema 2.4.1
                                MoveToClient(parser, parentNodeId, uinf);
                                break;
                            case 5: // 1.5 -- Schema 2.5.1
                                Reopen(parser, parentNodeId, uinf);
                                break;
                            case 6: // 1.6 -- Schema 2.7.1
                                MoveToPublicService(parser, parentNodeId, uinf);
                                break;

                        }
                        break;
                    case InputMajorType.Cpr:
                        switch (eiq.MinorType)
                        {
                            case 1: // CPR: 2.1
                                DeleteRegistrationsFromCpr(eiq.IdCardNo, uinf);
                                break;

                            //case 80: // CPR: 2.80 --UDR (The person has left Denmark)
                            //case 70: // CPR: 2.70 --FSV( The person has disappeared)
                            case 2: // CPR: UDR (Teh person has left Denmark)
                            case 3: // CPR: FSV( The person has disappeared) --UDB(The     person no longer has a permanent residence)
                            case 4: // CPR: UDB(The person no longer has a permanent     residence)
                            case 5:
                            case 6: // CPR: Call RKI
                            case 7:

                                try
                                {
                                    HandleCPRStatusUpdateOtherThanDeath(eiq.IdCardNo, uinf, eiq.MinorType);
                                }

                                catch (Exception exception)
                                {
                                    logger.ErrorFormat("An error occurred while updating     the cpr status for the InputQueue task for eiq ID = {0} -- stacktrace ---> {1}", eiq.Id,     exception);
                                    throw exception;
                                }

                                break;
                        }
                        break;
                    case InputMajorType.CustomerDeletion:
                        switch (eiq.MinorType)
                        {
                            case 1: // DeleteCustomer: 3.1
                                DeleteRegistrationsByCustomer(eiq.ExperianCustomerNumber, uinf);
                                break;
                        }
                        break;
                    case InputMajorType.IdCardCombined:

                        switch (eiq.MinorType)
                        {
                            case 1: // CombineIdCards: 4.1
                                CombineIdCards(parser, parentNodeId, uinf);
                                break;
                        }
                        break;
                    case InputMajorType.Document:

                        switch (eiq.MinorType)
                        {
                            case 1: // 5.1
                                AddDocumentToNode(parser, eiq.NodeId, eiq.Data, uinf);
                                break;
                            case 2: // Pass documents to a Feedback dossier node through     Upload Document.
                                AddDocumentToFeedbackDossierNode(parser, eiq.NodeId, uinf);
                                break;
                        }
                        break;
                    case InputMajorType.CustomerContractTerminated: //TTP1256
                        if (eiq.MinorType == 1)
                        {
                            HandleCustomerContractTermination(eiq.ExperianCustomerNumber, uinf);
                        }
                        break;
                        default:
                        break;
                }
                eiq.Status = 1; // Processed...
                UpdateInputQueueItem(eiq, uinf);
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Error while executing EsdhInputQueue task for eiq ID     = {0} -- stacktrace ---> {1}", eiq.Id, ex);
                eiq.Status = 0; // Status = ErrorProcessing! //#1131 Making the state to     0 if the failure is due to network or web service is down so that i can process next time
            //Added for 2134
                EventLog.WriteEntry("Task Scheduler", "An Error has occured while     processing the input queue case", EventLogEntryType.Error, 2);
                UpdateInputQueueItem(eiq, uinf);
            }
        }




My code is listed above....In the last catch block....I need to add a logic to handle if there is any database connective issue or any network access issue (Like the data cannot be fetched or some issue with databse from the server side) and make the corresponding status as 1 so that it can be picked later for processing.How can I go about adding this as a if statement in the ending catch block.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900