Click here to Skip to main content
15,900,667 members
Home / Discussions / C#
   

C#

 
GeneralRe: Entity Framework Questions - Round 1 Pin
Nathan Minier10-Oct-17 2:34
professionalNathan Minier10-Oct-17 2:34 
AnswerRe: Entity Framework Questions - Round 1 Pin
Gerry Schmitz21-Sep-17 13:05
mveGerry Schmitz21-Sep-17 13:05 
QuestionHow to save an excel file via network ? Pin
Member 1342184321-Sep-17 3:06
Member 1342184321-Sep-17 3:06 
GeneralRe: How to save an excel file via network ? Pin
Richard MacCutchan21-Sep-17 3:17
mveRichard MacCutchan21-Sep-17 3:17 
AnswerRe: How to save an excel file via network ? Pin
Eddy Vluggen21-Sep-17 6:28
professionalEddy Vluggen21-Sep-17 6:28 
AnswerRe: How to save an excel file via network ? Pin
Gerry Schmitz21-Sep-17 13:06
mveGerry Schmitz21-Sep-17 13:06 
Questionperformance counter in visual studio 217 C# Pin
AMMAR ALNAJIM20-Sep-17 20:41
AMMAR ALNAJIM20-Sep-17 20:41 
AnswerRe: performance counter in visual studio 217 C# Pin
Pete O'Hanlon20-Sep-17 21:10
mvePete O'Hanlon20-Sep-17 21:10 
AnswerRe: performance counter in visual studio 217 C# Pin
OriginalGriff20-Sep-17 22:59
mveOriginalGriff20-Sep-17 22:59 
AnswerRe: performance counter in visual studio 217 C# Pin
Eddy Vluggen20-Sep-17 23:20
professionalEddy Vluggen20-Sep-17 23:20 
QuestionC#-Form-DataGridView-Hangs Pin
Member 1341980320-Sep-17 3:05
Member 1341980320-Sep-17 3:05 
AnswerRe: C#-Form-DataGridView-Hangs Pin
Richard MacCutchan20-Sep-17 3:27
mveRichard MacCutchan20-Sep-17 3:27 
AnswerRe: C#-Form-DataGridView-Hangs Pin
Eddy Vluggen20-Sep-17 3:38
professionalEddy Vluggen20-Sep-17 3:38 
Questionmatching exact word c# Pin
Love Allah19-Sep-17 12:42
Love Allah19-Sep-17 12:42 
AnswerRe: matching exact word c# Pin
PIEBALDconsult19-Sep-17 12:45
mvePIEBALDconsult19-Sep-17 12:45 
GeneralRe: matching exact word c# Pin
Love Allah19-Sep-17 13:00
Love Allah19-Sep-17 13:00 
AnswerRe: matching exact word c# Pin
OriginalGriff19-Sep-17 20:02
mveOriginalGriff19-Sep-17 20:02 
QuestionHow to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 4:55
Bootzilla3319-Sep-17 4:55 
I'm trying to figure out how to handle multiple exceptions based off my code. I want to have an error for API, one for Tracking Number, and then one for if the XML isn't formatted for the entire XML. Would using try catch for each be the best method and if so how would I code that. The code in bold is what I need assistance with in regards for Tracking Number and API Here is what I have currently:

try
            {
                if (bool.Parse(WebConfigurationManager.AppSettings["Debug"]) == true)
                    File.WriteAllText(Path.Combine(Server.MapPath("Log"), DateTime.Now.ToString("MMddyyy_HHmmss") + ".xml"), xmlRequest);
                // Determine Method to Call
                XmlDocument doc = new XmlDocument();
                doc.XmlResolver = null;
                doc.LoadXml(xmlRequest);
               
                string method = doc.FirstChild.Name;
                XmlNode mainNode = doc.FirstChild;

                if (method.ToLower() == "xml")
                {
                    method = doc.FirstChild.NextSibling.Name;
                    mainNode = doc.FirstChild.NextSibling;
                }

                if (method == "AmazonTrackingRequest")
                {
                    Data.General.Shipment prc = new Data.General.Shipment();
                    string pronum = mainNode.SelectSingleNode("TrackingNumber")?.InnerText;
                    prc.GetByProNumber(decimal.Parse(pronum));

                   
                                        
                    rspxml.Root.Add(new XElement("API", "4.0"));
                    rspxml.Root.Add(new XElement("PackageTrackingInfo"));
                    rspxml.Root.Element("PackageTrackingInfo").Add(new XElement("TrackingNumber", prc.ProNumber.ToString()));
                    rspxml.Root.Add(new XElement("PackageDestinationLocation"));
                    rspxml.Root.Element("PackageDestinationLocation").Add(new XElement("City", prc.Consignee.ToString()));
                    rspxml.Root.Element("PackageDestinationLocation").Add(new XElement("StateProvince", prc.Consignee.ToString()));
                    rspxml.Root.Element("PackageDestinationLocation").Add(new XElement("PostalCode", prc.Consignee.ToString()));
                    rspxml.Root.Element("PackageDestinationLocation").Add(new XElement("CountryCode", prc.Consignee.ToString()));
                    rspxml.Root.Add(new XElement("PackageDeliveryDate"));
                    rspxml.Root.Element("PackageDeliveryDate").Add(new XElement("ScheduledDeliveryDate", prc.Consignee.ToString()));
                    rspxml.Root.Element("PackageDeliveryDate").Add(new XElement("ReScheduledDeliveryDate", prc.Consignee.ToString()));
                    rspxml.Root.Add(new XElement("TrackingEventHistory"));
                    foreach (Saia.Data.General.Shipment.HistoryItem itm in prc.History)
                    {
                        rspxml.Root.Add(new XElement("TrackingEventDetail"));
                        rspxml.Root.Element("TrackingEventDetail").Add(new XElement("EventStatus", prc.History.ToString()));
                        rspxml.Root.Element("TrackingEventDetail").Add(new XElement("EventReason", prc.History.ToString()));
                        rspxml.Root.Element("TrackingEventDetail").Add(new XElement("EventDateTime", prc.History.ToString()));
                        rspxml.Root.Add(new XElement("EventLocation"));
                        
                        
                    }


                }

            }
            catch (CodeException e)
            {
               Error here
            }
            catch (Exception e)
            {
               Error here
            }

            return rspxml.ToString();
        }
    }
}

SuggestionRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming19-Sep-17 5:22
mveRichard Deeming19-Sep-17 5:22 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 5:32
Bootzilla3319-Sep-17 5:32 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Richard Deeming19-Sep-17 5:57
mveRichard Deeming19-Sep-17 5:57 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 6:05
Bootzilla3319-Sep-17 6:05 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3319-Sep-17 9:58
Bootzilla3319-Sep-17 9:58 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
eddieangel19-Sep-17 12:18
eddieangel19-Sep-17 12:18 
GeneralRe: How to handle multiple exceptions(Try..Catch) Pin
Bootzilla3320-Sep-17 2:56
Bootzilla3320-Sep-17 2:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.