Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/poppa/csharp-lime-pro
A C# interface to the web services of the CRM Lime PRO
https://github.com/poppa/csharp-lime-pro
Last synced: 12 days ago
JSON representation
A C# interface to the web services of the CRM Lime PRO
- Host: GitHub
- URL: https://github.com/poppa/csharp-lime-pro
- Owner: poppa
- License: gpl-2.0
- Created: 2014-12-23T11:54:21.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-12T13:16:33.000Z (almost 9 years ago)
- Last Synced: 2024-11-04T03:41:35.501Z (2 months ago)
- Language: C#
- Size: 24.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
csharp-lime-pro
===============A C# helper module for the web services of the CRM **Lime PRO** by
[Lundalogik](https://github.com/lundalogik).There's a [PHP version](https://github.com/poppa/php-lime-pro) and a
[Java version](https://github.com/poppa/java-lime-pro) of this module
as well.This is not a full Lime PRO client but rather a helper module for building the
XML queries to send to Lime, as well as parsing the result. There is however
a sample client in the [test package](https://github.com/poppa/csharp-lime-pro/tree/master/Test).## Buildning an XML query
The easiest way to build a Lime XML query is by using the SQL to XML class. It
takes an SQL query and converts it into a [Node](https://github.com/poppa/csharp-lime-pro/blob/master/src/Xml.cs#L242)
object.```cs
using Lime.Xml;
using Lime.Sql;// ...
string sql =
"SELECT DISTINCT\n" +
" idsostype, descriptive, soscategory, soscategory.sosbusinessarea,\n" +
" webcompany, webperson, web, department, name\n" +
"FROM sostype\n" +
"WHERE active='1':numeric AND\n" +
" soscategory.sosbusinessarea != 2701 AND\n" +
" web=1 AND (webperson=1 OR webcompany=1)\n" +
"ORDER BY descriptive, soscategory DESC\n" +
"LIMIT 100";Node node = Parser.ParseSQL(sql);
```
The SQL query above will result in an XML document like this:
```xml
sostype
active
1
soscategory.sosbusinessarea
2701
web
1
webperson
1
webcompany
1
idsostype
descriptive
soscategory
soscategory.sosbusinessarea
webcompany
webperson
web
department
name
```
### Typehints
The SQL parser determines the data types in `WHERE` clause based on whether the
value is quoted or not. If it's not quoted it's assumed to be a numeric value.
If it's quoted it's assumed to be a string value. If it's quoted a check
for if the value is a (ISO 8601) date will take place.But in some cases you need to quote the value and have it as a numeric value,
for instance if you want to do a `IN` or `NOT IN` check on a numeric field.If that's the case you can use typehints:
```sql
WHERE some_col NOT IN '12;13;14':numeric
```Any thing like `:something` is assumed to be a typehint.
## Using a webservice client
Generate a webservice client from the Lime WSDL. In the test client I just
created in the namespace `Ws`.The webservice method `GetXmlQueryData` will return a string which is an XML
tree. This XML tree can be passed to the static `Xml.Node.Parse` method which
will turn the result into an `Xml.Node` object which also is an `Iterator` object
so it can easily be traversed.```cs
// ...
string sql =
"SELECT DISTINCT\n" +
" idsostype, descriptive, soscategory, soscategory.sosbusinessarea,\n" +
" webcompany, webperson, web, department, name\n" +
"FROM sostype\n" +
"WHERE active='1':numeric AND\n" +
" soscategory.sosbusinessarea != 2701 AND\n" +
" web=1 AND (webperson=1 OR webcompany=1)\n" +
"ORDER BY descriptive, soscategory DESC\n" +
"LIMIT 0, 5";var cli = new Ws.DataServiceClient("BasicHttpBinding_IDataService");
string data = cli.GetXmlQueryData(Builder.SqlToXml(sql));
Node ndata = Node.Parse(data);foreach (Node row in ndata.Children) {
Console.Write("* {0}\n", row.Attributes["descriptive"]);
}
```\# 2015-06-01