You are viewing limited content. For full access, please sign in.

Question

Question

EntryType Enumeration

asked on March 31, 2015 Show version history
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Laserfiche.RepositoryAccess;
using Laserfiche.DocumentServices;
using Laserfiche.RepositoryAccess.Records;
using Laserfiche.RepositoryAccess.Linq;

namespace ConsoleApplication3
{
    class Program
    {
        public static bool IsRecordSeries(string thafoldr, Session thasession)
        {
            try
            {
                RecordSeriesInfo RSI = Folder.GetRecordSeriesInfo(thafoldr, thasession);
                RSI.GetSeriesProperties();
                return true;
            }
            
            catch
            {
                return false;
            }
        }

        static void Main(string[] args)
        {
            Server myServ = new Server("LFServer.nothingbut.net");                   // Create Server Object
            RepositoryRegistrationCollection repository = myServ.GetRepositories();   // Get repo names
            RepositoryRegistration connectionrobot = repository["IMadeThisUp"];      // Registers Repository
            Session skynet = new Session();                                           // Creates a new session
            
            try
            {
                skynet.Connect(connectionrobot);   // Connects session to repo
                skynet.LogIn(connectionrobot);     // Uses ultra top secret password to log in
            }

            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);   // Throws exceptions if connection screws up
            }

            List<EntryRow> contents = new List<EntryRow>();
            FolderInfo rootFolder = Folder.GetFolderInfo("\\\\", skynet);
            EntryListingSettings entrySetting = new EntryListingSettings();
            entrySetting.EntryFilter = EntryTypeFilter.AllTypes;
            entrySetting.AddColumn(SystemColumn.DisplayName);

            // get the contents of the root folder
            using (FolderListing listing = rootFolder.OpenFolderListing(entrySetting, 1000))
            {
                // the listing is 1-based, 
                int rowCount = listing.RowsCount;
                for (int i = 1; i <= rowCount; ++i)
                {
                    // construct a new row from the data in the folder listing, and place it in the list
                    EntryRow newRow = new EntryRow();
                    newRow.Name = listing.GetDatumAsString(i, SystemColumn.DisplayName);
                    contents.Add(newRow);
                    
                }

                FolderInfo cur_foldr;
                RecordFolderProperties rfprop;
                List<string> serieslist = new List<string>();
                foreach (EntryRow thing in contents)
                {
                    string myfolder = "\\\\" + thing.Name;
                    Console.WriteLine(myfolder);
                    cur_foldr = Folder.GetFolderInfo(myfolder, skynet);

                    if (IsRecordSeries(myfolder, skynet))
                    {
                        serieslist.Add(myfolder);
                        //rfprop = cur_foldr.GetRFProperties();
                        Console.WriteLine("Yup");
                        //Console.WriteLine(thing.Name);

                    }
                    else
                    {
                        Console.WriteLine("Nope");
                    }
                    Console.ReadLine();
                }
                

            }
        }
    }
}

I'm working on a script to determine if a root folder is a RecordSeries and then determine which Record Folders and Records underneath that series are eligible for cutoff... Currently I start by testing the root folders for whether or not GetSeriesProperties throws an exception. I know I know, that's horrendous EAFP stuff, but I couldn't find a IsRecordSeries property. I did find the EntryType Enumeration from the documentation, but I'm not sure how to go about using it.

In short, my question is, "How do I go about using EntryType Enumeration in order to classify my documents as RecordSeries, Record Folders, Records, etc?"

0 0

Answer

SELECTED ANSWER
replied on March 31, 2015 Show version history

I figured it out!

Here's the relevant code! Lines 4, 10, and 11.

 

                FolderInfo cur_foldr;
                RecordFolderProperties rfprop;
                List<string> serieslist = new List<string>();
                EntryInfo einfo;
                foreach (EntryRow thing in contents)
                {
                    string myfolder = "\\\\" + thing.Name;
                    Console.WriteLine(myfolder);
                    cur_foldr = Folder.GetFolderInfo(myfolder, skynet);
                    einfo = Entry.GetEntryInfo(myfolder, skynet);
                    Console.WriteLine(einfo.EntryType);

                    if (IsRecordSeries(myfolder, skynet))
                    {
                        serieslist.Add(myfolder);
                        //rfprop = cur_foldr.GetRFProperties();
                        Console.WriteLine("Yup");
                        //Console.WriteLine(thing.Name);

                    }
                    else
                    {
                        Console.WriteLine("Nope");
                    }
                    Console.ReadLine()

 

1 0

Replies

replied on March 31, 2015

You can also use folderinfo.IsUnderRecordSeries to see if a folder is a records folder under a records series.

2 0
You are not allowed to follow up in this post.

Sign in to reply to this post.