Ejemplo n.º 1
0
        public override async Task Appearing()
        {
            await base.Appearing();

            var di = new DirectoryInfo(DataMaster.Setting.UserLocalPath);

            if (di.Exists)
            {
                foreach (var file in di.GetFiles())
                {
                    file.Delete();
                }
                foreach (var dir in di.GetDirectories())
                {
                    dir.Delete(true);
                }
            }
            else
            {
                di.Create();
            }

            _videoView.MediaOpened += _videoView_MediaOpened;
            _videoView.MediaFailed += _videoView_MediaFailed;
            _videoView.MediaEnded  += _videoView_MediaEnded;

            _timer.Tick    += _timer_Tick;
            _timer.Interval = TimeSpan.FromSeconds(1);

            _parts = new Queue <Part>(_curTest.Parts);
            DataMaster.SaveCurrentTestFile(DataMaster.Setting.UserLocalPath);
            NextQuestion();
        }
        private void PushFileToNetwork()
        {
            this.Log("PushFileToNetwork Start");
            if (!Utils.CheckPath(DataMaster.Setting.UserLocalPath) || !Utils.CheckPath(DataMaster.Setting.NetworkPath))
            {
                return;
            }
            var di        = new DirectoryInfo(DataMaster.Setting.UserLocalPath);
            var diNetwork = new DirectoryInfo(DataMaster.Setting.NetworkPath);

            if (di.Exists && diNetwork.Exists)
            {
                var today = DateTime.Now.ToString("yyyyMMdd");
                var name  = DataMaster.UserNamePath + "_" + DataMaster.UserDobPath;
                diNetwork = new DirectoryInfo(Path.Combine(DataMaster.Setting.NetworkPath, today));
                if (!diNetwork.Exists)
                {
                    diNetwork.Create();
                }
                diNetwork = new DirectoryInfo(Path.Combine(DataMaster.Setting.NetworkPath, today, name));
                if (!diNetwork.Exists)
                {
                    diNetwork.Create();
                }

                foreach (var file in diNetwork.GetFiles())
                {
                    file.Delete();
                }

                foreach (var file in di.GetFiles())
                {
                    File.Copy(file.FullName, Path.Combine(diNetwork.FullName, file.Name));
                }

                DataMaster.SaveCurrentTestFile(diNetwork.FullName);
            }
            this.Log("PushFileToNetwork End");
        }