日期:2014-05-17 浏览次数:20412 次
public static User XmlToUser(string xml) { XmlDocument doc = new XmlDocument(); User user = new User(); try { doc.LoadXml(xml); user.IDNo = (doc.SelectSingleNode("Request/IDNo").InnerText == null) ? "" : doc.SelectSingleNode("Request/IDNo").InnerText; user.IDType = (doc.SelectSingleNode("Request/IDType").InnerText == null) ? "" : doc.SelectSingleNode("Request/IDType").InnerText; ; user.MarrigeStatus = (doc.SelectSingleNode("Request/MarrigeStatus").InnerText == null) ? "" : doc.SelectSingleNode("Request/MarrigeStatus").InnerText; user.Mobile = (doc.SelectSingleNode("Request/Mobile").InnerText == null) ? "" : doc.SelectSingleNode("Request/Mobile").InnerText; user.Name = (doc.SelectSingleNode("Request/Name").InnerText == null) ? "" : doc.SelectSingleNode("Request/Name").InnerText; user.Sex = (doc.SelectSingleNode("Request/Sex").InnerText == null) ? "" : doc.SelectSingleNode("Request/Sex").InnerText; user.TelephoneNo = (doc.SelectSingleNode("Request/TelephoneNo").InnerText == null) ? "" : doc.SelectSingleNode("Request/TelephoneNo").InnerText; user.Uid = (doc.SelectSingleNode("Request/Uid").InnerText == null) ? 0 : Convert.ToInt32(doc.SelectSingleNode("Request/Uid").InnerText); user.Zip = (doc.SelectSingleNode("Request/Zip").InnerText == null) ? "" : doc.SelectSingleNode("Request/Zip").InnerText; user.DOB = (doc.SelectSingleNode("Request/DOB").InnerText == null) ? DateTime.Now : DateTime.Parse(doc.SelectSingleNode("Request/DOB").InnerText); user.CreateDate = (doc.SelectSingleNode("Request/CreateDate").InnerText == null) ? DateTime.Now : DateTime.Parse(doc.SelectSingleNode("Request/CreateDate").InnerText); user.Address = (doc.SelectSingleNode("Request/Address").InnerText == null) ? "" : doc.SelectSingleNode("Request/Address").InnerText; } catch { throw; } return user; }
catch (Exception ex) { Log.Write("\r\n----------------------------\r\n"); Log.Write("提交客户电子注册错误!" + DateTime.Now + "错误描述" + ex.ToString() + "\r\n"); Log.Write("----------------------------\r\n"); }
------解决方案--------------------
呵呵 你可以直接用log4net
web.config
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /> </configSections> <log4net> <logger name="logerror"> <level value="ERROR" /> <appender-ref ref="ErrorAppender" /> </logger> <logger name="loginfo"> <level value="INFO" /> <appender-ref ref="InfoAppender" /> </logger> <ap