Ejemplo n.º 1
0
        private void CheckUpdate()
        {
            UpdateCheckInfo info = null;

            if (!ApplicationDeployment.IsNetworkDeployed)  // 로컬실행
            {
                Program.Log.WriteInfo("배포된 버젼이 아닙니다.");
            }
            else
            {
                ApplicationDeployment AppDeploy = ApplicationDeployment.CurrentDeployment;

                info = AppDeploy.CheckForDetailedUpdate();

                if (info.UpdateAvailable)
                {
                    bool doUpdate = true;

                    if (doUpdate)
                    {
                        AppDeploy.Update();
                        CustomMessageBox.ShowDialog(Properties.Resources.MsgUpdateResultHeader,
                                                    Properties.Resources.MsgUpdateResultContent, MessageBoxIcon.Information, MessageBoxButtons.OK);
                        Close();
                        Application.Restart();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        //=------------------------------------------------------------------=
        // beginUpdate
        //=------------------------------------------------------------------=
        /// <summary>
        ///   Tells us to begin checking for a new version, and if there
        ///   is one, to download it.
        /// </summary>
        ///
        private void beginUpdate()
        {
            if (this.m_updating != true)
            {
                // Flag ourselves as updating.
                this.m_updating = true;

                // If the app is network deployed, then start a background update.
                if (ApplicationDeployment.IsNetworkDeployed)
                {
                    // Get the application deployment
                    // Hook up the UpdateCompleted event and the UpdateProgressChanged event
                    this.m_deployment = ApplicationDeployment.CurrentDeployment;
                    this.m_deployment.UpdateCompleted       += new AsyncCompletedEventHandler(deploymentUpdateCompleted);
                    this.m_deployment.UpdateProgressChanged += new DeploymentProgressChangedEventHandler(deploymentUpdateProgressChanged);

                    // Begin the asynchronous update
                    this.m_deployment.UpdateAsync();
                }
                else
                {
                    if (this.m_throwIfNotNetworkDeployed)
                    {
                        throw new NotNetworkDeployedException();
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void ToolStripMenuItem2Click(object sender, EventArgs e)
 {
     try
     {
         ApplicationDeployment updater = ApplicationDeployment.CurrentDeployment;
         bool verDepServer             = updater.CheckForUpdate();
         if (verDepServer) // Update available
         {
             DialogResult res = MessageBox.Show(
                 Resources.NewVersionYes,
                 Resources.Updater, MessageBoxButtons.YesNo);
             if (res == DialogResult.Yes)
             {
                 updater.Update();
                 MessageBox.Show(Resources.RestartMsg);
             }
         }
         else
         {
             MessageBox.Show(Resources.NewVersionNo, Resources.Updater);
         }
     } catch
     {
         MessageBox.Show(Resources.NewVersionNo, Resources.Updater);
     }
 }
Ejemplo n.º 4
0
        private void btn_update_Click(object sender, RoutedEventArgs e)
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                System.Deployment.Application.UpdateCheckInfo info = null;
                try
                {
                    ad.UpdateCompleted += new System.ComponentModel.AsyncCompletedEventHandler(ad_UpdateCompleted);
                    //ad_UpdateCompleted is a private method which handles what happens after the update is done
                    //tb_log.Text += "MinimumRequiredVersion" + info.MinimumRequiredVersion;
                    //tb_log.Text += "ActivationUri" + ad.ActivationUri;
                    tb_log.Text += "UpdateLocation" + ad.UpdateLocation;

                    info = ad.CheckForDetailedUpdate();

                    tb_log.Text += "AvailableVersion" + info.AvailableVersion;
                    tb_log.Text += "UpdateAvailable " + info.UpdateAvailable;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    if (info.UpdateAvailable)
                    {
                        //You can create a dialog or message that prompts the user that there's an update. Make sure the user knows that your are updating the application.
                        ad.UpdateAsync();//Updates the application asynchronously
                    }
                }
            }
        }
        /// <summary>
        /// Verifica si existe una nueva version de la aplicacion a través de ClickOnce
        /// </summary>
        /// <returns>True = Existe nueva version</returns>
        private static bool UpdateApp()
        {
            bool result = false;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                try
                {
                    ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;
                    UpdateCheckInfo       info        = updateCheck.CheckForDetailedUpdate();

                    if (info.UpdateAvailable)
                    {
                        result = true;
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new frmProgressBar());
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
        private void CheckForUpdates()
        {
            if (!ApplicationDeployment.IsNetworkDeployed)
            {
                MessageBox.Show("This application is not running in ClickOnce infra. \nNo update is available.");
                return;
            }

            ApplicationDeployment currentDeploy = ApplicationDeployment.CurrentDeployment;

            if (currentDeploy.CheckForUpdate())
            {
                //TODO: ensure all the data is syncronized before update
                //TODO: use different thread for update
                //currentDeploy.Update();

                currentDeploy.CheckForUpdateCompleted       += currentDeploy_CheckForUpdateCompleted;
                currentDeploy.CheckForUpdateProgressChanged += currentDeploy_CheckForUpdateProgressChanged;
                currentDeploy.UpdateCompleted += currentDeploy_UpdateCompleted;

                DialogResult dr = MessageBox.Show("Update downloaded, restart application?", "Application Update", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    Application.Restart();
                }
            }
        }
Ejemplo n.º 7
0
        public void UpdateTimerLoop(object sender, EventArgs e)
        {
            _UpdateTimer.Stop();
            try
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                if ((DateTime.Now - ad.TimeOfLastUpdateCheck).Hours > 6)
                {
                    Helpers.DebugInfo("Trying to get updates...");

                    var checkinfo = ad.CheckForDetailedUpdate();
                    if (checkinfo != null)
                    {
                        string shown_version = (string)Properties.Settings.Default["UpdateLastShownVersion"];
                        string new_version   = checkinfo.AvailableVersion.ToString();
                        Helpers.DebugInfo("Available version: " + new_version);
                        if (new_version != shown_version)
                        {
                            Properties.Settings.Default["UpdateLastShownVersion"] = new_version;
                            Properties.Settings.Default.Save();
                            MessageBox.Show(
                                "New version is available (" + new_version + ") at" + Environment.NewLine +
                                ApplicationDeployment.CurrentDeployment.UpdateLocation,
                                "TimeReporting " + ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(),
                                MessageBoxButtons.OK);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Helpers.DebugInfo("Exception during updating: " + ex.Message);
            }
            _UpdateTimer.Start();
        }
Ejemplo n.º 8
0
        private void FrmUpdate_Load(object sender, EventArgs e)
        {
            try
            {
                ADUpdateAsync = ApplicationDeployment.CurrentDeployment;
                ADUpdateAsync.CheckForUpdateProgressChanged += ADUpdateAsync_CheckForUpdateProgressChanged;
                ADUpdateAsync.CheckForUpdateCompleted       += ADUpdateAsync_CheckForUpdateCompleted;
                ADUpdateAsync.UpdateProgressChanged         += ADUpdateAsync_UpdateProgressChanged;
                ADUpdateAsync.UpdateCompleted += ADUpdateAsync_UpdateCompleted;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao buscar a atualização CurrentDeployment: " + ex.Message, ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            try
            {
                InstallUpdateSyncWithInfo();


                //UpdateApplication();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao atualizar o Sistema: " + ex.Message, ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
        protected override async Task <bool> CheckUpdateCore()
        {
            UpdateCheckInfo       info = null;
            ApplicationDeployment ad   = ApplicationDeployment.CurrentDeployment;

            try {
                info = ad.CheckForDetailedUpdate();
            }
            catch (DeploymentDownloadException) {
                return(false);
            }
            catch (InvalidDeploymentException) {
                return(false);
            }
            catch (InvalidOperationException) {
                return(false);
            }
            if (!info.UpdateAvailable)
            {
                return(false);
            }
            bool handled = false;
            AsyncCompletedEventHandler handler = (sender, e) => {
                handled = true;
            };

            ad.UpdateCompleted += handler;
            ad.UpdateAsync();
            while (!handled)
            {
                await Task.Delay(100);
            }
            ad.UpdateCompleted -= handler;
            return(true);
        }
Ejemplo n.º 10
0
        void ad_UpdateCompleted(object sender, AsyncCompletedEventArgs e)
        {
            ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

            ad.UpdateCompleted -= new AsyncCompletedEventHandler(ad_UpdateCompleted);
            if (e.Cancelled)
            {
                ShowMessage("The update of the application's latest version was cancelled.");
                UpdateCompleted();
                return;
            }
            else if (e.Error != null)
            {
                ShowMessage("ERROR: Could not install the latest version of Witty Twitter. Reason: \n" + e.Error.Message + "\nPlease report this error to the Witty developers.");
                return;
            }

            DialogResult dr = MessageBox.Show("The application has been updated.\nThe application must be restarted in order for changes to take effect.\n\nWould you like to restart the application now?", "Restart Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (DialogResult.OK == dr)
            {
                _restartApplication = true;
            }

            UpdateCompleted();
        }
Ejemplo n.º 11
0
        public static String CheckforNewVersion()
        {
            String latestVersion = String.Empty;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                UpdateCheckInfo info = null;
                try
                {
                    info = ad.CheckForDetailedUpdate();
                }
                catch
                {
                    return(latestVersion);
                }

                if (info.UpdateAvailable)
                {
                    latestVersion = String.Format("{0}", info.AvailableVersion);
                }
            }
            return(latestVersion);
        }
Ejemplo n.º 12
0
 private void UpdateProgram()
 {
     try
     {
         ApplicationDeployment currentDeployment = ApplicationDeployment.CurrentDeployment;
         if (ApplicationDeployment.CurrentDeployment.CheckForUpdate())
         {
             if (MessageBox.Show("發現新的版本,是否確定更新", "更新通知", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
             {
                 currentDeployment.UpdateProgressChanged += new DeploymentProgressChangedEventHandler(obj_UpdateProgressChanged);
                 currentDeployment.UpdateCompleted       += new AsyncCompletedEventHandler(obj_UpdateCompleted);
                 currentDeployment.UpdateAsync();
             }
             else
             {
                 Close();
             }
         }
         else
         {
             Close();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("目前為離線狀態。");
         Close();
     }
 }
Ejemplo n.º 13
0
        private void UpdateApp()
        {
            ApplicationDeployment updater = ApplicationDeployment.CurrentDeployment;
            bool verDepServer             = updater.CheckForUpdate();

            if (verDepServer) // Update disponible
            {
                DialogResult res = MessageBox.Show(
                    String.Format("Une nouvelle version est disponible{0}Mettre à jour maintenant ?",
                                  Environment.NewLine),
                    "Mise à jour",
                    MessageBoxButtons.YesNo);

                if (res == DialogResult.Yes)
                {
                    updater.Update();

                    MessageBox.Show("Attention, l'application va redémarrer", "Redémarrage",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);

                    Application.Restart();
                }
            }
            else
            {
                MessageBox.Show("Pas de nouvelle version disponible");
            }
        }
Ejemplo n.º 14
0
        private void CheckUpdate()
        {
            UpdateCheckInfo info = null;

            if (!ApplicationDeployment.IsNetworkDeployed)
            {
                //MessageBox.Show("NOT DEPLOYED !!! USING CLICKONCE PLEASE");
            }
            else
            {
                ApplicationDeployment appDeployment = ApplicationDeployment.CurrentDeployment;
                info = appDeployment.CheckForDetailedUpdate();
                if (info.UpdateAvailable)
                {
                    bool doUpdate = true;
                    if (doUpdate)
                    {
                        appDeployment.Update();
                        MessageBox.Show("프로그램이 업그레이드되어서 재시작합니다.");
                        this.Close();
                        Application.Restart();
                    }
                }
            }
        }
Ejemplo n.º 15
0
        public Main()
        {
            InitializeComponent();

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment appDeployment = ApplicationDeployment.CurrentDeployment;
                this.Text += " ver " + appDeployment.CurrentVersion.ToString();
            }
            else
            {
                this.Text += " ver NOT DEPLOYED";
            }

            //this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form_Gradient);

            this.panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel_Gradient);

            //this.button3.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel_Gradient2);
            //this.button4.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel_Gradient2);
            //this.button5.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel_Gradient2);
            //this.button7.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel_Gradient2);
            //this.button8.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel_Gradient2);
            //this.button9.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel_Gradient2);
            //this.button10.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel_Gradient2);
            //this.button11.Paint += new System.Windows.Forms.PaintEventHandler(this.Panel_Gradient2);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// This will create a Application Reference file on the users desktop
        /// if they do not already have one when the program is loaded.
        /// Check for them running the deployed version before doing this,
        /// so it doesn't kick it when you're running it from Visual Studio.
        /// </summary
        static void CheckForShortcut()
        {
            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                try
                {
                    ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                    if (ad.IsFirstRun)  //first time user has run the app since installation or update
                    {
                        log.Debug("First run of network deployed app. Adding desktop shortcut.");

                        string desktopPath  = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                        string shortcutPath = System.IO.Path.Combine(desktopPath, "DataMart Client.lnk");
                        if (System.IO.File.Exists(shortcutPath))
                        {
                            log.Debug("Shortcut already exits, deleting.");
                            System.IO.File.Delete(shortcutPath);
                        }

                        log.Debug("Creating shortcut at:" + shortcutPath);
                        IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut) new IWshRuntimeLibrary.WshShellClass().CreateShortcut(shortcutPath);
                        shortcut.TargetPath  = Application.ExecutablePath;
                        shortcut.Description = "DataMart Client";
                        shortcut.Save();
                    }
                }
                catch (Exception ex)
                {
                    log.Error("Error creating desktop shortcut.", ex);
                }
            }
        }
Ejemplo n.º 17
0
        public static void Update()
        {
            try
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                if (IsAsync)
                {
                    ad.UpdateCompleted       -= CurrentDeployment_UpdateCompleted;
                    ad.UpdateProgressChanged -= CurrentDeployment_UpdateProgressChanged;

                    ad.UpdateCompleted       += CurrentDeployment_UpdateCompleted;
                    ad.UpdateProgressChanged += CurrentDeployment_UpdateProgressChanged;
                    ad.UpdateAsync();
                }
                else
                {
                    IsDownloading = true;
                    ad.Update();
                    IsDownloading = false;
                    OnUpdateChecked(UpdateStateType.Updated);
                }
            }
            catch (DeploymentDownloadException dde)
            {
                OnUpdateChecked(
                    new Exception(
                        "Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " +
                        dde));
                IsDownloading = false;
                return;
            }
        }
Ejemplo n.º 18
0
        private void Ad_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
        {
            ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

            if (e.Error != null)
            {
                logger.Error(e.Error, "检查版本更新出错");
                return;
            }
            if (e.Cancelled)
            {
                return;
            }
            if (e.UpdateAvailable)
            {
                if (e.IsUpdateRequired)
                {
                    BeginUpdate();
                }
                else
                {
                    UpdateAction = () => BeginUpdate();
                    UpdateBar.Dispatcher.Invoke(() =>
                    {
                        UpdateBar.MainText   = string.Format("发现新版本: {0} 大小: {1}KiB", e.AvailableVersion, e.UpdateSizeBytes / 1024);
                        UpdateBar.ButtonText = "下载更新";
                        UpdateBar.Display    = true;
                    });
                }
            }
        }
Ejemplo n.º 19
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            logger = LogManager.GetLogger("ArieteMainFormUI");
            logger.Info("MainFormUI created.");
            cookieContainer = new CookieContainer();
            wc = new MyWebClient();
            NatUtility.DeviceFound += DeviceFound;
            NatUtility.DeviceLost  += DeviceLost;

            // Pulizia e creazione regole sul firewall per Ariete
            if (Utils.FirewallNetshIsRule())
            {
                Utils.FirewallNetshDeleteRule();
            }
            Utils.FirewallNetshExe();

            if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                this.Text += " v" + ad.CurrentVersion.ToString();
            }
            else
            {
                this.Text += " Debug";
            }
        }
 public ClickOnceApplicationDeployment()
 {
     if (IsNetworkDeployed)
     {
         _deployment = ApplicationDeployment.CurrentDeployment;
     }
 }
Ejemplo n.º 21
0
 public static void InstallUpdate()
 {
     if (ApplicationDeployment.IsNetworkDeployed)
     {
         ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
         if (info.UpdateAvailable)
         {
             try
             {
                 ad.Update();
                 if (OnUpdateSuccess != null)
                 {
                     OnUpdateSuccess();
                     OnUpdateFail    = null;
                     OnUpdateSuccess = null;
                 }
             }
             catch (DeploymentDownloadException dde)
             {
                 LoggerManager.Error(dde, "Update deployement failed");
                 if (OnUpdateFail != null)
                 {
                     OnUpdateFail();
                     OnUpdateFail    = null;
                     OnUpdateSuccess = null;
                 }
             }
         }
     }
 }
Ejemplo n.º 22
0
        public static void checkForUpdate(Boolean isManualCheck = false)
        {
            Settings.Instance.Proxy.Configure();
            if (System.Diagnostics.Debugger.IsAttached)
            {
                return;
            }

            Program.isManualCheck = isManualCheck;
            if (isManualCheck)
            {
                MainForm.Instance.btCheckForUpdate.Text = "Checking...";
            }

            if (isClickOnceInstall())
            {
                ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
                if (isManualCheck || ad.TimeOfLastUpdateCheck < DateTime.Now.AddDays(-1))
                {
                    log.Debug("Checking for ClickOnce update...");
                    ad.CheckForUpdateCompleted -= new CheckForUpdateCompletedEventHandler(checkForUpdate_completed);
                    ad.CheckForUpdateCompleted += new CheckForUpdateCompletedEventHandler(checkForUpdate_completed);
                    ad.CheckForUpdateAsync();
                }
            }
            else
            {
                BackgroundWorker bwUpdater = new BackgroundWorker();
                bwUpdater.WorkerReportsProgress      = false;
                bwUpdater.WorkerSupportsCancellation = false;
                bwUpdater.DoWork             += new DoWorkEventHandler(checkForZip);
                bwUpdater.RunWorkerCompleted += new RunWorkerCompletedEventHandler(checkForZip_completed);
                bwUpdater.RunWorkerAsync();
            }
        }
Ejemplo n.º 23
0
        private void UpdateProgram()
        {
            bool flag = false;

            try
            {
                ApplicationDeployment currentDeployment = ApplicationDeployment.CurrentDeployment;
                if (ApplicationDeployment.CurrentDeployment.CheckForUpdate())
                {
                    Program.Counter++;
                    currentDeployment.UpdateProgressChanged += obj_UpdateProgressChanged;
                    currentDeployment.UpdateCompleted       += obj_UpdateCompleted;
                    currentDeployment.UpdateAsync();
                    flag = true;
                }
            }
            catch (Exception)
            {
                Close();
            }
            if (!flag)
            {
                StartProgram();
                Close();
            }
        }
Ejemplo n.º 24
0
        //</SNIPPET8>

        //<SNIPPET9>
        private void DownloadFileGroupSync(string fileGroup)
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;

                if (deployment.IsFirstRun)
                {
                    try
                    {
                        if (deployment.IsFileGroupDownloaded(fileGroup))
                        {
                            deployment.DownloadFileGroup(fileGroup);
                        }
                    }
                    catch (InvalidOperationException ioe)
                    {
                        MessageBox.Show("This application is not a ClickOnce application. Error: " + ioe.Message);
                        return;
                    }

                    downloadStatus.Text = String.Format("Download of file group {0} complete.", fileGroup);
                }
            }
        }
Ejemplo n.º 25
0
 private void InstallUpdateSyncWithInfo2()
 {
     if (ApplicationDeployment.IsNetworkDeployed == true)
     {
         ApplicationDeployment thisDeployment = ApplicationDeployment.CurrentDeployment;
         //this.Text = "正在检测更新...";
         if (thisDeployment.CheckForUpdate() == true)
         {
             if (MessageBox.Show("检测到有新的版本可以进行更新,现在需要更新吗?", "选择是否要进行更新", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
             {
                 // this.Text = "正在更新中";
                 thisDeployment.Update();
                 MessageBox.Show("更新完毕,将要重启程序!");
                 Application.Restart();
             }
             else
             {
                 //  this.Text = Application.ProductName + " " + Application.ProductVersion;
             }
         }
         else
         {
             MessageBox.Show("并没有新的版本进行更新!");
         }
     }
     else
     {
         MessageBox.Show("这不是网络发布的程序");
     }
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Checks for any ClickOnce updates.
        /// </summary>
        private void CheckForUpdates()
        {
            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment deployment = ApplicationDeployment.CurrentDeployment;
                deployment.CheckForUpdateCompleted += CheckForUpdateCompleted;
                deployment.UpdateProgressChanged   += UpdateProgressChanged;
                deployment.UpdateCompleted         += UpdateCompleted;

                try
                {
                    deployment.CheckForUpdateAsync();
                }
                catch (Exception ex)
                {
                    if (ex is InvalidOperationException ||
                        ex is InvalidDeploymentException ||
                        ex is DeploymentDownloadException)
                    {
                        // Swallow.
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 27
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            //https://stackoverflow.com/questions/24282560/get-office-addin-publish-version
            string versionNumber = string.Empty;

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                ApplicationDeployment applicationDeployment = ApplicationDeployment.CurrentDeployment;
                Version version = applicationDeployment.CurrentVersion;
                versionNumber = String.Format("{0}.{1}.{2}.{3}", version.Major, version.Minor, version.Build, version.Revision);
            }

            _customTaskPanelCtrl = new CustomTaskPanelCtrl(versionNumber);

            try
            {
                _customTaskPane         = this.CustomTaskPanes.Add(_customTaskPanelCtrl, "#### My Task Panel ####");
                _customTaskPane.Width   = 400;
                _customTaskPane.Visible = true;


                //labelVersionTab1.Text = string.Format("Addin v{0}", versionNumber);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //BindRandomValues(2, 3);
            AssignArrayToRange();
        }
Ejemplo n.º 28
0
 public AppDeploymentWrapper()
 {
     if (ApplicationDeployment.IsNetworkDeployed)
     {
         _applicationDeployment = ApplicationDeployment.CurrentDeployment;
     }
 }
Ejemplo n.º 29
0
        private void CheckUpdate()
        {
            UpdateCheckInfo info = null;

            if (!ApplicationDeployment.IsNetworkDeployed)  // 로컬실행
            {
                Log.WriteInfo("배포된 버젼이 아닙니다.");
            }
            else
            {
                ApplicationDeployment AppDeploy = ApplicationDeployment.CurrentDeployment;

                info = AppDeploy.CheckForDetailedUpdate();

                if (info.UpdateAvailable)
                {
                    bool doUpdate = true;

                    if (doUpdate)
                    {
                        AppDeploy.Update();
                        MessageBox.Show(Resources.ProgramUpdateMsg, Resources.MsgBoxTitleUpdate);
                        this.Close();
                        Application.Restart();
                    }
                }
            }
        }
        static internal string GetLaunchUrlWithArgs()
        {
            if (!LaunchedFromUrl)
            {
                throw new ApplicationException("Launch URL not available (not launched from URL)");
            }

            // Only works for .NET 1.1+
            AppDomain domain       = AppDomain.CurrentDomain;
            object    obj          = domain.GetData("APP_LAUNCH_URL");
            string    appLaunchUrl = (obj != null ? obj.ToString() : "");
            //added By Rajesh required for clickonce.
            ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

            appLaunchUrl = ad.ActivationUri.ToString();
            // Fall back for .NET 1.0
            if (Empty(appLaunchUrl))
            {
                const string ext        = ".config";
                string       configFile = domain.SetupInformation.ConfigurationFile;
                Debug.Assert(configFile.ToLower().EndsWith(ext));
                appLaunchUrl = configFile.Substring(0, configFile.Length - ext.Length);
            }

            return(appLaunchUrl);
        }
        public async Task ProcessApplicationDeploymentCopy()
        {
            string type = "type1";
            string version = "1.0";
            string expected = "type1_1.0";

            MockReliableStateManager stateManager = new MockReliableStateManager();
            MockApplicationOperator applicationOperator = new MockApplicationOperator
            {
                CopyPackageToImageStoreAsyncFunc = (cluster, appPackage, appType, appVersion) => Task.FromResult(appType + "_" + appVersion)
            };

            ApplicationDeployService target = new ApplicationDeployService(stateManager, applicationOperator, this.CreateServiceParameters());
            ApplicationDeployment appDeployment = new ApplicationDeployment("", ApplicationDeployStatus.Copy, "", type, version, "", "", DateTimeOffset.UtcNow);
            ApplicationDeployment actual = await target.ProcessApplicationDeployment(appDeployment, CancellationToken.None);

            Assert.AreEqual(expected, actual.ImageStorePath);
            Assert.AreEqual(ApplicationDeployStatus.Register, actual.Status);
        }
        public async Task ProcessApplicationDeploymentCreate()
        {
            MockReliableStateManager stateManager = new MockReliableStateManager();
            MockApplicationOperator applicationOperator = new MockApplicationOperator
            {
                CopyPackageToImageStoreAsyncFunc = (cluster, appPackage, appType, appVersion) => Task.FromResult(appType + "_" + appVersion)
            };

            ApplicationDeployService target = new ApplicationDeployService(stateManager, applicationOperator, this.CreateServiceContext());
            ApplicationDeployment appDeployment = new ApplicationDeployment(
                "",
                ApplicationDeployStatus.Create,
                "",
                "type1",
                "1.0.0",
                "",
                "",
                DateTimeOffset.UtcNow);
            ApplicationDeployment actual = await target.ProcessApplicationDeployment(appDeployment, CancellationToken.None);

            Assert.AreEqual(ApplicationDeployStatus.Complete, actual.Status);
        }