示例#1
0
        static int install(int L)
        {
            if (!LuaCommon.CheckAndShowArgsError(L, LConst.String, LConst.Function))
            {
                return(0);
            }

            string url            = Lua.Lua_tostring(L, 2);
            int    callbackF      = Lua.LuaL_ref(L, Lua._LUA_REGISTRYINDEX);
            string fullUrlAddress = url;
            var    mi             = LuaManager.GetLuaManager(L).DetailV_.GetType().GetMethod("CombineUrl4Install");

            if (mi != null)
            {
                var result = mi.Invoke(LuaManager.GetLuaManager(L).DetailV_, new object[] { url });
                fullUrlAddress = result != null?result.ToString() : url;
            }

            try
            {
                var AsyncOperation = InstallationManager.AddPackageAsync("企业App", new Uri(fullUrlAddress));

                if (callbackF > 0)
                {
                    Action <int, int> callBackAction = (progress, status) =>
                    {
                        Dictionary <string, object> callbackParams = new Dictionary <string, object>();
                        callbackParams.Add("url", url);
                        callbackParams.Add("progress", progress);
                        callbackParams.Add("status", status);

                        LuaManager.GetLuaManager(L).ExecuteCallBackFunctionWithTableParam(callbackF, callbackParams);
                    };

                    AsyncOperation.Progress = (result, progress) =>
                    {
                        LogLib.RYTLog.Log(fullUrlAddress + ",Status:" + result.Status.ToString() + "," + progress);
                        callBackAction((int)progress, 0);
                    };
                    AsyncOperation.Completed = (info, state) =>
                    {
                        LogLib.RYTLog.Log(fullUrlAddress + ",Status:" + state.ToString() + "," + 100);
                        if (state == AsyncStatus.Completed)
                        {
                            callBackAction(100, 1);
                        }
                        else
                        {
                            callBackAction(100, 2);
                        }
                    };
                }
            }
            catch (Exception e)
            {
                LogLib.RYTLog.ShowMessage(e.Message, "企业App安装异常");
            }

            return(0);
        }
        internal async void DoUpdate(IAppVersion availableUpdate)
        {
            var       aetxUri      = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + HockeyClient.Current.AsInternal().AppIdentifier + ".aetx", UriKind.Absolute);
            var       downloadUri  = new Uri(HockeyClient.Current.AsInternal().ApiBaseVersion2 + "apps/" + HockeyClient.Current.AsInternal().AppIdentifier + "/app_versions/" + availableUpdate.Id + ".appx", UriKind.Absolute);
            Exception installError = null;

            try
            {
                var result = await InstallationManager.AddPackageAsync(availableUpdate.Title, downloadUri);
            }
            catch (Exception e)
            {
                installError = e;
                HockeyClient.Current.AsInternal().HandleInternalUnhandledException(e);
            }
            if (installError != null)
            {
                await new MessageDialog(String.Format(LocalizedStrings.LocalizedResources.UpdateAPIError, installError.Message)).ShowAsync();
                await Launcher.LaunchUriAsync(downloadUri).AsTask();
            }
        }
示例#3
0
        // Performs one of the following tasks when a LOB app is tapped: installs the app, starts the app, or stops
        // the installation of the app.
        private void CompanyAppList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            LongListSelector companyAppList = (LongListSelector)sender;

            try
            {
                // If selected item is null (no selection) do nothing.
                if (companyAppList.SelectedItem == null)
                {
                    return;
                }

                CompanyAppViewModel selectedApp = companyAppList.SelectedItem as CompanyAppViewModel;

                // Clear the selection in the list.
                companyAppList.SelectedItem = null;

                // App is not installed yet, so start installing it.
                if (selectedApp.Status == Status.NotInstalled || selectedApp.Status == Status.Canceled)
                {
                    Windows.Foundation.IAsyncOperationWithProgress <PackageInstallResult, uint> result;
                    selectedApp.Status        = Status.Installing;
                    selectedApp.ProgressValue = 0;
                    result = InstallationManager.AddPackageAsync(selectedApp.Title, selectedApp.XapPath);

                    result.Completed   = InstallCompleted;
                    result.Progress    = InstallProgress;
                    selectedApp.Result = result;
                }

                // App is already installed, so start it.
                else if (selectedApp.Status == Status.Installed)
                {
                    this.LaunchApp(selectedApp.ProductId);
                }

                // App is in the process of installing; determine if the user is trying to stop the installation.
                else if (selectedApp.Status == Status.Installing || selectedApp.Status == Status.InstallFailed)
                {
                    if (selectedApp.Result != null)
                    {
                        MessageBoxResult result = MessageBox.Show("Are you sure you want to stop the company app installation?",
                                                                  "Stop installation?",
                                                                  MessageBoxButton.OKCancel);

                        if (result == MessageBoxResult.OK)
                        {
                            selectedApp.Result.Cancel();
                            selectedApp.Status = Status.Canceled;
                        }
                    }
                    else
                    {
                        foreach (var installingPackage in InstallationManager.GetPendingPackageInstalls())
                        {
                            installingPackage.Cancel();
                        }

                        selectedApp.Status = Status.Canceled;
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
                companyAppList.SelectedItem = null;
            }
        }