Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

Bootzilla33

@Bootzilla33
About
Posts
50
Topics
28
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to reference resource from Resources file
    B Bootzilla33

    Richard Deeming wrote:

    TempData.Put(TempDataKey.Dor.RESPONSE_ADD_MESSAGE, StatusMessageModel.Create(Properties.Resources.ExamItemResponseAddSuccessfully, false));

    I'm trying to replace the TempData.Put(TempDataKey...) stuff because I that is in the Constants file and I'm getting rid of that altogether. I want to have the message come from the Resources file.

    C# tutorial help question learning

  • How to reference resource from Resources file
    B Bootzilla33

    I have a bunch of messages in a Constants file that I want to convert all string constants for messages displayed to users to be moved to a localized/globalization resource file. I created a Resources.resx file and I'm trying to figure out how to reference a resource in a controller. For example this resource in my Resources.resx file

    internal static string ExamItemResponseAddSuccessfully {
    get {
    return ResourceManager.GetString("ExamItemResponseAddSuccessfully", resourceCulture);
    }
    }

    I want to reference it in a controller POST action to replace the bolded reference to the string constant in the method below. How do I reference the resource above in the method below.

    public async Task CreateDorItemResponse(CreateEditDorItemResponseViewModel dorToCreateItemResponse, CancellationToken cancellationToken)
    {
    // Create a new Dor Item PacketResponse to receive the required properties from the view model
    var newDorItemResponse = new DorItemResponse();

            // Attempt to transfer the properties from the view model into the Dor
            if (ModelState.IsValid)
            {
                try
                {
                    //Get the item to return back to Edit Item page.
                    var item = await \_dorService.GetItemAsync(dorToCreateItemResponse.ItemId, cancellationToken)
                        .ConfigureAwait(true);
                    // Save the Dor Item Response
                    \_mapper.Map(dorToCreateItemResponse, newDorItemResponse);
                    newDorItemResponse.CreatedBy = User.Identity.Name;
                    newDorItemResponse.ModifiedBy = User.Identity.Name;
                    await \_dorService.CreateEditItemResponse(newDorItemResponse, User.Identity.Name, cancellationToken).ConfigureAwait(true);
                    **TempData.Put(TempDataKey.Dor.RESPONSE\_ADD\_MESSAGE, StatusMessageModel.Create(Constants.Dor.RESPONSE\_ADD\_SUCCESS, false));**
                    return RedirectToAction(nameof(EditDorItem), new {id = item.ItemId, dorId = item.DorId});
                }
                catch (Exception)
                {
                    // Save failed, add an error message and reload the same page
                    TempData.Put(TempDataKey.Dor.RESPONSE\_ADD\_MESSAGE, StatusMessageModel.Create(Constants.Dor.RESPONSE\_UPDATE\_FAIL));
                }
            }
            // Validation failed, reload the same page
    
    C# tutorial help question learning

  • How to randomly generate a number or characters in an Authorization Class file
    B Bootzilla33

    Another smarmy smartass. Wow you are you fucking dumb. I don't have any other code besides what I posted. I don't know where to begin with code to generate a PIN number that's why I asked! Fuck off asshole seriously. I don't want to hear it from the moderators. There is no excuse for responding to me the way this guy responded to me. None!

    C# json database security help tutorial

  • How to randomly generate a number or characters in an Authorization Class file
    B Bootzilla33

    I need help creating a class file that randomly generates a number of 10 characters, 0-9, A-Z. By generating a PIN it will create an authorization workflow to allow the user to authenticate the app. This number will be directed to a config file instead of a URL. The user goes thru a auth process and instead of calling back a URL there will be a page to randonly generate a pin. The randomly generated PIN will be stored in a database table. For the database columns would get set properties be the best approach for each column in that table? Would this be the best approach for REST API? I am not very familiar with API's. Something like this

    public class AuthorizationPIN
    {
    public int Id { get; set; }
    public string AccessCode { get; set; }
    public string PIN { get; set; }

    }
    
    C# json database security help tutorial

  • C# .Select Method
    B Bootzilla33

    Would something like this work

    var query = (from c in doc.Root.Descendants("TrackingEvent") select c).ToList();
    foreach (XElement element in query)
    {
    new XElement("EventStatus", EventCode.Delivered.ToXml()),
    Response.Write(element.Value);
    }

    C# csharp xml json help tutorial

  • C# .Select Method
    B Bootzilla33

    I want to do a .Select for the rest of the fields: EventStatus, EventReason, and EventDateTime like I'm doing for the TrackingEvent and am not sure how to do that. Richard Deeming was helpful in get me started with this but need help with the rest. TrackingEventHistory is the root for XML element I'm trying to output. The rest (EventStatus, EventReason, EventDateTime) are "children" within that root. There can be multiple TrackingEventHistory's so I'm trying to create a loop for the root and it's children. I'm not sure if .Select is the best way.

    new XElement("TrackingEventHistory",
    prc.History.Cast().Select(item => new XElement("TrackingEventDetail",
    new XElement("EventStatus", EventCode.Delivered.ToXml()),
    new XElement("EventReason", prc.History),
    new XElement("EventDateTime", prc.History))

    C# csharp xml json help tutorial

  • Error 'not all code paths return a value'
    B Bootzilla33

    Getting errors in this code on 'ToXml':

    public class EventCode
    {
    public static string ToXml(Soap.EventCode.EvCodes value)
    {
    switch (value)
    {
    case Soap.EventCode.EvCodes.DispatchedForDelivery:
    case Soap.EventCode.EvCodes.Delivered:
    return "OD";
    case Soap.EventCode.EvCodes.DepartedFromTerminal:
    return "L1";
    }
    }
    }

    What am I doing incorrectly so I can fix this error:

    C# help wcf xml

  • Need help with API Values in XElement
    B Bootzilla33

    Bootzilla33 wrote:

    I asked this question in another thread but no one answered it so I'm creating a new thread to see if someone can help. I need help with pass the value in the API to XElement in C# Here the a piece of the API schema:

    <xsd:element
    name="EventStatus" type="xsd:string">
    xsd:annotation\
    xsd:documentation\Event Status</xsd:documentation>
    </xsd:annotation>
    </xsd:element>

    Is this how that would be done?

    new XElement("EventStatus", "Event Status"),
     
    ),

    XML / XSL question csharp database xml json

  • Need help with API Values
    B Bootzilla33

    I asked this question in another thread but no one answered it so I'm creating a new thread to see if someone can help. I need help with pass the value in the API to XElement in C# Here the a piece of the API schema:

    Event Status

    Is this how that would be done?

    new XElement("EventStatus", "Event Status"),

    ),

    C# question csharp database xml json

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    Someone please help me with this. I would greatly appreciate it. Thanks

    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    Bootzilla33 wrote:

    Here the a piece of the API schema:

    <xsd:element
    name="EventStatus" type="xsd:string">
    xsd:annotation\
    xsd:documentation\Event Status</xsd:documentation>
    </xsd:annotation>
    </xsd:element>

    I guess it will look like this?

    new XElement("EventStatus", "Event Status"),
    

    ),

    Just need help with this and I think I'm done.

    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    Yes i've read it and if that is the case then the values in the API are the same as the XElement so Here the a piece of the API schema:

    Event Status

    I guess it will look like this?

            new XElement("EventStatus", "Event Status"),
            
        ),
    
    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    Richard Deeming wrote:

    If you have to pass a value, then pass the value that the API is expecting.

    What would that be? Something like:

    new XElement("PickupStoreInfo",
    new XElement("PickupDueDateDetails",
    new XElement("Date", Date),
    new XElement("UTCOffset", UTCOffset)
    ),

    Not sure???

    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    I have the same thing for prc.Consignee. So what would you suggest something like this:

    ),
    new XElement("PickupStoreInfo",
    new XElement("PickupDueDateDetails",
    new XElement("Date"),
    new XElement("UTCOffset")
    ),

    I pretty much have to pass a value in the node or else how else would I get the values?

    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33
    1. This may help explain. This is some of the XML I am trying to write out:

    LK
    AQ
    2004-08-22T11:00:00-
    08:00
    SEATTLE
    WA
    98107
    US
    JOHN GALT

    2004-08-25
    -07:00
    92253
    US-PRI-DEL-03
    19632
    NW Market St
    SEATTLE
    WA
    98107
    US

    Am I doing a rspxml.Root.Add for each section or can I use like this:

    new XElement("PickupStoreInfo",
    new XElement("PickupDueDateDetails",
    new XElement("Date", prc.History),
    new XElement("UTCOffset", prc.History)
    ),

    So based off this, how would that be written out in the code. 2) I updated the code and that seems to be working ok. 3) It does compile. And yes those are supposed to be prc.History. There are only two elements/fields that I'm concerned with and that is the Consignee and History so yes they should be prc.History. I just need to pull in the fields for in those two areas.

    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    OK this is what I have now and it seems to be working. A couple of questions/issues: 1. If you look at the commented out code below with the .ToString, I have PickupStoreInfo and then PickupDueDateDetails which is setup similar to the TrackingEventHistory and TrackingEventDetail, so would that be set up the same way with the Cast or should that be setup differently or is it ok like it is now.

    rspxml.Root.Add(new XElement("PickupStoreInfo"));
    // rspxml.Root.Add(new XElement("PickupDueDateDetails"));
    // rspxml.Root.Element("PickupDueDateDetails").Add(new XElement("Date", prc.History.ToString()));
    // rspxml.Root.Element("PickupDueDateDetails").Add(new XElement("UTCOffset", prc.History.ToString()));

    2. You mentioned about using one of either XDocument or XmlDocument, I tried this and when I change to XDocument on this line:

    XmlDocument doc = new XmlDocument();

    I get errors 'XDocument' does not contain a definition for 'XmlResolver' and no extension method 'XmlResolver' accepting a first argument of type 'XDocument' could be found (are you missing a using directive or an assembly reference?). Same error definition for FirstChild, LoadXML. If I change everything to XmlDocument like on this line from XDocument to XmlDocument:

    rspxml = XDocument.Parse

    I get 'XmlDocument does not contain definition for 'Parse'. 3.Is all of my syntax correct, specifically all of the parentheses after this line:

    new XElement("CountryCode", prc.History)

    I really appreciate all of your help and look forward to your response. Here is the full code for this method:

    public string ProcessXML(string xmlRequest)
    {
    XDocument rspxml = null;
    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;
    
    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    I already have these using System.Linq; using System.Xml.Linq; You mentioned Cast to something else but not sure what to do there. Anyone else with any suggestions would be appreciated.If no one has any suggestions then I will have to go back to the ToString code I had previously and just go with that. This is what I have now:

    public string ProcessXML(string xmlRequest)
    {
    XDocument rspxml = null;
    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")
                {
                    Saia.Data.General.Shipment prc = new Data.General.Shipment();
                    string pronum = mainNode.SelectSingleNode("TrackingNumber").InnerText;
                    prc.GetByProNumber(decimal.Parse(pronum));
    
                    if (string.IsNullOrEmpty(pronum))
                    {
                        rspxml = XDocument.Parse("4.012345678ERROR\_101INVALID TRACKING NUMBER");
                    }
                    else
                    {
                        decimal tn = 0.0m;
    
                        if (decimal.TryParse(pronum, out tn))
    
                        {
                            prc.GetByProNumber(tn);
                        }
                        else
                        {
                            Console.WriteLine("Unable to parse '{0}'.", pronum);
    
    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    rspxml.Root.Add(
    new XElement("API", "4.0"),
    new XElement("PackageTrackingInfo",
    new XElement("TrackingNumber", prc.ProNumber)
    ),
    new XElement("PackageDestinationLocation",
    new XElement("City", prc.Consignee),
    new XElement("StateProvince", prc.Consignee),
    new XElement("PostalCode", prc.Consignee),
    new XElement("CountryCode", prc.Consignee)
    ),
    new XElement("PackageDeliveryDate",
    new XElement("ScheduledDeliveryDate", prc.Consignee),
    new XElement("ReScheduledDeliveryDate", prc.Consignee)
    ),
    new XElement("TrackingEventHistory",
    prc.History.Select(item => new XElement("TrackingEventDetail",
    // TODO: Use the correct properties from the item, which weren't shown in your code:
    new XElement("EventStatus", item.EventStatus),
    new XElement("EventReason", item.EventReason),
    new XElement("EventDateTime", item.EventDateTime),
    new XElement("EventLocation", item.EventLocation)
    )
    )
    );

    @RichardDeeming, Question about this code. On the

    new XElement("TrackingEventHistory",
    prc.History.Select(item => new XElement("TrackingEventDetail",

    line what should that be because you have .Select but that gives me an error 'Shipment.HistoryCollection' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'Shipment.HistoryCollection' could be found (are you missing a using directive or an assembly reference?) Is that code I should use and need to add something to eliminate the error. What I was thinking it should be is:

    new XElement("TrackingEventHistory",
    new XElement("TrackingEventDetail",
    // TODO: Use the correct properties from the item, which weren't shown in your code:
    new XElement("EventStatus", prc.History),
    new XElement("EventReason", prc.History),
    new XElement("EventDateTime", prc.History),
    new XElement("EventLocation", prc.History)

    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    I am using XML because I'm outputting it to AWS. So I don't have a choice unfortunately.

    C# sysadmin debugging xml json help

  • How to handle multiple exceptions(Try..Catch)
    B Bootzilla33

    So where would the model class go in relation to my code. Would it be outside of the XElement code? Before it? After it?

    C# sysadmin debugging xml json help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups