|
Hi,
I have Sage Peachtree 2012. I can see the API folder in C:\Program Files (x86)\Sage\Peachtree but there are no documentation available.
Anyone tried to work on the integration to read / write into Sage Peachtree with C#?
How to get started with it?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
Googling using the following certainly seems to suggest that documentation can be found.
peachtree api documentation
|
|
|
|
|
OK, this may be a stupid question, but I am trying to write an utility method to convert an instance of a class to Dictionary<string, string> where the key being the property's name and the value being its value. I have already taken care of string and the primitive types and other types. The problem is with System.Array and collections.
What I am trying to achieve is, if I have an instance of a class having ICollection<string> MyProperty property with a few string values, the dictionary item for this property should be something like {MyProperty, {Val1,Val2,..}} i.e. comma separated values as the value for the dictionary item.
The method I have is:
private string GetValueForNonPrimitiveProperty(PropertyInfo property)
{
StringBuilder value = new StringBuilder();
if (property.PropertyType == typeof(string))
{
value.Append(property.GetValue(this));
}
else if (property.PropertyType.Namespace.Contains(CollectionsNamespace) || property.PropertyType.IsArray)
{
var collection = property.GetValue(this);
}
...
return value.ToString();
} is giving me proper value-collection in collection variable along with "appropriate" type but only at runtime (it's an object at compile-time). But since I only get to know the "actual" type of the collection (like List<string> , List<int> , etc, but List of only simple types), I am not sure how to iterate through those values.
I tried casting collection to List<object> hoping to then iterate over after casting, but the cast is returning a null .
Also, simply checking the property-type's namespace against "System.Collections" doesn't seem to be the proper way to check for a collection-type. Please suggest.
Any help would be greatly appreciated.
Whether I think I can, or think I can't, I am always bloody right!
modified 23-Sep-14 7:58am.
|
|
|
|
|
Just curious: are you actually trying handle instances of Classes that might have multi-dimensional Arrays, or generic Lists which contain other generic Lists, like: List<List<int>> ?
Is it possible you "off-load" the possibly complex parsing task by serializing the Class instance into XML, or JSON, and then read that back in, and parse that ?
Care to say why you are pursing this ?
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
No, there will only be collections of simple types (int, string, etc), as I see the classes. It's not entirely my code.
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Agent__007 wrote: there will only be collections of simple types (int, string, etc), That leaves me with the question of why this particular string format representation of the Class' content is what you want. What's wrong about the XML, or JSON result of serializing ?
In any case, good luck
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
BillWoodruff wrote: why this particular string format representation of the Class' content is what you want. As far as I am told, these values of collections (like Value1,Value2,..) will be passed to an API through its URI. I can't argue with them or even think much about it at the moment as I am working on 3 projects in parallel...
I have found a solution, please see the replies below. Thanks anyway.
And yeah, I indeed need a good luck! Thanks for that..
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
I appreciate you were not offended by my question; I was planning to delete this (second) post, feeling like it kind of violates some kind of ethic I can't quite define ... "Thou shalt not Nag" ?
I post "speculative" questions on CP, and, this is the language discussion forum; may we all enjoy the freedom to explore the "outer limits," and, how excellent that, in many cases ... including this one ... the result is valuable, and educational !
cheers, Bill
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
Just out of curiosity, what is the final purpose of this exercise?
That said, you could try this code inside
else if (property.PropertyType.Namespace.Contains(CollectionsNamespace) || property.PropertyType.IsArray)
{
object[] values = (object[])property.GetValue(data, null);
if (values != null)
{
foreach (object o in values)
{
Type t = o.GetType();
}
}
}
|
|
|
|
|
Sorry, but the cast to object[] doesn't work. I have found a solution, please see Eddy Vluggen's answer below. Thanks anyway
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Hopefully this may be of some use.
List<int>; d = new List<int>() { 1, 2, 3, 4, 5, 6 };
if (typeof(IList).IsAssignableFrom(d.GetType()) == true && d.GetType().IsGenericType == true)
{
IList x = d;
Type t = x.GetType().GetGenericArguments()[0];
foreach (object item in x)
{
switch (t.Name)
{
case "Int32":
int r = (int)item;
break;
default:
break;
}
}
}
My only part I wasn't sure of was casting the object back to type that was in the list, So I used a simple switch statement to do the hard work for me. Also apologies for the crap variable naming too.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Interesting! But I think I can simply cast the collection it to IEnumerable<object> and then simply .ToString() them in the final string, that should work, as I see the classes at the moment. Thank you very much!
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
If it is an IEnumerable, then it can be iterated.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Told you that was a stupid question! But I wonder how I missed that.
Did a cast to IEnumerable<object> and it worked! Thank you very much!
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Hi Everyone .
how TCPServer can send file to client ??
but my question is i want to send file to client : but client is having some folder like Usr, Bin and etc.
but i want send file from server to client folder to "USR"
is it possible . if any knows please help me out
|
|
|
|
|
Usually clients actively fetch data from a server.
Do you want to push a file to a connected client?
|
|
|
|
|
yes. but client is having folder USER and BIN.
i want store file in to USER folder in client side.
|
|
|
|
|
|
That could be considered a malware approach! Do not do that.
|
|
|
|
|
The client decides where to store the file, you cannot control it from the server.
|
|
|
|
|
Hi all,
I have my html page. I put the correct and full path of images. As I run the page it's showing all images perfectly. But when I use this html code as a newsletter, all content is coming except images.
my images code is like below
<pre lang="HTML"> <img height="0" src="https://XXXXXXXXX/1410944453/bdb6c634e3/IUWM.jpg" style="max-width: 200px; width: 200px; height: auto !important;" width="200" /></pre>
|
|
|
|
|
Does this have anything to do with C#?
|
|
|
|
|
if mails comes through c# code? then?
|
|
|
|
|
Then show the code that is not working and explain why. All you have given us is a vague description of something not happening.
|
|
|
|
|
As Richard has stated this isn't a C# problem, but a Outlook problem. It all changed when they dropped internet explorer from rendering the HTML emails and swapped it to word.
I would have a read of this SO Question[^], the first answer shows you in code how to achieve it.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|