public HttpResponseMessage DownloadOnToken(string TokenId)
        {
            
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Request");
            }

            DownloadActions downloadActions = new DownloadActions();
            TokenResponseModel responseModel = downloadActions.DownloadOnToken(TokenId);

            if (responseModel.Error != null)
            {
                return Request.CreateResponse(HttpStatusCode.OK, responseModel, "application/json");
            }


            FileInfo fileinfo = new FileInfo(responseModel.filePath);
            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            response.ClearContent();
            response.Clear();
            response.ContentType = "application/x-gzip";
            response.AddHeader("Content-Disposition", "attachment; filename=" + fileinfo.Name + ";");
            response.AddHeader("Content-Length", fileinfo.Length.ToString());
            response.TransmitFile(fileinfo.FullName);
            response.Flush();
            response.End();


            return Request.CreateResponse(HttpStatusCode.OK, responseModel, "application/json");
        }
        public HttpResponseMessage DownloadDataset(DataRequestModel requestModel)
        {


            if (requestModel == null)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Request");
            }

            requestModel = new DataRequestModel()
            {
                AppId = requestModel.AppId,
                DatasetID = requestModel.DatasetID,
                GUID = requestModel.GUID,
                DeviceId = requestModel.DeviceId

                //AppId = 1,
                //DatasetID = 4,
                //GUID = Guid.Parse("90b2044c-ae0a-46f3-9260-acf3a058294a"),
                //DeviceId = "Hammads"
            };

            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Request");
            }

            DownloadActions downloadActions = new DownloadActions();
            DataResponseModel responseModel = downloadActions.DownloadData(requestModel);

            if (responseModel.Error != null)
            {
                return Request.CreateResponse(HttpStatusCode.OK, responseModel, "application/json");
            }

            return Request.CreateResponse(HttpStatusCode.OK, responseModel, "application/json");
        }