private FileTransferConfigurationModel getFileTransferConfigurationModel(PurchaseOrderHeader poh, FileRecipient fileRecipient) { FileTransferConfigurationModel template = null; switch (fileRecipient) { case FileRecipient.Warehouse: LocationModel warehouse = null; if (poh.LocationId != null) { warehouse = LookupService.FindLocationModel(poh.LocationId.Value, false); } if (warehouse != null) { template = DataTransferService.FindFileTransferConfigurationForWarehouseModel(warehouse, FileTransferDataType.WarehousePurchase); } break; case FileRecipient.FreightForwarder: FreightForwarderModel freightForwarder = null; if (poh.FreightForwarderId != null) { freightForwarder = LookupService.FindFreightForwarderModel(poh.FreightForwarderId.Value, false); } if (freightForwarder != null) { template = DataTransferService.FindFileTransferConfigurationForFreightForwarder(freightForwarder, FileTransferDataType.FreightForwarderPurchase); } break; } return(template); }
//重置 protected void DeleteAll_Click(object sender, EventArgs e) { try { FileName.Reset(); DropDownListLevel.Reset(); DropDownListAgency.Reset(); DropDownListFile.Reset(); LevinTime.Reset(); LevinUnit.Reset(); FileRecipient.Reset(); PageContext.RegisterStartupScript("clearFile();"); } catch (Exception ex) { pm.SaveError(ex, this.Request); } }
private Error processPurchaseOrder(PurchaseOrderHeader poh, FileTransferConfigurationModel template, FileRecipient fileRecipient) { var error = new Error(); // Load the template configuration file string configFile = getTemplateFileName(template), tempFile = "", zipFile = ""; XElement doc = XElement.Load(configFile); var file = doc.Element("File"); error = createPurchaseOrderDataFile(poh, file, ref tempFile); if (!error.IsError) { // Check if the file is compressed individually and sent bool bCompress = file.Attribute("CompressFile").Value.ParseBool(); if (bCompress) { // File is to be compressed zipFile = tempFile.ChangeExtension(".zip"); error = Zip.ZipFile(tempFile, zipFile); if (error.IsError) { FileManagerService.FileManagerService.DeleteFile(zipFile); } else { tempFile = zipFile; } } bool bDelTempFile = true; if (!error.IsError) { if (file.Attribute("FTPFile").Value.ParseBool()) { // Copy the file to the FTP pickup folder error = moveFileToFTPFolder(tempFile, template.SourceFolder, poh.OrderNumber + (bCompress ? ".zip" : ".txt")); } if (!error.IsError && file.Attribute("EMailFile").Value.ParseBool()) { // Queue the file to be sent as an email var company = CompanyService.FindCompanyModel(poh.CompanyId); var purchaser = MembershipManagementService.FindUserModel(poh.SalespersonId.Value); string email = ""; if (fileRecipient == FileRecipient.FreightForwarder) { var fforwarder = LookupService.FindFreightForwarderModel(poh.FreightForwarderId.Value); if (string.IsNullOrEmpty(fforwarder.Email)) { error.SetError(EvolutionResources.errCantSendEMailToBlankFreightForwarderAddress); } else { email = fforwarder.Email; } } else { error.SetError(EvolutionResources.errEMailingWarehouseNotSupported); } if (!error.IsError) { var recipient = new UserModel { EMail = email }; var message = new EMailMessage(purchaser, recipient, MessageTemplateType.PurchaseOrderNotificationFF); EMailService(company).AddOrganisationDetails(message.Dict); EMailService().AddUserDetails(purchaser, message.Dict); message.AddProperty("PURCHASEORDERNO", poh.OrderNumber.Value); message.AddAttachment(tempFile); error = EMailService().SendEMail(message); if (!error.IsError) { bDelTempFile = false; } } } } if (bDelTempFile) { FileManagerService.FileManagerService.DeleteFile(tempFile); } } return(error); }