地图的先前工作版本:在此版本中,输入数据的类型为xs:date地图的目标版本:在此版本中,我在平面文件中将数据类型更改为xs:string。我还添加了以下在新地图中突出显示的C#脚本:public static System.DateTime MyConcat(string param1){ string[] formats = { "yyyy\\/MM\\/dd", "dd-MM-yyyy","yyyy-MM-dd", "dd\\/MM\\/yyyy" }; return System.DateTime.ParseExact(param1, formats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None); }我将字符串'2018-03-15'传递给数据输入。我得到的错误:ABC.MW.BackEnds.CENTRAL.DocsInformacaoFinanceira.Balancete.Mappers.MapBalancete。错误:转换失败。---> System.Reflection.TargetInvocationException:调用的目标引发了异常。---> System.Xml.Xsl.XslTransformException:调用扩展功能'DateFormat'时发生错误。有关错误的完整说明,请参见InnerException。---> System.FormatException:无法将字符串识别为有效的DateTime。在System.DateTimeParse.ParseExact(String s,String format,DateTimeFormatInfo dtfi,DateTimeStyles样式)从错误中我推断出问题是从字符串到日期时间的隐式转换。但是我不知道它可能在哪里发生。我找到了错误的根源。这是上一个工作函数中的脚本调用的方法。我认为xs:date和我的脚本返回的不是同一回事。给出错误的函数代码: public string DateFormat(string value, string FormatoOrigem, string FormatoDestino) { DateTime myDate; if (string.IsNullOrEmpty(value)) return ""; //myDate = DateTime.MinValue; else myDate = System.DateTime.ParseExact(value, FormatoOrigem, System.Globalization.CultureInfo.InvariantCulture); return myDate.ToString(FormatoDestino, System.Globalization.CultureInfo.InvariantCulture); }调用该函数的脚本输入:
- 2 回答
- 0 关注
- 218 浏览
添加回答
举报
0/150
提交
取消