1: using System;
2: using System.Web.Http;
3:
4: namespace Ia.Ngn.Cl.Model.Api.Controller
5: {
6: ////////////////////////////////////////////////////////////////////////////
7:
8: /// <summary publish="true">
9: /// Trace API Controller class.
10: /// </summary>
11: ///
12: /// <remarks>
13: /// Copyright © 2001-2018 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
14: ///
15: /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
16: /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
17: ///
18: /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19: /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20: ///
21: /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
22: ///
23: /// Copyright notice: This notice may not be removed or altered from any source distribution.
24: /// </remarks>
25: public class TraceController : ApiController
26: {
27: ////////////////////////////////////////////////////////////////////////////
28:
29: /// <summary>
30: ///
31: /// </summary>
32: public TraceController()
33: {
34: }
35:
36: ////////////////////////////////////////////////////////////////////////////
37:
38: /// <summary>
39: /// Function used to call trace without having to use Entity Framework or connectionStrings
40: /// <code>
41: /// protected void Session_Start(object sender, EventArgs e)
42: /// {
43: /// // call trace inspect
44: /// using(kw.com.ia.api.trace.TraceClient traceClient = new kw.com.ia.api.trace.TraceClient()
45: /// {
46: ///
47: /// Ia.Cl.Model.Trace.Inspect(this.Request, traceClient.Inspect);
48: ///
49: /// //traceClient.Close();
50: /// }
51: /// }
52: /// </code>
53: /// </summary>
54: [HttpGet]
55: [Route("api/trace/insert/{userHostAddress}/{uriString}/{guidString}/{serverVariables}")]
56: public bool Insert(string userHostAddress, string uriString, string guidString, string serverVariables)
57: {
58: bool traceInserted;
59: Uri uri;
60: Guid guid;
61:
62: // function is used in Func and must return an int value;
63:
64: try
65: {
66: uri = new Uri(uriString);
67: guid = Guid.Parse(guidString);
68:
69: traceInserted = Ia.Cl.Model.Trace.Insert(userHostAddress, uri, guid, serverVariables);
70: }
71: catch (ArgumentNullException)
72: {
73: traceInserted = false;
74: }
75: catch (UriFormatException)
76: {
77: traceInserted = false;
78: }
79: catch (FormatException)
80: {
81: traceInserted = false;
82: }
83:
84: return traceInserted;
85: }
86:
87: ////////////////////////////////////////////////////////////////////////////
88: ////////////////////////////////////////////////////////////////////////////
89: }
90:
91: ////////////////////////////////////////////////////////////////////////////
92: ////////////////////////////////////////////////////////////////////////////
93: }