Пример #1
0
        public string receiver(string stuff, string action)
        {
            string path = @"C:\Users\Shahbaaz\efb\in\";
            path += action;
            path += ".txt";
            Away a = new Away();
            a.content = action;
            ServiceController myService = new ServiceController("eFacebookMediatorService");
            myService.ExecuteCommand((int)MyCustomCommands.FileAccess);
            File.WriteAllText(path, stuff);
            int dwStartTime = System.Environment.TickCount;

            a.statusManager = false;
            while (1 != 0)
            {
                if (a.statusManager == true)
                {
                    a.statusManager = false;
                    return a.sendManager;
                }
                else
                    continue;

            }
        }
Пример #2
0
        // Start the Windows service.
        protected override void OnStart(string[] args)
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
            }
            Away a = new Away();
            a.statusManager = false;

            serviceHost = new ServiceHost(typeof(FocalService));
            serviceHost.Open();

            FileSystemWatcher Watcher;
            string pathToFolder = @"C:\Users\Shahbaaz\efb\out";
            Watcher = new FileSystemWatcher { Path = pathToFolder, IncludeSubdirectories = false, Filter = "*.*" };
            Watcher.Changed += new FileSystemEventHandler(FileWasChanged);
            Watcher.EnableRaisingEvents = true;
        }
Пример #3
0
 public void makeFiles()
 {
     Away a = new Away();
     string path = @"C:\test\watched\";
     path += a.content;
     var ts = DateTime.UtcNow - new DateTime(1970, 1, 1);
     path += ts.TotalMilliseconds;
     if (!File.Exists(path))
     {
         // Create a file to write to.
         using (StreamWriter sw = File.CreateText(path))
         {
             sw.WriteLine("Created");
         }
     }
 }
Пример #4
0
        public void writeToDrive()
        {
            Away b = new Away();

            string anotherPath = @"C:\test\read\send.txt";
            File.WriteAllText(anotherPath, "The message was " + b.content + ". Response created at " + DateTime.Now.ToString("HH:mm:ss tt") + Environment.NewLine);
        }
Пример #5
0
        public void FileWasChanged(object source, FileSystemEventArgs e)
        {
            int dwStartTime = System.Environment.TickCount;

            while (true)
            {

                if (System.Environment.TickCount - dwStartTime > 20) break;

            }

            FileInfo file = new FileInfo(e.FullPath);
            string nom = file.Name;
            int f = nom.IndexOf(".");
            nom = nom.Substring(0, f);
            Away a = new Away();
            try
            {

                if (nom == a.content)
                {
                    a.sendManager = File.ReadAllText(e.FullPath);
                    a.statusManager = true;
                }
            }
            catch (IOException err)
            {
                string path = @"C:\test\errors\log.txt";
                File.AppendAllText(path, err.ToString());

            }
        }