我有一个wpf Datagrid,它显示有关远程硬盘的一些信息。当磁盘空间不足某个阈值时,我想为一行着色。
这是我用C#代码获得结果的方式:
/*
* Creating the outbound adaptor to send files from local to FTP server
*
* */
public IntegrationFlow localToFtpFlow(Branch myBranch) {
return IntegrationFlows.from(Files.inboundAdapter(new File(myBranch.getBranchCode()))
.filter(new ChainFileListFilter<File>()
.addFilter(new RegexPatternFileListFilter("final" + myBranch.getBranchCode() + ".csv"))
.addFilter(new FileSystemPersistentAcceptOnceFileListFilter(metadataStore(dataSource), "foo"))),//FileSystemPersistentAcceptOnceFileListFilter
e -> e.poller(Pollers.fixedDelay(10_000)))
.enrichHeaders(h ->h.headerExpression("file_originalFile", "new java.io.File('BEY/FEFOexport" + myBranch.getBranchCode() + ".csv')",true))
.transform(p -> {
LOG1.info("Sending file " + p + " to FTP branch " + myBranch.getBranchCode());
return p;
})
.log()
.handle(Ftp.outboundAdapter(createNewFtpSessionFactory(myBranch), FileExistsMode.REPLACE)
.useTemporaryFileName(true)
.autoCreateDirectory(false)
.remoteDirectory(myBranch.getFolderPath()), e -> e.advice(expressionAdvice()))
.get();
}
/*
* Creating the advice for routing the payload of the outbound message on different expressions (success, failure)
*
* */
@Bean
public Advice expressionAdvice() {
ExpressionEvaluatingRequestHandlerAdvice advice = new ExpressionEvaluatingRequestHandlerAdvice();
advice.setSuccessChannelName("success.input");
advice.setOnSuccessExpressionString("payload.delete() + ' was successful'");
//advice.setFailureChannelName("failure.input");
advice.setOnFailureExpressionString("payload + ' was bad, with reason: ' + #exception.cause.message");
advice.setTrapException(true);
return advice;
}
/*
* Creating FTP connection based on the branch ftp data entered.
* */
public DefaultFtpSessionFactory createNewFtpSessionFactory(Branch branch) {
final DefaultFtpSessionFactory factory = new DefaultFtpSessionFactory();
factory.setHost(branch.getHost());
factory.setUsername(branch.getUsern());
factory.setPort(branch.getFtpPort());
factory.setPassword(branch.getPassword());
return factory;
}
public DefaultFtpSessionFactory createNewFtpSessionFactory() {
final DefaultFtpSessionFactory factory = new DefaultFtpSessionFactory();
factory.setHost("bey-notes-fs.bey.ei");
factory.setUsername("bey-ftp");
factory.setPort(21);
factory.setPassword("spicysilk");
return factory;
}
/*
* Creating a metadata store to be used across the application flows to prevent reprocessing the file if it is already processed.
* This will save the new file in a metadata table in the DB with the state of the report, so when a new copy comes with different date it will be processed only.
* */
@Bean
public ConcurrentMetadataStore metadataStore(final DataSource dataSource) {
return new JdbcMetadataStore(dataSource);
}
/*
* Success channel that will handle the AdviceMessage from the outbound adapter
*
* */
@Bean
public IntegrationFlow success(){
return f -> f.transform("inputMessage.headers['file_originalFile']")
// .handle(Message.class,(m,h)-> this.delegatingSessionFactory().setThreadKey(m, h.get(String.valueOf("inputMessage.headers['file_originalFile']",1,3)))
.handle(Message.class,(m,h)-> delegatingSessionFactory().setThreadKey(m,"CAI"))
.handle(Ftp.outboundAdapter(delegatingSessionFactory(), FileExistsMode.REPLACE)
.useTemporaryFileName(true)
.autoCreateDirectory(true)
.remoteDirectory("/ftp/erbranch/EDMS/FEFO/History/").get());
}
@Bean
public DelegatingSessionFactory delegatingSessionFactory(){
SessionFactoryLocator<FTPFile> sff = sessionFactoryLocator();
return new DelegatingSessionFactory<>(sff);
}
@Bean
public SessionFactoryLocator<FTPFile> sessionFactoryLocator() {
final List<Branch> branchConnections = new ArrayList<>();
branchRepository.findAll().forEach(branchConnections::add);
final Map<Object, SessionFactory<FTPFile>> factories = new LinkedHashMap<>();
/*if(branchConnections.isEmpty()){
//return null;
factories.put("BEY",createNewFtpSessionFactory());
}*/
for (Branch br : branchConnections) {
// create a factory for every key containing server type, url and port
if (factories.get(br.getId()) == null) {
factories.put(br.getBranchCode(), createNewFtpSessionFactory(br));
}
}
return new DefaultSessionFactoryLocator<FTPFile>(factories,createNewFtpSessionFactory());//,defaultFtpSessionFactory);
}
}
“值”是这样的两倍:29,22。
在我的数据网格中,我在远程计算机上具有与硬盘一样多的行。我做了一些尝试,但是它总是使整个数据网格着色。
有人可以帮助我吗? 如果我错过了一些细节,请随时告诉我。
编辑
例如,如果C驱动器的Go数少于5,则我想将该行涂成红色。 谢谢:)