Beispiel #1
0
        private static IRepository GetFtpRepo(ILoader loader, IPsnConfiguration psnConfig, int deviceNumber, string host, int port, string username, string password)
        {
            IRepository repo          = null;
            Exception   backException = null;
            var         signal        = new ManualResetEvent(false);

            Console.Write("Getting ftp repos async... ");
            loader.GetFtpRepositoryInfosAsync(host, port, username, password, (eventArgs, infos) => {
                try {
                    Console.WriteLine("done!");
                    repo = loader.GetFtpRepository(infos.First(i => i.DeviceNumber == deviceNumber), "ftp loc " + deviceNumber, "1", psnConfig);
                    Console.WriteLine("Repo taken async");
                }
                catch (Exception ex) {
                    backException = ex;
                }
                finally {
                    signal.Set();
                }
            });
            signal.WaitOne();
            if (backException != null)
            {
                throw backException;
            }
            return(repo);
        }
Beispiel #2
0
        private static void GetAllFtpRepos(ILoader loader, IEnumerable <IPsnConfiguration> availablePsnConfigurations, string host, int port, string username, string password)
        {
            var psnConfigs = availablePsnConfigurations.ToList();
            var repos      = new List <IRepository>();
            var signal     = new ManualResetEvent(false);

            //loader.GetFtpRepositoryInfosAsync("10.10.10.10", 21, "1", "1", (eventArgs, infos) => {
            Console.Write("Getting ftp repos async... ");
            loader.GetFtpRepositoryInfosAsync(host, port, username, password, (eventArgs, infos) => {
                Console.WriteLine("done!");
                foreach (var info in infos)
                {
                    Console.WriteLine(info.DeviceNumber);
                    repos.Add(loader.GetFtpRepository(info, "1", "1", psnConfigs.First()));
                    Console.WriteLine("Builded repo on information: " + info.ToString());
                }
                Console.WriteLine("All repositories builded on it's informations");
                signal.Set();
            });
            signal.WaitOne();
            signal.Reset();
            Console.WriteLine("FTP repos taken: " + repos.Count);
            foreach (var repo in repos)
            {
                IRepository repo1 = repo;
                Console.WriteLine(repo1 + " > opening...");
                repo.Open(ea => {
                    Console.WriteLine(repo1 + " > opened: " + ea.Message);
                    Console.WriteLine(repo1 + " > l[0].s[0].PsnLogs count = " + repo1.Locomotives[0].Sections[0].Psns.Count);
                    signal.Set();
                }, ea => Console.WriteLine(repo1 + " > " + ea.ProgressPercent + "%"));
                signal.WaitOne();
                signal.Reset();
            }
        }