Beispiel #1
0
        /// <summary>
        /// Officeファイルのプロパティ取得
        /// </summary>
        /// <param name="list">対象のファイル</param>
        /// <returns>取得結果</returns>
        private bool ReadByDSO(ClsFilePropertyList list)
        {
            bool result = false;

            DSOFile.OleDocumentProperties docProperty = new DSOFile.OleDocumentProperties();
            DSOFile.SummaryProperties     summary;
            try
            {
                // ファイルを開く
                docProperty.Open(list.filePath, false, DSOFile.dsoFileOpenOptions.dsoOptionDefault);
                // プロパティの取得
                summary = docProperty.SummaryProperties;

                if (summary.Keywords != null)
                {
                    string[] PropertyData = summary.Keywords.Split(';');
                    if (PropertyData[0] != "")
                    {
                        list.fileSecrecy = PropertyData[0].Trim(); // 機密区分を取得
                    }
                    else
                    {
                        list.fileSecrecy = "区分なし";
                    }
                    // プロパティが2つ以上ある場合文書分類を取得
                    if (PropertyData.Count() >= 2)
                    {
                        list.fileClassification = PropertyData[1].Trim();
                    }
                    // プロパティが3つ以上ある場合事業所を取得
                    if (PropertyData.Count() >= 3)
                    {
                        list.fileOfficeCode = PropertyData[2].Trim();
                    }

                    // 他事務所ファイル判定
                    if (Globals.ThisAddIn.clsCommonSettings.strOfficeCode != list.fileOfficeCode.Trim())
                    {
                        // 他事務所ファイルの場合、登録なし扱にする
                        list.fileSecrecy = "";
                    }
                }
                else
                {
                    list.fileSecrecy = "区分なし";
                }
                result = true;
            }
            finally
            {
                docProperty.Close();
            }
            return(result);
        }
    public static void DoSomethingWithInstanceVariable(DataSet files, DataTable myFile)
    {
        DataColumn col = files.dt.Columns["Pfad"];

        foreach (DataRow row in Files.dt.Rows)
        {
            OleDocumentProperties myFile = new DSOFile.OleDocumentProperties();
            myFile.Open(@"" + row[col] + "", false, DSOFile.dsoFileOpenOptions.dsoOptionDefault);
            foreach (DSOFile.CustomProperty property in myFile.CustomProperties)
            {
                if (property.Name == "Überarbeitet")
                {
                    MessageBox.Show("Gefunden");
                }
            }
            myFile.Close();
        }
    }
Beispiel #3
0
        public override bool RunBody(State state)
        {
            RequirePropertyHandlerRegistered();
            RequireExtHasHandler();

#if x86
            const string cval = "ccomment***";

            //Create a temp file to put metadata on
            string fileName = CreateFreshFile(1);

            // Use DSOFile to set the value
            var dso = new DSOFile.OleDocumentProperties();
            dso.Open(fileName);
            var sum = dso.SummaryProperties;
            sum.Comments = cval;
            dso.Save();
            dso.Close();
            Marshal.ReleaseComObject(dso);  // preempt GC for CCW

            string svalue = null;

            var handler = new CPropertyHandler();
            handler.Initialize(fileName, 0);

            PropVariant value = new PropVariant();
            handler.GetValue(new TestDriverCodePack.PropertyKey(new Guid("F29F85E0-4FF9-1068-AB91-08002B27B3D9"), 6), value);
            svalue = (string)value.Value;

            Marshal.ReleaseComObject(handler); // preempt GC for CCW

            File.Delete(fileName);             // only works if all have let go of the file

            return(svalue == cval);
#else
            state.RecordEntry("Test skipped because DSOFile is 32-bit only");
            return(true);
#endif
        }
Beispiel #4
0
        private void btDecrypt_Click(object sender, EventArgs e)
        {
            string fileName = "";
            string SSN      = "";

            if (tbDirectory.Text.Trim().Equals(""))
            {
                if (fBrowser.ShowDialog() == DialogResult.OK)
                {
                    this.tbDirectory.Text = fBrowser.SelectedPath;
                    this.tbDirectory.Refresh();
                }
            }
            // directory is still empty
            if (tbDirectory.Text.Trim().Equals(""))
            {
                MessageBox.Show("No directory selected!");
            }
            else
            {
                // cleanup text box
                if (!(this.tbDirectory.Text.Trim().EndsWith("\\")))
                {
                    this.tbDirectory.Text = this.tbDirectory.Text + "\\";
                    this.tbDirectory.Refresh();
                }


                curDir = new DirectoryInfo(this.tbDirectory.Text);

                //MessageBox.Show(curDir.ToString());
                //Create the OleDocumentProperties object.
                DSOFile.OleDocumentProperties dso = new DSOFile.OleDocumentProperties();

                theFiles = curDir.GetFiles("*.D*9", SearchOption.AllDirectories);

                //MessageBox.Show(theFiles.ToString());

                int total   = theFiles.Count();
                int current = 0;

                foreach (FileInfo fi in theFiles)
                {
                    //MessageBox.Show(fi.Directory.ToString());

                    current += 1;
                    //MessageBox.Show(fi.ToString());
                    fileName = @"" + fi.Directory.ToString() + "//" + fi.ToString().Trim();
                    lastdate = fi.LastWriteTime;
                    //fileName = @"" + this.tbDirectory.Text + fi.ToString().Trim();
                    //Open the file for writing if we can. If not we will get an exception.
                    try
                    {
                        dso.Open(fileName, false, DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
                    }
                    catch
                    {
                        MessageBox.Show("Threw an exception " + fileName);
                    }

                    lblResults.Text = "Current File Name:  " + fi.ToString();
                    lblResults.Refresh();
                    lblTime.Text = "File " + System.Convert.ToString(current) + " of " + System.Convert.ToString(total);
                    lblTime.Refresh();

                    // truncate the file name
                    fileName = fi.ToString().Substring(0, 8);

                    // convert to an SSN
                    SSN = getSSN(fileName);

                    //Set the summary properties that you want.
                    dso.SummaryProperties.Title = SSN;
                    //lastdate = dso.SummaryProperties.DateLastSaved.ToString();

                    //dso.SummaryProperties.Title = "dog";
                    //Save the Summary information.
                    dso.Save();
                    //Close the file.
                    dso.Close(false);
                    fi.LastWriteTime = lastdate;
                }

                lblResults.Text = "Finished";
                lblResults.Refresh();
            }
        }