public void InsertPageData(TrackingDetails trak, uint session, string appName, bool eventonly = false)
        {
            Logger.WriteDebug("DataAccess: InsertPageData");
            string appId = Helper.GetDbValue(GetAppIdFromAppName(trak.AppName));
            string pageId = Helper.GetDbValue(GetPageIdFromPageName(trak.PageName, appId));
            string query = string.Empty;
            if (!eventonly)
            {
                query += string.Format("INSERT INTO {0}auto ([SessionId],[AppID],[PageID],[IP],[MachineName],[DeviceType],[Browser],[BrowserVersion],[Location],[OS],[Datetime]) VALUES('{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}'); ",
                appName, session, appId, pageId, trak.IP, trak.MachineName, trak.DeviceType, trak.Browser, Helper.GetBrowserVersion(trak.BrowserVersion), trak.Location, trak.OS, trak.Datetime);
                ExecuteNonQuery(query);
                query = string.Empty;
            }

            if (trak.UserAttributes != null)
            {
                foreach (var c in trak.UserAttributes)
                {
                    query += string.Format("INSERT INTO {0}user ([UId],[SessionId],[AppID],[PageID],[Datetime],[KeyPair],[ValuePair]) VALUES('{1}','{2}','{3}','{4}','{5}','{6}','{7}'); ",
                       appName, Guid.NewGuid().ToString(), session, appId, pageId, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), c.Key, c.Value);
                }
            }

            ExecuteNonQuery(query);
        }
 public HttpResponseMessage TrackEvent(TrackingDetails trak)
 {
     try
     {
         if (trak != null)
         {
             bool isSuccess = business.InsertPageData(trak, true);
             return Request.CreateResponse<bool>(HttpStatusCode.OK, isSuccess);
         }
         else
             return Request.CreateResponse(HttpStatusCode.BadRequest, "requestObject is Empty");
     }
     catch (Exception ex)
     {
         Logger.WriteError(ex);
         return Request.CreateResponse(HttpStatusCode.BadRequest, ex.ToString());
     }
 }
 public HttpResponseMessage TrackPageLoad(TrackingDetails trak)
 {
     try
     {
         if (trak != null)
         {
             trak.IP = HttpContext.Current.Request.UserHostAddress;
             trak.MachineName = HttpContext.Current.Request.UserHostName;
             business.UserAgent = Request.Headers.UserAgent.ToString();
             bool isSuccess = business.InsertPageData(trak);
             return Request.CreateResponse<bool>(HttpStatusCode.OK, isSuccess);
         }
         else
             return Request.CreateResponse(HttpStatusCode.BadRequest, "requestObject is Empty");
     }
     catch (Exception ex)
     {
         Logger.WriteError(ex);
         return Request.CreateResponse(HttpStatusCode.BadRequest, ex.ToString());
     }
 }