Пример #1
0
        public async void ConnectAndGetLatest()
        {
            ftp.UnlockComponent("test");

            ftp.Hostname = "ftp.bodirectors.com";
            ftp.Username = Email + "@bodirectors.com";
            ftp.Password = Password;



            OutputFile = await ApplicationData.Current.LocalFolder.GetFileAsync("OutputNames.xml");

            SettingsFile = await ApplicationData.Current.LocalFolder.GetFileAsync("SettingsData.xml");

            ProfilePictureFile = await ApplicationData.Current.LocalFolder.GetFileAsync("profile.jpg");


            isFileDownloaded = await ftp.ConnectAsync();

            isFileDownloaded = await ftp.GetFileAsync("OutputNames.xml", OutputFile.Path);

            isFileDownloaded = await ftp.GetFileAsync("SettingsData.xml", SettingsFile.Path);

            isFileDownloaded = await ftp.GetFileAsync("profile.jpg", ProfilePictureFile.Path);

            isConnected = isFileDownloaded;

            (App.Current as App).SettingsXML = XDocument.Load(await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync("SettingsData.xml"));
            (App.Current as App).NamesXML    = XDocument.Load(await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync("SettingsData.xml"));

            await ftp.DisconnectAsync();
        }
Пример #2
0
        public async void UpdatingPinsThread(int TimerInSeconds)
        {
            StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("OutputNames.xml");

            ConnectingToFtp();


            period = TimeSpan.FromSeconds(TimerInSeconds);


            ThreadPoolTimer PeriodicTimer = ThreadPoolTimer.CreatePeriodicTimer(async(source) =>
            {
                await ftp.ConnectAsync();
                isFileAvailable = await ftp.GetFileAsync("OutputNames.xml", file.Path);
                await ftp.DisconnectAsync();



                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High,
                                                                                                            async() =>
                {
                    try
                    {
                        NamesXML = XDocument.Load(await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync("OutputNames.xml"));

                        var DataQuery = from r in NamesXML.Descendants("Output")
                                        select r;

                        TimeSpan.FromSeconds(1);
                        for (int i = 0; i < 4; i++)
                        {
                            XElement Data = DataQuery.ElementAt(i);


                            if (OriginalStates[i] != Data.Element("status").Value)
                            {
                                OriginalStates[i] = Data.Element("status").Value;
                                SetPinNumber(Convert.ToByte(i + 1));
                                ChangeState();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                    }
                }
                                                                                                            );
            }, period);
        }
Пример #3
0
        public async void getLatestOutputs()
        {
            StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("OutputNames.xml");

            await ftp.ConnectAsync();

            isFileAvailable = await ftp.GetFileAsync("OutputNames.xml", file.Path);

            await ftp.DisconnectAsync();
        }
Пример #4
0
        private async Task DownloadFile()
        {
            await Task.Delay(200);

            InfoText = DownloadConnectionStatus.Text;
            ftp.UnlockComponent("test");

            ftp.Hostname = "ftp.bodirectors.com";
            ftp.Username = (App.Current as App).Email + "@bodirectors.com";
            ftp.Password = (App.Current as App).Password;

            StorageFile file = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("SettingsData.xml");

            DownloadConnectionStatus.Text = "Getting latest file from server.";
            await ftp.ConnectAsync();

            isFileAvailable = await ftp.GetFileAsync("SettingsData.xml", file.Path);

            await ftp.DisconnectAsync();

            DownloadConnectionStatus.Text = "File Downlaoded\n\n";
            isFileAvailable = false;
        }