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);
        }
Exemple #2
0
        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();
 }