public void ImportFarClauseData(object configuration, Guid userGuid, string errorPath, bool isDelete)
        {
            var configDictionary = _importFileService.GetFileUsingJToken(configuration.ToString());

            this.errorLogPath = errorPath + this.errorFile;
            var importConfigData = _importFileService.GetConfigurationSetting(configuration.ToString());

            if (importConfigData != null)
            {
                if (!string.IsNullOrWhiteSpace(importConfigData.InputFolderPath))
                {
                    this.inputFolderPath = importConfigData.InputFolderPath;
                    this.logOutputPath   = importConfigData.LogOutputPath;

                    //get list of csv file
                    var csvFile = _importFileService.GetAllCsvFilesFromDirectory(this.inputFolderPath, errorLogPath);
                    if (csvFile != null && csvFile.Length > 0)
                    {
                        var farClauseHeader = _importFileService.GetCSVHeader(importConfigData.CSVToAttributeMapping.ToString());
                        foreach (var file in csvFile)
                        {
                            var farClauseList = GetFarClauseListFromCsvFile <DMFarClause>(file, farClauseHeader);
                            var fileHeader    = _importFileService.GetCSVHeaderFromFile(file, farClauseHeader);
                            //import customer contact
                            var importedList = ImportFarClause(farClauseList, userGuid);
                            var fileName     = Path.GetFileNameWithoutExtension(file);
                            this.fileExtension = Path.GetExtension(file);
                            var exportFileName = _exportCsvService.GetExportFileName(fileName, this.fileNameToAppend, this.fileExtension);

                            //list for exporting to csv with status
                            var exportHeader = _exportCsvService.GetExportCSVHeader(fileHeader);
                            var exportList   = MapperHelper.GetExportList(importedList, exportHeader);

                            var isFileSaved = _exportCsvService.SaveCSVWithStatus(exportList.ToList(), logOutputPath, exportFileName, exportHeader);
                            if (isFileSaved)
                            {
                                _importFileService.MoveFile(inputFolderPath, this.logOutputPath, fileName, fileExtension, isDelete);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Import data from csv file to the system
        /// </summary>
        /// <param name="configuration"></param>
        public void ImportCustomerData(object configuration, Guid userGuid, string errorLogPath, bool isDelete)
        {
            var configDictionary = _importFileService.GetFileUsingJToken(configuration.ToString());
            var importConfigData = GetConfigurationSetting(configuration.ToString());

            if (importConfigData != null)
            {
                if (!string.IsNullOrWhiteSpace(importConfigData.InputFolderPath))
                {
                    this.inputFolderPath  = importConfigData.InputFolderPath;
                    this.outputFolderPath = importConfigData.LogOutputPath;
                    var watch = System.Diagnostics.Stopwatch.StartNew();
                    //get list of csv file
                    var csvFile = _importFileService.GetAllCsvFilesFromDirectory(this.inputFolderPath, errorLogPath);
                    if (csvFile != null && csvFile.Length > 0)
                    {
                        var customerHeader = _importFileService.GetCSVHeader(importConfigData.CSVToAttributeMapping.ToString());
                        foreach (var file in csvFile)
                        {
                            var customerList = GetCustomerListFromCsvFile <DMCustomer>(file, customerHeader);
                            var fileHeader   = _importFileService.GetCSVHeaderFromFile(file, customerHeader);
                            if (customerList == null)
                            {
                                _exportCsvService.ErrorLog(this.errorFile, inputFolderPath, errorLogPath, "Invalid Header");
                                break;
                            }
                            else
                            {
                                //import Customer
                                var importedList                = ImportCustomer(customerList, userGuid);
                                var fileName                    = Path.GetFileNameWithoutExtension(file);
                                var fileNameWithExtension       = Path.GetFileName(file);
                                var fileExtension               = Path.GetExtension(file);
                                var fileNameForExportWithStatus = _exportCsvService.GetExportFileName(fileName, this.fileNameToAppend, fileExtension);

                                var exportHeader = _exportCsvService.GetExportCSVHeader(fileHeader);
                                var exportList   = MapperHelper.GetExportList(importedList, exportHeader).ToList();
                                var isFileSaved  = _exportCsvService.SaveCSVWithStatus(exportList, outputFolderPath, fileNameForExportWithStatus, exportHeader);
                                if (isFileSaved)
                                {
                                    _importFileService.MoveFile(inputFolderPath, this.outputFolderPath, fileName, fileExtension, isDelete);
                                }
                            }
                        }
                    }

                    watch.Stop();
                    var duration = watch.Elapsed.Duration();
                    Console.WriteLine(duration);
                }
            }
        }
Beispiel #3
0
        //endoffice internal method

        /// <summary>
        /// Import data from csv file to the system
        /// </summary>
        /// <param name="configuration"></param>
        public void ImportModsData(object configuration, Guid userGuid, string errorLogPath, bool isDelete)
        {
            var configDictionary = _importFileService.GetFileUsingJToken(configuration.ToString());
            var importConfigData = GetConfigurationSetting(configuration.ToString());

            if (importConfigData != null)
            {
                if (!string.IsNullOrWhiteSpace(importConfigData.InputFolderPath))
                {
                    this.inputFolderPath  = importConfigData.InputFolderPath;
                    this.outputFolderPath = importConfigData.LogOutputPath;
                    this.errorLogPath     = errorLogPath;

                    //get list of csv file
                    var csvFile = _importFileService.GetAllCsvFilesFromDirectory(this.inputFolderPath, errorLogPath);
                    if (csvFile != null && csvFile.Length > 0)
                    {
                        var modHeader = _importFileService.GetCSVHeader(importConfigData.CSVToAttributeMapping.ToString());
                        foreach (var file in csvFile)
                        {
                            var modsList    = GetModsListFromCsvFile <DMMods>(file, modHeader);
                            var fileHeaders = _importFileService.GetCSVHeaderFromFile(file, modHeader);
                            if (modsList == null)
                            {
                                _exportCsvService.ErrorLog(this.errorFile, inputFolderPath, errorLogPath, "Invalid Header");
                                break;
                            }
                            else
                            {
                                //import Office
                                var importedList                = ImportMods(modsList, userGuid);
                                var fileName                    = Path.GetFileNameWithoutExtension(file);
                                var fileNameWithExtension       = Path.GetFileName(file);
                                var fileExtension               = Path.GetExtension(file);
                                var fileNameForExportWithStatus = GetExportFileName(fileName, this.fileNameToAppend) + fileExtension;

                                //list for exporting to csv with status

                                var exportHeader = _exportCsvService.GetExportCSVHeader(modHeader);
                                var exportList   = MapperHelper.GetExportList(importedList, exportHeader).ToList();
                                var isFileSaved  = _exportCsvService.SaveCSVWithStatus(exportList.ToList(), outputFolderPath, fileNameForExportWithStatus, exportHeader);
                                if (isFileSaved)
                                {
                                    _importFileService.MoveFile(inputFolderPath, this.outputFolderPath, fileName, fileExtension, isDelete);
                                }
                            }
                        }
                    }
                }
            }
        }