//Import attachment public void ImportAttachment(FileConfiguration configuration, Guid userGuid, string errorLogPath, bool isDelete) { this.errorLogPath = errorLogPath; this.loggedUser = userGuid; var directoryList = _importFileService.GetAllFolder(configuration.SourcePath, this.errorLogPath); var employeeSourcePath = string.Empty; var subContractorSourcePath = string.Empty; var wbsSourcePath = string.Empty; var revenueSourcePath = string.Empty; var attachmentList = new List <AttachmentModel>(); var contractNumber = string.Empty; foreach (var node in directoryList) { int nodeID; if (int.TryParse(node, out nodeID)) { var contract = _contractsService.GetContractByTaskNodeID(nodeID); if (contract != null) { //employee billing rate attachment migration contractNumber = !string.IsNullOrWhiteSpace(contract.ContractNumber) ? contract.ContractNumber : "(NotProvided)"; employeeSourcePath = configuration.SourcePath + $"\\{nodeID}\\EmployeeBillingRates\\"; var employeeBillingRates = _importFileService.GetAllFilesFromDirectory(employeeSourcePath, errorLogPath); ImportContractAttachment(employeeBillingRates, EnumGlobal.ResourceType.EmployeeBillingRates.ToString(), contract.ContractGuid, contract.ContractGuid, isDelete); //sub contractor billing rates attachment migration subContractorSourcePath = configuration.SourcePath + $"\\{nodeID}\\SubContractorBillingRates\\"; var subContractorBillingRateList = _importFileService.GetAllFilesFromDirectory(subContractorSourcePath, errorLogPath); ImportContractAttachment(subContractorBillingRateList, EnumGlobal.ResourceType.LaborCategoryRates.ToString(), contract.ContractGuid, contract.ContractGuid, isDelete); //work breakdown structure attachment migration wbsSourcePath = configuration.SourcePath + $"\\{nodeID}\\WorkBreakDownStructure\\"; var wbsList = _importFileService.GetAllFilesFromDirectory(wbsSourcePath, errorLogPath); ImportContractAttachment(wbsList, EnumGlobal.ResourceType.WorkBreakDownStructure.ToString(), contract.ContractGuid, contract.ContractGuid, isDelete); //recenue recognization attachment migration revenueSourcePath = configuration.SourcePath + $"\\{nodeID}\\RevenueRecognition\\"; var revenueList = _importFileService.GetAllFilesFromDirectory(revenueSourcePath, errorLogPath); ImportContractAttachment(revenueList, EnumGlobal.ResourceType.RevenueRecognition.ToString(), contract.ContractGuid, contract.ContractGuid, isDelete); //mod attachment migration ImportContractModAttachment(configuration, nodeID, contract.ContractGuid, isDelete); //import attachment for taskorder if (isInitailCall) { initialConfiguration = configuration; } var isTaskAvailable = _contractsService.CheckTaskOdrderByContractGuid(contract.ContractGuid); if (isTaskAvailable) { parentNodeID = node; this.isInitailCall = false; parentTaskOrderGuid = contract.ContractGuid; var taskConfiguration = new FileConfiguration(); taskConfiguration.SourcePath = configuration.SourcePath; taskConfiguration.DestinationPath = configuration.DestinationPath; if (!configuration.SourcePath.Contains("TaskOrders")) { taskConfiguration.SourcePath = taskConfiguration.SourcePath + $"\\{parentNodeID}\\TaskOrders"; } ImportAttachment(taskConfiguration, userGuid, errorLogPath, isDelete); } else if (!string.IsNullOrWhiteSpace(contract.TaskNodeID.ToString()) && parentNodeID == contract.MasterTaskNodeID.ToString()) { continue; } else { parentTaskOrderGuid = contract.ContractGuid; configuration = initialConfiguration; } } } } }