public string ExportCustomerAccountFilter(CustomerVehicleModel objCustomerVehicleModel) { var filename = "Customer_" + DateTime.Now.ToString(Constants.dateTimeFormat24HForFileName) + ".csv"; FileInfo file = new FileInfo(Server.MapPath("~/Attachment/ExportFiles/" + filename)); Int16 IsDataFound = 0; try { string strQuery = " WHERE 1=1"; if (objCustomerVehicleModel.SearchEnable) { #region Filter Query if (objCustomerVehicleModel.AccountId > 0) { strQuery += " AND CA.ACCOUNT_ID LIKE '%" + objCustomerVehicleModel.AccountId + "%'"; } if (!string.IsNullOrEmpty(objCustomerVehicleModel.ResidentId)) { strQuery += " AND CA.RESIDENT_ID LIKE '%" + objCustomerVehicleModel.ResidentId + "%'"; } if (!string.IsNullOrEmpty(objCustomerVehicleModel.MobileNo)) { strQuery += " AND CA.MOB_NUMBER LIKE '%" + objCustomerVehicleModel.MobileNo + "%' "; } if (!string.IsNullOrEmpty(objCustomerVehicleModel.EmailId)) { strQuery += " AND LOWER(CA.EMAIL_ID) LIKE '%" + objCustomerVehicleModel.EmailId.ToLower() + "%' "; } if (!string.IsNullOrEmpty(objCustomerVehicleModel.FirstName)) { strQuery += " AND LOWER(CA.FIRST_NAME) LIKE '%" + objCustomerVehicleModel.FirstName.ToLower() + "%' "; } if (!string.IsNullOrEmpty(objCustomerVehicleModel.VehRegNo)) { strQuery += " AND LOWER(CV.VEH_REG_NO) LIKE '%" + objCustomerVehicleModel.VehRegNo.ToLower() + "%'"; } IsDataFound = CSVUtility.CreateCsvWithTitleFilter(file.FullName, CustomerAccountBLL.GetFilterCSV(strQuery), "Customer", objCustomerVehicleModel); #endregion } else { IsDataFound = CSVUtility.CreateCsvWithTitle(file.FullName, CustomerAccountBLL.GetFilterCSV(strQuery), "Customer"); } if (IsDataFound == 0) { filename = "No Data to Export."; } } catch (Exception ex) { HelperClass.LogMessage("Failed Export Customer CSV " + ex); } string Det = JsonConvert.SerializeObject(filename, Formatting.Indented); return(Det.Replace("\r", "").Replace("\n", "")); }