} // Save public void Save(int nItemID, AccountModel oData) { string sFileName = Path.Combine(m_sCurPath, nItemID.ToString() + ".new.xml"); Info("Saving new data to {0}", sFileName); try { File.WriteAllText(sFileName, SerializeDataHelper.SerializeToString(oData)); } catch (Exception e) { Error("Failed to save data: {0}", e.Message); } // try } // Save
} // GetConnectionString private void Run() { DataTable tbl = m_oDB.ExecuteReader(RetrieveSecurityDataQuery); var bck = new FileSaver(m_oLog); foreach (DataRow row in tbl.Rows) { var nID = (int)row[0]; var sName = row[1].ToString(); var oOldData = (byte[])row[2]; var sType = row[3].ToString(); var guid = new Guid(row[4].ToString()); if (!m_oVendors.ContainsKey(guid)) { continue; } m_oLog.Info("Marketplace {0} ({1}) of type {2}", sName, nID, sType); AccountModel am = ConvertSecurityInfo(oOldData, sType); if (am == null) { continue; } string sSerialisedData = SerializeDataHelper.SerializeToString(am); m_oLog.Info("New security info: {0}", sSerialisedData); if (!bck.Save(nID, oOldData)) { continue; } bck.Save(nID, am); m_oDB.ExecuteNonQuery( "UPDATE MP_CustomerMarketPlace SET SecurityData = CONVERT(VARBINARY(4096), @info) WHERE Id = @id", CommandSpecies.Text, new QueryParameter("@info", sSerialisedData), new QueryParameter("@id", nID) ); } // for each row tbl.Dispose(); } // Run