public ResponseModel GetReports() { int deleteCount = 0; ResponseModel objResponseModel = new ResponseModel(); List <ReportModel> obReportResponseModel = new List <ReportModel>(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller newReport = new SettingsCaller(); obReportResponseModel = newReport.GetReportList(new ReportService(Cache, Db), authenticate.TenantId); statusCode = obReportResponseModel.Count == 0 ? (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = obReportResponseModel; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel DeleteCRMRole(int CRMRoleID) { int deleteCount = 0; ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller newCRM = new SettingsCaller(); deleteCount = newCRM.DeleteCRMRole(new CRMRoleService(Cache, Db), authenticate.TenantId, CRMRoleID); statusCode = deleteCount == 0 ? (int)EnumMaster.StatusCode.RecordInUse : (int)EnumMaster.StatusCode.RecordDeletedSuccess; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = deleteCount; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel GetRolesByUserID() { ResponseModel objResponseModel = new ResponseModel(); CRMRoleModel objCRMRoleResponseModel = new CRMRoleModel(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller newCRM = new SettingsCaller(); objCRMRoleResponseModel = newCRM.GetCRMRoleByUserID(new CRMRoleService(Cache, Db), authenticate.TenantId, authenticate.UserMasterID); statusCode = objCRMRoleResponseModel == null ? (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = objCRMRoleResponseModel; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel GetSLA(int SLAFor = 1) { ResponseModel objResponseModel = new ResponseModel(); List <SLAResponseModel> objSLAResponseModel = new List <SLAResponseModel>(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller newCRM = new SettingsCaller(); //_objresponseModel = newCRM.SLAList(new SLAServices(_connectioSting), authenticate.TenantId, pageNo, PageSize); objSLAResponseModel = newCRM.SLAList(new SLAServices(Cache, Db), authenticate.TenantId, SLAFor); statusCode = objSLAResponseModel.Count == 0 ? (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = objSLAResponseModel; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel ValidateAlertNameExist(int alertTypeId) { string resultMessage = ""; ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller _newAlert = new SettingsCaller(); resultMessage = _newAlert.VallidateAlert(new AlertService(Cache, Db), alertTypeId, authenticate.TenantId); statusCode = string.IsNullOrEmpty(resultMessage) ? (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = resultMessage; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel CreateUpdateCRMRole(int CRMRoleID, string RoleName, bool RoleisActive, string ModulesEnabled, string ModulesDisabled) { int count = 0; ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller newCRM = new SettingsCaller(); count = newCRM.InsertUpdateCRMRole(new CRMRoleService(Cache, Db), CRMRoleID, authenticate.TenantId, RoleName, RoleisActive, authenticate.UserMasterID, ModulesEnabled, ModulesDisabled); if (CRMRoleID.Equals(0)) { statusCode = count == 0 ? (int)EnumMaster.StatusCode.RecordAlreadyExists : (int)EnumMaster.StatusCode.Success; } else { statusCode = count == 0 ? (int)EnumMaster.StatusCode.InternalServiceNotWorking : (int)EnumMaster.StatusCode.Success; } statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = count; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel InserCreateReporttReport(string ReportName, bool isReportActive, string TicketReportParams, bool IsDaily, bool IsDailyForMonth, bool IsWeekly, bool IsWeeklyForMonth, bool IsDailyForYear, bool IsWeeklyForYear) { int insertCount = 0; ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller newReport = new SettingsCaller(); insertCount = newReport.InsertReport(new ReportService(Cache, Db), authenticate.TenantId, ReportName, isReportActive, TicketReportParams, IsDaily, IsDailyForMonth, IsWeekly, IsWeeklyForMonth, IsDailyForYear, IsWeeklyForYear, authenticate.UserMasterID); statusCode = insertCount == 0 ? (int)EnumMaster.StatusCode.InternalServiceNotWorking : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = insertCount; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel CreateSLA([FromBody] SLAModel insertSLA) { int insertCount = 0; ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller newSLA = new SettingsCaller(); insertSLA.TenantID = authenticate.TenantId; insertSLA.CreatedBy = authenticate.UserMasterID; insertCount = newSLA.InsertSLA(new SLAServices(Cache, Db), insertSLA); statusCode = insertCount == 0 ? (int)EnumMaster.StatusCode.RecordAlreadyExists : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = insertCount; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel ModifyTemplate(int TemplateID, string TemplateName, string issueType, bool isTemplateActive, string templateSubject, string templateContent) { int updateCount = 0; ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; try { ////Get token (Double encrypted) and get the tenant id string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller newTemplate = new SettingsCaller(); updateCount = newTemplate.UpdateTemplate(new TemplateService(Cache, Db), authenticate.TenantId, TemplateID, TemplateName, issueType, isTemplateActive, authenticate.UserMasterID, templateSubject, templateContent); statusCode = updateCount == 0 ? (int)EnumMaster.StatusCode.InternalServiceNotWorking : (int)EnumMaster.StatusCode.Success; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = updateCount; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel SendReportMail([FromBody] ReportMailModel reportmailmodel) { ResponseModel objResponseModel = new ResponseModel(); TicketingCaller ticketingCaller = new TicketingCaller(); MasterCaller masterCaller = new MasterCaller(); try { string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); SettingsCaller _dbsearchMaster = new SettingsCaller(); bool IsSent = _dbsearchMaster.SendReportMail(new ReportService(Cache, Db), reportmailmodel.EmailID, reportmailmodel.FilePath, authenticate.TenantId, authenticate.UserMasterID); if (IsSent) { objResponseModel.Status = true; objResponseModel.StatusCode = (int)EnumMaster.StatusCode.Success; objResponseModel.Message = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)(int) EnumMaster.StatusCode.Success); objResponseModel.ResponseData = "Mail sent successfully."; } else { objResponseModel.Status = false; objResponseModel.StatusCode = (int)EnumMaster.StatusCode.InternalServerError; objResponseModel.Message = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)(int) EnumMaster.StatusCode.InternalServerError); objResponseModel.ResponseData = "Mail sent failure."; } } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel ReportSearch([FromBody] ReportSearchModel searchparams) { List <SearchResponseReport> searchResult = null; ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; int resultCount = 0; SettingsCaller dbSearchMaster = new SettingsCaller(); 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)); searchparams.TenantID = authenticate.TenantId; // add tenantID to request searchparams.curentUserId = authenticate.UserMasterID; // add currentUserID to request //searchparams.TenantID = 1; // add tenantID to request //searchparams.curentUserId = 9; // add currentUserID to request resultCount = dbSearchMaster.GetReportSearch(new ReportService(Cache, Db), searchparams); statusCode = resultCount > 0 ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = resultCount; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel BulkUploadUser(int UserFor) { string downloadFilePath = string.Empty; string bulkUploadFilesPath = string.Empty; bool errorFileSaved = false; bool successfilesaved = false; int count = 0; UserCaller userCaller = new UserCaller(); SettingsCaller fileU = new SettingsCaller(); ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; string fileName = ""; string finalAttchment = ""; string timeStamp = DateTime.Now.ToString("ddmmyyyyhhssfff"); DataSet dataSetCSV = new DataSet(); string[] filesName = null; List <string> CSVlist = new List <string>(); string successFileName = string.Empty, errorFileName = string.Empty; string errorFilePath = string.Empty; string successFilePath = string.Empty; try { var files = Request.Form.Files; string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); #region FilePath bulkUploadFilesPath = rootPath + "\\" + "BulkUpload\\UploadFiles" + "\\" + CommonFunction.GetEnumDescription((EnumMaster.FileUpload)UserFor); downloadFilePath = rootPath + "\\" + "BulkUpload\\DownloadFiles" + "\\" + CommonFunction.GetEnumDescription((EnumMaster.FileUpload)UserFor); #endregion #region Read from Form if (files.Count > 0) { for (int i = 0; i < files.Count; i++) { fileName += files[i].FileName.Replace(".", timeStamp + ".") + ","; } finalAttchment = fileName.TrimEnd(','); } //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 = appRoot + "\\" + "UploadFiles"+"\\"+ CommonFunction.GetEnumDescription((EnumMaster.FIleUpload)HierarchyFor); if (files.Count > 0) { filesName = finalAttchment.Split(","); for (int i = 0; i < files.Count; i++) { using (var ms = new MemoryStream()) { files[i].CopyTo(ms); var fileBytes = ms.ToArray(); MemoryStream msfile = new MemoryStream(fileBytes); FileStream docFile = new FileStream(bulkUploadFilesPath + "\\" + filesName[i], FileMode.Create, FileAccess.Write); msfile.WriteTo(docFile); docFile.Close(); ms.Close(); msfile.Close(); } } } #endregion dataSetCSV = CommonService.csvToDataSet(bulkUploadFilesPath + "\\" + filesName[0]); //dataSetCSV = CommonService.csvToDataSet("D:\\TP\\UserBulk.csv"); CSVlist = userCaller.UserBulkUpload(new UserServices(Cache, Db), authenticate.TenantId, authenticate.UserMasterID, UserFor, dataSetCSV); #region Create Error and Succes files and Insert in FileUploadLog if (!string.IsNullOrEmpty(CSVlist[0])) { if (CSVlist[0].ToLower().Contains("username")) { successFileName = "UserSuccessFile.csv"; successFilePath = downloadFilePath + "\\User\\ Success" + "\\" + successFileName; successfilesaved = CommonService.SaveFile(successFilePath, CSVlist[0]); } else { successFileName = "MappedCategorySuccessFile.csv"; successFilePath = downloadFilePath + "\\MappedCategory\\ Success" + "\\" + successFileName; successfilesaved = CommonService.SaveFile(successFilePath, CSVlist[0]); } } if (!string.IsNullOrEmpty(CSVlist[1])) { if (CSVlist[1].ToLower().Contains("username")) { errorFileName = "UserErrorFile.csv"; errorFilePath = downloadFilePath + "\\User\\ Error" + "\\" + errorFileName; errorFileSaved = CommonService.SaveFile(errorFilePath, CSVlist[0]); } else { errorFileName = "MappedCategoryErrorFile.csv"; errorFilePath = downloadFilePath + "\\MappedCategory\\ Error" + "\\" + errorFileName; errorFileSaved = CommonService.SaveFile(errorFilePath, CSVlist[0]); } } if (!string.IsNullOrEmpty(CSVlist[1])) { errorFileSaved = CommonService.SaveFile(downloadFilePath + "\\User\\Error" + "\\" + "UserErrorFile.csv", CSVlist[1]); } count = fileU.CreateFileUploadLog(new FileUploadService(Cache, Db), authenticate.TenantId, filesName[0], successfilesaved, errorFileName, successFileName, authenticate.UserMasterID, "User", errorFilePath, successFilePath, UserFor); #endregion statusCode = count > 0 ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = count; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel BulkUploadCategory(IFormFile File, int CategoryFor = 1) { string downloadFilePath = string.Empty; string bulkUploadFilesPath = string.Empty; bool errorfilesaved = false; bool successFilesaved = false; int count = 0; MasterCaller masterCaller = new MasterCaller(); SettingsCaller fileU = new SettingsCaller(); ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; DataSet dataSetCSV = new DataSet(); string fileName = ""; string finalAttchment = ""; string timeStamp = DateTime.Now.ToString("ddmmyyyyhhssfff"); string[] filesName = null; List <string> CSVlist = new List <string>(); try { var files = Request.Form.Files; if (files.Count > 0) { for (int i = 0; i < files.Count; i++) { fileName += files[i].FileName.Replace(".", timeStamp + ".") + ","; } finalAttchment = fileName.TrimEnd(','); } var Keys = Request.Form; 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 = appRoot + "\\" + UploadedBulkFile; if (files.Count > 0) { filesName = finalAttchment.Split(","); for (int i = 0; i < files.Count; i++) { using (var ms = new MemoryStream()) { files[i].CopyTo(ms); var fileBytes = ms.ToArray(); MemoryStream msfile = new MemoryStream(fileBytes); FileStream docFile = new FileStream(Folderpath + "\\" + filesName[i], FileMode.Create, FileAccess.Write); msfile.WriteTo(docFile); docFile.Close(); ms.Close(); msfile.Close(); string s = Convert.ToBase64String(fileBytes); byte[] a = Convert.FromBase64String(s); // act on the Base64 data } } } string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); #region FilePath bulkUploadFilesPath = appRoot + "\\" + "BulkUpload\\UploadFiles" + "\\" + CommonFunction.GetEnumDescription((EnumMaster.FileUpload)CategoryFor); downloadFilePath = appRoot + "\\" + "BulkUpload\\DownloadFiles" + "\\" + CommonFunction.GetEnumDescription((EnumMaster.FileUpload)CategoryFor); #endregion dataSetCSV = CommonService.csvToDataSet(Folderpath + "\\" + finalAttchment); CSVlist = masterCaller.CategoryBulkUpload(new CategoryServices(Cache, Db), authenticate.TenantId, authenticate.UserMasterID, CategoryFor, dataSetCSV); #region Create Error and Succes files and Insert in FileUploadLog if (!string.IsNullOrEmpty(CSVlist[0])) { errorfilesaved = CommonService.SaveFile(downloadFilePath + "\\Category\\ Error" + "\\" + "CategoryErrorFile.csv", CSVlist[0]); } if (!string.IsNullOrEmpty(CSVlist[1])) { successFilesaved = CommonService.SaveFile(downloadFilePath + "\\Category\\Success" + "\\" + "CategorySuccessFile.csv", CSVlist[1]); } count = fileU.CreateFileUploadLog(new FileUploadService(Cache, Db), authenticate.TenantId, "Categorymaster.csv", errorfilesaved, "CategoryErrorFile.csv", "CategorySuccessFile.csv", authenticate.UserMasterID, "Category", downloadFilePath + "\\Category\\Error" + "\\" + "CategoryErrorFile.csv", downloadFilePath + "\\Category\\ Success" + "\\" + "CategorySuccessFile.csv", CategoryFor ); #endregion statusCode = count > 0 ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = CSVlist.Count; } catch (Exception) { throw; } return(objResponseModel); }
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); }
public ResponseModel BulkUploadUser(int UserFor = 1) { string DownloadFilePath = string.Empty; string BulkUploadFilesPath = string.Empty; bool errorfilesaved = false; bool successfilesaved = false; int count = 0; UserCaller userCaller = new UserCaller(); SettingsCaller fileU = new SettingsCaller(); ResponseModel objResponseModel = new ResponseModel(); int StatusCode = 0; string statusMessage = ""; string fileName = ""; string finalAttchment = ""; string timeStamp = DateTime.Now.ToString("ddmmyyyyhhssfff"); DataSet DataSetCSV = new DataSet(); string[] filesName = null; List <string> CSVlist = new List <string>(); string successfilename = string.Empty, errorfilename = string.Empty; string errorfilepath = string.Empty; string successfilepath = string.Empty; try { var files = Request.Form.Files; if (files.Count > 0) { for (int i = 0; i < files.Count; i++) { fileName += files[i].FileName.Replace(".", timeStamp + ".") + ","; } finalAttchment = fileName.TrimEnd(','); } var Keys = Request.Form; string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token)); #region FilePath string Folderpath = Directory.GetCurrentDirectory(); filesName = finalAttchment.Split(","); BulkUploadFilesPath = Path.Combine(Folderpath, BulkUpload, UploadFiles, CommonFunction.GetEnumDescription((EnumMaster.FileUpload)UserFor)); DownloadFilePath = Path.Combine(Folderpath, BulkUpload, DownloadFile, CommonFunction.GetEnumDescription((EnumMaster.FileUpload)UserFor)); if (!Directory.Exists(BulkUploadFilesPath)) { Directory.CreateDirectory(BulkUploadFilesPath); } if (files.Count > 0) { for (int i = 0; i < files.Count; i++) { using (var ms = new MemoryStream()) { files[i].CopyTo(ms); var fileBytes = ms.ToArray(); MemoryStream msfile = new MemoryStream(fileBytes); FileStream docFile = new FileStream(Path.Combine(BulkUploadFilesPath, filesName[i]), FileMode.Create, FileAccess.Write); msfile.WriteTo(docFile); docFile.Close(); ms.Close(); msfile.Close(); string s = Convert.ToBase64String(fileBytes); byte[] a = Convert.FromBase64String(s); // act on the Base64 data } } } #endregion DataSetCSV = CommonService.csvToDataSet(Path.Combine(BulkUploadFilesPath, filesName[0])); CSVlist = userCaller.UserBulkUpload(new UserServices(_connectioSting), authenticate.TenantId, authenticate.UserMasterID, UserFor, DataSetCSV); #region Create Error and Success files and Insert in FileUploadLog string SuccessFileName = "UserSuccessFile_" + timeStamp + ".csv"; string ErrorFileName = "UserErrorFile_" + timeStamp + ".csv"; string SuccessFileUrl = rootPath + BulkUpload + "/" + DownloadFile + "/" + CommonFunction.GetEnumDescription((EnumMaster.FileUpload)UserFor) + "/Success/" + SuccessFileName; string ErrorFileUrl = rootPath + BulkUpload + "/" + DownloadFile + "/" + CommonFunction.GetEnumDescription((EnumMaster.FileUpload)UserFor) + "/Error/" + ErrorFileName; if (!string.IsNullOrEmpty(CSVlist[0])) { if (!CSVlist[0].ToLower().Contains("username")) { SuccessFileName = "MappedCategorySuccessFile_" + timeStamp + ".csv"; } successfilesaved = CommonService.SaveFile(Path.Combine(DownloadFilePath, "Success", SuccessFileName), CSVlist[0]); } if (!string.IsNullOrEmpty(CSVlist[1])) { if (!CSVlist[1].ToLower().Contains("username")) { ErrorFileName = "MappedCategoryErrorFile" + timeStamp + ".csv"; } errorfilesaved = CommonService.SaveFile(Path.Combine(DownloadFilePath, "Error", ErrorFileName), CSVlist[1]); } count = fileU.CreateFileUploadLog(new FileUploadService(_connectioSting), authenticate.TenantId, filesName[0], errorfilesaved, ErrorFileName, SuccessFileName, authenticate.UserMasterID, "User", SuccessFileUrl, ErrorFileUrl, UserFor); #endregion StatusCode = count > 0 ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)StatusCode); objResponseModel.Status = true; objResponseModel.StatusCode = StatusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = count; } catch (Exception) { throw; } return(objResponseModel); }
public ResponseModel BulkUploadSLA() { SettingsCaller newSLA = new SettingsCaller(); ResponseModel objResponseModel = new ResponseModel(); int statusCode = 0; string statusMessage = ""; string fileName = ""; string finalAttchment = ""; string timeStamp = DateTime.Now.ToString("ddmmyyyyhhssfff"); DataSet dataSetCSV = new DataSet(); string[] filesName = null; try { var files = Request.Form.Files; string token = Convert.ToString(Request.Headers["X-Authorized-Token"]); Authenticate authenticate = new Authenticate(); authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token)); #region Read from Form if (files.Count > 0) { for (int i = 0; i < files.Count; i++) { fileName += files[i].FileName.Replace(".", "_" + authenticate.UserMasterID + "_" + timeStamp + ".") + ","; } finalAttchment = fileName.TrimEnd(','); } 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 = appRoot + "\\" + "BulkUpload\\SLA"; if (files.Count > 0) { filesName = finalAttchment.Split(","); for (int i = 0; i < files.Count; i++) { using (var ms = new MemoryStream()) { files[i].CopyTo(ms); var fileBytes = ms.ToArray(); MemoryStream msfile = new MemoryStream(fileBytes); FileStream docFile = new FileStream(Folderpath + "\\" + filesName[i], FileMode.Create, FileAccess.Write); msfile.WriteTo(docFile); docFile.Close(); ms.Close(); msfile.Close(); } } } dataSetCSV = CommonService.csvToDataSet(Folderpath + "\\" + filesName[0]); #endregion // DataSetCSV = CommonService.csvToDataSet("D:\\TP\\hierarchymaster.csv"); int result = newSLA.SLABulkUpload(new SLAServices(Cache, Db), authenticate.TenantId, authenticate.UserMasterID, dataSetCSV); statusCode = result > 0 ? (int)EnumMaster.StatusCode.Success : (int)EnumMaster.StatusCode.RecordNotFound; statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)statusCode); objResponseModel.Status = true; objResponseModel.StatusCode = statusCode; objResponseModel.Message = statusMessage; objResponseModel.ResponseData = result; } catch (Exception) { throw; } return(objResponseModel); }