tag:blogger.com,1999:blog-90005062796291295992024-03-12T17:42:59.493-07:00Web Api ServicesAnonymoushttp://www.blogger.com/profile/07725042225303796840noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-9000506279629129599.post-11947099737556149552012-07-14T06:33:00.000-07:002012-07-14T06:39:43.514-07:00Kanga api<a href="https://kangapi.codeplex.com/">yup, I'm done with it. The kanga api project has started.</a>
It has been quite easy to play with <a href="http://kangamodeling.codeplex.com/">this modeling platform published on CodePlex</a>.
<div class="separator" style="clear: both; text-align: center;">
<a href="http://farm9.staticflickr.com/8007/7567731492_6cc7d852c3.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="257" width="500" src="http://farm9.staticflickr.com/8007/7567731492_6cc7d852c3.jpg" /></a></div>
It's a nice project and they also expose an api in order to provide a services based software.
But for educational purpose I've been playing around with the code and embedded it in an MVC4 Web Api project.
<br/>
Also provided a method to visualize the diagram as encoded base64 background image. I'm still working on this. Not sure why the image doesn't show up, it could be a different way to encode it through my c# classAnonymoushttp://www.blogger.com/profile/07725042225303796840noreply@blogger.com0tag:blogger.com,1999:blog-9000506279629129599.post-69783442697738530772012-07-12T08:34:00.000-07:002012-07-12T08:55:21.885-07:00RGraphWebApi instructions #1First of all you should understand two things.
<ul>
<li>
we need to automatize the way data ara loaded. Of course you can get your data from a db or any other repository but it was quite natural to me consider csv as the basic structure out of which data could be displayed. (the folder -repository- is App_Data\Series)
</li>
<li>
the structure is this:
<ul>
<li>
we do have a header, that is not accounted while the data are loaded by the application
<br/>
<b>X;Y;XLabel;YLabel;Notes</b>
</li>
<li>
and rows of data according to the header
<br/>
12,00;;Jan;;notes for january
</li>
</ul>
</li>
</ul>
Now how do we go from this?
It's quite simple:
<br/>
we do have a class that has a property collection of DataPoint;
<br/>
the property is called
<strong>public <span class="blue">List</span> <<span class="blue">DataPoint</span> > SeriesPoints</strong>
and can you guess what a DataPoint is?<br/>
Well, you can judge for yourself:
<br/>
<span class="blue"> public</span> <span class="azure"> class</span> DataPoint<br/>
{<br/>
[Required]<br/>
<span class="blue">public</span> <span class="azure">decimal</span> X { get; set; }<br/>
<span class="blue">public</span> <span class="azure">decimal?</span> Y { get; set; }<br/>
[Required]<br/>
<span class="blue">public</span> <span class="azure">string</span> XLabel { get; set; }<br/>
<span class="blue">public</span> <span class="azure">string</span> YLabel { get; set; }<br/>
<span class="blue">public</span> <span class="azure">string</span> Notes { get; set; }<br/>
}<br/>
<h1>Elementary my dear Watson!!!</h1>
<style type="text/css">
.azure
{
color:azure; font-weight: bold;
}
.blue
{
color:blue; font-weight: bold;
}
.green
{
color:green; font-weight: bold;
}
.code
{
font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif;
font-weight: bold;
}
</style>Anonymoushttp://www.blogger.com/profile/07725042225303796840noreply@blogger.com0tag:blogger.com,1999:blog-9000506279629129599.post-31847541436808616962012-07-10T06:06:00.001-07:002012-07-10T06:34:54.579-07:00Web Api default xml formatter.The default formatter in the <a target="_blank" href="http://www.asp.net/web-api">Mvc web api</a> is an XML formatter.<br />
To disable it, it's necessary to remove it from the default formatters.<br />
In the Global.asax.cs (if we talk c#) you should add these lines of code:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-YL_ohePyiHY/T_cIFOZfkDI/AAAAAAAAApY/vWbwHIW956E/s1600/web_api1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://1.bp.blogspot.com/-YL_ohePyiHY/T_cIFOZfkDI/AAAAAAAAApY/vWbwHIW956E/s400/web_api1.png" width="600" /></a></div>
<blockquote class="code">
<span class="green"> // The Web API Configuration Object</span><br />
<span class="blue"> var</span> config = GlobalConfiguration.Configuration;
<br />
<span class="green"> // Remove the XML Formatter</span><br />
<span class="blue"> var</span> xmlFormatter = config.Formatters<br />
.Where(f =><br />
{<br />
<span class="blue"> return</span> f.SupportedMediaTypes.Any(v => v.MediaType == "text/xml");<br />
})<br />
.FirstOrDefault();<br />
<br />
<span class="blue"> if</span> (xmlFormatter != <span class="blue"> null</span>)<br />
{<br />
config.Formatters.Remove(xmlFormatter);<br />
}<br />
<br /></blockquote>
<style type="text/css">
.blue
{
color:blue; font-weight: bold;
}
.green
{
color:green; font-weight: bold;
}
.code
{
font-family: "Segoe UI", Verdana, Helvetica, Sans-Serif;
font-weight: bold;
}
</style>Anonymoushttp://www.blogger.com/profile/07725042225303796840noreply@blogger.com0