Esempio n. 1
0
        //  /////////////////
        //
        //  design
        //
        //   at startup, count how many external drives are available  - there should only be one.
        //
        //   if one drive, select that drive and create the default storage directory
        //    then inform the DVR function that a drive has been found and is ready
        //

        //   setup a function to watch for changes in connected drives
        //   if a new drive is added, start the hotswap switch over, expect the previous drive to be disconnected

        //   if the currently selected drive is disconnected, notify the DVR the primary drive was lost

        //   if no drives are available, watch for new ones to be added, if one is added make it the primary.


        public DriveManager(APPLICATION_DATA appData, OnDriveChangeEvent callback, string defaultStorageDir)
        {
            try
            {
                m_AppData = appData;
                m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
                m_Log                     = (ErrorLog)m_AppData.Logger;
                OnDriveChange             = callback;
                m_DefaultStorageDirectory = defaultStorageDir;
                singleton                 = new object();

                m_HotSwapStatusString = new ThreadSafeQueue <string>(20);

                // make the list of current drives now that we are going into a active mode
                m_DriveListAtStartup = Environment.GetLogicalDrives();// to be used later if a drive change is detected


                // are we running as AnalystsWorkstation, and no repositories found? if so, then use user-config storage area instead
                bool runDriveCheckLoop = true;
                if (!m_AppData.RunninAsService)
                {
                    string[] drives = GetAllFirstEvidenceDrives();
                    if (drives == null)
                    {
                        drives = new string[0];
                    }
                    if (drives.Length < 1)
                    {
                        //   runDriveCheckLoop = false;

                        m_Log.Log("User App Path =  " + Application.UserAppDataPath, ErrorLog.LOG_TYPE.INFORMATIONAL);


                        m_CentralRepositoryDrive = Application.UserAppDataPath.Split(':')[0] + ":\\";
                        m_SelectedDrive          = m_CentralRepositoryDrive;

                        m_Log.Log("dm setting central to " + m_CentralRepositoryDrive, ErrorLog.LOG_TYPE.INFORMATIONAL);

                        RunDelayedDriveChangeNoticeThread();// run the new drive notify after this constructor completes execution
                    }
                }

                // look for drive changes..
                // SetupDriveWatcher();  // USB events do not always fire correctly when hubs are used on  certain computers
                if (runDriveCheckLoop)
                {
                    StartPollForDriveChangesThread();
                }
            }
            catch (Exception ex)
            {
                m_Log.Log("DriveManager ex: " + ex.Message, ErrorLog.LOG_TYPE.FATAL);
            }
        }
Esempio n. 2
0
        //  /////////////////
        //
        //  design
        //
        //   at startup, count how many external drives are available  - there should only be one.
        //
        //   if one drive, select that drive and create the default storage directory
        //    then inform the DVR function that a drive has been found and is ready
        //
        //   setup a function to watch for changes in connected drives
        //   if a new drive is added, start the hotswap switch over, expect the previous drive to be disconnected
        //   if the currently selected drive is disconnected, notify the DVR the primary drive was lost
        //   if no drives are available, watch for new ones to be added, if one is added make it the primary.
        public DriveManager(APPLICATION_DATA appData, OnDriveChangeEvent callback, string defaultStorageDir )
        {
            try
            {
                m_AppData = appData;
                m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
                m_Log = (ErrorLog)m_AppData.Logger;
                OnDriveChange = callback;
                m_DefaultStorageDirectory = defaultStorageDir;
                singleton = new object();

                m_HotSwapStatusString = new ThreadSafeQueue<string>(20);

                // make the list of current drives now that we are going into a active mode
                m_DriveListAtStartup = Environment.GetLogicalDrives();// to be used later if a drive change is detected

                // are we running as AnalystsWorkstation, and no repositories found? if so, then use user-config storage area instead
                bool runDriveCheckLoop = true;
                if ( ! m_AppData.RunninAsService)
                {
                    string[] drives = GetAllFirstEvidenceDrives();
                    if ( drives == null) drives = new string[0];
                    if (drives.Length < 1)
                    {
                     //   runDriveCheckLoop = false;

                        m_Log.Log("User App Path =  " + Application.UserAppDataPath, ErrorLog.LOG_TYPE.INFORMATIONAL);

                        m_CentralRepositoryDrive = Application.UserAppDataPath.Split(':')[0]+  ":\\";
                        m_SelectedDrive = m_CentralRepositoryDrive;

                        m_Log.Log("dm setting central to " + m_CentralRepositoryDrive, ErrorLog.LOG_TYPE.INFORMATIONAL);

                        RunDelayedDriveChangeNoticeThread();// run the new drive notify after this constructor completes execution
                    }
                }

                // look for drive changes..
               // SetupDriveWatcher();  // USB events do not always fire correctly when hubs are used on  certain computers
                if ( runDriveCheckLoop)
                    StartPollForDriveChangesThread();
            }
            catch (Exception ex)
            {
                m_Log.Log("DriveManager ex: " + ex.Message, ErrorLog.LOG_TYPE.FATAL);
            }
        }