private void MenuExportTXT_Click(object sender, EventArgs e) { string vFileName = "msmq.txt"; string vFileFullPath = string.Format("{0}{1}", gFilePath, vFileName); List <string> vMSMQList = MSMQHelper.GetLocalMSMQInfo(); if (vMSMQList == null || vMSMQList.Count == 0) { UpdateStatusMessage(gEmptyErrorMsg, null); return; } if (!Directory.Exists(gFilePath)) { Directory.CreateDirectory(gFilePath); } if (File.Exists(vFileFullPath)) { File.Delete(vFileFullPath); } using (StreamWriter sw = new StreamWriter(vFileFullPath, false, Encoding.UTF8)) { for (int vIndex = 0; vIndex < vMSMQList.Count(); vIndex++) { sw.WriteLine(vMSMQList[vIndex]); } } UpdateStatusMessage("MSMQ TXT檔已匯出", null); }
/// 根據lBoxLocalMSMQ的值來建立MSMQ /// <summary> /// 根據lBoxLocalMSMQ的值來建立MSMQ /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCreate_Click(object sender, EventArgs e) { if (lBoxLocalMSMQ == null && lBoxLocalMSMQ.Items.Count == 0) { this.lbStatus.Text = "預建立之MSMQ為空值,請至少建立一筆"; return; } //先將原本local端的MSMQ刪除 if (gOriMSMQValueList != null && gOriMSMQValueList.Count > 0) { foreach (string vPath in gOriMSMQValueList) { MSMQHelper.DeleteMSMQ(string.Format(@".\{0}", vPath)); } } //根據目前lBoxLocalListBox的MSMQ建立 foreach (string vPath in lBoxLocalMSMQ.Items) { try { MSMQHelper.CreateMSMQ(string.Format(@".\{0}", vPath)); } catch (ArgumentException exAr) { this.lbStatus.Text = string.Format("{0}的值為null或空", vPath); } catch (Exception ex) { this.lbStatus.Text = ex.Message; } } this.lbStatus.Text = "已建立完畢"; this.Dispose(); }
public ImportFileForm(string pFilePath, MSMQHelper.FileTypes pFileType) { InitializeComponent(); gOriMSMQValueList = MSMQHelper.GetLocalMSMQInfo(); if (gOriMSMQValueList != null) { lBoxLocalMSMQ.DataSource = gOriMSMQValueList.Select(item => (string)item.Clone()).ToList <string>(); } this.lbStatus.Text = "匯入畫面啟動成功"; Thread vThread = new Thread(new ParameterizedThreadStart(this.ReadFile)); vThread.IsBackground = true; vThread.Start(new FileInfo(pFilePath, pFileType)); }
private void MenuExportCSV_Click(object sender, EventArgs e) { string vFileName = "msmq.csv"; string vFileFullPath = string.Format("{0}{1}", gFilePath, vFileName); List <string> vMSMQList = MSMQHelper.GetLocalMSMQInfo(); if (vMSMQList == null || vMSMQList.Count == 0) { UpdateStatusMessage(gEmptyErrorMsg, null); return; } IWorkbook wb = new HSSFWorkbook(); ISheet ws = wb.CreateSheet("MSMQ"); //excel title ws.CreateRow(0); ws.GetRow(0).CreateCell(0).SetCellValue("MSMQ Name"); //excel data for (int vIndex = 0; vIndex < vMSMQList.Count(); vIndex++) { ws.CreateRow(vIndex + 1); ws.GetRow(vIndex + 1).CreateCell(0).SetCellValue(vMSMQList[vIndex]);//只有一筆資料列 } if (!Directory.Exists(gFilePath)) { Directory.CreateDirectory(gFilePath); } if (File.Exists(vFileFullPath)) { File.Delete(vFileFullPath); } using (FileStream file = new FileStream(vFileFullPath, FileMode.CreateNew)) { wb.Write(file); } UpdateStatusMessage("MSMQ CSV檔已匯出", null); }
private void LoadMSMQInformation() { lBoxMSMQ.DataSource = MSMQHelper.GetLocalMSMQInfo(); }