C# 循环执行infopath 2010重复部分,并使用C按相反顺序显示数据#

C# 循环执行infopath 2010重复部分,并使用C按相反顺序显示数据#,c#,visual-studio-2010,infopath,infopath2010,C#,Visual Studio 2010,Infopath,Infopath2010,我在InfoPath 2010中创建了一个表单,其中隐藏了c#代码。此表单的目的是作为我们在此处处理的问题的运行日志。C#用于生成一封格式非常特殊的电子邮件。此电子邮件的正文需要按相反顺序显示重复字段中的项目(最新的在顶部)。我的第一个问题是试图找到一种方法,将重复部分中的数据填充到电子邮件正文中。我终于找到了这个foreach循环,它成功地按标准顺序打印了数据 foreach (XPathNavigator node in runningLogTable) { logEntry = n

我在InfoPath 2010中创建了一个表单,其中隐藏了c#代码。此表单的目的是作为我们在此处处理的问题的运行日志。C#用于生成一封格式非常特殊的电子邮件。此电子邮件的正文需要按相反顺序显示重复字段中的项目(最新的在顶部)。我的第一个问题是试图找到一种方法,将重复部分中的数据填充到电子邮件正文中。我终于找到了这个foreach循环,它成功地按标准顺序打印了数据

foreach (XPathNavigator node in runningLogTable)
{
    logEntry = node.SelectSingleNode("@my:entry", this.NamespaceManager).Value;
    logTime = node.SelectSingleNode("my:CurrentTime", this.NamespaceManager).Value;
    sb.Append(convertTime(logTime) + "\n");
    sb.Append(logEntry + "\n\n");
}
资料来源:

顺便说一下,此循环位于stringBuilder函数内部。我的问题是,如何按相反的顺序执行此操作?

我已经在谷歌上搜索了好几天,我不知道我是否只是不知道正确的术语或是什么,但不用说,我一直无法找到一个有效的解决方案。我知道一定有一个简单的解决方案,我只是看不到。

不确定为什么这个问题会被忽略,但有几个人帮助我(特别是储蓄),他们引导我走上了一条不同的道路。我能够使用以下方法使代码正常工作:

            //Lets get those log entries!
        List<string> logEntries = new List<string>(); // Create a list array to hold each entry
        List<string> logTimes = new List<string>(); // Create a list array to hold each log time

        foreach (XPathNavigator entry in runningLogTable) // iterate through the repeating section of the log
        {
            logEntry = entry.SelectSingleNode("@my:entry", this.NamespaceManager).Value; // Get the string value from each field
            logTime = entry.SelectSingleNode("my:CurrentTime", this.NamespaceManager).Value; // Get the string value for the time from each field.
            logEntries.Add(logEntry); // Add each log entry to the list starting at position (index) 0
            logTimes.Add(convertTime(logTime)); // Add each time entry to the list starting at position (index) 0
            // Each log entry should align with the correct time entry since both start at index 0.
        }
        for (int i = (logEntries.Count - 1); i >= 0; i--) // get the count of the log entries list and loop through each indexed position in reverse.
        {
            sb.Append(logTimes[i].ToString() + "\n"); // append each indexed entry to the log starting from the last position and moving to the first (0)
            sb.Append(logEntries[i].ToString() + "\n\n"); // append each indexed time to the log starting from the last position and moving to the first (0)
        }
//让我们来获取那些日志条目!
列表日志项=新列表();//创建一个列表数组来保存每个条目
列表日志时间=新建列表();//创建一个列表数组来保存每个日志时间
foreach(runningLogTable中的XPathNavigator条目)//迭代日志的重复部分
{
logEntry=entry.SelectSingleNode(@my:entry),this.NamespaceManager.Value;//从每个字段获取字符串值
logTime=entry.SelectSingleNode(“my:CurrentTime”,this.NamespaceManager).Value;//从每个字段获取时间的字符串值。
logEntries.Add(logEntry);//从位置(索引)0开始将每个日志项添加到列表中
添加(convertTime(logTime));//将每个时间项添加到从位置(索引)0开始的列表中
//每个日志条目都应该与正确的时间条目对齐,因为它们都从索引0开始。
}
for(inti=(logEntries.Count-1);i>=0;i--)//获取日志项列表的计数,并反向遍历每个索引位置。
{
sb.Append(logTimes[i].ToString()+“\n”);//从最后一个位置开始,移动到第一个位置(0),将每个索引项追加到日志中
sb.Append(logEntries[i].ToString()+“\n\n”);//从最后一个位置开始,移动到第一个位置(0),将每个索引时间追加到日志中
}
感谢所有帮助过我的人。我希望我能链接到一个用户名,因为保存确实保存了我


谢谢大家

好吧,我不知道发生了什么。有一些回应,我刷新了一下,他们就不见了?我被改造了吗?