public int InsertRow(OracleConnection connection, BGPBmobileRow item, out string msg) { int ret = 0; msg = null; try { string query = "INSERT INTO RCD.VALID_BGPBMobileDATA (DocDate, ShiftDate, PayDate, RRN, Amount, Amount_Dis, FileName, Tags) " + "values (:1, :2, :3, :4, :5, :6, :7, :8)"; OracleCommand command = new OracleCommand(query, connection); command.Parameters.Add(crp(OracleType.DateTime, item.DocDate, "1", false)); command.Parameters.Add(crp(OracleType.DateTime, item.ShiftDate, "2", false)); command.Parameters.Add(crp(OracleType.DateTime, item.PayDate, "3", false)); command.Parameters.Add(crp(OracleType.Char, item.RRN, "4", false)); command.Parameters.Add(crp(OracleType.Number, Math.Round(item.Amount, 2), "5", false)); command.Parameters.Add(crp(OracleType.Number, Math.Round(item.AmountDis, 2), "6", false)); command.Parameters.Add(crp(OracleType.Char, item.FileName, "7", false)); command.Parameters.Add(crp(OracleType.Char, item.Tags, "8", false)); command.ExecuteNonQuery(); } catch (Exception ex) { msg = ex.Message; return(-1); } return(ret); }
public int ReadFile(string filename, out List <BGPBmobileRow> container, out string msg) { int ret = 0; msg = null; container = new List <BGPBmobileRow>(); BGPBmobileRow item; root Fields; string text; data rowdata; try { string FilePath = Path.Combine(m_app.PathIN, filename); if (File.Exists(FilePath)) { XmlDocument xDoc = new XmlDocument(); xDoc.Load(FilePath); // получим корневой элемент XmlElement xRoot = xDoc.DocumentElement; text = null; text = xRoot.GetAttribute("datestart"); DateTime.TryParse(text, out dtBegin); text = null; text = xRoot.GetAttribute("dateend"); DateTime.TryParse(text, out dtEnd); XmlNodeList nodeList = xRoot.GetElementsByTagName("data"); foreach (XmlNode xnode in nodeList) { item = new BGPBmobileRow(); rowdata = new data(); text = null; text = xnode["date"].InnerText; DateTime.TryParse(text.Replace('T', ' '), out item.DocDate); text = null; text = xnode["shiftdate"].InnerText; DateTime.TryParse(text, out item.ShiftDate); text = null; text = xnode["paydata"].InnerText; DateTime.TryParse(text, out item.PayDate); item.RRN = xnode["rrn"].InnerText; text = null; text = xnode["summa"].InnerText; double.TryParse(text, out item.Amount); text = null; text = xnode["dissumma"].InnerText; double.TryParse(text, out item.AmountDis); item.FileName = filename; text = null; text = xnode["emtcodefrom"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<EMT={0}>", text); } text = null; text = xnode["azscode"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<AZS={0}>", text); } text = null; text = xnode["oilcode"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<OIL={0}>", text); } text = null; text = xnode["price"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<PRICE={0}>", text); } text = null; text = xnode["amount"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<QNT={0}>", text); } text = null; text = xnode["cardcode"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<CARD={0}>", text); } text = null; text = xnode["discount"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<DIS={0}>", text); } text = null; text = xnode["curcode"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<CUR={0}>", text); } text = null; text = xnode["contract_currency"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<CCUR={0}>", text); } text = null; text = xnode["exrate"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<RATE={0}>", text); } text = null; text = xnode["emtprice"].InnerText; if (!string.IsNullOrEmpty(text)) { item.Tags += string.Format("<EPRICE={0}>", text); } container.Add(item); } // using (FileStream fs = new FileStream(FilePath, FileMode.OpenOrCreate)) // { // XmlSerializer formatter = new XmlSerializer(typeof(root)); // Fields = (root)formatter.Deserialize(fs); // } // XmlSerializer ser = new XmlSerializer(typeof(root)); // TextReader reader = new StreamReader(FilePath, Encoding.Default); // Fields = ser.Deserialize(reader) as root; // reader.Close(); } } catch (Exception ex) { msg = ex.Message; return(-1); } return(ret); }