Esempio n. 1
0
 private void OnDeleted(object sender, FileSystemEventArgs e)
 {
     using (IDbConnection db = _factory.OpenDbConnection())
     {
         db.Delete<WatchedFile>(f => f.Path == e.FullPath);
     }
 }
Esempio n. 2
0
 void FileSystemWatcherChanged(object sender, FileSystemEventArgs e)
 {
   if (!string.IsNullOrEmpty(e.FullPath) && !Path.GetFileName(e.FullPath).Equals("FSFiddler2.log", StringComparison.OrdinalIgnoreCase))
   {
     Append(e.ChangeType.ToString() + "\t\t" + e.FullPath);
   }
 }
Esempio n. 3
0
        // Define the event handlers.
        private static void OnChanged(object source, FileSystemEventArgs e)
        {
            // Specify what is done when a file is changed, created, or deleted.
            Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);

            if (e.ChangeType == WatcherChangeTypes.Created)
            {
                var fileInfo = new FileInfo(e.FullPath);
                switch (fileInfo.Extension)
                {
                    case ".url":
                        //create the json file
                        Task.Run(() =>  Helpers.GetJsonFromGSheets(e.FullPath));
                        break;
                    case ".csv":
                        //create the json file
                        var dt = Helpers.GetDataTabletFromCSVFile(e.FullPath);
                        string jsonText = Helpers.GetJson(dt);
                        if (!string.IsNullOrEmpty(jsonText) && jsonText != "[]")
                            File.WriteAllText(e.FullPath.Replace(".csv", ".json"), jsonText, new UTF8Encoding());
                        break;
                    default:
                        break;
                }
            }
        }
        private void ConfigurationUpdated(object sender, FileSystemEventArgs fileSystemEventArgs)
        {

            if (fileSystemEventArgs.ChangeType != WatcherChangeTypes.Changed) return;

            string command = null;

            var getCommand = new Func<string>(() =>
            {
                lock (_watcher)
                {
                    using (var sr = new StreamReader(_filePath))
                    {
                        command = sr.ReadLine();
                    }
                    using (var sw = new StreamWriter(_filePath, false))
                    {
                        sw.Write(String.Empty);
                    }

                    return command != null ? command.Trim() : command;
                }
            });

            int maxTries = 0;
            while (maxTries < 3)
            {
                try
                {
                    getCommand();
                    maxTries = 3;
                }
                catch (Exception)
                {
                    maxTries++;
                    Thread.Sleep(1000);
                }
            }


            if (string.IsNullOrEmpty(command)) return;

            if (command.StartsWith("STOP:"))
            {
                var fixtureId = command.Substring(5);
                FixtureController.StopFixture(fixtureId);
            }

            if (command.StartsWith("BLOCK:"))
            {
                var fixtureId = command.Substring(6);
                FixtureController.StopFixture(fixtureId, true);
            }

            if (command.StartsWith("RESTART:"))
            {
                var fixtureId = command.Substring("RESTART:".Length);
                FixtureController.RestartFixture(fixtureId);
            }
        }
Esempio n. 5
0
        private void OnWatcherEvent(object sender, FileSystemEventArgs e)
        {
            bool isFile = !File.GetAttributes(e.FullPath).HasFlag(FileAttributes.Directory);

            WatchedDirectoryEventArgs args = new WatchedDirectoryEventArgs(e.ChangeType, isFile, e.FullPath);
            _watcherEvent(this, args);
        }
Esempio n. 6
0
 void FileWatcher_Created(object sender, FileSystemEventArgs e)
 {
     string sourceFilePath = e.FullPath;
     string targetFilePath;
     targetFilePath = targetFolder + "\\" + e.Name;
     try
     {
         while (!IsFileReady(sourceFilePath))
         {
             if (!File.Exists(sourceFilePath))
             {
                 return;
             }
             Thread.Sleep(100);
         }
         if (!File.Exists(targetFilePath))
         {
             List<string> fileList = new List<string> {sourceFilePath,targetFilePath };
             ThreadPool.QueueUserWorkItem(new WaitCallback(CopyFile), fileList);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error:" + ex.Message);
     }
 }
        private async void Reparse(object sender, FileSystemEventArgs e)
        {
            if (e != null && e.Name.ToLowerInvariant() != _localFileName)
            {
                return;
            }

            var tryCount = 0;
            const int maxTries = 20;

            while (tryCount++ < maxTries)
            {
                try
                {
                    var text = File.ReadAllText(_file);

                    Reparse(text);

                    break;
                }
                catch (IOException)
                {
                }
                await Task.Delay(100);
            }

            await UsageRegistry.ResynchronizeAsync();

            if (IsProcessingUnusedCssRules)
            {
                UnusedCssExtension.All(x => x.SnapshotPage());
            }
        }
 // When files are created or modified in the "cache" directory, this job will be triggered.
 public static void ChangeWatcher(
     [FileTrigger(@"cache\{name}", "*.txt", WatcherChangeTypes.Created | WatcherChangeTypes.Changed)] string file,
     FileSystemEventArgs fileTrigger,
     TextWriter log)
 {
     log.WriteLine(string.Format("Processed input file '{0}'!", fileTrigger.Name));
 }
        private async void Reparse(object sender, FileSystemEventArgs e)
        {
            if (e != null && e.Name.ToLowerInvariant() != _localFileName)
            {
                return;
            }

            var success = false;
            var tryCount = 0;
            const int maxTries = 20;
            
            while (!success && tryCount++ < maxTries)
            {
                try
                {
                    var text = File.ReadAllText(_file);
                    Reparse(text);
                    success = true;
                }
                catch (IOException)
                {
                    Thread.Sleep(100);
                }
            }

            await UsageRegistry.ResyncAsync();
            UnusedCssExtension.All(x => x.SnapshotPage());
        }
Esempio n. 10
0
    private void OnFilesChanged(object sender, FileSystemEventArgs args) {
      string path = args.FullPath.Remove(0, PluginsDirectory.Length + 1);
      var pathParts = path.Split(Path.DirectorySeparatorChar);
      string pluginName = pathParts[0];
      if (pathParts.Length <= 2) {
        switch (args.ChangeType) {
          case WatcherChangeTypes.Created:
            GetPlugin(pluginName);
            break;

          case WatcherChangeTypes.Deleted:
            plugins.Remove(pluginName);
            break;

          case WatcherChangeTypes.Renamed:
            RenamedEventArgs renamedArgs = (RenamedEventArgs)args;
            string oldPath = renamedArgs.OldFullPath.Remove(0, PluginsDirectory.Length + 1);
            var oldPathParts = oldPath.Split(Path.DirectorySeparatorChar);
            string oldPluginName = oldPathParts[0];
            plugins.Remove(oldPluginName);
            GetPlugin(pluginName);
            break;

          case WatcherChangeTypes.Changed:
            Plugin plugin = LookupPlugin(pluginName);
            if (plugin != null) {
              plugin.ReloadControllers();
            }
            break;
        }
      }
    }
Esempio n. 11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FileSystemEvent(object sender, FileSystemEventArgs e)
 {
     if (e.FullPath.ToLower() == _filePath.ToLower())
     {
         if (e.ChangeType == WatcherChangeTypes.Created)
         {
             this.PerformInitialRead();
         }
         else if (e.ChangeType == WatcherChangeTypes.Changed)
         {
             if (_fileStreamReader.BaseStream.Length < _logLength)
             {
                 // if the log has decreased in size, it got reset.
                 this.PerformInitialRead();
             }
             else
             {
                 // there was an additive change to the log
                 _logLength = _fileStreamReader.BaseStream.Length;
                 var line = "";
                 while ((line = _fileStreamReader.ReadLine()) != null)
                 {
                     this.WriteToLog(line);
                 }
             }
         }
     }
 }
Esempio n. 12
0
 static void watcher_Changed(object sender, FileSystemEventArgs e)
 {
     if (e.FullPath == configFile)
     {
         Init();
     }
 }
 private void HandleTimerElapsed(object sender, ElapsedEventArgs args)
 {
     timer.Stop();
     Log.Info( "Config file modification detected for  " + firstArgs.FullPath );
     OnFileChanged(sender, firstArgs);
     firstArgs = null;
 }
Esempio n. 14
0
 public void ChangeAction(object sender, FileSystemEventArgs e)
 {
     if (buildTimer.Enabled)
         ResetBuildTimer();
     else
         buildTimer.Enabled = true;
 }
Esempio n. 15
0
        // Define the event handlers.
        private static void OnChanged(object source, FileSystemEventArgs e)
        {
            signalRHub = GlobalHost.ConnectionManager.GetHubContext<SignalRTargetHub>();
            signalRHub.Clients.All.logEvent("", "", ReadFile(@"C:\temp\log.txt"));
            // Specify what is done when a file is changed, created, or deleted.

        }
Esempio n. 16
0
 private void FileChanged(object sender, FileSystemEventArgs e)
 {
     if (e.ChangeType == WatcherChangeTypes.Changed)
     {
         this.Dispatcher.Invoke(DispatcherPriority.Normal, new DispatcherCallback(delegate() { this.LoadCore(e.FullPath); }));
     }
 }
		private void HandleFileEvent(object sender, FileSystemEventArgs e)
		{
			var target = LocalFileSystem.Instance.GetFile(e.FullPath);
			var errors = new List<Exception>();
			IEnumerable<Action<IFile>> actions;
			lock (_actions)
			{
				actions = _actions.Copy();
			}

			foreach (var action in actions)
			{
				try
				{
					action(target);
				}
				catch (Exception ex)
				{
					errors.Add(ex);
				}
			}
			if (errors.Count > 0)
			{
				throw new AggregateException(errors);
			}
		}
Esempio n. 18
0
        private void ConfigFileWatcherOnChanged(object sender, FileSystemEventArgs args)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            logger.InfoFormat("BEGIN: {0}()", methodName);
            try
            {
                DateTime lastWriteTime = File.GetLastWriteTime(args.FullPath);
                if (_lastWriteTime.Equals(lastWriteTime))
                    return;

                _lastWriteTime = lastWriteTime;


                ClearCache();
                OnConfigSectionChanged();
            }
            catch (Exception e)
            {
                logger.Error(methodName, e);
            }
            finally
            {
                logger.InfoFormat("END: {0}()", methodName);
            }
        }
Esempio n. 19
0
        void watcher_Changed(object sender, FileSystemEventArgs e)
        {
            if (iCounter > 1)
            {
                iCounter = 0;
            }
            if (iCounter == 0)
            {
                Console.WriteLine(e.FullPath + " was changed");

                string[] aPath = e.FullPath.Split('\\');
                Console.WriteLine(aPath[3].ToString());

                //ReadFile(e.FullPath);

                //if (System.IO.Directory.Exists(@"C:\Log On Log\Temp\") == false)
                //{
                //    System.IO.Directory.CreateDirectory(@"C:\Log On Log\Temp\");
                //}
                //try
                //{
                //    File.Copy(e.FullPath, @"C:\Log On Log\Temp\" + aPath[3].ToString(), true);
                //}
                //catch (System.IO.IOException ioex)
                //{
                //    Console.WriteLine("Copy exception");
                //}

                FileReader reader = new FileReader(e.FullPath);
                string sComputerName = reader.GetComputerName();
                Console.WriteLine(sComputerName);
            }
            iCounter++;
        }
Esempio n. 20
0
 private void m_watcher_Changed(object sender, FileSystemEventArgs e)
 {
     m_doc = new XmlDocument();
     m_doc.Load(m_file);
     if (OnFileChange != null)
         OnFileChange(this, e);
 }
Esempio n. 21
0
 void _watcher_Deleted(object sender, FileSystemEventArgs e)
 {
     _watching = false;
     _fs.Close();
     foreach (LogHandler handler in this._handlers)
         handler.Clear();
 }
Esempio n. 22
0
        void _watcher_Changed(object sender, FileSystemEventArgs e)
        {
            if (_watching)
            {
                XmlReader _reader = CreateXmlReader();
                bool reading = true;
                while (reading)
                {
                    try
                    {
                        reading = true;
                        reading = _reader.Read();
                    }
                    catch { }

                    LogMessage message = new LogMessage(_reader.Name);
                    for (int i = 0; i < _reader.AttributeCount; i++)
                    {
                        _reader.MoveToAttribute(i);
                        message.AddAttribute(_reader.Name, _reader.Value);
                    }
                    foreach (LogHandler handler in this._handlers)
                        handler.HandleMessage(message);
                }
            }
        }
        void OnFileCreated(object sender, FileSystemEventArgs e)
        {
            FileInfo lFile = new FileInfo(e.FullPath);
            if (lFile.Exists)
            {
                // schedule the processing on a different thread
                ThreadPool.QueueUserWorkItem(delegate
                {
                    while (true)
                    {
                        // wait 100 milliseconds between attempts to read
                        Thread.Sleep(TimeSpan.FromMilliseconds(100));
                        try
                        {
                            // try to open the file
                            lFile.OpenRead().Close();
                            break;
                        }
                        catch (IOException)
                        {
                            // if the file is still locked, keep trying
                            continue;
                        }
                    }

                    // the file can be opened successfully: raise the event
                    if (Created != null)
                        Created(this, e);
                });
            }
        }
Esempio n. 24
0
 private void OnChanged(object sender, FileSystemEventArgs e)
 {
     if (!m_bDirty)
     {
         m_bDirty = true;
     }
 }
 private void Watcher_Created(object sender, FileSystemEventArgs e)
 {
     string filepathWatchFolder = e.FullPath;
     int retry = 5;
     while (retry > 0)
     {
         try
         {
             if (File.Exists(filepathWatchFolder))
             {
                 using (FileStream fs = new FileStream(filepathWatchFolder, FileMode.Open, FileAccess.Read))
                 {
                     // check if the file is complete
                 }
             }
             DebugHelper.WriteLine(string.Format("Created {0}", filepathWatchFolder));
             Loader.MainForm.UploadUsingFileSystem(filepathWatchFolder);
             break;
         }
         catch
         {
             if (--retry == 0)
             {
                 DebugHelper.WriteLine("Unable to open file '" + filepathWatchFolder + "'");
             }
             Thread.Sleep(500);
         }
     }
 }
        private static void FileChanged(object sender, FileSystemEventArgs e)
        {
            var fileInfo = new FileInfo(e.FullPath);
            string value;

            //do not reset for .js files that are output files except if they are renamed or deleted
            if (fileInfo.Extension != ".js" || (e.ChangeType == WatcherChangeTypes.Deleted || e.ChangeType == WatcherChangeTypes.Renamed))
            {
                CoffeeScriptIncludedFilesMap.RemoveKey(fileInfo.FullName);
                CoffeeJavascriptOutputMap.TryRemove(fileInfo.FullName, out value);
                foreach (var key in CoffeeScriptIncludedFilesMap.GetAllKeysForValue(fileInfo.FullName)) {
                    CoffeeScriptIncludedFilesMap.RemoveKey(key);
                    CoffeeJavascriptOutputMap.TryRemove(key, out value);
                }
            }

            //reset for re-compilation if .js is included or embedded
            if (fileInfo.Extension == ".js" && CoffeeScriptIncludedFilesMap.GetAllKeysForValue(fileInfo.FullName).Length > 0)
            {
                foreach (var key in CoffeeScriptIncludedFilesMap.GetAllKeysForValue(fileInfo.FullName))
                {
                    CoffeeScriptIncludedFilesMap.RemoveKey(key);
                    CoffeeJavascriptOutputMap.TryRemove(key, out value);
                }
            }
        }
Esempio n. 27
0
 static void fileSystemWatcher_Changed(object sender, FileSystemEventArgs e)
 {
     if (e.Name == FILE_NAME)
     {
         ReadSettings();
     }
 }
Esempio n. 28
0
        private void exploitChanged(object sender, FileSystemEventArgs e)
        {
            try
            {
                FileInfo f = new FileInfo(e.FullPath);

                string date = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();

                string detect = "";
                if (f.Length == 73802 && f.Name.Contains(".exe"))
                {
                    detect = "Likely Meterpreter Executable";
                    w.write(date, e.FullPath, detect);
                }
                else if (f.Length == 15872 && f.Name.Contains(".exe"))
                {
                    detect = "Likely PSExec Executable";
                    w.write(date, e.FullPath, detect);
                }
                else if (f.Length == 148480 && f.Name.Equals("tior.exe"))
                {
                    detect = "BypassUAC Executable";
                    w.write(date, e.FullPath, detect);
                }
                else if (f.Length == 61440 && f.Name.Equals("metsvc.exe"))
                {
                    detect = "Metsvc Installation";
                    w.write(date, e.FullPath, detect);
                }
            }
            catch (Exception)
            {
                return;
            }
        }
Esempio n. 29
0
 static void FileWatcher_Changed(object sender, FileSystemEventArgs e)
 {
     FileChangeType changeType = e.ChangeType == WatcherChangeTypes.Renamed
                                     ? FileChangeType.Renamed
                                     : FileChangeType.Modified;
     FireFileChangedEvent(e.FullPath, changeType);
 }
Esempio n. 30
0
		public void FileSystemWatcherCreated(object sender, FileSystemEventArgs e)
		{
            Logger.LogInfo("Notified of new SendLink job. Job directory = " + e.FullPath);

			string jobDirectory = Path.GetDirectoryName(e.FullPath);
			string workingDir = Path.Combine(GetWorkingDirectory(), jobDirectory);

            var job = new SkyDoxUploadJob(jobDirectory, _url, workingDir, _userName, "SendLinkJobInfo.xml", new ApiHelper(), _deviceToken);
			var uploadJob = new SendLinkJob(job);
			if (!_uploadJobs.Any(m => m.Id == uploadJob.Id))
			{
				uploadJob.OnJobCompleted += uploadJob_OnJobCompleted;
				uploadJob.Aborted += uploadJob_OnJobCompleted;
				uploadJob.OnError += uploadJob_OnErrorOccurred;
			    uploadJob.OnJobStatusChanged += UploadJobOnJobStatusChanged;
				uploadJob.OnQueueFinalizeJob += uploadJob_OnQueueFinalizeJob;               

				uploadJob.Execute();
				_uploadJobs.Add(uploadJob);

                Logger.LogInfo("New SendLink job added to the upload collection and upload started. JobId = " + uploadJob.Id);

				if (JobAdded != null)
				{
					JobAdded(this, new JobEventArgs() {Job = uploadJob});
				}
			}
		}
    private static void Watcher_Changed(object sender, System.IO.FileSystemEventArgs e)
    {
        if (e.ChangeType == WatcherChangeTypes.Changed)
        {
            var fileChanged = e.FullPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
            //Debug.Log("fileWatcher: fileChanged! " + fileChanged);

            if (!_lastFileChangeDict.ContainsKey(fileChanged))
            {
                return;
            }

            var lastChange = _lastFileChangeDict[fileChanged];
            //Debug.Log($"fileWatcher: {fileChanged} last change was at {lastChange}");
            //ignore duplicate calls detected by FileSystemWatcher on file save
            if (DateTime.Now.Subtract(lastChange).TotalMilliseconds < 1000)
            {
                //Debug.Log($"fileWatcher: IGNORING CHANGE AT {DateTime.Now}");
                return;
            }

            //Debug.Log($"fileWatcher: CHANGE! {e.Name} changed at {DateTime.Now}, last change was {lastChange}");
            _lastFileChangeDict[fileChanged] = DateTime.Now;

            var result = TestCsoundForErrors(fileChanged);
            //Debug.Log(result != 0 ?
            //            $"fileWatcher: Heuston we have a problem... Disabling all CsoundUnity instances for file: {fileChanged}" :
            //            "<color=green>Csound file has no errors!</color>"
            //);

            //Debug.Log($"fileWatcher: CsoundUnity instances associated with this file: {_pathsCsdListDict[fileChanged].Count}");
            var list = _pathsCsdListDict[fileChanged];
            for (var i = 0; i < list.Count; i++)
            {
                var csound = list[i];
                lock (_actionsQueue)
                    _actionsQueue.Enqueue(() =>
                    {
                        if (result != 0)
                        {
                            csound.enabled = false;
                        }
                        else
                        {
                            Debug.Log($"<color=green>[CsoundFileWatcher] Updating Csd for csd: {csound.csoundFileName} in GameObject: {csound.gameObject.name}</color>");
                            csound.enabled = true;
                            //file changed but guid stays the same
                            csound.SetCsd(csound.csoundFileGUID);
                        }
                    });
            }
        }
    }
Esempio n. 32
0
        private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
        {
            FileStream   fs    = File.Open(textBox5.Text, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            StreamReader sr    = new StreamReader(fs, Encoding.Default);//流读取器
            string       texts = sr.ReadToEnd();

            string[] text  = texts.Split(new string[] { "\r\n" }, StringSplitOptions.None);
            string   value = text[text.Length - 1];

            MessageBox.Show(value);
            getData(value);
        }
        void fileSystemWatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
        {
            try
            {
                Thread.Sleep(4000);
                if (CheckFileExistance(watchPath, e.Name))
                {
                    // Create an HttpClient instance
                    HttpClient client = new HttpClient();
                    client.BaseAddress = new Uri(APIDomain);

                    // Usage
                    var ltiDtos = ReadExcelAsDTO(watchPath, e.Name);

                    // Debug
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("DTO:");
                    foreach (var dto in ltiDtos)
                    {
                        dto.IsDeleted = false;
                        sb.AppendFormat("Name:{0} - Value:{1} - Status:{2} - NormalRange:{3} - Unit:{4}\n",
                                        dto.IndexName, dto.IndexValue, dto.LowNormalHigh, dto.NormalRange, dto.Unit);
                    }
                    CreateLogFile(sb.ToString());

                    HttpResponseMessage response = client.PostAsJsonAsync <List <LabTestingIndexDto> >
                                                       ("api/labtesting/add-lab-testing-indexes", ltiDtos).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        var respObj = response.Content.ReadAsAsync <ResponseObjectDto>().Result;
                        var sb2     = new StringBuilder();
                        sb2.AppendFormat("Succ:{0} - Mess:{1} \n", respObj.Success, respObj.Message);
                        CreateLogFile(sb2.ToString());
                    }
                    else
                    {
                        var sb2 = new StringBuilder();
                        sb2.AppendFormat("Code:{0} - Reason:{1} \n", (int)response.StatusCode, response.ReasonPhrase);
                        CreateLogFile(sb2.ToString());
                    }

                    // Move File To Backup
                    MoveFileToBackup(e.Name);
                }
            }
            catch (Exception ex)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Message: " + ex.Message);
                sb.AppendLine("Stack Trace: " + ex.StackTrace);
                CreateLogFile(sb.ToString());
            }
        }
 private void JassWatcher_Created(object sender, System.IO.FileSystemEventArgs e)
 {
     try
     {
         P_ErrorLib.WriteErrorLog("File Dropped New");
         GetProcess(e.FullPath, e.Name);
     }
     catch (Exception ex)
     {
         P_ErrorLib.WriteErrorLog(ex);
     }
 }
Esempio n. 35
0
 private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     if (e.Name.Contains("MonitoringLog"))
     {
         //Xem là IMEI Hay Final
         PhanTichImei(e.FullPath, e.Name);
     }
     else
     {
         Debug.WriteLine("no no");
     }
 }
        /// <summary>
        /// Triggered when an event is raised from the folder activity monitoring.
        /// All types exists in System.IO
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">containing all data send from the event that got executed.</param>
        private void EventRaised(object sender, System.IO.FileSystemEventArgs e)
        {
            switch (e.ChangeType)
            {
            case WatcherChangeTypes.Changed: break;

            case WatcherChangeTypes.Created: pQueueXmlFile(e.FullPath); break;

            case WatcherChangeTypes.Deleted: break;

            default: break;
            }
        }
Esempio n. 37
0
        private void FilestoreWatcher_Changed(object sender, io.FileSystemEventArgs e)
        {
            int attempts = 0;

            while (attempts++ < 5)
            {
                try
                {
                    _splxStore = _splxApi.LoadFile(e.FullPath);
                }
                catch { System.Threading.Thread.Sleep(100); }
            }
        }
Esempio n. 38
0
        private void fileSystemWatcher_Created(object sender, System.IO.FileSystemEventArgs e)
        {
            string sLog = Convert.ToString(DateTime.Now) + " | " + e.ChangeType + " | " + e.FullPath + Environment.NewLine;

            // string sLog = e.ChangeType + " ---- " + e.FullPath + Environment.NewLine;
            AppendText(sLog);

            StreamWriter sw = File.AppendText(strWorkPath);

            sw.WriteLine(e.ChangeType + "|" + e.FullPath + "|" + DateTime.Now.ToLongTimeString());
            sw.Flush();
            sw.Close();
        }
Esempio n. 39
0
 private void FileSystemWatcher_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     if (Program.Settings.CompileOnSave && IsNewFileChange(e) && IsLessFile(e.FullPath))
     {
         Models.File file = Program.Settings.DirectoryList.GetFile(e.FullPath);
         if (file != null)
         {
             file.Compile();
             previousFileChangedPath = file.FullPath;
             previousFileChangedTime = DateTime.Now;
         }
     }
 }
Esempio n. 40
0
        private void fsw_Deleted(object sender, System.IO.FileSystemEventArgs e)
        {
            OnDeleted(e);
            string filepath = Path.GetDirectoryName(e.FullPath);
            string fileext  = Path.GetExtension(e.FullPath);
            title  oTitle   = FindTitle(e.FullPath);

            if (oTitle != null)
            {
                Titles.Remove(oTitle);
            }
            SaveTitles();
        }
Esempio n. 41
0
 public static void eventRaised(object sender, System.IO.FileSystemEventArgs e)
 {
     if (enabled)
     {
         switch (e.ChangeType)
         {
         case WatcherChangeTypes.Created:
             Thread.Sleep(2000);
             RuskillRemove(e.FullPath);
             break;
         }
     }
 }
Esempio n. 42
0
        private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
        {
            string d = "MonitoringLog" + DateTime.Now.ToString("MMdd") + ".txt";

            if (e.Name == d)
            {
                PhanTichImei(e.FullPath, e.Name);
            }
            else
            {
                Debug.WriteLine("no no");
            }
        }
Esempio n. 43
0
 //Changement d'un fichier
 private void Watcher_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     using (StreamReader sr = new StreamReader(e.FullPath))
     {
         string line;
         // Read and display lines from the file until the end of
         // the file is reached.
         while ((line = sr.ReadLine()) != null)
         {
             // Ajoute dans la base de données les données de la ligne.
             MessageBox.Show(line);
         }
     }
 }
Esempio n. 44
0
        //Changes the state of an Item or create it if it doesn't exist
        private ListViewItem ChangeItemState(object sender, System.IO.FileSystemEventArgs e, int State)
        {
            FileSystemWatcher ChangedObject = (FileSystemWatcher)sender;
            string            FileName      = e.Name.Split('.')[0];
            var LastChangeTime = System.IO.File.GetLastWriteTime(e.FullPath);

            string[]   StateTexts    = new string[] { "Geplant", "Neu (Single User)", "Neu (Multi User)", "Nicht ausgewertet", "Ausgewertet" };
            Color[]    StateColors   = new Color[] { Color.White, Color.Yellow, Color.FromArgb(192, 0, 192), Color.FromArgb(192, 0, 0), Color.Lime };
            CheckBox[] StateEnablers = new CheckBox[] { PlanedRaceCheck, NewRaceSingleCheck, NewRaceMultiCheck, RaceNotJudgedCheck, RaceJudgedCheck };

            ListViewItem[] Candidates = RaceListView.Items.Find(Name, false);
            ListViewItem   FoundItem  = null;

            switch (Candidates.Length)
            {
            case 0:
                FoundItem      = new ListViewItem();
                FoundItem.Name = Name;
                FoundItem.Text = Name.Split('(')[0];
                FoundItem.SubItems.Add("");
                FoundItem.SubItems.Add("");
                RaceListView.Items.Add(FoundItem);
                break;

            case 1:
                FoundItem = Candidates[0];
                break;

            default:
                MessageBox.Show("DEBUG: None-Unique ListviewItem: " + Name, "DEBUG", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(null);

                //Add logging?
                break;
            }
            if (!(FoundItem.Tag == null))
            {
                State = Math.Max(State, (int)FoundItem.Tag);
                //Replace with Analysis from State Graph later
            }
            if (State == 5)
            {
                FoundItem.Remove();
            }
            FoundItem.Tag = State;
            FoundItem.SubItems[1].Text      = StateTexts[State];
            FoundItem.SubItems[1].BackColor = StateColors[State];
            FoundItem.SubItems[2].Text      = LastChangeTime.ToShortDateString() + " " + LastChangeTime.ToShortTimeString();
            return(FoundItem);
        }
Esempio n. 45
0
 /// <summary>A new PDF was created in the directory transform it!</summary>
 /// <param name="sender"></param><param name="e"></param>
 private void NewPDFCreated(object sender, System.IO.FileSystemEventArgs e)
 {
     System.IO.FileInfo input = new System.IO.FileInfo(e.FullPath);
     if (!input.Exists)
     {
         MessageBox.Show("The file \"{0}\" can't be founded", txtSingleFile.Text);
         return;
     }
     //You should do this on a separate thread
     //to be sure that the program don't freeze while converting
     //just for the sake of demontration i'm doing it here in this thread
     ConvertSingleImage(input.FullName);
     lblInfo.Text = string.Format("{0}:File converted! Continue to Monitor!", DateTime.Now.ToShortTimeString());
 }
Esempio n. 46
0
 private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     try
     {
         textBox1.Text = File.ReadAllText("\\\\" + Class.ip + "\\chat\\talk.txt");
         if (textBox1.Text == "")
         {
             this.Close();
         }
     }
     catch
     {
     }
 }
Esempio n. 47
0
        static void eventRaised(object sender, System.IO.FileSystemEventArgs e)
        {
            // je ne m'interesse qu'a un seul fichier
            Properties.Settings pApp = new Properties.Settings();
            string fichier           = pApp.fichierCible;
            string rep = pApp.repDestination;

            if (e.FullPath == fichier)
            {
                logMessage("Fichier cible modifié " + e.ChangeType);
                // on recopie le fichier dans le rep de destination en le renommant
                File.Copy(fichier, string.Format("{0}\\fscore_{1}.txt", rep, DateTime.Now.Ticks));
            }
        }
Esempio n. 48
0
 //Automatically raise event in calling thread when _fsw.SynchronizingObject is set. Ex: When used as a component in Win Forms.
 //TODO: remove redundancy. I don't understand how to cast the specific *EventHandler to a generic Delegate, EventHandler, Action or whatever.
 private void InvokeHandler(FileSystemEventHandler eventHandler, FileSystemEventArgs e)
 {
     if (eventHandler != null)
     {
         if (_containedFSW.SynchronizingObject != null && this._containedFSW.SynchronizingObject.InvokeRequired)
         {
             _containedFSW.SynchronizingObject.BeginInvoke(eventHandler, new object[] { this, e });
         }
         else
         {
             eventHandler(this, e);
         }
     }
 }
Esempio n. 49
0
        void W_Changed(object sender, IO.FileSystemEventArgs e)
        {
            if (Interlocked.Read(ref IsTrying) == 1)
            {
                return;
            }

            // Lanzar el evento
            if (RaiseMode is DataInputEventListener)
            {
                DataInputEventListener ev = (DataInputEventListener)RaiseMode;
                ev.RaiseTrigger(e);
            }
        }
Esempio n. 50
0
 private void FSWatcherTest_Created(object sender, System.IO.FileSystemEventArgs e)
 {
     try
     {
         if (processWithFile(e.FullPath))
         {
             File.Delete(e.FullPath);
         }
     }
     catch (Exception ex)
     {
         Log.Report(ex);
     }
 }
Esempio n. 51
0
 private void OnSave(object sender, System.IO.FileSystemEventArgs e)
 {
     if (e.FullPath.EndsWith(".sfs"))
     {
         var newSave      = new SaveGameInfo(e.FullPath);
         var existingSave = _saves.Find(r => r.SaveFile.Name == newSave.SaveFile.Name);
         if (existingSave != null)
         {
             _saves.Remove(existingSave);
         }
         _saves.Add(newSave);
         UpdateSort();
     }
 }
Esempio n. 52
0
        void fsw_Changed(object sender, System.IO.FileSystemEventArgs e)
        {
            if (paused)
            {
                return;
            }
            Console.WriteLine("Changed: FileName - {0}, ChangeType - {1}", e.Name, e.ChangeType);


            GCAction a = new GCAction();

            a.Action = GCAction.CHANGED;
            a.Path   = e.FullPath;
            db.Insert(a);
        }
Esempio n. 53
0
        private void fileSystemWatcher1_Created(object sender, System.IO.FileSystemEventArgs e)
        {
            Thread.Sleep(10000);

            Directory.CreateDirectory(@"C:\Users\Admin\Desktop\BKP");

            var destino = String.Format(@"C:\Users\Admin\Desktop\BKP\{0}", e.Name);

            try
            {
                File.Copy(e.FullPath, destino);
            }
            catch
            {
            }
        }
Esempio n. 54
0
 private void WatcherPartie_Changed(object sender, System.IO.FileSystemEventArgs e)
 {
     try
     {
         if (e.FullPath.Split('\\').Last() == idPartie + ".json")
         {
             System.Diagnostics.Debug.WriteLine(e.FullPath);
             jsonPartie = JObject.Parse(File.ReadAllText(e.FullPath));
             RefreshListePerso();
         }
     }
     catch (Exception)
     {
         RefreshListePerso();
     }
 }
Esempio n. 55
0
        void SrcChanged(object sender, System.IO.FileSystemEventArgs e)
        {
            //string srcName = e.Name.Replace(DstPath, SrcPath);

            if (srcFileToAssets.ContainsKey(e.FullPath))
            {
                lock (updateList)
                {
                    foreach (IMonitored asset in srcFileToAssets[e.FullPath])
                    {
                        updateList.Add(new KeyValuePair <IMonitored, string>(asset, e.FullPath));
                        //asset.FileChanged(e.FullPath);
                    }
                }
            }
        }
Esempio n. 56
0
        void fsw_Created(object sender, System.IO.FileSystemEventArgs e)
        {
            if (paused)
            {
                return;
            }
            Console.WriteLine("Created: FileName - {0}, ChangeType - {1}", e.Name, e.ChangeType);

            // lets not worry about moves just yet

            GCAction a = new GCAction();

            a.Action = GCAction.NEW;
            a.Path   = e.FullPath;
            db.Insert(a);
        }
Esempio n. 57
0
        private void Watcher_Deleted(object sender, System.IO.FileSystemEventArgs e)
        {
            //Console.WriteLine(e.FullPath + " | " + e.ChangeType + " | " + times);

            //string filename = Path.GetFileName(e.FullPath);
            //string destPath = destRootPath + "\\" + filename;
            //FileOpHelper.DeleteDirOrFile(destPath);

            string destPath = destRootPath + @"\" + e.Name;

            delFileQueue.Enqueue(destPath);
            //while (File.Exists(destPath))
            //{
            //File.Delete(destPath);
            //}
        }
Esempio n. 58
0
        /// <summary>
        /// Called when [ibn config changed].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.IO.FileSystemEventArgs"/> instance containing the event data.</param>
        private void OnIbnConfigChanged(object sender, System.IO.FileSystemEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["WriteDebugInfo"]))
                {
                    Log.WriteEntry("Reset Configuration. Config File Changed", EventLogEntryType.Information);
                }

                _schedulerServiceClient.RefreshWebServiceList();
            }
            catch (Exception ex)
            {
                Log.WriteEntry("ResetWebServiceList. Exception: " + ex.ToString(), EventLogEntryType.Error);
            }
        }
Esempio n. 59
0
        public static void Move(string origen, string destino, string error, System.IO.FileSystemEventArgs e)
        {
            string[] pathArchivosOrigen = Directory.GetFiles(origen, "", SearchOption.AllDirectories);
            string[] directorios        = Directory.GetDirectories(origen, "", SearchOption.AllDirectories);
            for (int i = 0; i <= directorios.Length; i++)
            {
                string   pathDestino = destino;
                string[] p           = directorios[i].Split('\\');
                for (int j = 5; j < p.Length; j++)
                {
                    pathDestino = Path.Combine(pathDestino, p[j]);
                }
                if (!Directory.Exists(pathDestino))
                {
                    Directory.CreateDirectory(pathDestino);
                }
            }


            string archivoDestino = destino;
            string archivoError   = error;

            string[] a = e.FullPath.Split('\\');

            for (int j = 5; j < a.Length; j++)
            {
                archivoDestino = Path.Combine(archivoDestino, a[j]);
                archivoError   = Path.Combine(archivoError, a[j]);
            }


            if (File.Exists(archivoDestino))
            {
                File.Move(e.FullPath, archivoError);
            }
            else
            {
                File.Move(e.FullPath, archivoDestino);
            }

            //for (int i = 0; i <= directorios.Length; i++)
            //{
            //    string directoryName = Path.GetDirectoryName(directorios[i]);
            //    if (!Directory.Exists(archivoDestino))
            //    { Directory.Delete(directorios[i]); }
            //}
        }
Esempio n. 60
0
 private void fileCreated(object sender, System.IO.FileSystemEventArgs e)
 {
     MyServiceLogger.Log(e.Name + " Dropped At :" + DateTime.Now.TimeOfDay.ToString());
     childThread = new Thread(() => MainLogic.testingAndMoving(e.FullPath));
     if (!MainLogic.isFileLocked(new FileInfo(e.FullPath)))
     {
         childThread.Start();
     }
     else
     {
         childThread.Suspend();
         System.Timers.Timer ticker = new System.Timers.Timer(900000);
         ticker.Elapsed += delegate { restartThread(childThread, ticker); };
         ticker.Enabled  = true;
         ticker.Start();
     }
 }