Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » TraceController

Public general use code classes and xml files that we've compiled and used over the years:

Trace API Controller class.

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