예제 #1
0
        private void ExportDaliyReport()
        {
            if (_PathReport.Length <= 0)
            {
                SetMsg("匯出報表至伺服器失敗,沒有設定[每日報表匯出路徑]。");
                Thread.Sleep(300);
                return;
            }

            //先判斷今天是否有測試紀錄;//
            string    DateFrom = DateTime.Today.ToString("yyyy-MM-dd") + " 00:00:00";
            string    DateTo   = DateTime.Today.ToString("yyyy-MM-dd") + " 23:59:59";
            DataTable dtTest   = DaoSQL.Instance.GetTestHistory(DateFrom, DateTo);

            if (dtTest.Rows.Count <= 0)
            {
                return;
            }

            //客戶要求取得全部的測試資料;//
            dtTest           = DaoSQL.Instance.GetTestHistory();
            dtTest.TableName = DateTime.Today.ToString("yyyy-MM-dd");

            //先取得所有資料集;//
            DataSet Ds = new DataSet();

            Ds.Tables.Add(dtTest);

            //String TimeForFileName = DateTime.Now.ToString("yyyy-MM-dd");
            //string FileName = string.Format("./{0}-{1}_{2}.xls", m_Machine.機台代碼, m_Machine.描述, TimeForFileName);
            //客戶要求每次上傳報告都是上傳全部,所以不須加上時間;//
            string FileName = string.Format("./{0}-{1}.xls", m_Machine.機台代碼, m_Machine.描述);

            //輸出檔案成Excel檔;//
            try
            {
                FileExport.ExportDataSetToExcel(Ds, FileName);
            }
            catch (Exception ex)
            {
                Logger.Error(string.Format("匯出報表檔案失敗!\r\n資訊:{0}", ex.Message));
            }

            //將這檔案上傳到指定路徑;//
            try
            {
                NetTranslate.Transport(FileName, _PathReport, Path.GetFileName(FileName));
            }
            catch (Exception Ex)
            {
                Logger.Error(string.Format("傳送報表資訊失敗!\r\n資訊:{0}", Ex.Message));
            }

            //刪除報表檔案;//
            File.Delete(FileName);
        }
예제 #2
0
        private void BtnBackup_Click(object sender, EventArgs e)
        {
            DialogResult Ret = MessageBoxEx.Show(this, "確定要上傳本地端[車型代號]及[操作員代號]至伺服器??", "訊息", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Ret != DialogResult.Yes)
            {
                return;
            }

            this.Cursor = Cursors.AppStarting;

            string       Msg     = string.Empty;
            DbCheckState DbState = MyNetworkPlacesDbTest(out Msg);

            switch (DbState)
            {
            case DbCheckState.eDB_FOUND:
                //查遠端資料庫存在,更新指定資料表;//
                DaoErrMsg Err = DaoSQL.Instance.UploadLocalDatabase(tbPathDb.Text);
                if (Err.isError)
                {
                    MessageBoxEx.Show(this, Err.ErrorMsg, "訊息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBoxEx.Show(this, "[車型代號]及[操作員代號]資訊已上傳成功", "訊息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                break;

            case DbCheckState.eDB_NOT_FOUND:
                //查遠端資料庫不存在,直接上傳本地端的DB;//
                DaoSQL.Instance.CloseDatabase();
                string DestPath = Path.GetDirectoryName(tbPathDb.Text);
                string FileName = Path.GetFileName(tbPathDb.Text);

                if (DestPath == null)
                {
                    DestPath = tbPathDb.Text;
                    FileName = DaoConfigFile.Instance.m_FileDatabase;
                }
                else if (FileName == null || FileName.Length == 0 || Path.GetExtension(FileName) != "mdb")
                {
                    FileName = DaoConfigFile.Instance.m_FileDatabase;
                }

                NetTranslate.Transport(DaoConfigFile.Instance.FileDatabase, DestPath, FileName);
                MessageBoxEx.Show(this, "[車型代號]及[操作員代號]資訊已上傳成功", "訊息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DaoSQL.Instance.OpenDatabase();
                break;
            }

            this.Cursor = Cursors.Default;
        }
예제 #3
0
        private bool MyNetworkPlacesTest(string Path, bool isClose)
        {
            NetTranslate.KillLink(tbPathServer.Text);

            if (NetTranslate.connectState(Path, tbAccount.Text, tbPW.Text) == false)
            {
                return(false);
            }

            if (isClose)
            {
                NetTranslate.KillLink(tbPathServer.Text);
            }

            return(true);
        }
예제 #4
0
        /// <summary>
        /// 檢查伺服器狀態
        /// </summary>
        /// <returns></returns>
        private bool MyNetworkPlacesTest()
        {
            if (_PathServer.Length <= 0)
            {
                return(false);
            }

            NetTranslate.KillLink(_PathServer);

            if (NetTranslate.connectState(_PathServer, _Account, _PW) == false)
            {
                return(false);
            }

            return(true);
        }
예제 #5
0
        private static bool MyNetworkPlacesTest(string ServerPath)
        {
            string Account = string.Empty;
            string PW      = string.Empty;

            DaoSQL.Instance.GetServerAccount(out Account, out PW);

            NetTranslate.KillLink(ServerPath);

            if (NetTranslate.connectState(ServerPath, Account, PW) == false)
            {
                return(false);
            }

            NetTranslate.KillLink(ServerPath);

            return(true);
        }
예제 #6
0
        private void FormBackup_Shown(object sender, EventArgs e)
        {
            //備份本機資料;//
            SetMsg("備份本機資料");
            BackupLocalData();
            SetProcess(33);
            Thread.Sleep(300);

            //檢查伺服器路徑是否可以連線;//
            if (MyNetworkPlacesTest() == false)
            {
                SetMsg("無法備份資料至伺服器,請檢察網路狀態或備份路徑設定。");
                SetProcess(66);
                Thread.Sleep(500);

                SetMsg("無法匯出報表至伺服器,請檢察網路狀態或備份路徑設定。");
                SetProcess(100);
                Thread.Sleep(500);
            }
            else
            {
                //備份資料至Server;//
                SetMsg("備份資料至伺服器");
                BackupToServer();
                SetProcess(66);
                Thread.Sleep(300);

                //匯出報表至Server;//
                SetMsg("匯出報表至伺服器");
                ExportDaliyReport();
                SetProcess(100);
                Thread.Sleep(300);
            }

            NetTranslate.KillLink(_PathServer);
            this.DialogResult = DialogResult.Cancel;
        }