public static void EncodeTap(string sourceXml, string destTap, string toVer) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(sourceXml); XmlTap tap = new XmlTap(); byte[] data = tap.Encode(xmlDoc, toVer); FileStream writer = new FileStream(destTap, FileMode.Create, FileAccess.Write); writer.Write(data, 0, data.Length); writer.Close(); }
public static void EncodeTap(string sourceXml, string destTap) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(sourceXml); string toVer = ""; XmlNode relVer = xmlDoc.SelectSingleNode("//ReleaseVersionNumber"); if (relVer != null) { if (relVer.InnerText.Equals("9")) toVer = "3.9"; else if (relVer.InnerText.Equals("10")) toVer = "3.10"; } XmlTap tap = new XmlTap(); byte[] data = tap.Encode(xmlDoc, toVer); FileStream writer = new FileStream(destTap, FileMode.Create, FileAccess.Write); writer.Write(data, 0, data.Length); writer.Close(); }
public static void ConvertVer(string source, string toVer) { XmlTap tap = new XmlTap(); XmlDocument xmlDoc = tap.DecodeTap(source); // edit if (toVer.Equals("3.9")) { VerTo39(ref xmlDoc); } else if (toVer.Equals("3.10")) { VerTo310(ref xmlDoc); } byte[] data = tap.Encode(xmlDoc, toVer); FileStream writer = new FileStream(source + ".tap" + toVer, FileMode.Create, FileAccess.Write); writer.Write(data, 0, data.Length); writer.Close(); xmlDoc = null; tap = null; }
public static void DecodeTap(string sourceTapFile, string destXmlFile) { FileStream reader = File.OpenRead(sourceTapFile); byte[] data = new byte[reader.Length]; reader.Read(data, 0, data.Length); reader.Close(); XmlTap tap = new XmlTap(); tap.Decode(data, destXmlFile); data = null; }
private void buttonImport_Click(object sender, System.EventArgs e) { Cursor.Current = Cursors.WaitCursor; statusBar.Text = "Importing taps..."; progress.Visible = true; progress.Value = 0; XmlTap tap = new XmlTap(); XmlDocument xmlTap = null; for (int i=0; i<listFile.SelectedItems.Count; i++) { try { // decode as XML tap xmlTap = tap.DecodeTap(FullPath(treeFolder.SelectedNode) + "\\" + listFile.SelectedItems[i].Text); // import into DB if (xmlTap != null) { XmlNode relVer = xmlTap.SelectSingleNode("//ReleaseVersionNumber"); if (relVer != null) { if (relVer.InnerText.Equals("10")) DB.ImportTap310(xmlTap); else if (relVer.InnerText.Equals("11")) DB.ImportTap311(xmlTap); } } else { DB.AsyncWriteLog("TAP Import error: " + FullPath(treeFolder.SelectedNode) + "\\" + listFile.SelectedItems[i].Text + " decoding failed."); } } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Roamer", MessageBoxButtons.OK, MessageBoxIcon.Error); } progress.Value = i * 100 /listFile.SelectedItems.Count; } if (AppSetting.Get("CalcBillAfterImport", false)) { try { DB.CalcInBill(); } catch (Exception ex) { MessageBox.Show("In call calculation failed. " + ex); } } progress.Visible = false; statusBar.Text = "Completed."; Cursor.Current = Cursors.Default; }