private void ImageSavingTest()
        {
            folderChangeEvent             = new FolderChangeEvent(pathTextbox.Text);
            folderChangeEvent._shouldStop = true;
            folderChangeEvent.BeginWatchChangeInFolder();
            thread1 = new Thread(folderChangeEvent.TrackingEventChangeInFolder);
            thread1.Start();

            if (isPhaseCorrect())
            {
                thread3 = new Thread(OutputPhase);
                thread3.Start();

                phaseModeTCP = new PhaseModeTCP(pOnCmdtxt.Text, pOffCmdtxt.Text, AcquisitionType.Continous, null, (int)onPhaseTimeVal, (int)offPhaseTimeVal, IPAdress, (int)Port);
                phaseModeTCP.InitTCPConnection();
                phaseModeTCP.goodreadPattern = goodreadtxt.Text;
                phaseModeTCP.noreadPattern   = noreadtxt.Text;
                phaseModeTCP._shouldStop     = true;
                thread2 = new Thread(phaseModeTCP.GenerateSignalBaseOnConfiguration);
                thread2.Start();
            }
            else if (isOneShotCorrect())
            {
                thread3 = new Thread(OutputOneShot);
                thread3.Start();

                oneShotTCP = new OneShotTCP(oneShotCmdtxt.Text, IPAdress, (int)Port);
                oneShotTCP.SetTimer((int)timetrigger);
                oneShotTCP.InitTCPConnection();
                oneShotTCP.goodreadPattern = goodreadtxt.Text;
                oneShotTCP.noreadPattern   = noreadtxt.Text;
                oneShotTCP._shouldStop     = true;
                thread2 = new Thread(oneShotTCP.GenerateSignalBaseOnConfiguration);
                thread2.Start();
            }
            else
            {
                // continous mode
            }
        }
Esempio n. 2
0
        private void HandleRootFolderDeleteEvent(FolderChangeEvent dce)
        {
            MonitorLayer.Instance.UnMonitorPath(dce.OldPath.FullName);
            //Find the logical Address for the old path
            //Do not create the logical address if not found.
            string logicalAddress = ProfilingLayer.Instance.ConvertPhysicalToLogical(dce.OldPath.FullName, false);
            //Get all the tag that contains this logicalAddress inside the tag.

            List<Tag> tag = TaggingLayer.Instance.RetrieveParentTagByPath(logicalAddress);
            //If tag count is 0 return as there is nothing to process.
            if (tag.Count == 0)
            {
                return;
            }
            //Find the similiar paths for the logical Path
            //The return is physical address
            List<string> convertedList = FindSimilarSeamlessPathForFile(logicalAddress);
            convertedList.Remove(dce.OldPath.FullName);

            //////// Massive Path Table Code /////////////
            for (int i = 0; i < convertedList.Count; i++)
            {
                string dest = convertedList[i];
                if (_pathTable.JustPop(dce.OldPath.FullName, dest, TableType.Delete))
                {
                    convertedList.Remove(dest);
                    i--;
                    continue;
                }
            }
            ///////////////// For each Path in the converted List ///////////////////
            ///////////////////////////////// Create a entry such that source = convertedPath and destination is the original Path ///////////
            ///////////////////////For each other path , create a Source + dest pair //////////
            ///////////////// Create an additional Path Entry for each of the Siblings ////////////////
            for (int i = 0; i < convertedList.Count; i++)
            {
                _pathTable.AddPathPair(convertedList[i], dce.OldPath.FullName, TableType.Delete);
                for (int j = i + 1; j < convertedList.Count; j++)
                {
                    _pathTable.AddPathPair(convertedList[i], convertedList[j], TableType.Delete);
                    _pathTable.AddPathPair(convertedList[j], convertedList[i], TableType.Delete);
                }
            }
            ///////// End of Path Table Code ////////////////
            //For each path in the convertedList , extract the parent Path.


            List<string> parentList = new List<string>();
            foreach (string path in convertedList)
            {
                FileInfo info = new FileInfo(PathHelper.RemoveTrailingSlash(path));
                string parent = info.Directory == null ? "" : info.Directory.FullName;
                parentList.Add(parent);
            }
            //If the parent list if empty , it means that there is nothing to sync and thus return.
            if (parentList.Count == 0)
            {
                return;
            }
            //Create the request and Send it.
            Debug.Assert(dce.OldPath.Parent != null);
            AutoSyncRequest request = new AutoSyncRequest(dce.OldPath.Name, dce.OldPath.Parent.FullName, parentList, AutoSyncRequestType.Delete, SyncConfig.Instance, ConvertTagListToTagString(tag));
            SendAutoRequest(request);
            FindAndCleanDeletedPaths();
            _userInterface.TagsChanged();
        }
Esempio n. 3
0
 /// <summary>
 /// Handling Folder Change (New,Rename)
 /// </summary>
 /// <param name="fe">Folder Change Event with all the information for hte file change</param>
 public void HandleFolderChange(FolderChangeEvent fe)
 {
     try
     {
         if (fe.Event == EventChangeType.CREATED)
         {
             HandleFolderNewEvent(fe);
         }
         else if (fe.Event == EventChangeType.RENAMED)
         {
             HandleFolderRenameEvent(fe);
         }
         else if (fe.Event == EventChangeType.DELETED)
         {
             HandleRootFolderDeleteEvent(fe);
         }
     }
     catch (Exception e)
     {
         ServiceLocator.GetLogger(ServiceLocator.DEBUG_LOG).Write(e);
     }
 }
Esempio n. 4
0
 private void ExecuteFolder(FileSystemEvent fse)
 {
     FolderChangeEvent folderEvent;
     switch (fse.EventType)
     {
         case EventChangeType.CREATED:
             //ServiceLocator.GetLogger(ServiceLocator.DEVELOPER_LOG).Write("Folder Created: " + fse.Path);
             folderEvent = new FolderChangeEvent(new DirectoryInfo(fse.Path), EventChangeType.CREATED);
             ServiceLocator.MonitorI.HandleFolderChange(folderEvent);
             break;
         case EventChangeType.DELETED:
             //ServiceLocator.GetLogger(ServiceLocator.DEVELOPER_LOG).Write("Folder Deleted: " + fse.Path);
             folderEvent = new FolderChangeEvent(new DirectoryInfo(fse.Path), EventChangeType.DELETED);
             ServiceLocator.MonitorI.HandleFolderChange(folderEvent);
             break;
         case EventChangeType.RENAMED:
             //ServiceLocator.GetLogger(ServiceLocator.DEVELOPER_LOG).Write("Folder Renamed: " + fse.OldPath + " " + fse.Path);
             folderEvent = new FolderChangeEvent(new DirectoryInfo(fse.OldPath), new DirectoryInfo(fse.Path));
             ServiceLocator.MonitorI.HandleFolderChange(folderEvent);
             break;
         default:
             Debug.Assert(false);
             break;
     }
 }