Example #1
0
        private static void DebugExceuteCollectOutlookPSTPath()
        {
            CollectOutlookPSTPathStatus status = CollectOutlookPSTPathStatus.StartGetVersion;
            OfficeCheck officeCheck            = new OfficeCheck();

            status = officeCheck.ExceuteCollectOutlookPSTPath();
        }
        private void button3_Click(object sender, EventArgs e)
        {
            CollectOutlookPSTPathStatus status = CollectOutlookPSTPathStatus.StartGetVersion;
            OfficeCheck officeCheck            = new OfficeCheck();

            status = officeCheck.ExceuteCollectOutlookPSTPath();
            MessageBox.Show("status = " + status);
        }
        public void TestGetMSOutlookApplicationVersion()
        {
            CollectOutlookPSTPathStatus status = CollectOutlookPSTPathStatus.StartGetVersion;
            OfficeCheck officeCheck            = new OfficeCheck();

            status = officeCheck.ExceuteCollectOutlookPSTPath();
            Assert.AreNotEqual(CollectOutlookPSTPathStatus.StartGetVersion, status);
        }
Example #4
0
        /// <summary>
        /// 執行取得Outlook flag的function
        /// </summary>
        /// <returns></returns>
        public CollectOutlookPSTPathStatus ExceuteCollectOutlookPSTPath()
        {
            int OutlookVersion = int.MinValue;
            CollectOutlookPSTPathStatus status = CollectOutlookPSTPathStatus.StartGetVersion;
            string OutputPathAndName           = string.Empty;
            string OutputFileName = string.Empty;

            string[]      PstPaths      = null;
            List <string> ExistPstPaths = null;


            // 執行檢查是否有取到Outlook Version
            OutlookVersion = GetMSOutlookVersion();
            if (OutlookVersion == int.MinValue)
            {
                return(status);
            }
            status = CollectOutlookPSTPathStatus.DoneByGetVersion;

            // 執行檢查是否取得PST Search log
            PstPaths = GetMSOutlookPstPaths();
            if (PstPaths == null)
            {
                return(status);
            }

            // 檢查檔案是否存在
            ExistPstPaths = new List <string>();
            long fileSize = 0;

            //const long limitSize = 8000000000;
            //const long limitSize = 1900000000;
            //int overLimitSize = 0;
            foreach (string path in PstPaths)
            {
                if (File.Exists(path) == false)
                {
                    continue;
                }

                fileSize = new FileInfo(path).Length;
                //overLimitSize = fileSize > limitSize ? 1 : 0;
                ExistPstPaths.Add(string.Format("{0}\t{1}\t{2}", Environment.MachineName, Convert.ToString(fileSize), path));
            }
            status = CollectOutlookPSTPathStatus.DoneByGetPstPathList;

            // 執行檢查Output檔案到local
            OutputFileName    = string.Format("{0}.txt", Environment.MachineName);
            OutputPathAndName = string.Format(@"D:\{0}", OutputFileName);
            try
            {
                File.WriteAllLines(OutputPathAndName, ExistPstPaths.ToArray(), Encoding.UTF8);
            }
            catch (DirectoryNotFoundException dnf)
            {
                // 當有找不到路徑的問題時, 強制寫入C:\ProgramData的目錄裡
                OutputPathAndName = string.Format(@"C:\ProgramData\{0}_Outlook.txt", Environment.MachineName);
                File.WriteAllText(OutputPathAndName, dnf.StackTrace, Encoding.UTF8);
                File.AppendAllText(OutputPathAndName, Environment.NewLine, Encoding.UTF8);
                File.AppendAllText(OutputPathAndName, dnf.Message, Encoding.UTF8);
                return(CollectOutlookPSTPathStatus.IllegalStatus);
            }
            catch (IOException ioe)
            {
                OutputPathAndName = string.Format(@"C:\ProgramData\{0}_Outlook.txt", Environment.MachineName);
                File.WriteAllText(OutputPathAndName, ioe.StackTrace, Encoding.UTF8);
                File.AppendAllText(OutputPathAndName, Environment.NewLine, Encoding.UTF8);
                File.AppendAllText(OutputPathAndName, ioe.Message, Encoding.UTF8);
                return(CollectOutlookPSTPathStatus.IllegalStatus);
            }

            status = CollectOutlookPSTPathStatus.DoneByOutputFileToLocalDisk;
            // 回寫路徑到DB

            //status = CollectOutlookPSTPathStatus.DoneByInsertIntoDB;
            // 無法回寫路徑時, 是否可上傳檔案到指定的路徑
            File.Copy(OutputPathAndName, @"\\mv2\public\StevenLiu\CollectOutlookPSTPaths\" + OutputFileName, true);
            // 已複製後
            File.Delete(OutputPathAndName);
            //File.Copy(OutputPathAndName, @"D:\99_TempArea\" + OutputFileName);
            status = CollectOutlookPSTPathStatus.DoneByUploadFile;

            return(status);
        }