Beispiel #1
0
        /// <summary>
        /// Called when the initial file system scan completes.
        /// </summary>
        /// <param name="scan">The scan object</param>
        /// <param name="e">Exception that was raised if the scan failed, null on success.</param>
        public void OnInitialScanCompleted(KfsScan scan, bool success, Exception e)
        {
            Logging.Log("Initial scan finished.");

            Debug.Assert(ScanRunningFlag);
            Debug.Assert(InitialScanStatus != InitScanStatus.OK);

            InitialScanDate = DateTime.Now;
            ScanRunningFlag = false;

            if (success)
            {
                // If the status != none, it means the FSWatcher encountered an error.
                // The initial scan is NOT completed and must be run again. Otherwise,
                // synchronize the results.
                if (InitialScanStatus == InitScanStatus.None)
                {
                    InitialScanStatus = InitScanStatus.OK;
                    RequestStatusViewUpdate("InitialScan completed with success");
                    scan.Sync();
                }
            }
            else
            {
                OnScanFailed();

                DisallowUserOp("initial scan failed", AllowedOpStatus.None);
                if (e != null)
                {
                    Logging.Log("Initial scan failed : " + e.Message + ".");
                    Logging.LogException(e);
                }
            }

            Pipeline.Run("initial scan completed", true);
        }
Beispiel #2
0
 protected override void Run()
 {
     m_scan = new KfsScan(m_share, "");
     m_scan.Scan();
 }
Beispiel #3
0
        /// <summary>
        /// Called when the KFS share becomes idle.
        /// </summary>
        private void OnKfsIdle(Object sender, EventArgs args)
        {
            if (!CheckCtx(KwmCoreKwsOpStep.KfsIdle)) return;

            // Wait for the share to be idle, if required.
            KfsShare share = GetKfsShare();
            if (!share.IsKfsIdle()) return;

            // Make sure we do not receive any more notifications.
            share.OnKfsIdle -= OnKfsIdle;

            // Enter the KFS gate.
            share.Gate.GateEntry("SKURL file upload");

            try
            {
                // Get the list of relative paths to the attachment files in
                // the share.
                List<String> shareAttachList = new List<String>();
                foreach (String srcPath in m_outlookAttachList)
                    shareAttachList.Add(m_shareAttachDirRelPath + "/" + Path.GetFileName(srcPath));

                // Get the absolute path to the share attachment directory.
                String shareAttachDirAbsPath = share.MakeAbsolute(m_shareAttachDirRelPath);

                // Create the share attachment directory.
                Directory.CreateDirectory(shareAttachDirAbsPath);

                // Move the Outlook attachments inside the share.
                for (int i = 0; i < m_outlookAttachList.Count; i++)
                    File.Move(m_outlookAttachList[i], share.MakeAbsolute(shareAttachList[i]));

                // Scan the files to upload and synchronize with the share.
                KfsScan scan = new KfsScan(share, m_shareAttachDirRelPath);
                scan.Scan();
                scan.Sync();

                // The scan should have found the files to upload and requested
                // the update of their status. Update the local status and the
                // status view as required.
                share.UpdateLocalStatus();
                share.RequestStatusViewUpdate("SKURL file scan");
                share.UpdateStatusViewIfNeeded();

                // Make sure all the files are Not Added.
                foreach (String filePath in shareAttachList)
                {
                    KfsStatusPath statusPath = share.StatusView.GetPath(filePath);
                    if (statusPath == null || statusPath.Status != PathStatus.NotAdded)
                        throw new Exception("file " + filePath + " is not ready for upload");
                }

                // Flag the files for upload.
                share.Gate.AddInternalFiles(shareAttachList, m_emailID);

                // Notify the user.
                Wm.UiBroker.NotifyUser(new AttachManagementNotificationItem(m_kws, m_outlookRequest.Cmd));

                // Try to remove the directory where Outlook put its
                // attachments. This assumes that all files provided by
                // Outlook come from the same directory, which is a more than
                // reasonable assumption considering that it's programmed to do
                // that.
                try
                {
                    Directory.Delete(Path.GetDirectoryName(m_outlookAttachList[0]));
                }

                catch (Exception) { }

                // We're done.
                HandleSuccess();
            }

            catch (Exception ex)
            {
                HandleMiscFailure(ex);
            }

            finally
            {
                // Exit the KFS gate.
                share.Gate.GateExit("SKURL file upload");
            }
        }