|
public static string ToXml(Soap.EventCode.EvCodes value)
{
string returnValue = null;
switch (value)
{
case Soap.EventCode.EvCodes.DispatchedForDelivery:
case Soap.EventCode.EvCodes.Delivered:
returnValue ="OD"; break;
case Soap.EventCode.EvCodes.DepartedFromTerminal:
returnValue ="L1"; break;
}
return returnValue;
}
modified 26-Sep-17 7:17am.
|
|
|
|
|
You'll need some break s in there.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
corrected 
|
|
|
|
|
Are you sure? It's showing as "modified", but I still don't see any break s.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
oh my!!
earlier "= " sign was missing, initially i thought that and corrected, after adding the code in visual studio code editor i realized that "break " is missing.
Now its finally corrected
this is the problem when writing the code without using code editor software
|
|
|
|
|
In your example there would be nothing to return if value where not one of the handled cases. You need to specify a return value for ALL cases or throw an exception for invalid values. One way to do this is by using the default case in your switch statement.
Here is an example:
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";
default: throw new ArgumentOutOfRangeException(nameof(value), "Unsupported Evcode: " + value);
}
}
}
modified 19-Oct-17 11:32am.
|
|
|
|
|
Anyone know if it's possible to extract or read the contents of VBA BAS files from MS Access using C#?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Certainly possible. Doesn't mean it is cost effective though.
You would of course first need to figure out the format of the file.
Although you might want to consider whether all you want to do is read it. If you want to execute it then reading it is probably pointless unless you intended to replicate functionality that probably exists somewhere.
|
|
|
|
|
I don't want to execute it.
Do you know HOW to extract the code from VBA?>
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Well, I'm thoroughly confused by your response.
enhzflep wrote: Mate, there's no need to SHOUT. Your question is perfectly clear without it. It merely gives the impression of someone too inarticulate to ask for the information they require who then becomes frustrated and raises their voice at the person that perfectly answered their ill-formed question. Not generally seen as a desirable personal attribute... Where did you get "shouting" or "raising their voices" from? Where did this little tirade come from? You'll have to clarify that for me.
enhzflep wrote: Typing "c# extract vba from access" into google
I DID look at Google. I ALWAYS go to Google. I also always come here because I know CP to be a treasure trove of experienced developers. More than once I've gotten answers or code from other devs here without spending hours sifting through half baked or off topic Google code samples.
enhzflep wrote: Since I've got 20 seconds to kill that I can donate to someone clearly to busy to expend it themselves, here's the first couple.
How did you come to a point where you felt it necessary to insult me? Again, I'm going on the assumption here that I somehow offended you, which I can't for the life of me see how or where.
Look, I asked a simple question. You clearly don't have an answer. I'm not interested in continuing a discussion with someone who has no substantive contribution to the problem other than redirect me to Google.
Save your replies.. I don't feed trolls.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Kevin Marois wrote: I DID look at Google. I ALWAYS go to Google
You should specifically mention that in your first post. Given that there are so many google results you might also want to point out why those are inadequate in your post (first one.)
|
|
|
|
|
enhzflep wrote: Mate, there's no need to SHOUT
I think he was emphasizing rather than shouting.
|
|
|
|
|
No idea, in fact I started working in C# last week (and you can imagine the level of knowledge I have now).
Two ideas:
- If it would be possible to open access files in Visual studio you could try to use the DTE option (accessing the same Visual studio interface programatically to do what you are after).
-- In case this is not possible, who knows if you have an alternative to DTE but for Microsoft Access.
- Another method that could work (again no idea) see: automating access[^]
No idea if any of this could help you... just thought it wouldn't harm to let it here.
Hope this helps.
Good luck!
|
|
|
|
|
|
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"),
),
|
|
|
|
|
|
Bootzilla33 wrote: Is this how that would be done?
No.
From the fragment you have an 'element' which has an 'attribute' which has a 'name' of "name" (the two are not the same) and has a 'value' of "EventStatus".
Then you have another attribute also.
Then that element has other elements under it.
The documentation for XElement demonstrates some of this and more importantly demonstrates how you can print out the result so you can see it yourself.
XElement Class (System.Xml.Linq)[^]
You can look for other examples using XElement and XAttribute.
I want to emphasize that figuring out how to print these out is the most important thing you can learn. You need that even once you understand most of it.
|
|
|
|
|
Hello Community.
I have built an aplication wich interacts with a webserver as if it were a browsing user. It can log in, browse products and select a product to buy. Unfortunately when it comes to actually buying the product the server returns just the logintoken and the shopping cart is still empty.
I suppose the session cookie is not sent.
Is there any way I can debug the httpclienthandler? I am a beginner in Programming and I hoped there was a way similar to Chome debugger console.
best regards,
julian
|
|
|
|
|
Hi there,
I am experiencing issue with split method. When I try split something like this:
06302017;37;Denver; Other Non-Interest Expense from RI item 7.d. : Travel Expense=$88,799. Excess public-facing website address listings f rom
RC-M line 8.b.: sparkalpha.com, www.getsparkalpha.com, www.getsparkalpha.com, www.sparkalpha.com; 07282017;Other; RCM; M4b
The tab that occurs is not my doing but what actually happens with that mass of string and I believe it is causing my problem. It splits this in half into two different arrays. This is problematic because each item separated by a ';' corresponds to a field so it causes an out of bounds error. Any suggestions on how to get it to keep the 8 different strings within the split? Based on how my program is run, I cannot make a special case of this and expect it to work well.
By the way, I didn't write the line that I'm trying to split so I cannot fix it myself. I am grabbing a file from a website location and then splitting it so that the data can be used for a database.
Thank you for your help.
|
|
|
|
|
Split is unlikely to do what you want. It sounds like you are looking for a CSV reader.
Or, if you are using SQL Server, try the bcp utility.
|
|
|
|
|
I'm currently taking in the file through a Streamreader and then running a method which has the split method. It works for all other lines except that one. It's because of the tab that inconveniently gets thrown in. I'm trying to use C# right now. I will see if CSV reader is any better.
|
|
|
|
|
What are you trying to split it into? If you know what characters you want to split on then just add them to the splitter set.
|
|
|
|
|
I am trying to split it by ';'. This is a file that I'm reading in. 20170630;37;Denver;Other Non-Interest Expense from RI item 7.d. : Travel Expense=$88,799. Excess public-facing w ebsite address listings f rom
RC-M line 8.b.: sparkalpha.com, www.getsparkalpha.com, www.getsparkalpha.com, www.sparkcapitalone.com.;20170728;Explanations;Call;m1b
C# keeps bringing the RC-M down a line (tabs it which isn't in the file). It is screwing up my delimitation and causing an out of bounds error. This doesn't happen anywhere else in the file.
class Program
{
static void Main(string[] args)
{
string CurrentLine;
string FilePath = "C:\\12837.SDF.txt";
using (StreamReader sr = new StreamReader(FilePath))
{
while(!sr.EndOfStream)
{
CurrentLine = sr.ReadLine();
GetSplit(CurrentLine);
}
}
}
private static void GetSplit(string CurrentLine)
{
string[] array = CurrentLine.Split(';');
string first = array[0];
string second = array[1];
string third = array[2];
string four = array[3];
Console.WriteLine(first + " " + second + " " + third + " " + four);
}
}
}
This is the test code I'm running for reference and not the actual code I end up using but it still comes up no matter what. I tried to Replace it and I might just try to skip the line when it pops up. By the way, I have the comments in there because I'm trying to see how many indexes it actually brings in.
Here's what it looks like in console:
20170630 112837 Denver Other Non-Interest Expense from RI item 7.d. : Travel Expense=$88,799. Excess public-facing w ebsite address listings f rom
RC-M line 8.b.: sparkalpha.com, www.getsparkalpha.com, www.getsparkalpha.com, www.sparkcapitalone.com. 20170728 explanations RIE
Here's what the different line looks like:
20170630 112837 Denver Adjustment investment
|
|
|
|
|
WoodChuckChuckles wrote: C# keeps bringing the RC-M down a line I don't know what you mean by that, but I don't think C# will do anything with your data. When I run your code (using the text in your question) I get the following output:
1: 20170630
2: 37
3: Denver
4: Other Non-Interest Expense from RI item 7.d. : Travel Expense =$88,799.Excess public-facing website address listings fromRC-M line 8.b.: sparkalpha.com, www.getsparkalpha.com, www.getsparkalpha.com, www.sparkcapitalone.com.
5: 20170728
6: Explanations
7: Call
8: m1b
|
|
|
|