public ResponseModel DownloadReportSearch(int SchedulerID) { ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; SettingsCaller dbSearchMaster = new SettingsCaller(); string strCSV = string.Empty; try { string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); var temp = SecurityService.DecryptStringAES(token); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); strCSV = dbSearchMaster.DownloadReportSearch(new ReportService(Cache, Db), SchedulerID, authenticate.UserMasterID, authenticate.TenantId); string dateformat = DateTime.Now.ToString("yyyyMMddHHmmssffff"); string csvname = "Repost" + SchedulerID + "_" + dateformat + ".csv"; var exePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); Regex appPathMatcher = new Regex(@"(?<!fil)[A-Za-z]:\\+[\S\s]*?(?=\\+bin)"); var appRoot = appPathMatcher.Match(exePath).Value; string folderPath = Path.Combine(appRoot, "ReportDownload"); string URLFolderpath = Path.Combine(rootPath, "ReportDownload"); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } folderPath = Path.Combine(folderPath, csvname); URLFolderpath = URLFolderpath + @"/" + csvname; CommonService.SaveFile(folderPath, strCSV); statusCode = (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; if (System.IO.File.Exists(folderPath)) { FileInfo fileInfo = new FileInfo(folderPath); float sizeInMB = (fileInfo.Length / 1024f) / 1024f; if (sizeInMB > 5) { objResponseModel.ResponseData = !string.IsNullOrEmpty(URLFolderpath) ? URLFolderpath + "@mail" : null; } else { objResponseModel.ResponseData = URLFolderpath; } } // objResponseModel.ResponseData = !string.IsNullOrEmpty(URLFolderpath) ? URLFolderpath : null; } catch (Exception) { throw; } return(objResponseModel); }