public static bool WriteConfig(EBMStream EbmStream) { try { string path = ConfigurationManager.AppSettings["StreamConfigPath"]; //string path = ConfigurationManager.AppSettings[Program.IsCopyProcess ? "StreamConfigPathCopy" : "StreamConfigPath"]; JObject jo = new JObject(); jo["ElementaryPid"] = EbmStream.ElementaryPid; jo["PMT_Pid"] = EbmStream.PMT_Pid; jo["Program_id"] = EbmStream.Program_id; jo["sDestSockAddress"] = EbmStream.sDestSockAddress; jo["Section_length"] = EbmStream.Section_length; jo["sLocalSockAddress"] = EbmStream.sLocalSockAddress; jo["Stream_BitRate"] = EbmStream.Stream_BitRate; jo["Stream_id"] = EbmStream.Stream_id; File.WriteAllText(path, jo.ToString(), Encoding.UTF8); //byte[] bytes = Encoding.Default.GetBytes(jo.ToString()); //string str = Convert.ToBase64String(bytes); //BinaryWriter bw = new BinaryWriter(new FileStream(path, FileMode.Create)); //bw.Write(str); //bw.Close(); return(true); } catch { return(false); } }
public EBMMain() { InitializeComponent(); AdminAccount = true; UpdateFormTitle(""); string path = AppDomain.CurrentDomain.BaseDirectory; ConfigFile.Instanse.fileName = @path + "EBMTest.cfg"; SingletonInfo.GetInstance().InlayCA.SignCounter = Convert.ToInt32(cf["SignCounter"].ToString()); SingletonInfo.GetInstance().IsProtocolGX = cf["IsProtocolGX"].ToString() == "1" ? true : false;// 1表示广西协议(true) 2表示国标协议(false) IsStartStream = false; EbmStream = new EBMStream(); MenuItemTSSetting_Click(MenuItemTSSetting, EventArgs.Empty); formStreamSet.WindowState = FormWindowState.Minimized; InitTable(); InitEBStream(); //if (formIndex == null || formIndex.IsDisposed) //{ // formIndex = new EBMIndex(); //} //formIndex.MdiParent = this; //formIndex.Visible = false; calcel = new Calcle(); calcel.MyEvent += new Calcle.MyDelegate(NetErrorDeal); InitStreamTable(); this.Load += EBMMain_Load; }
public void GetEBMStream(ref EBMStream stream) { stream.ElementaryPid = Convert.ToInt32(textElementaryPid.Text.Trim()); stream.PMT_Pid = Convert.ToInt32(textPMT_Pid.Text.Trim()); stream.Program_id = Convert.ToInt32(textProgram_id.Text.Trim()); stream.sDestSockAddress = textsDestSockAddress.Text.Trim(); stream.Section_length = Convert.ToInt32(textSection_length.Text.Trim()); stream.sLocalSockAddress = textsLocalSockAddress.Text.Trim(); stream.Stream_BitRate = Convert.ToInt32(textStream_BitRate.Text.Trim()); stream.Stream_id = Convert.ToInt32(textStream_id.Text.Trim()); }
private EBMStream GetEBMStream() { EBMStream stream = new EBMStream(); stream.ElementaryPid = Convert.ToInt32(textElementaryPid.Text.Trim()); stream.PMT_Pid = Convert.ToInt32(textPMT_Pid.Text.Trim()); stream.Program_id = Convert.ToInt32(textProgram_id.Text.Trim()); stream.sDestSockAddress = textsDestSockAddress.Text.Trim(); stream.Section_length = Convert.ToInt32(textSection_length.Text.Trim()); stream.sLocalSockAddress = textsLocalSockAddress.Text.Trim(); stream.Stream_BitRate = Convert.ToInt32(textStream_BitRate.Text.Trim()); stream.Stream_id = Convert.ToInt32(textStream_id.Text.Trim()); return(stream); }
private static bool WriteSerializeConfig(EBMStream EbmStream) { try { string path = ConfigurationManager.AppSettings["ConfigPath"]; FileStream fileStream = new FileStream(path, FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fileStream, EbmStream); fileStream.Close(); return(true); } catch { return(false); } }
public EBMMain() { InitializeComponent(); UpdateFormTitle(""); IsStartStream = false; EbmStream = new EBMStream(); MenuItemTSSetting_Click(MenuItemTSSetting, EventArgs.Empty); formStreamSet.WindowState = FormWindowState.Minimized; InitEBStream(); if (formIndex == null || formIndex.IsDisposed) { formIndex = new EBMIndex(); } formIndex.MdiParent = this; formIndex.Visible = false; InitStreamTable(); }
private static EBMStream ReadSerializeConfig() { try { string path = ConfigurationManager.AppSettings["ConfigPath"]; if (!File.Exists(path)) { File.Create(path).Close(); return(null); } FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); BinaryFormatter bf = new BinaryFormatter(); EBMStream stream = bf.Deserialize(fileStream) as EBMStream; fileStream.Close(); return(stream); } catch { return(null); } }