예제 #1
0
        private void button_option_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                UpdateWidget updateWidget = new UpdateWidget();
                updateWidget.setVersion(Rigel.PluginVersion, VSTOUpdater.ServerVersion);
                VSTOUpdater.UpdateLog.TryGetValue("slogan", out string slogan);
                VSTOUpdater.UpdateLog.TryGetValue("content", out string content);
                VSTOUpdater.UpdateLog.TryGetValue("sjhs", out string sjhs);
                List <string> lists = new List <string>();
                if (sjhs != null)
                {
                    lists = sjhs.Split(',').ToList <string>();
                }
                updateWidget.setInfo(slogan, content);

                Int32.TryParse(Rigel.PluginVersion.Replace(".", ""), out int local);
                Int32.TryParse(VSTOUpdater.ServerVersion.Replace(".", ""), out int server);
                if ((lists.Contains(Rigel.UserID) || lists.Contains("all")) && local < server)
                {
                    VSTOUpdater.NeedUpdate = true;
                }
                else
                {
                    updateWidget.setVersion(Rigel.PluginVersion, Rigel.PluginVersion);
                    VSTOUpdater.NeedUpdate = false;
                }

                updateWidget.setNeedUpdate(VSTOUpdater.NeedUpdate);



                if (VSTOUpdater.NeedUpdate)
                {
                    Logger.LogInfo("需要更新版本:" + VSTOUpdater.ServerVersion);
                }
                Logger.LogInfo("开始更新从:" + Rigel.PluginVersion + "升级到:" + VSTOUpdater.ServerVersion);

                DialogResult result = ThisAddIn.FormShower.ShowDialog(updateWidget);
                if (result == DialogResult.OK && VSTOUpdater.Update())
                {
                    PromptBox.Prompt("更新完成,需要重新启动软件。");
                    return;
                }
            }
            catch (Exception ex)
            {
                PromptBox.Prompt("非常抱歉更新失败,请联系工作人员!");
                Logger.LogError(ex.ToString());
            }
        }
예제 #2
0
        private async void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            TaskPaneDict    = new Dictionary <PowerPoint.DocumentWindow, CustomTaskPane>();
            Rigel.PluginDir = Regditer.GetValue(Regditer.RootKey.CurrentUser, Rigel.UserRegKey, "InstallPath");
            Rigel.UserName  = Regditer.GetValue(Regditer.RootKey.CurrentUser, Rigel.UserRegKey, "UserName");
            Rigel.UserToken = Regditer.GetValue(Regditer.RootKey.CurrentUser, Rigel.UserRegKey, "UserToken");

            /*if(String.IsNullOrEmpty(Rigel.PluginDir))
             * {
             *  PromptBox.Error("没有找到安装目录!");
             * }*/
            //Rigel.PluginDir += "/";
            Rigel.InitWorkConfig();
            FormShower       = new FormMgr(new IntPtr(this.Application.HWND));
            App.ResourceType = ResourceType.None;
            this.Application.WindowActivate += WindowActivate_Event;

            Rigel.PluginVersion = "1.0.0.25";
            var aaaa = System.Reflection.Assembly.GetExecutingAssembly();

            if (ApplicationDeployment.IsNetworkDeployed)
            {
                try {
                    ApplicationDeployment applicationDeployment = ApplicationDeployment.CurrentDeployment;
                    Logger.LogInfo("UpdatedVersion:" + applicationDeployment.UpdatedVersion.ToString());
                    Logger.LogInfo("CurrentVersion" + applicationDeployment.CurrentVersion.ToString());
                    Rigel.PluginVersion = applicationDeployment.CurrentVersion.ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            VSTOUpdater.CheckUpdate().Wait();


            /*if (VSTOUpdater.NeedUpdate)
             * {
             *  UpdateWidget updateWidget = new UpdateWidget();
             *  updateWidget.setNeedUpdate(VSTOUpdater.NeedUpdate);
             *  updateWidget.setVersion(Rigel.PluginVersion, VSTOUpdater.ServerVersion);
             *  VSTOUpdater.UpdateLog.TryGetValue("slogan", out string slogan);
             *  VSTOUpdater.UpdateLog.TryGetValue("content", out string content);
             *  updateWidget.setInfo(slogan, content);
             *  DialogResult result = ThisAddIn.FormShower.ShowDialog(updateWidget);
             *  if (result == DialogResult.OK)
             *  {
             *      VSTOUpdater.Update(); ;
             *  }
             * }*/
        }