示例#1
0
        private LeagueInfo(CancellationToken ct)
        {
            UpdateTask = Task.Run(async() =>
            {
                OnUpdateStarted?.Invoke(this, new UpdateEventArgs(0));

                var version = await GetLatestVersion(ct);

                Directory.CreateDirectory(_leagueDataFolder);
                var path = Path.Combine(_leagueDataFolder, $"{version}.json");

                if (File.Exists(path))
                {
                    var json = File.ReadAllText(path);
                    _data    = JsonConvert.DeserializeObject <LeagueData>(json);

                    if (_data.LeagueDeckVersion == null || _data.LeagueDeckVersion < GetLeagueDeckVersion())
                    {
                        Logger.Instance.LogMessage(TracingLevel.DEBUG, "LeagueDeckVersionUpdated");
                        await UpdateData(version, path, ct).ContinueWith(x => OnUpdateCompleted?.Invoke(this, new UpdateEventArgs(1)));
                    }
                }
                else
                {
                    await UpdateData(version, path, ct).ContinueWith(x => OnUpdateCompleted?.Invoke(this, new UpdateEventArgs(1)));
                }
            });

            Logger.Instance.LogMessage(TracingLevel.DEBUG, "LeagueInfo - Constructor");
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AutoUpdateLayout);

            // Create your application here
            progressBar  = FindViewById <ProgressBar>(Resource.Id.progressBar1);
            progressBar2 = FindViewById <ProgressBar>(Resource.Id.progressBar2);

            progressBar.Max  = 100;
            progressBar2.Max = 100;

            FileDelete();

            //CheckUpdate();

            var url = new System.Uri(string.Format(@"{0}{1}", GlobalSetting.Instance.MOBILEEndpoint.ToString(), @"/com.daesangit.barcodeinspection.apk"));

            Task task = Task.Factory.StartNew(async() =>
            {
                await DownloadFileAsync(url);

                var child = Task.Factory.StartNew(() =>
                {
                    if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N)
                    {
                        Intent intent = new Intent(Intent.ActionInstallPackage);
                        intent.SetDataAndType(FileProvider.GetUriForFile(this.ApplicationContext, "com.daesangit.barcodeinspection.fileprovider", new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads) + "/com.daesangit.barcodeinspection.apk")), "application/vnd.android.package-archive");
                        intent.SetFlags(ActivityFlags.GrantReadUriPermission | ActivityFlags.NewTask);
                        StartActivity(intent);
                    }
                    else
                    {
                        Intent intent = new Intent(Intent.ActionView);
                        intent.SetDataAndType(Android.Net.Uri.FromFile(new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads) + "/com.daesangit.barcodeinspection.apk")), "application/vnd.android.package-archive");
                        intent.SetFlags(ActivityFlags.NewTask);
                        StartActivity(intent);
                    }
                }, TaskCreationOptions.AttachedToParent);

                var third = Task.Factory.StartNew(() =>
                {
                    OnUpdateCompleted?.Invoke();
                    this.Finish();
                }, TaskCreationOptions.AttachedToParent);
            });

            task.Wait();
        }
示例#3
0
        void DataComplete(RacingEvent data, CompletionStatus status)
        {
            if (status == CompletionStatus.Completed || status == CompletionStatus.NoChange)
            {
                foreach (ShellTile tile in ShellTile.ActiveTiles)
                {
                    StandardTileData tileData = RacingEventDataConverter.Convert(data);

                    tile.Update(tileData);
                }
            }

            OnUpdateCompleted.Invoke();
        }
        public static void UpdateSettingsAsset()
        {
            settings = AssetDatabase.LoadAssetAtPath <Settings>(assetPath);
            if (settings == null)
            {
                if (AssetDatabase.IsValidFolder(Path.rootPath + "/" + folderName) == false)
                {
                    AssetDatabase.CreateFolder(Path.rootPath, folderName);
                }

                settings = ScriptableObject.CreateInstance <Settings>();
                AssetDatabase.CreateAsset(settings, assetPath);
                AssetDatabase.SaveAssets();
            }

            OnUpdateCompleted?.Invoke();
        }
        private void CheckUpdate()
        {
            var ad = new AlertDialog.Builder(this).Create();

            try
            {
                var webClient = new WebClient();
                var url       = new System.Uri(string.Format(@"{0}{1}", GlobalSetting.Instance.MOBILEEndpoint.ToString(), @"/com.gwise.voidbarcode.apk"));
                webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
                webClient.DownloadFileAsync(url, Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads) + "/com.gwise.voidbarcode.apk");
                webClient.DownloadFileCompleted += (s, e) =>
                {
                    if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.N)
                    {
                        Intent intent = new Intent(Intent.ActionInstallPackage);
                        intent.SetDataAndType(FileProvider.GetUriForFile(this.ApplicationContext, "com.gwise.voidbarcode.fileprovider", new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads) + "/com.gwise.voidbarcode.apk")), "application/vnd.android.package-archive");
                        //intent.SetData(FileProvider.GetUriForFile(this.ApplicationContext, "com.gwise.voidbarcode.fileprovider", new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads) + "/com.gwise.voidbarcode.apk")));
                        intent.AddFlags(ActivityFlags.GrantReadUriPermission | ActivityFlags.NewTask);
                        StartActivity(intent);
                    }
                    else
                    {
                        Intent intent = new Intent(Intent.ActionView);
                        intent.SetDataAndType(Android.Net.Uri.FromFile(new File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads) + "/com.gwise.voidbarcode.apk")), "application/vnd.android.package-archive");
                        intent.AddFlags(ActivityFlags.NewTask); // ActivityFlags.NewTask 이 옵션을 지정해 주어야 업데이트 완료 후에 [열기]라는 화면이 나온다.
                        StartActivity(intent);
                    }

                    OnUpdateCompleted?.Invoke();
                    this.Finish();
                };
            }
            catch (System.Exception ex)
            {
                ad = new AlertDialog.Builder(this).Create();
                ad.SetTitle("INFO");
                ad.SetMessage(ex.Message);
                ad.SetCanceledOnTouchOutside(true);
                ad.Show();
            }
            finally
            {
            }
        }
 protected override void OnDestroy()
 {
     base.OnDestroy();
     OnUpdateCompleted?.Invoke();
     OnUpdateCompleted = null;
 }
示例#7
0
 private static void Update()
 {
     Call("update", GetPathsFromSelectedObject());
     OnUpdateCompleted?.Invoke();
 }