コード例 #1
0
        /// <summary>
        /// 下載XML檔案
        /// </summary>
        public void getXmlFiles( )
        {
            //string[] arr = new string[] { "R22", "R23", "R04", "RS9", "RS4", "R96", "R08","R89","R99" };
            string[] arr        = new string[] { "R00", "R22", "RS9", "RS4", "R99", "R96", "R89", "R08", "R04" };
            string   filePath   = "";
            string   fileName   = "";
            string   okPath     = "";
            string   returnPath = ""; //回傳下載的路徑

            try
            {
                //批次操作

                pl.startLog();
                for (int i = 0; i < arr.Length - 1; i++)
                {
                    this.type = (PROCESS_TYPE)Enum.Parse(typeof(PROCESS_TYPE), arr[i]);
                    filePath  = this.ftp + "/" + arr[i] + "/WORK/";
                    okPath    = this.ftp + "/" + arr[i] + "/OK/";
                    // fileName = arr[i] + this.ecKey + "DFM" + DateTime.Now.ToString("yyyyMMdd") + ".XML.zip";

                    string target = filePath;

                    LCL.Net.Ftp ftp      = new LCL.Net.Ftp(target, this.id, this.pwd);
                    string[]    fileList = ftp.getFileList();

                    if (fileList != null)
                    {
                        foreach (string myFileName in fileList)
                        {
                            //測試用
                            //fileName = arr[i] + this.ecKey + "DFM" + execDate + ".XML.zip";
                            fileName = myFileName;
                            pl.logMessage("\r\n開始下載檔案:" + filePath + fileName);
                            returnPath = downloadFile(filePath, fileName, okPath);
                            pl.logMessage("完成下載檔案:" + filePath + fileName);
                            if (returnPath != "")
                            {
                                pl.logMessage("\r\n開始讀入檔案:" + returnPath);
                                processFile(returnPath);
                                pl.logMessage("完成讀入檔案:" + returnPath);
                            }
                        }
                    }
                    else
                    {
                        pl.logMessage(filePath + "沒有任何檔案");
                    }
                }
                pl.endLog();
            }
            catch (Exception e) {
                FileLog.logError(e.ToString());
            }
        }
コード例 #2
0
        /// <summary>
        /// 下載XML檔案
        /// </summary>
        public void getXmlFiles( )
        {
            //string[] arr = new string[] { "R22", "R23", "R04", "RS9", "RS4", "R96", "R08","R89","R99" };
            string[] arr = new string[] { "R00","R22", "RS9","RS4","R99","R96","R89","R08","R04" };
            string filePath = "";
            string fileName = "";
            string okPath = "";
            string returnPath = ""; //回傳下載的路徑

            try
            {
                //批次操作

                pl.startLog();
                for (int i = 0; i < arr.Length - 1; i++)
                {
                    this.type = (PROCESS_TYPE)Enum.Parse(typeof(PROCESS_TYPE),arr[i]);
                    filePath = this.ftp + "/" + arr[i] + "/WORK/";
                    okPath = this.ftp + "/" + arr[i] + "/OK/";
                    // fileName = arr[i] + this.ecKey + "DFM" + DateTime.Now.ToString("yyyyMMdd") + ".XML.zip";

                    string target = filePath;

                    LCL.Net.Ftp ftp = new LCL.Net.Ftp(target, this.id, this.pwd);
                    string[] fileList = ftp.getFileList();

                    if (fileList != null)
                    {
                        foreach (string myFileName in fileList)
                        {
                            //測試用
                            //fileName = arr[i] + this.ecKey + "DFM" + execDate + ".XML.zip";
                            fileName = myFileName;
                            pl.logMessage("\r\n開始下載檔案:" + filePath + fileName);
                            returnPath = downloadFile(filePath, fileName, okPath);
                            pl.logMessage("完成下載檔案:" + filePath + fileName);
                            if (returnPath != "")
                            {
                                pl.logMessage("\r\n開始讀入檔案:" + returnPath);
                                processFile(returnPath);
                                pl.logMessage("完成讀入檔案:" + returnPath);
                            }
                        }

                    }
                    else {
                        pl.logMessage(filePath + "沒有任何檔案");
                    }

                }
                pl.endLog();
            }
            catch (Exception e) {
                FileLog.logError( e.ToString());
            }
        }