Pārlūkot izejas kodu

mxg:添加Updater

mengxiangge 5 gadi atpakaļ
vecāks
revīzija
e95e645582

+ 69 - 0
FWindSoft/Revit/XiaoHong/App.cs

@@ -0,0 +1,69 @@
+/* ==============================================================================
+ * 功能描述:App  
+ * 创 建 者:Garrett
+ * 创建日期:2019/11/8 9:23:25
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace LRH
+{
+    /// <summary>
+    /// App
+    /// </summary>
+    public class App
+    {
+        [STAThread]
+        static void Main(string[] args)
+        {
+#if DEBUG
+            MainWindow win = new MainWindow();
+            Application myAp = new Application();
+            myAp.ShutdownMode = ShutdownMode.OnExplicitShutdown;
+            myAp.Run(win);
+#else
+            var runPath=Directory.GetParent(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory)).ToString();
+            string fullPath = Path.Combine(runPath, "Updater", "Update.exe");
+
+            //有参数时直接启动
+            if (args != null && args.Length > 0 || !File.Exists(fullPath))
+            {
+                MainWindow win = new MainWindow();
+                Application myAp = new Application();
+                myAp.ShutdownMode = ShutdownMode.OnExplicitShutdown;
+                myAp.Run(win);
+            }
+            else
+            {
+                try
+                { 
+                    //无参数可看做双击启动,启动前检测版本
+                    //arguments参数用空格分开,"Program Files"使用时被拆分成两个参数,使用时请注意
+                    //设置启动动作,确保以管理员身份运行
+                    ProcessStartInfo startInfo = new ProcessStartInfo(fullPath)
+                    {
+                        UseShellExecute = true,
+                        Verb = "runas",
+                        WindowStyle = ProcessWindowStyle.Normal,
+                        Arguments = Assembly.GetExecutingAssembly().Location,
+                        CreateNoWindow = true
+                    };
+                    Process.Start(startInfo);
+                }
+                catch (Exception e)
+                {
+                    MessageBox.Show(e.StackTrace);
+                }
+              
+            }
+#endif
+        }
+    }
+}

+ 0 - 14
FWindSoft/Revit/XiaoHong/App.xaml

@@ -1,14 +0,0 @@
-<Application x:Class="LRH.App"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:local="clr-namespace:LRH"
-             StartupUri="MainWindow.xaml">
-    <Application.Resources>
-        <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
-            <!--<ResourceDictionary.MergedDictionaries >
-                <ResourceDictionary Source="/LRH;component/Themes/SystemColors.xaml"/>
-            </ResourceDictionary.MergedDictionaries>-->
-        </ResourceDictionary>
-    </Application.Resources>
-</Application>

+ 0 - 36
FWindSoft/Revit/XiaoHong/App.xaml.cs

@@ -1,36 +0,0 @@
-using LRH;
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Threading;
-
-namespace LRH
-{
-    /// <summary>
-    /// App.xaml 的交互逻辑
-    /// </summary>
-    public partial class App : Application
-    {
-        protected override void OnStartup(StartupEventArgs e)
-        {
-            //1、将动图编译成splashScreen
-            //2、将动图编译成资源进行如下代码操作
-            SplashScreen s = new SplashScreen("Screen.gif");
-            s.Show(true);
-            var items = RevitManager.GetRevitItems();
-            //DispatcherPriority.Loaded优先级,在窗体加载完成时才进行执行。通过优先级去控制顺序
-            //Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(ex=>MessageBox.Show(ex.ToString())), this);
-            base.OnStartup(e);
-        }
-        //[STAThread]
-        //public static void Main()
-        //{//此方法和app.xaml冲突
-        //    App app = new App();
-        //    app.Run();
-        //}
-    }
-}

+ 2 - 9
FWindSoft/Revit/XiaoHong/LRH.csproj

@@ -13,7 +13,7 @@
     <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <WarningLevel>4</WarningLevel>
     <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
-    <Deterministic>true</Deterministic>
+    <Deterministic>false</Deterministic>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -57,20 +57,13 @@
     <Reference Include="PresentationFramework" />
   </ItemGroup>
   <ItemGroup>
-    <ApplicationDefinition Include="App.xaml">
-      <Generator>MSBuild:Compile</Generator>
-      <SubType>Designer</SubType>
-    </ApplicationDefinition>
+    <Compile Include="App.cs" />
     <Compile Include="Controls\WindowBase.cs" />
     <Compile Include="RevitManager.cs" />
     <Page Include="MainWindow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
-    <Compile Include="App.xaml.cs">
-      <DependentUpon>App.xaml</DependentUpon>
-      <SubType>Code</SubType>
-    </Compile>
     <Compile Include="MainWindow.xaml.cs">
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>

+ 2 - 2
FWindSoft/Revit/XiaoHong/Properties/AssemblyInfo.cs

@@ -51,5 +51,5 @@ using System.Windows;
 // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
 // 方法是按如下所示使用“*”: :
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyFileVersion("1.0.0.*")]

BIN
FWindSoft/Updater/Update.exe


+ 10 - 0
FWindSoft/Updater/Update.exe.config

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configuration>
+  <appSettings>
+    <add key="IsAutoUpdate" value="true"/>
+    <add key="URL" value="http://api.sagacloud.cn/dp-auxiliary/"/>
+    <add key="Key" value="SagaPlugln o _Package"/>
+    <add key="RevitServiceId" value="revit"/>
+    <add key="RevitServiceSecret" value="63afbef6906c342b"/>
+  </appSettings>
+</configuration>